0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-22 14:39:45 -05:00

🐛 Fix components texts not displayed in assets panel

This commit is contained in:
Alejandro Alonso 2023-03-03 13:31:32 +01:00 committed by Alonso Torres
parent e8027d3316
commit 9e35229ebd
4 changed files with 13 additions and 6 deletions

View file

@ -7,6 +7,7 @@
- Fix custom fonts not rendered correctly [Taiga #4874](https://tree.taiga.io/project/penpot/issue/4874)
- Fix problem with shadows and blur on multiple selection
- Fix problem with redo shortcut
- Fix Component texts not displayed in assets panel [Taiga #4907](https://tree.taiga.io/project/penpot/issue/4907)
- Fix search field has implemented shared styles for "close icon" and "search icon" [Taiga #4927](https://tree.taiga.io/project/penpot/issue/4927)
- Fix Handling correctly slashes "/" in emails [Taiga #4906](https://tree.taiga.io/project/penpot/issue/4906)
- Fix Change text color from selected colors [Taiga #4933](https://tree.taiga.io/project/penpot/issue/4933)

View file

@ -287,7 +287,6 @@
:fill "none"}
[:& shape-wrapper {:shape frame}]]]))
;; Component for rendering a thumbnail of a single componenent. Mainly
;; used to render thumbnails on assets panel.
(mf/defc component-svg
@ -334,7 +333,8 @@
:fill "none"}
[:> shape-container {:shape root-shape}
[:& root-shape-wrapper {:shape root-shape :view-box vbox}]]]))
[:& (mf/provider muc/is-component?) {:value true}
[:& root-shape-wrapper {:shape root-shape :view-box vbox}]]]]))
(mf/defc object-svg
{::mf/wrap [mf/memo]}
@ -468,7 +468,7 @@
(let [texts (->> objects
(vals)
(filterv #(= (:type %) :text))
(mapv :content)) ]
(mapv :content))]
(->> (rx/from texts)
(rx/map fonts/get-content-fonts)

View file

@ -27,3 +27,4 @@
(def current-zoom (mf/create-context nil))
(def workspace-read-only? (mf/create-context nil))
(def is-component? (mf/create-context false))

View file

@ -8,6 +8,8 @@
(:require
[app.common.text :as txt]
[app.main.fonts :as fonts]
[app.main.ui.context :as ctx]
[app.main.ui.shapes.text.fo-text :as fo]
[app.main.ui.shapes.text.svg-text :as svg]
[app.util.object :as obj]
[rumext.v2 :as mf]))
@ -22,10 +24,13 @@
(mf/defc text-shape
{::mf/wrap-props false}
[props]
(let [{:keys [position-data content] :as shape} (obj/get props "shape")]
(let [{:keys [position-data content] :as shape} (obj/get props "shape")
is-component? (mf/use-ctx ctx/is-component?)]
(mf/with-memo [content]
(load-fonts! content))
(when (some? position-data)
[:> svg/text-shape props])))
;; Old components can have texts without position data that must be rendered via foreign key
(cond
(some? position-data) [:> svg/text-shape props]
is-component? [:> fo/text-shape props])))