mirror of
https://github.com/penpot/penpot.git
synced 2025-06-08 21:52:13 +02:00
Single attribute context menu
This commit is contained in:
parent
ae2da534e9
commit
359ec592fb
1 changed files with 34 additions and 27 deletions
|
@ -211,35 +211,42 @@
|
||||||
:selected-shapes selected-shapes})))
|
:selected-shapes selected-shapes})))
|
||||||
|
|
||||||
(defn border-radius-attribute-actions [{:keys [token-id selected-shapes] :as _props}]
|
(defn border-radius-attribute-actions [{:keys [token-id selected-shapes] :as _props}]
|
||||||
(let [all-attributes #{:r1 :r2 :r3 :r4}
|
(let [token {:id token-id}
|
||||||
ids-by-attributes (wtt/shapes-ids-by-applied-attributes {:id token-id} selected-shapes all-attributes)
|
all-attributes #{:r1 :r2 :r3 :r4}
|
||||||
|
ids-by-attributes (wtt/shapes-ids-by-applied-attributes token selected-shapes all-attributes)
|
||||||
shape-ids (into #{} (map :id selected-shapes))
|
shape-ids (into #{} (map :id selected-shapes))
|
||||||
all? (wtt/shapes-applied-all? ids-by-attributes shape-ids all-attributes)
|
all? (wtt/shapes-applied-all? ids-by-attributes shape-ids all-attributes)
|
||||||
selected? #(and
|
selected-pred #(and
|
||||||
(not all?)
|
(not all?)
|
||||||
(seq (% ids-by-attributes)))]
|
(seq (% ids-by-attributes)))
|
||||||
[{:title "All"
|
single-attributes (->> {:r1 "Top Left"
|
||||||
:selected? all?
|
:r2 "Top Right"
|
||||||
:action #(if all?
|
:r3 "Bottom Left"
|
||||||
(st/emit! (wtc/unapply-token {:token {:id token-id}
|
:r4 "Bottom Right"}
|
||||||
:attributes all-attributes
|
(map (fn [[attr title]]
|
||||||
:shape-ids shape-ids}))
|
(let [selected? (selected-pred attr)]
|
||||||
(st/emit! (wtc/apply-token {:token {:id token-id}
|
{:title title
|
||||||
:attributes all-attributes
|
:selected? selected?
|
||||||
:on-update-shape wtc/update-shape-radius
|
:action (if selected?
|
||||||
:shape-ids shape-ids})))}
|
(st/emit! (wtc/unapply-token {:token token
|
||||||
{:title "Top Left"
|
:attributes #{attr}
|
||||||
:selected? (selected? :r1)
|
:shape-ids shape-ids}))
|
||||||
:action (when all? #(js/console.log "all"))}
|
(st/emit! (wtc/apply-token {:token token
|
||||||
{:title "Top Right"
|
:attributes #{attr}
|
||||||
:selected? (selected? :r2)
|
:on-update-shape wtc/update-shape-radius-single-corner
|
||||||
:action (when all? #(js/console.log "all"))}
|
:shape-ids shape-ids})))}))))]
|
||||||
{:title "Bottom Right"
|
(concat
|
||||||
:selected? (selected? :r3)
|
[{:title "All"
|
||||||
:action (when all? #(js/console.log "all"))}
|
:selected? all?
|
||||||
{:title "Bottom Left"
|
:action #(if all?
|
||||||
:selected? (selected? :r4)
|
(st/emit! (wtc/unapply-token {:token token
|
||||||
:action (when all? #(js/console.log "all"))}]))
|
:attributes all-attributes
|
||||||
|
:shape-ids shape-ids}))
|
||||||
|
(st/emit! (wtc/apply-token {:token token
|
||||||
|
:attributes all-attributes
|
||||||
|
:on-update-shape wtc/update-shape-radius-all
|
||||||
|
:shape-ids shape-ids})))}]
|
||||||
|
single-attributes)))
|
||||||
|
|
||||||
(defn shape-attribute-actions [{:keys [token-id token-type selected-shapes] :as context-data}]
|
(defn shape-attribute-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]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue