mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 12:26:10 +02:00
✨ Show recent fonts only on text edition area not in typographies
This commit is contained in:
parent
39b29ee3f0
commit
b8f2f3e34d
2 changed files with 15 additions and 9 deletions
|
@ -301,6 +301,7 @@
|
||||||
opts #js {:ids ids
|
opts #js {:ids ids
|
||||||
:values values
|
:values values
|
||||||
:on-change on-change
|
:on-change on-change
|
||||||
|
:show-recent true
|
||||||
:on-blur
|
:on-blur
|
||||||
(fn []
|
(fn []
|
||||||
(tm/schedule
|
(tm/schedule
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
;; (conj backends id)))
|
;; (conj backends id)))
|
||||||
|
|
||||||
(mf/defc font-selector
|
(mf/defc font-selector
|
||||||
[{:keys [on-select on-close current-font] :as props}]
|
[{:keys [on-select on-close current-font show-recent] :as props}]
|
||||||
(let [selected (mf/use-state current-font)
|
(let [selected (mf/use-state current-font)
|
||||||
state (mf/use-state {:term "" :backends #{}})
|
state (mf/use-state {:term "" :backends #{}})
|
||||||
|
|
||||||
|
@ -189,8 +189,8 @@
|
||||||
:ref input
|
:ref input
|
||||||
:spell-check false
|
:spell-check false
|
||||||
:on-change on-filter-change}]
|
:on-change on-filter-change}]
|
||||||
[:hr]
|
(when (and recent-fonts show-recent)
|
||||||
(when recent-fonts
|
[:hr]
|
||||||
[*
|
[*
|
||||||
[:p.title (tr "workspace.options.recent-fonts")]
|
[:p.title (tr "workspace.options.recent-fonts")]
|
||||||
(for [font recent-fonts]
|
(for [font recent-fonts]
|
||||||
|
@ -249,7 +249,7 @@
|
||||||
:current? (= (:id font) (:id selected))}])))
|
:current? (= (:id font) (:id selected))}])))
|
||||||
|
|
||||||
(mf/defc font-options
|
(mf/defc font-options
|
||||||
[{:keys [values on-change on-blur] :as props}]
|
[{:keys [values on-change on-blur show-recent] :as props}]
|
||||||
(let [{:keys [font-id font-size font-variant-id]} values
|
(let [{:keys [font-id font-size font-variant-id]} values
|
||||||
|
|
||||||
font-id (or font-id (:font-id txt/default-text-attrs))
|
font-id (or font-id (:font-id txt/default-text-attrs))
|
||||||
|
@ -312,14 +312,17 @@
|
||||||
(reset! open-selector? false)
|
(reset! open-selector? false)
|
||||||
(when (some? on-blur)
|
(when (some? on-blur)
|
||||||
(on-blur))
|
(on-blur))
|
||||||
(st/emit! (fts/add-recent-font (mf/ref-val last-font)))))]
|
(when (mf/ref-val last-font)
|
||||||
|
(st/emit! (fts/add-recent-font (mf/ref-val last-font))))
|
||||||
|
))]
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
(when @open-selector?
|
(when @open-selector?
|
||||||
[:& font-selector
|
[:& font-selector
|
||||||
{:current-font font
|
{:current-font font
|
||||||
:on-close on-font-selector-close
|
:on-close on-font-selector-close
|
||||||
:on-select on-font-select}])
|
:on-select on-font-select
|
||||||
|
:show-recent show-recent}])
|
||||||
|
|
||||||
[:div.row-flex
|
[:div.row-flex
|
||||||
[:div.input-select.font-option
|
[:div.input-select.font-option
|
||||||
|
@ -434,12 +437,13 @@
|
||||||
i/titlecase]]))
|
i/titlecase]]))
|
||||||
|
|
||||||
(mf/defc typography-options
|
(mf/defc typography-options
|
||||||
[{:keys [ids editor values on-change on-blur]}]
|
[{:keys [ids editor values on-change on-blur show-recent]}]
|
||||||
(let [opts #js {:editor editor
|
(let [opts #js {:editor editor
|
||||||
:ids ids
|
:ids ids
|
||||||
:values values
|
:values values
|
||||||
:on-change on-change
|
:on-change on-change
|
||||||
:on-blur on-blur}]
|
:on-blur on-blur
|
||||||
|
:show-recent show-recent}]
|
||||||
[:div.element-set-content
|
[:div.element-set-content
|
||||||
[:> font-options opts]
|
[:> font-options opts]
|
||||||
[:div.row-flex
|
[:div.row-flex
|
||||||
|
@ -580,4 +584,5 @@
|
||||||
i/actions]]]
|
i/actions]]]
|
||||||
|
|
||||||
[:& typography-options {:values typography
|
[:& typography-options {:values typography
|
||||||
:on-change on-change}]])]]))
|
:on-change on-change
|
||||||
|
:show-recent false}]])]]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue