mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
⚡ Memoize options in text-decoration-options* component
Wrap the two radio-button option maps in mf/with-memo [token-applied] so the vector and its (tr ...) calls are evaluated only when the token-applied prop changes, not on every render. Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
b8aa243c2b
commit
a94a7221fb
@ -190,6 +190,19 @@
|
|||||||
[{:keys [values on-change on-blur token-applied]}]
|
[{:keys [values on-change on-blur token-applied]}]
|
||||||
(let [token-row (contains? cf/flags :token-typography-row)
|
(let [token-row (contains? cf/flags :token-typography-row)
|
||||||
text-decoration (some-> (:text-decoration values) d/name)
|
text-decoration (some-> (:text-decoration values) d/name)
|
||||||
|
options
|
||||||
|
(mf/with-memo [token-applied]
|
||||||
|
[{:value "underline"
|
||||||
|
:id "underline-text-decoration"
|
||||||
|
:disabled (and token-row (some? token-applied))
|
||||||
|
:label (tr "workspace.options.text-options.underline" (sc/get-tooltip :underline))
|
||||||
|
:icon i/text-underlined}
|
||||||
|
{:value "line-through"
|
||||||
|
:id "line-through-text-decoration"
|
||||||
|
:disabled (and token-row (some? token-applied))
|
||||||
|
:label (tr "workspace.options.text-options.strikethrough" (sc/get-tooltip :line-through))
|
||||||
|
:icon i/text-stroked}])
|
||||||
|
|
||||||
handle-change
|
handle-change
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps on-change on-blur)
|
(mf/deps on-change on-blur)
|
||||||
@ -206,16 +219,7 @@
|
|||||||
:name "text-decoration-options"
|
:name "text-decoration-options"
|
||||||
:disabled (and token-row (some? token-applied))
|
:disabled (and token-row (some? token-applied))
|
||||||
:allow-empty true
|
:allow-empty true
|
||||||
:options [{:value "underline"
|
:options options}]]))
|
||||||
:id "underline-text-decoration"
|
|
||||||
:disabled (and token-row (some? token-applied))
|
|
||||||
:label (tr "workspace.options.text-options.underline" (sc/get-tooltip :underline))
|
|
||||||
:icon i/text-underlined}
|
|
||||||
{:value "line-through"
|
|
||||||
:id "line-through-text-decoration"
|
|
||||||
:disabled (and token-row (some? token-applied))
|
|
||||||
:label (tr "workspace.options.text-options.strikethrough" (sc/get-tooltip :line-through))
|
|
||||||
:icon i/text-stroked}]}]]))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Helpers
|
;; Helpers
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user