From 84d96a1004cef29dda54521c69bc5ffa661a3e2d Mon Sep 17 00:00:00 2001 From: Akshay Gupta Date: Wed, 29 May 2024 18:47:17 +0530 Subject: [PATCH] Add initial spacing context menu entries --- .../ui/workspace/tokens/context_menu.cljs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs index 1acf6657f..6f53ef28d 100644 --- a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs @@ -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