mirror of
https://github.com/penpot/penpot.git
synced 2025-01-06 14:50:20 -05:00
✨ Allow setting stroke-color via context-menu
This commit is contained in:
parent
b3b8121d60
commit
3d99c2a5eb
5 changed files with 18 additions and 7 deletions
|
@ -74,7 +74,8 @@
|
|||
|
||||
(sm/register! ::color
|
||||
[:map
|
||||
[:color {:optional true} token-name-ref]])
|
||||
[:fill {:optional true} token-name-ref]
|
||||
[:stroke-color {:optional true} token-name-ref]])
|
||||
|
||||
(def color-keys (schema-keys ::color))
|
||||
|
||||
|
|
|
@ -128,13 +128,20 @@
|
|||
{:reg-objects? true
|
||||
:attrs [:strokes]}))
|
||||
|
||||
(defn update-color
|
||||
[value shape-ids]
|
||||
(defn update-color [f value shape-ids]
|
||||
(let [color (some->> value
|
||||
(tinycolor/valid-color)
|
||||
(tinycolor/->hex)
|
||||
(str "#"))]
|
||||
(wdc/change-fill shape-ids {:color color} 0)))
|
||||
(f shape-ids {:color color} 0)))
|
||||
|
||||
(defn update-fill
|
||||
[value shape-ids]
|
||||
(update-color wdc/change-fill value shape-ids))
|
||||
|
||||
(defn update-stroke-color
|
||||
[value shape-ids]
|
||||
(update-color wdc/change-stroke value shape-ids))
|
||||
|
||||
(defn update-shape-dimensions [value shape-ids attributes]
|
||||
(ptk/reify ::update-shape-dimensions
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
[app.common.data :as d]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.tokens :as dt]
|
||||
[app.main.data.workspace.shape-layout :as dwsl]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.dropdown :refer [dropdown]]
|
||||
|
@ -185,6 +184,9 @@
|
|||
:r3 "Bottom Right"}
|
||||
:on-update-shape-all wtch/update-shape-radius-all
|
||||
:on-update-shape wtch/update-shape-radius-single-corner})
|
||||
:color (fn [context-data]
|
||||
[(generic-attribute-actions #{:fill} "Fill" (assoc context-data :on-update-shape wtch/update-fill))
|
||||
(generic-attribute-actions #{:stroke-color} "Stroke" (assoc context-data :on-update-shape wtch/update-stroke-color))])
|
||||
:spacing spacing-attribute-actions
|
||||
:sizing sizing-attribute-actions
|
||||
:rotation (partial generic-attribute-actions #{:rotation} "Rotation")
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
:color
|
||||
{:title "Color"
|
||||
:attributes ctt/color-keys
|
||||
:on-update-shape wtch/update-color
|
||||
:on-update-shape wtch/update-fill
|
||||
:modal {:key :tokens/color
|
||||
:fields [{:label "Color" :key :color}]}}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
(def attributes->shape-update
|
||||
{#{:rx :ry} (fn [v ids _] (wtch/update-shape-radius-all v ids))
|
||||
#{:r1 :r2 :r3 :r4} wtch/update-shape-radius-single-corner
|
||||
ctt/color-keys wtch/update-color
|
||||
#{:fill} wtch/update-fill
|
||||
#{:stroke-color} wtch/update-stroke-color
|
||||
ctt/stroke-width-keys wtch/update-stroke-width
|
||||
ctt/sizing-keys wtch/update-shape-dimensions
|
||||
ctt/opacity-keys wtch/update-opacity
|
||||
|
|
Loading…
Reference in a new issue