0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

Add initial spacing context menu entries

This commit is contained in:
Akshay Gupta 2024-05-29 18:47:17 +05:30
parent bdefc97c21
commit 84d96a1004
No known key found for this signature in database

View file

@ -20,6 +20,7 @@
[app.main.store :as st]
[app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.icons :as i]
[app.main.data.workspace.shape-layout :as dwsl]
[app.main.ui.workspace.context-menu :refer [menu-entry prevent-default]]
[app.main.ui.workspace.tokens.core :as wtc]
[app.util.dom :as dom]
@ -50,6 +51,22 @@
:token-type-props updated-token-type-props
:selected-shapes selected-shapes})))
(defn update-layout-spacing [value shape-ids attribute]
(st/emit! (dwsl/update-layout shape-ids {:layout-padding {:p1 value}})))
(defn apply-spacing-token [token-id token-type-props attribute selected-shapes]
(let [token (dt/get-token-data-from-token-id token-id)
updated-token-type-props (if (#{:padding-p1} attribute)
(assoc token-type-props
:on-update-shape update-layout-spacing
:attributes #{attribute})
token-type-props)]
(wtc/on-apply-token {:token token
:token-type-props updated-token-type-props
:selected-shapes selected-shapes})))
(defn additional-actions [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]
(case token-type
:border-radius [{:title "All" :action #(apply-border-radius-token token-id token-type-props :all selected-shapes)}
@ -57,6 +74,16 @@
{:title "Top Right" :action #(apply-border-radius-token token-id token-type-props :r2 selected-shapes)}
{:title "Bottom Right" :action #(apply-border-radius-token token-id token-type-props :r3 selected-shapes)}
{:title "Bottom Left" :action #(apply-border-radius-token token-id token-type-props :r4 selected-shapes)}]
:spacing [{:title "All" :action #(js/console.log "All spacing")}
{:title "Gap" :action #(js/console.log "Gap")}
{:title "Vertical padding" :action #(js/console.log "Vertical Padding")}
{:title "Horizontal padding" :action #(js/console.log "Horizontal Padding")}
{:title "Row Gap" :action #(js/console.log "Row Gap")}
{:title "Top" :action #(js/console.log "Top")}
{:title "Right" :action #(js/console.log "Right")}
{:title "Bottom" :action #(js/console.log "Bottom")}
{:title "Left" :action #(apply-spacing-token token-id token-type-props :padding-p1 selected-shapes)}
]
[]))
(defn generate-menu-entries [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]
@ -74,7 +101,7 @@
:fields fields
:token token})))}]
specific-actions (additional-actions context-data)
all-actions (concat default-actions specific-actions)]
all-actions (concat specific-actions default-actions)]
all-actions))
(mf/defc token-pill-context-menu