♻️ Convert text-palette components to modern * format

Convert typography-item, palette and text-palette to typography-item*,
palette* and text-palette* using {:keys [...]} destructuring. Rename
prop name-only? to is-name-only in typography-item*. Update internal
call sites to [:> ...] and update the :refer import in palette.cljs.
This commit is contained in:
Andrey Antukh 2026-04-02 16:14:40 +00:00 committed by Belén Albeza
parent fbee875d75
commit 90d052464f
2 changed files with 21 additions and 22 deletions

View File

@ -23,7 +23,7 @@
[app.main.ui.icons :as deprecated-icon]
[app.main.ui.workspace.color-palette :refer [color-palette*]]
[app.main.ui.workspace.color-palette-ctx-menu :refer [color-palette-ctx-menu*]]
[app.main.ui.workspace.text-palette :refer [text-palette]]
[app.main.ui.workspace.text-palette :refer [text-palette*]]
[app.main.ui.workspace.text-palette-ctx-menu :refer [text-palette-ctx-menu]]
[app.util.dom :as dom]
[app.util.i18n :refer [tr]]
@ -207,9 +207,9 @@
:close-menu on-close-menu
:on-select-palette on-select-text-palette-menu
:selected selected-text}]
[:& text-palette {:size size
:selected selected-text
:width vport-width}]])
[:> text-palette* {:size size
:selected selected-text
:width vport-width}]])
(when color-palette?
[:*
[:> color-palette-ctx-menu* {:show show-menu?

View File

@ -22,8 +22,9 @@
[potok.v2.core :as ptk]
[rumext.v2 :as mf]))
(mf/defc typography-item
[{:keys [file-id selected-ids typography name-only? size current-file-id]}]
(mf/defc typography-item*
{::mf/private true}
[{:keys [file-id selected-ids typography size current-file-id]}]
(let [font-data (f/get-font-data (:font-id typography))
font-variant-id (:font-variant-id typography)
variant-data (->> font-data :variants (d/seek #(= (:id %) font-variant-id)))
@ -60,14 +61,12 @@
:font-weight (:font-weight typography)
:font-style (:font-style typography)}}
(:name typography)]
(when-not name-only?
[:*
[:div {:class (stl/css :typography-font)}
(:name font-data)]
[:div {:class (stl/css :typography-data)}
(str (:font-size typography) "px | " (:name variant-data))]])]))
[:div {:class (stl/css :typography-font)}
(:name font-data)]
[:div {:class (stl/css :typography-data)}
(str (:font-size typography) "px | " (:name variant-data))]]))
(mf/defc palette
(mf/defc palette*
[{:keys [selected selected-ids current-file-id file-typographies libraries size width]}]
(let [file-id
(case selected
@ -165,7 +164,7 @@
:max-width (str width "px")
:right (str (* offset-step offset) "px")}}
(for [[idx item] (map-indexed vector current-typographies)]
[:& typography-item
[:> typography-item*
{:key idx
:file-id file-id
:current-file-id current-file-id
@ -178,7 +177,7 @@
:disabled (= offset max-offset)
:on-click on-right-arrow-click} deprecated-icon/arrow])]))
(mf/defc text-palette
(mf/defc text-palette*
{::mf/wrap [mf/memo]}
[{:keys [size width selected] :as props}]
(let [selected-ids (mf/deref refs/selected-shapes)
@ -189,10 +188,10 @@
file-typographies (mf/deref refs/workspace-file-typography)
libraries (mf/deref refs/files)
current-file-id (mf/use-ctx ctx/current-file-id)]
[:& palette {:current-file-id current-file-id
:selected-ids selected-ids
:file-typographies file-typographies
:libraries libraries
:width width
:selected selected
:size size}]))
[:> palette* {:current-file-id current-file-id
:selected-ids selected-ids
:file-typographies file-typographies
:libraries libraries
:width width
:selected selected
:size size}]))