mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
🐛 Fix not properly display library color
This commit is contained in:
parent
f32531b39f
commit
6d666c4926
2 changed files with 15 additions and 25 deletions
|
@ -50,21 +50,18 @@
|
||||||
on-reorder on-detach on-open on-close on-remove
|
on-reorder on-detach on-open on-close on-remove
|
||||||
disable-drag on-focus on-blur select-only select-on-focus]}]
|
disable-drag on-focus on-blur select-only select-on-focus]}]
|
||||||
(let [current-file-id (mf/use-ctx ctx/current-file-id)
|
(let [current-file-id (mf/use-ctx ctx/current-file-id)
|
||||||
file-colors (mf/deref refs/workspace-file-colors)
|
|
||||||
shared-libs (mf/deref refs/libraries)
|
shared-libs (mf/deref refs/libraries)
|
||||||
hover-detach (mf/use-state false)
|
hover-detach (mf/use-state false)
|
||||||
on-change (h/use-ref-callback on-change)
|
on-change (h/use-ref-callback on-change)
|
||||||
src-colors (if (= (:file-id color) current-file-id)
|
|
||||||
file-colors
|
|
||||||
(dm/get-in shared-libs [(:file-id color) :data :colors]))
|
|
||||||
|
|
||||||
color-name (dm/get-in src-colors [(:id color) :name])
|
src-colors (dm/get-in shared-libs [(:ref-file color) :data :colors])
|
||||||
|
color-name (dm/get-in src-colors [(:ref-id color) :name])
|
||||||
|
|
||||||
multiple-colors? (uc/multiple? color)
|
multiple-colors? (uc/multiple? color)
|
||||||
library-color? (and (:id color) color-name (not multiple-colors?))
|
library-color? (and (:ref-id color) color-name (not multiple-colors?))
|
||||||
gradient-color? (and (not multiple-colors?)
|
gradient-color? (and (not multiple-colors?)
|
||||||
(:gradient color)
|
(:gradient color)
|
||||||
(get-in color [:gradient :type]))
|
(dm/get-in color [:gradient :type]))
|
||||||
image-color? (and (not multiple-colors?)
|
image-color? (and (not multiple-colors?)
|
||||||
(:image color))
|
(:image color))
|
||||||
|
|
||||||
|
@ -124,10 +121,9 @@
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps color on-change)
|
(mf/deps color on-change)
|
||||||
(fn [value]
|
(fn [value]
|
||||||
(let [color (assoc color
|
(let [color (-> color
|
||||||
:opacity (/ value 100)
|
(assoc :opacity (/ value 100))
|
||||||
:id nil
|
(dissoc :ref-id :ref-file))]
|
||||||
:file-id nil)]
|
|
||||||
(st/emit! (dwl/add-recent-color color)
|
(st/emit! (dwl/add-recent-color color)
|
||||||
(on-change color)))))
|
(on-change color)))))
|
||||||
|
|
||||||
|
@ -209,13 +205,11 @@
|
||||||
:gradient-name-wrapper gradient-color?)}
|
:gradient-name-wrapper gradient-color?)}
|
||||||
[:div {:class (stl/css :color-bullet-wrapper)}
|
[:div {:class (stl/css :color-bullet-wrapper)}
|
||||||
[:& cb/color-bullet {:color (cond-> color
|
[:& cb/color-bullet {:color (cond-> color
|
||||||
(nil? color-name) (assoc
|
(nil? color-name) (dissoc :ref-id :ref-file))
|
||||||
:id nil
|
|
||||||
:file-id nil))
|
|
||||||
:mini true
|
:mini true
|
||||||
:on-click handle-click-color}]]
|
:on-click handle-click-color}]]
|
||||||
(cond
|
(cond
|
||||||
;; Rendering a color with ID
|
;; Rendering a color with ID
|
||||||
library-color?
|
library-color?
|
||||||
[:*
|
[:*
|
||||||
[:div {:class (stl/css :color-name)
|
[:div {:class (stl/css :color-name)
|
||||||
|
@ -235,7 +229,7 @@
|
||||||
gradient-color?
|
gradient-color?
|
||||||
[:*
|
[:*
|
||||||
[:div {:class (stl/css :color-name)}
|
[:div {:class (stl/css :color-name)}
|
||||||
(uc/gradient-type->string (get-in color [:gradient :type]))]]
|
(uc/gradient-type->string (dm/get-in color [:gradient :type]))]]
|
||||||
|
|
||||||
;; Rendering an image
|
;; Rendering an image
|
||||||
image-color?
|
image-color?
|
||||||
|
@ -250,7 +244,7 @@
|
||||||
""
|
""
|
||||||
(-> color :color cc/remove-hash))
|
(-> color :color cc/remove-hash))
|
||||||
:placeholder (tr "settings.multiple")
|
:placeholder (tr "settings.multiple")
|
||||||
:className (stl/css :color-input)
|
:class (stl/css :color-input)
|
||||||
:on-focus on-focus
|
:on-focus on-focus
|
||||||
:on-blur on-blur
|
:on-blur on-blur
|
||||||
:on-change handle-value-change}]])]
|
:on-change handle-value-change}]])]
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.types.color :as ctc]
|
||||||
[app.main.ui.components.numeric-input :refer [numeric-input*]]
|
[app.main.ui.components.numeric-input :refer [numeric-input*]]
|
||||||
[app.main.ui.components.reorder-handler :refer [reorder-handler]]
|
[app.main.ui.components.reorder-handler :refer [reorder-handler]]
|
||||||
[app.main.ui.components.select :refer [select]]
|
[app.main.ui.components.select :refer [select]]
|
||||||
|
@ -147,12 +148,7 @@
|
||||||
[:& reorder-handler {:ref dref}])
|
[:& reorder-handler {:ref dref}])
|
||||||
|
|
||||||
;; Stroke Color
|
;; Stroke Color
|
||||||
[:& color-row {:color {:color (:stroke-color stroke)
|
[:& color-row {:color (ctc/stroke->shape-color stroke)
|
||||||
:opacity (:stroke-opacity stroke)
|
|
||||||
:id (:stroke-color-ref-id stroke)
|
|
||||||
:file-id (:stroke-color-ref-file stroke)
|
|
||||||
:gradient (:stroke-color-gradient stroke)
|
|
||||||
:image (:stroke-image stroke)}
|
|
||||||
:index index
|
:index index
|
||||||
:title title
|
:title title
|
||||||
:on-change on-color-change-refactor
|
:on-change on-color-change-refactor
|
||||||
|
|
Loading…
Add table
Reference in a new issue