mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
Add context menu for opacity, rotation and stroke width
This commit is contained in:
parent
93c249c77a
commit
f10a4f28ea
1 changed files with 28 additions and 3 deletions
|
@ -162,11 +162,18 @@
|
||||||
(defn apply-dimensions-token [{:keys [token-id token-type-props selected-shapes]} attributes]
|
(defn apply-dimensions-token [{:keys [token-id token-type-props selected-shapes]} attributes]
|
||||||
(let [token (dt/get-token-data-from-token-id token-id)
|
(let [token (dt/get-token-data-from-token-id token-id)
|
||||||
attributes (set attributes)
|
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
|
(assoc token-type-props
|
||||||
:on-update-shape update-shape-position
|
:on-update-shape update-shape-position
|
||||||
:attributes attributes)
|
: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
|
(wtc/on-apply-token {:token token
|
||||||
:token-type-props updated-token-type-props
|
:token-type-props updated-token-type-props
|
||||||
:selected-shapes selected-shapes})))
|
:selected-shapes selected-shapes})))
|
||||||
|
@ -194,6 +201,12 @@
|
||||||
:token-type-props updated-token-type-props
|
:token-type-props updated-token-type-props
|
||||||
:selected-shapes selected-shapes})))
|
: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}]
|
(defn additional-actions [{:keys [token-id token-type selected-shapes] :as context-data}]
|
||||||
(let [attributes->actions (fn [update-fn coll]
|
(let [attributes->actions (fn [update-fn coll]
|
||||||
(for [{:keys [attributes] :as item} coll]
|
(for [{:keys [attributes] :as item} coll]
|
||||||
|
@ -236,11 +249,23 @@
|
||||||
[{:title "Spacing" :submenu :spacing}
|
[{:title "Spacing" :submenu :spacing}
|
||||||
{:title "Sizing" :submenu :sizing}
|
{:title "Sizing" :submenu :sizing}
|
||||||
{:title "Border Radius" :submenu :border-radius}
|
{: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 "x" :attributes #{:x}}
|
||||||
{:title "y" :attributes #{:y}}])
|
{:title "y" :attributes #{:y}}])
|
||||||
;;TODO: Background blur {:title "Background blur" :attributes #{:width}}])
|
;;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}]
|
(defn generate-menu-entries [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue