mirror of
https://github.com/penpot/penpot.git
synced 2026-05-27 10:53:51 +00:00
🐛 Remove duplicated tokens on stroke panel
This commit is contained in:
parent
579de6558a
commit
436bc23da4
@ -45,13 +45,17 @@
|
|||||||
token (get resolved-tokens applied-tokens-in-shape)]
|
token (get resolved-tokens applied-tokens-in-shape)]
|
||||||
token))
|
token))
|
||||||
|
|
||||||
;; Current token implementation on fills only supports one token per shape and has to be the first fill
|
;; Current token implementation on strokes only supports one token per shape and has to be the first stroke
|
||||||
;; This must be improved in the future
|
;; This must be improved in the future
|
||||||
|
(defn- is-first-element?
|
||||||
|
[idx]
|
||||||
|
(= 0 idx))
|
||||||
|
|
||||||
(defn- has-color-token?
|
(defn- has-color-token?
|
||||||
"Returns true if the resolved token matches the color and is the first fill (idx = 0)."
|
"Returns true if the resolved token matches the color and is the first stroke (idx = 0)."
|
||||||
[resolved-token stroke-type idx]
|
[resolved-token stroke-type idx]
|
||||||
(and (= (:resolved-value resolved-token) (:color stroke-type))
|
(and (= (:resolved-value resolved-token) (:color stroke-type))
|
||||||
(= 0 idx)))
|
(is-first-element? idx)))
|
||||||
|
|
||||||
(mf/defc stroke-panel*
|
(mf/defc stroke-panel*
|
||||||
[{:keys [shapes objects resolved-tokens color-space]}]
|
[{:keys [shapes objects resolved-tokens color-space]}]
|
||||||
@ -60,12 +64,11 @@
|
|||||||
[:div {:key (:id shape) :class "stroke-shape"}
|
[:div {:key (:id shape) :class "stroke-shape"}
|
||||||
(for [[idx stroke] (map-indexed vector (:strokes shape))]
|
(for [[idx stroke] (map-indexed vector (:strokes shape))]
|
||||||
(for [property properties]
|
(for [property properties]
|
||||||
(let [property property
|
(let [value (css/get-css-value objects stroke property)
|
||||||
value (css/get-css-value objects stroke property)
|
|
||||||
stroke-type (stroke->color stroke)
|
stroke-type (stroke->color stroke)
|
||||||
property-name (cmm/get-css-rule-humanized property)
|
property-name (cmm/get-css-rule-humanized property)
|
||||||
property-value (css/get-css-property objects stroke property)
|
property-value (css/get-css-property objects stroke property)
|
||||||
resolved-token (get-resolved-token property shape resolved-tokens)
|
resolved-token (when (is-first-element? idx) (get-resolved-token property shape resolved-tokens))
|
||||||
has-color-token (has-color-token? resolved-token stroke-type idx)]
|
has-color-token (has-color-token? resolved-token stroke-type idx)]
|
||||||
(if (= property :border-color)
|
(if (= property :border-color)
|
||||||
[:> color-properties-row* {:key (str idx property)
|
[:> color-properties-row* {:key (str idx property)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user