mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
♻️ Remove duplicated code (#9096)
This commit is contained in:
parent
8bf8601d29
commit
d549be3376
@ -607,46 +607,6 @@
|
||||
:state state})]
|
||||
(apply rx/of (map #(%) actions)))))))))
|
||||
|
||||
(def attributes->shape-update
|
||||
"Maps each attribute-set to the update function that applies it to a shape.
|
||||
Used both here (to resolve the correct update fn when explicit attrs are
|
||||
passed to toggle-token) and in propagation.cljs (re-exported from there)."
|
||||
{ctt/border-radius-keys update-shape-radius-for-corners
|
||||
ctt/color-keys update-fill-stroke
|
||||
ctt/stroke-width-keys update-stroke-width
|
||||
ctt/sizing-keys apply-dimensions-token
|
||||
ctt/opacity-keys update-opacity
|
||||
ctt/rotation-keys update-rotation
|
||||
|
||||
;; Typography
|
||||
ctt/font-family-keys update-font-family
|
||||
ctt/font-size-keys update-font-size
|
||||
ctt/font-weight-keys update-font-weight
|
||||
ctt/letter-spacing-keys update-letter-spacing
|
||||
ctt/text-case-keys update-text-case
|
||||
ctt/text-decoration-keys update-text-decoration
|
||||
ctt/typography-token-keys update-typography
|
||||
ctt/shadow-keys update-shadow
|
||||
ctt/line-height-keys update-line-height
|
||||
|
||||
;; Layout
|
||||
#{:x :y} update-shape-position
|
||||
#{:p1 :p2 :p3 :p4} update-layout-padding
|
||||
#{:m1 :m2 :m3 :m4} update-layout-item-margin
|
||||
#{:column-gap :row-gap} update-layout-gap
|
||||
#{:width :height} apply-dimensions-token
|
||||
#{:layout-item-min-w :layout-item-min-h
|
||||
:layout-item-max-w :layout-item-max-h} update-layout-sizing-limits})
|
||||
|
||||
;; Flattened per-individual-key version of attributes->shape-update.
|
||||
;; Allows O(1) lookup of the update function for any single attribute.
|
||||
(def ^:private attr->shape-update
|
||||
(reduce
|
||||
(fn [acc [attr-set update-fn]]
|
||||
(into acc (map (fn [k] [k update-fn]) attr-set)))
|
||||
{}
|
||||
attributes->shape-update))
|
||||
|
||||
;; Events to apply / unapply tokens to shapes ------------------------------------------------------------
|
||||
|
||||
(def attributes->shape-update
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user