mirror of
https://github.com/penpot/penpot.git
synced 2025-05-15 20:06:39 +02:00
🐛 Fix color picker not working
This commit is contained in:
parent
1b44fe8fec
commit
16fcc60a59
2 changed files with 29 additions and 14 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.text.fontfaces
|
(ns app.main.ui.shapes.text.fontfaces
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
[app.main.fonts :as fonts]
|
[app.main.fonts :as fonts]
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
[app.main.ui.shapes.embed :as embed]
|
[app.main.ui.shapes.embed :as embed]
|
||||||
|
@ -47,19 +48,12 @@
|
||||||
|
|
||||||
(mf/ref-val fonts-css-ref)))
|
(mf/ref-val fonts-css-ref)))
|
||||||
|
|
||||||
(mf/defc fontfaces-style
|
(mf/defc fontfaces-style-render
|
||||||
{::mf/wrap-props false
|
{::mf/wrap-props false
|
||||||
::mf/wrap [#(mf/memo' % (mf/check-props ["shapes"]))]}
|
::mf/wrap [#(mf/memo' % (mf/check-props ["fonts"]))]}
|
||||||
[props]
|
[props]
|
||||||
(let [shapes (obj/get props "shapes")
|
|
||||||
|
|
||||||
content (->> shapes (mapv :content))
|
(let [fonts (obj/get props "fonts")
|
||||||
|
|
||||||
;; Retrieve the fonts ids used by the text shapes
|
|
||||||
fonts (->> content
|
|
||||||
(mapv fonts/get-content-fonts)
|
|
||||||
(reduce set/union #{})
|
|
||||||
(hooks/use-equal-memo))
|
|
||||||
|
|
||||||
;; Fetch its CSS fontfaces
|
;; Fetch its CSS fontfaces
|
||||||
fonts-css (use-fonts-css fonts)
|
fonts-css (use-fonts-css fonts)
|
||||||
|
@ -75,5 +69,23 @@
|
||||||
;; Creates a style tag by replacing the urls with the data uri
|
;; Creates a style tag by replacing the urls with the data uri
|
||||||
style (replace-embeds fonts-css fonts-urls fonts-embed)]
|
style (replace-embeds fonts-css fonts-urls fonts-embed)]
|
||||||
|
|
||||||
(when (seq style)
|
(when (d/not-empty? style)
|
||||||
[:style style])))
|
[:style style])))
|
||||||
|
|
||||||
|
(mf/defc fontfaces-style
|
||||||
|
{::mf/wrap-props false
|
||||||
|
::mf/wrap [#(mf/memo' % (mf/check-props ["shapes"]))]}
|
||||||
|
[props]
|
||||||
|
(let [shapes (->> (obj/get props "shapes")
|
||||||
|
(filterv #(= :text (:type %))))
|
||||||
|
|
||||||
|
content (->> shapes (mapv :content))
|
||||||
|
|
||||||
|
;; Retrieve the fonts ids used by the text shapes
|
||||||
|
fonts (->> content
|
||||||
|
(mapv fonts/get-content-fonts)
|
||||||
|
(reduce set/union #{})
|
||||||
|
(hooks/use-equal-memo))]
|
||||||
|
|
||||||
|
(when (d/not-empty? fonts)
|
||||||
|
[:> fontfaces-style-render {:fonts fonts}])))
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
(ns app.main.ui.workspace.shapes.frame
|
(ns app.main.ui.workspace.shapes.frame
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
|
[app.common.pages :as cp]
|
||||||
[app.main.ui.shapes.frame :as frame]
|
[app.main.ui.shapes.frame :as frame]
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||||
[app.main.ui.shapes.text.fontfaces :as ff]
|
[app.main.ui.shapes.text.fontfaces :as ff]
|
||||||
|
@ -76,8 +77,10 @@
|
||||||
objects (unchecked-get props "objects")
|
objects (unchecked-get props "objects")
|
||||||
thumbnail? (unchecked-get props "thumbnail?")
|
thumbnail? (unchecked-get props "thumbnail?")
|
||||||
|
|
||||||
shape (gsh/transform-shape shape)
|
shape (gsh/transform-shape shape)
|
||||||
children (mapv #(get objects %) (:shapes shape))
|
children (mapv #(get objects %) (:shapes shape))
|
||||||
|
|
||||||
|
all-children (cp/get-children-objects (:id shape) objects)
|
||||||
|
|
||||||
rendered? (mf/use-state false)
|
rendered? (mf/use-state false)
|
||||||
|
|
||||||
|
@ -93,7 +96,7 @@
|
||||||
|
|
||||||
(when-not show-thumbnail?
|
(when-not show-thumbnail?
|
||||||
[:> shape-container {:shape shape :ref on-dom}
|
[:> shape-container {:shape shape :ref on-dom}
|
||||||
[:& ff/fontfaces-style {:shapes children}]
|
[:& ff/fontfaces-style {:shapes all-children}]
|
||||||
[:& frame-shape {:shape shape
|
[:& frame-shape {:shape shape
|
||||||
:childs children}]])
|
:childs children}]])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue