mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 15:39:50 -05:00
✨ Mixed typographies for texts
This commit is contained in:
parent
7248b168fa
commit
c28fce58f1
3 changed files with 21 additions and 8 deletions
|
@ -338,6 +338,7 @@
|
|||
:left nil})
|
||||
|
||||
selected (mf/deref refs/selected-shapes)
|
||||
local (deref refs/workspace-local)
|
||||
|
||||
add-typography
|
||||
(mf/use-callback
|
||||
|
@ -357,7 +358,7 @@
|
|||
{:typography-ref-file (when-not local? file-id)
|
||||
:typography-ref-id (:id typography)}
|
||||
(d/without-keys typography [:id :name]))]
|
||||
(run! #(st/emit! (dwt/update-text-attrs {:id % :editor nil :attrs attrs}))
|
||||
(run! #(st/emit! (dwt/update-text-attrs {:id % :editor (get-in local [:editors %]) :attrs attrs}))
|
||||
selected)))
|
||||
|
||||
on-context-menu
|
||||
|
|
|
@ -303,4 +303,5 @@
|
|||
[:& text-menu {:ids ids
|
||||
:type type
|
||||
:values text-values
|
||||
:editor editor
|
||||
:shapes [shape]}]]))
|
||||
|
|
|
@ -207,10 +207,23 @@
|
|||
|
||||
|
||||
(mf/defc typography-entry
|
||||
[{:keys [typography read-only? on-select on-change on-deattach on-context-menu]}]
|
||||
(let [open? (mf/use-state false)
|
||||
[{:keys [typography read-only? on-select on-change on-deattach on-context-menu editting? focus-name?]}]
|
||||
(let [open? (mf/use-state editting?)
|
||||
selected (mf/deref refs/selected-shapes)
|
||||
hover-deattach (mf/use-state false)]
|
||||
hover-deattach (mf/use-state false)
|
||||
name-input-ref (mf/use-ref nil)]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps editting?)
|
||||
(fn [] (reset! open? editting?)))
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps focus-name?)
|
||||
(fn []
|
||||
(when-let [node (mf/ref-val name-input-ref)]
|
||||
(dom/focus! node)
|
||||
(dom/select-text! node))))
|
||||
|
||||
[:*
|
||||
[:div.element-set-options-group.typography-entry
|
||||
[:div.typography-selection-wrapper
|
||||
|
@ -270,10 +283,8 @@
|
|||
[:div.row-flex
|
||||
[:input.element-name.adv-typography-name
|
||||
{:type "text"
|
||||
:ref name-input-ref
|
||||
:value (:name typography)
|
||||
:on-change #(on-change {:name (dom/get-target-val %)})}]]]
|
||||
[:& typography-options {:values typography
|
||||
:on-change on-change}]]
|
||||
)
|
||||
|
||||
]]))
|
||||
:on-change on-change}]])]]))
|
||||
|
|
Loading…
Add table
Reference in a new issue