mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
⚡ Memoize static options in grow-options* component
Wrap the three radio-button option maps in mf/with-memo [] so the vector and its (tr ...) calls are evaluated once per mount instead of on every render. Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
dfd992aa49
commit
b8aa243c2b
@ -142,6 +142,20 @@
|
||||
[{:keys [ids values on-blur]}]
|
||||
(let [grow-type (:grow-type values)
|
||||
editor-instance (mf/deref refs/workspace-editor)
|
||||
options
|
||||
(mf/with-memo []
|
||||
[{:value "fixed"
|
||||
:id "text-fixed-grow"
|
||||
:label (tr "workspace.options.text-options.grow-fixed")
|
||||
:icon i/text-fixed}
|
||||
{:value "auto-width"
|
||||
:id "text-auto-width-grow"
|
||||
:label (tr "workspace.options.text-options.grow-auto-width")
|
||||
:icon i/text-auto-width}
|
||||
{:value "auto-height"
|
||||
:id "text-auto-height-grow"
|
||||
:label (tr "workspace.options.text-options.grow-auto-height")
|
||||
:icon i/text-auto-height}])
|
||||
|
||||
handle-change
|
||||
(mf/use-fn
|
||||
@ -170,18 +184,7 @@
|
||||
[:> radio-buttons* {:selected (d/name grow-type)
|
||||
:on-change handle-change
|
||||
:name "grow-text-options"
|
||||
:options [{:value "fixed"
|
||||
:id "text-fixed-grow"
|
||||
:label (tr "workspace.options.text-options.grow-fixed")
|
||||
:icon i/text-fixed}
|
||||
{:value "auto-width"
|
||||
:id "text-auto-width-grow"
|
||||
:label (tr "workspace.options.text-options.grow-auto-width")
|
||||
:icon i/text-auto-width}
|
||||
{:value "auto-height"
|
||||
:id "text-auto-height-grow"
|
||||
:label (tr "workspace.options.text-options.grow-auto-height")
|
||||
:icon i/text-auto-height}]}]]))
|
||||
:options options}]]))
|
||||
|
||||
(mf/defc text-decoration-options*
|
||||
[{:keys [values on-change on-blur token-applied]}]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user