From 98d7895e2a0a4803a1547df6cc6f85c1fc87e901 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Mon, 13 May 2024 11:23:30 +0200 Subject: [PATCH] Add stroke-width token --- common/src/app/common/types/token.cljc | 7 +++++++ .../src/app/main/ui/workspace/tokens/core.cljs | 14 ++++++++++++++ .../src/app/main/ui/workspace/tokens/modals.cljs | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/common/src/app/common/types/token.cljc b/common/src/app/common/types/token.cljc index 7ee478bc5..67b86ef8c 100644 --- a/common/src/app/common/types/token.cljc +++ b/common/src/app/common/types/token.cljc @@ -35,6 +35,7 @@ (def token-types #{:boolean :border-radius + :stroke-width :box-shadow :dimension :numeric @@ -66,6 +67,12 @@ (def border-radius-keys (schema-keys ::border-radius)) +(sm/def! ::stroke-width + [:map + [:stroke-width {:optional true} ::sm/uuid]]) + +(def stroke-width-keys (schema-keys ::stroke-width)) + (sm/def! ::dimensions [:map [:width {:optional true} ::sm/uuid] diff --git a/frontend/src/app/main/ui/workspace/tokens/core.cljs b/frontend/src/app/main/ui/workspace/tokens/core.cljs index 551130a7d..dee160729 100644 --- a/frontend/src/app/main/ui/workspace/tokens/core.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/core.cljs @@ -71,6 +71,13 @@ (st/emit! (dch/update-shapes shape-ids #(assoc % :opacity value)))) +(defn update-stroke-width + [value shape-ids] + (st/emit! + (dch/update-shapes shape-ids (fn [shape] + (when (seq (:strokes shape)) + (assoc-in shape [:strokes 0 :stroke-width] value)))))) + (defn update-layout-spacing-column [value _shape-ids] (let [selected-shapes (wsh/lookup-selected @st/state)] (st/emit! @@ -91,6 +98,13 @@ :modal {:key :tokens/border-radius :fields [{:label "Border Radius" :key :border-radius}]}}] + [:stroke-width + {:title "Stroke Width" + :attributes ctt/stroke-width-keys + :on-update-shape update-stroke-width + :modal {:key :tokens/stroke-width + :fields [{:label "Stroke Width" + :key :stroke-width}]}}] [:box-shadow {:title "Box Shadow" :modal {:key :tokens/box-shadow diff --git a/frontend/src/app/main/ui/workspace/tokens/modals.cljs b/frontend/src/app/main/ui/workspace/tokens/modals.cljs index 83c1ef5c2..9404c9c07 100644 --- a/frontend/src/app/main/ui/workspace/tokens/modals.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/modals.cljs @@ -22,6 +22,12 @@ [properties] [:& tokens-properties-form properties]) +(mf/defc stroke-width-modal + {::mf/register modal/components + ::mf/register-as :tokens/stroke-width} + [properties] + [:& tokens-properties-form properties]) + (mf/defc box-shadow-modal {::mf/register modal/components ::mf/register-as :tokens/box-shadow}