0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 18:48:37 -05:00

💄 Add cosmetic improvements on rect options sidebar

This commit is contained in:
Andrey Antukh 2023-05-30 11:38:19 +02:00
parent 6e7595f48c
commit 03271ce3fc

View file

@ -23,44 +23,51 @@
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc options (mf/defc options
{::mf/wrap [mf/memo]} {::mf/wrap [mf/memo]
[{:keys [shape] :as props}] ::mf/wrap-props false}
(let [ids [(:id shape)] [{:keys [shape]}]
type (:type shape) (let [shape-id (:id shape)
measure-values (select-measure-keys shape) ids (hooks/use-equal-memo [shape-id])
layer-values (select-keys shape layer-attrs) type (:type shape)
constraint-values (select-keys shape constraint-attrs) measure-values (select-measure-keys shape)
fill-values (select-keys shape fill-attrs) layer-values (select-keys shape layer-attrs)
stroke-values (select-keys shape stroke-attrs) constraint-values (select-keys shape constraint-attrs)
layout-item-values (select-keys shape layout-item-attrs) fill-values (select-keys shape fill-attrs)
layout-container-values (select-keys shape layout-container-flex-attrs) stroke-values (select-keys shape stroke-attrs)
layout-item-values (select-keys shape layout-item-attrs)
layout-container-values (select-keys shape layout-container-flex-attrs)
is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) is-layout-child* (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids))
is-layout-child? (mf/deref is-layout-child-ref) is-layout-child? (mf/deref is-layout-child*)
is-flex-parent-ref (mf/use-memo (mf/deps ids) #(refs/flex-layout-child? ids)) is-flex-parent* (mf/use-memo (mf/deps ids) #(refs/flex-layout-child? ids))
is-flex-parent? (mf/deref is-flex-parent-ref) is-flex-parent? (mf/deref is-flex-parent*)
is-grid-parent* (mf/use-memo (mf/deps ids) #(refs/grid-layout-child? ids))
is-grid-parent? (mf/deref is-grid-parent*)
is-grid-parent-ref (mf/use-memo (mf/deps ids) #(refs/grid-layout-child? ids))
is-grid-parent? (mf/deref is-grid-parent-ref)
is-layout-child-absolute? (ctl/layout-absolute? shape) is-layout-child-absolute? (ctl/layout-absolute? shape)
ids (hooks/use-equal-memo ids) parents-by-ids* (mf/use-memo (mf/deps ids) #(refs/parents-by-ids ids))
parents-by-ids-ref (mf/use-memo (mf/deps ids) #(refs/parents-by-ids ids)) parents (mf/deref parents-by-ids*)]
parents (mf/deref parents-by-ids-ref)]
[:* [:*
[:& measures-menu {:ids ids [:& measures-menu {:ids ids
:type type :type type
:values measure-values :values measure-values
:shape shape}] :shape shape}]
[:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] [:& layout-container-menu
{:type type
:ids ids
:values layout-container-values
:multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
[:& grid-cell/options [:& grid-cell/options
{:shape (first parents) {:shape (first parents)
:cell (ctl/get-cell-by-shape-id (first parents) (first ids))}]) :cell (ctl/get-cell-by-shape-id (first parents) (first ids))}])
(when is-layout-child? (when ^boolean is-layout-child?
[:& layout-item-menu [:& layout-item-menu
{:ids ids {:ids ids
:type type :type type
@ -70,7 +77,8 @@
:is-grid-parent? is-grid-parent? :is-grid-parent? is-grid-parent?
:shape shape}]) :shape shape}])
(when (or (not is-layout-child?) is-layout-child-absolute?) (when (or (not ^boolean is-layout-child?)
^boolean is-layout-child-absolute?)
[:& constraints-menu {:ids ids [:& constraints-menu {:ids ids
:values constraint-values}]) :values constraint-values}])