mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 07:06:12 +02:00
🐛 Fix create color asset from selected layer
This commit is contained in:
parent
c189b5e638
commit
78551cea61
3 changed files with 38 additions and 17 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
- Fix files can be opened from multiple urls [Taiga #5310](https://tree.taiga.io/project/penpot/issue/5310)
|
- Fix files can be opened from multiple urls [Taiga #5310](https://tree.taiga.io/project/penpot/issue/5310)
|
||||||
|
- Fix asset color item was created from the selected layer [Taiga #5180](https://tree.taiga.io/project/penpot/issue/5180)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.broadcast :as mbc]
|
[app.main.broadcast :as mbc]
|
||||||
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.modal :as md]
|
[app.main.data.modal :as md]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.layout :as layout]
|
[app.main.data.workspace.layout :as layout]
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.texts :as dwt]
|
[app.main.data.workspace.texts :as dwt]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
|
[app.main.store :as st]
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
@ -604,3 +606,35 @@
|
||||||
(assoc :alpha 0)
|
(assoc :alpha 0)
|
||||||
(assoc :offset 1)
|
(assoc :offset 1)
|
||||||
(materialize-color-components))]))))))))))
|
(materialize-color-components))]))))))))))
|
||||||
|
|
||||||
|
(defn select-color
|
||||||
|
[position]
|
||||||
|
(ptk/reify ::select-color
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state _]
|
||||||
|
(let [selected (wsh/lookup-selected state)
|
||||||
|
shapes (wsh/lookup-shapes state selected)
|
||||||
|
shape (first shapes)
|
||||||
|
fills (if (cph/text-shape? shape)
|
||||||
|
(:fills (dwt/current-text-values
|
||||||
|
{:editor-state (dm/get-in state [:workspace-editor-state (:id shape)])
|
||||||
|
:shape shape
|
||||||
|
:attrs (conj dwt/text-fill-attrs :fills)}))
|
||||||
|
(:fills shape))
|
||||||
|
fill (first fills)
|
||||||
|
single? (and (= 1 (count selected))
|
||||||
|
(= 1 (count fills)))
|
||||||
|
data (if single?
|
||||||
|
(d/without-nils {:color (:fill-color fill)
|
||||||
|
:opacity (:fill-opacity fill)
|
||||||
|
:gradient (:fill-color-gradient fill)})
|
||||||
|
{:color "#406280"
|
||||||
|
:opacity 1})]
|
||||||
|
(rx/of (md/show :colorpicker
|
||||||
|
{:x (:x position)
|
||||||
|
:y (:y position)
|
||||||
|
:on-accept #(st/emit! (dwl/add-color data))
|
||||||
|
:data data
|
||||||
|
:position :right})
|
||||||
|
(ptk/event ::ev/event {::ev/name "add-asset-to-library"
|
||||||
|
:asset-type "color"}))))))
|
||||||
|
|
|
@ -1546,25 +1546,11 @@
|
||||||
|
|
||||||
read-only? (mf/use-ctx ctx/workspace-read-only?)
|
read-only? (mf/use-ctx ctx/workspace-read-only?)
|
||||||
|
|
||||||
add-color
|
|
||||||
(mf/use-fn
|
|
||||||
(fn [value _]
|
|
||||||
(st/emit! (dwl/add-color value))))
|
|
||||||
|
|
||||||
add-color-clicked
|
add-color-clicked
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps file-id)
|
(fn [event]
|
||||||
(fn [event]
|
(let [position (dom/get-client-position event)]
|
||||||
(st/emit! (dw/set-assets-section-open file-id :colors true)
|
(st/emit! (dc/select-color position)))))
|
||||||
(ptk/event ::ev/event {::ev/name "add-asset-to-library"
|
|
||||||
:asset-type "color"}))
|
|
||||||
(modal/show! :colorpicker
|
|
||||||
{:x (.-clientX event)
|
|
||||||
:y (.-clientY event)
|
|
||||||
:on-accept add-color
|
|
||||||
:data {:color "#406280"
|
|
||||||
:opacity 1}
|
|
||||||
:position :right})))
|
|
||||||
|
|
||||||
create-group
|
create-group
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue