From f10a4f28eaea0e104bae5d0a27d3a4dc56419472 Mon Sep 17 00:00:00 2001 From: Akshay Gupta Date: Wed, 12 Jun 2024 16:18:51 +0530 Subject: [PATCH] Add context menu for opacity, rotation and stroke width --- .../ui/workspace/tokens/context_menu.cljs | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) 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 f3a54d0df..69b68be33 100644 --- a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs @@ -162,11 +162,18 @@ (defn apply-dimensions-token [{:keys [token-id token-type-props selected-shapes]} attributes] (let [token (dt/get-token-data-from-token-id token-id) attributes (set attributes) - updated-token-type-props (if (set/superset? #{:x :y} attributes) + updated-token-type-props (cond + (set/superset? #{:x :y} attributes) (assoc token-type-props :on-update-shape update-shape-position :attributes attributes) - token-type-props)] + + (set/superset? #{:stroke-width} attributes) + (assoc token-type-props + :on-update-shape wtc/update-stroke-width + :attributes attributes) + + :else token-type-props)] (wtc/on-apply-token {:token token :token-type-props updated-token-type-props :selected-shapes selected-shapes}))) @@ -194,6 +201,12 @@ :token-type-props updated-token-type-props :selected-shapes selected-shapes}))) +(defn apply-rotation-opacity-stroke-token [{:keys [token-id token-type-props selected-shapes]} attributes] + (let [token (dt/get-token-data-from-token-id token-id)] + (wtc/on-apply-token {:token token + :token-type-props token-type-props + :selected-shapes selected-shapes}))) + (defn additional-actions [{:keys [token-id token-type selected-shapes] :as context-data}] (let [attributes->actions (fn [update-fn coll] (for [{:keys [attributes] :as item} coll] @@ -236,11 +249,23 @@ [{:title "Spacing" :submenu :spacing} {:title "Sizing" :submenu :sizing} {:title "Border Radius" :submenu :border-radius} - ;; TODO: BORDER_WIDTH {:title "Border Width" :attributes #{:width} :children true} + {:title "Border Width" :attributes #{:stroke-width}} {:title "x" :attributes #{:x}} {:title "y" :attributes #{:y}}]) ;;TODO: Background blur {:title "Background blur" :attributes #{:width}}]) + :opacity (attributes->actions + apply-rotation-opacity-stroke-token + [{:title "opacity" :attributes #{:opacity}}]) + + :rotation (attributes->actions + apply-rotation-opacity-stroke-token + [{:title "rotation" :attributes #{:rotation}}]) + + :stroke-width (attributes->actions + apply-rotation-opacity-stroke-token + [{:title "stroke width" :attributes #{:stroke-width}}]) + []))) (defn generate-menu-entries [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]