mirror of
https://github.com/penpot/penpot.git
synced 2025-07-04 11:57:17 +02:00
🐛 Fix the color palette to work with texts and groups.
This commit is contained in:
parent
d37a2766db
commit
d3fe0a8abd
2 changed files with 43 additions and 2 deletions
|
@ -25,6 +25,7 @@
|
||||||
[uxbox.main.data.workspace.notifications :as dwn]
|
[uxbox.main.data.workspace.notifications :as dwn]
|
||||||
[uxbox.main.data.workspace.persistence :as dwp]
|
[uxbox.main.data.workspace.persistence :as dwp]
|
||||||
[uxbox.main.data.workspace.transforms :as dwt]
|
[uxbox.main.data.workspace.transforms :as dwt]
|
||||||
|
[uxbox.main.data.workspace.texts :as dwtxt]
|
||||||
[uxbox.main.repo :as rp]
|
[uxbox.main.repo :as rp]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.streams :as ms]
|
[uxbox.main.streams :as ms]
|
||||||
|
@ -598,6 +599,30 @@
|
||||||
(let [pid (:current-page-id state)]
|
(let [pid (:current-page-id state)]
|
||||||
(update-in state [:workspace-data pid :objects id] merge attrs)))))
|
(update-in state [:workspace-data pid :objects id] merge attrs)))))
|
||||||
|
|
||||||
|
(defn update-shape-recursive
|
||||||
|
[id attrs]
|
||||||
|
(us/verify ::us/uuid id)
|
||||||
|
(us/verify ::shape-attrs attrs)
|
||||||
|
(ptk/reify ::update-shape
|
||||||
|
dwc/IBatchedChange
|
||||||
|
dwc/IUpdateGroup
|
||||||
|
(get-ids [_] [id])
|
||||||
|
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(let [page-id (:current-page-id state)
|
||||||
|
grouped #{:frame :group}]
|
||||||
|
(update-in state [:workspace-data page-id :objects]
|
||||||
|
(fn [objects]
|
||||||
|
(let [childs (d/concat [id] (helpers/get-children id objects))]
|
||||||
|
(reduce (fn [objects id]
|
||||||
|
(let [obj (get objects id)]
|
||||||
|
(if (contains? grouped (:type obj))
|
||||||
|
objects
|
||||||
|
(update objects id merge attrs))))
|
||||||
|
objects
|
||||||
|
childs))))))))
|
||||||
|
|
||||||
;; --- Update Page Options
|
;; --- Update Page Options
|
||||||
|
|
||||||
(defn update-options
|
(defn update-options
|
||||||
|
@ -621,6 +646,22 @@
|
||||||
(let [selected (get-in state [:workspace-local :selected])]
|
(let [selected (get-in state [:workspace-local :selected])]
|
||||||
(rx/from (map #(update-shape % attrs) selected))))))
|
(rx/from (map #(update-shape % attrs) selected))))))
|
||||||
|
|
||||||
|
(defn update-color-on-selected-shapes
|
||||||
|
[{:keys [fill-color stroke-color] :as attrs}]
|
||||||
|
(us/verify ::shape-attrs attrs)
|
||||||
|
(ptk/reify ::update-color-on-selected-shapes
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [selected (get-in state [:workspace-local :selected])
|
||||||
|
page-id (get-in state [:workspace-page :id])]
|
||||||
|
(->> (rx/from selected)
|
||||||
|
(rx/map (fn [id]
|
||||||
|
(let [shape (get-in state [:workspace-data page-id :objects id])]
|
||||||
|
(if (and (string? fill-color)
|
||||||
|
(= :text (:type shape)))
|
||||||
|
(dwtxt/update-text-attrs {:id id :attrs {:fill fill-color}})
|
||||||
|
(update-shape-recursive id attrs))))))))))
|
||||||
|
|
||||||
;; --- Shape Movement (using keyboard shorcuts)
|
;; --- Shape Movement (using keyboard shorcuts)
|
||||||
|
|
||||||
(declare initial-selection-align)
|
(declare initial-selection-align)
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
select-color
|
select-color
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(if (kbd/shift? event)
|
(if (kbd/shift? event)
|
||||||
(st/emit! (udw/update-selected-shapes {:stroke-color color}))
|
(st/emit! (udw/update-color-on-selected-shapes {:stroke-color color}))
|
||||||
(st/emit! (udw/update-selected-shapes {:fill-color color}))))]
|
(st/emit! (udw/update-color-on-selected-shapes {:fill-color color}))))]
|
||||||
|
|
||||||
[:div.color-cell {:key (str color)
|
[:div.color-cell {:key (str color)
|
||||||
:on-click select-color}
|
:on-click select-color}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue