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

pass context menu attributes as map and some minor fixes

This commit is contained in:
Akshay Gupta 2024-05-28 17:03:26 +05:30
parent 9066ad9e39
commit bb3ee22780

View file

@ -50,7 +50,7 @@
:token-type-props updated-token-type-props :token-type-props updated-token-type-props
:selected-shapes selected-shapes}))) :selected-shapes selected-shapes})))
(defn additional-actions [token-type token-id selected-shapes token-type-props] (defn additional-actions [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]
(case token-type (case token-type
:border-radius [{:title "All" :action #(apply-border-radius-token token-id token-type-props :all selected-shapes)} :border-radius [{:title "All" :action #(apply-border-radius-token token-id token-type-props :all selected-shapes)}
{:title "Top Left" :action #(apply-border-radius-token token-id token-type-props :r1 selected-shapes)} {:title "Top Left" :action #(apply-border-radius-token token-id token-type-props :r1 selected-shapes)}
@ -59,7 +59,7 @@
{:title "Bottom Left" :action #(apply-border-radius-token token-id token-type-props :r4 selected-shapes)}] {:title "Bottom Left" :action #(apply-border-radius-token token-id token-type-props :r4 selected-shapes)}]
[])) []))
(defn generate-menu-entries [token-type-props token-id token-type selected-shapes] (defn generate-menu-entries [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]
(let [{:keys [modal]} token-type-props (let [{:keys [modal]} token-type-props
default-actions [{:title "Delete Token" :action #(st/emit! (dt/delete-token token-id))} default-actions [{:title "Delete Token" :action #(st/emit! (dt/delete-token token-id))}
{:title "Duplicate Token" :action #(st/emit! (dt/duplicate-token token-id))} {:title "Duplicate Token" :action #(st/emit! (dt/duplicate-token token-id))}
@ -73,15 +73,15 @@
:position :right :position :right
:fields fields :fields fields
:token token})))}] :token token})))}]
specific-actions (additional-actions token-type token-id selected-shapes token-type-props) specific-actions (additional-actions context-data)
all-actions (concat default-actions specific-actions)] all-actions (concat default-actions specific-actions)]
all-actions)) all-actions))
(mf/defc token-pill-context-menu (mf/defc token-pill-context-menu
[{:keys [token-id token-type-props token-type selected-shapes]}] [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]
(let [menu-entries (generate-menu-entries token-type-props token-id token-type selected-shapes)] (let [menu-entries (generate-menu-entries context-data)]
[:* (for [[index entry] (d/enumerate menu-entries)] (for [[index entry] (d/enumerate menu-entries)]
[:& menu-entry {:title (:title entry) :on-click (:action entry)}])])) [:& menu-entry {:title (:title entry) :on-click (:action entry) :key index}])))
(mf/defc token-context-menu (mf/defc token-context-menu
[] []