0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 14:12:36 -05:00

Merge pull request #126 from tokens-studio/rotation-token

Add ability to apply rotation token
This commit is contained in:
Akshay Gupta 2024-05-22 15:14:54 +05:30 committed by GitHub
commit 44f55308a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -112,12 +112,20 @@
(def dimensions-keys (schema-keys ::dimensions)) (def dimensions-keys (schema-keys ::dimensions))
(sm/def! ::rotation
[:map
[:rotation ::sm/uuid]])
(def rotation-keys (schema-keys ::rotation))
(sm/def! ::tokens (sm/def! ::tokens
[:map {:title "Applied Tokens"}]) [:map {:title "Applied Tokens"
:closed true}])
(sm/def! ::applied-tokens (sm/def! ::applied-tokens
(merge-schemas ::tokens (merge-schemas ::tokens
::border-radius ::border-radius
::sizing ::sizing
::spacing ::spacing
::rotation
::dimensions)) ::dimensions))

View file

@ -10,6 +10,7 @@
[app.common.types.shape.radius :as ctsr] [app.common.types.shape.radius :as ctsr]
[app.common.types.token :as ctt] [app.common.types.token :as ctt]
[app.main.data.tokens :as dt] [app.main.data.tokens :as dt]
[app.main.data.workspace :as udw]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.shape-layout :as dwsl] [app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
@ -101,6 +102,10 @@
(when (seq (:strokes shape)) (when (seq (:strokes shape))
(assoc-in shape [:strokes 0 :stroke-width] value)))))) (assoc-in shape [:strokes 0 :stroke-width] value))))))
(defn update-rotation [value shape-ids]
(st/emit! (udw/trigger-bounding-box-cloaking shape-ids)
(udw/increase-rotation shape-ids value)))
(defn update-layout-spacing-column [value shape-ids] (defn update-layout-spacing-column [value shape-ids]
(doseq [shape-id shape-ids] (doseq [shape-id shape-ids]
(let [shape (dt/get-shape-from-state shape-id @st/state) (let [shape (dt/get-shape-from-state shape-id @st/state)
@ -172,6 +177,8 @@
:key :other}]}}] :key :other}]}}]
[:rotation [:rotation
{:title "Rotation" {:title "Rotation"
:attributes ctt/rotation-keys
:on-update-shape update-rotation
:modal {:key :tokens/rotation :modal {:key :tokens/rotation
:fields [{:label "Rotation" :fields [{:label "Rotation"
:key :rotation}]}}] :key :rotation}]}}]