mirror of
https://github.com/penpot/penpot.git
synced 2025-01-20 13:42:59 -05:00
🐛 Fix sets tree not working in themes modal
This commit is contained in:
parent
3afdc72a4e
commit
58278867cc
2 changed files with 13 additions and 11 deletions
|
@ -254,7 +254,7 @@
|
||||||
[{:keys [state set-state]}]
|
[{:keys [state set-state]}]
|
||||||
(let [{:keys [theme-path]} @state
|
(let [{:keys [theme-path]} @state
|
||||||
[_ theme-group theme-name] theme-path
|
[_ theme-group theme-name] theme-path
|
||||||
token-sets (mf/deref refs/workspace-ordered-token-sets)
|
token-sets (mf/deref refs/workspace-token-sets-tree)
|
||||||
theme (mf/deref (refs/workspace-token-theme theme-group theme-name))
|
theme (mf/deref (refs/workspace-token-theme theme-group theme-name))
|
||||||
on-back #(set-state (constantly {:type :themes-overview}))
|
on-back #(set-state (constantly {:type :themes-overview}))
|
||||||
on-submit #(st/emit! (wdt/update-token-theme [(:group theme) (:name theme)] %))
|
on-submit #(st/emit! (wdt/update-token-theme [(:group theme) (:name theme)] %))
|
||||||
|
|
|
@ -60,9 +60,8 @@
|
||||||
:default-value default-value}]))
|
:default-value default-value}]))
|
||||||
|
|
||||||
(mf/defc sets-tree-set-group
|
(mf/defc sets-tree-set-group
|
||||||
[{:keys [label tree-depth tree-path selected? collapsed? on-select editing? on-edit on-edit-submit]}]
|
[{:keys [label tree-depth tree-path selected? collapsed? on-select editing? on-edit on-edit-reset on-edit-submit]}]
|
||||||
(let [editing?' (editing? tree-path)
|
(let [editing?' (editing? tree-path)
|
||||||
{:keys [on-create on-reset] :as ctx} (sets-context/use-context)
|
|
||||||
on-click
|
on-click
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps editing? tree-path)
|
(mf/deps editing? tree-path)
|
||||||
|
@ -103,15 +102,14 @@
|
||||||
(if editing?'
|
(if editing?'
|
||||||
[:& editing-label
|
[:& editing-label
|
||||||
{:default-value label
|
{:default-value label
|
||||||
:on-cancel on-reset
|
:on-cancel on-edit-reset
|
||||||
:on-create on-reset
|
:on-create on-edit-reset
|
||||||
:on-submit #(on-edit-submit)}]
|
:on-submit #(on-edit-submit)}]
|
||||||
[:div {:class (stl/css :set-name)} label])]))
|
[:div {:class (stl/css :set-name)} label])]))
|
||||||
|
|
||||||
(mf/defc sets-tree-set
|
(mf/defc sets-tree-set
|
||||||
[{:keys [set label tree-depth tree-path selected? on-select active? on-toggle editing? on-edit on-edit-submit]}]
|
[{:keys [set label tree-depth tree-path selected? on-select active? on-toggle editing? on-edit on-edit-reset on-edit-submit]}]
|
||||||
(let [set-name (.-name set)
|
(let [set-name (.-name set)
|
||||||
{:keys [on-reset] :as ctx} (sets-context/use-context)
|
|
||||||
editing?' (editing? tree-path)
|
editing?' (editing? tree-path)
|
||||||
active?' (active? set-name)
|
active?' (active? set-name)
|
||||||
on-click
|
on-click
|
||||||
|
@ -148,8 +146,8 @@
|
||||||
(if editing?'
|
(if editing?'
|
||||||
[:& editing-label
|
[:& editing-label
|
||||||
{:default-value label
|
{:default-value label
|
||||||
:on-cancel on-reset
|
:on-cancel on-edit-reset
|
||||||
:on-create on-reset
|
:on-create on-edit-reset
|
||||||
:on-submit #(on-edit-submit set-name (ctob/update-name set %))}]
|
:on-submit #(on-edit-submit set-name (ctob/update-name set %))}]
|
||||||
[:*
|
[:*
|
||||||
[:div {:class (stl/css :set-name)} label]
|
[:div {:class (stl/css :set-name)} label]
|
||||||
|
@ -165,7 +163,7 @@
|
||||||
:id ic/tick}])]])]))
|
:id ic/tick}])]])]))
|
||||||
|
|
||||||
(mf/defc sets-tree
|
(mf/defc sets-tree
|
||||||
[{:keys [set-path set-node tree-depth tree-path on-select selected? on-toggle active? editing? on-edit on-edit-submit]
|
[{:keys [set-path set-node tree-depth tree-path on-select selected? on-toggle active? editing? on-edit on-edit-reset on-edit-submit]
|
||||||
:or {tree-depth 0}
|
:or {tree-depth 0}
|
||||||
:as props}]
|
:as props}]
|
||||||
(let [[set-prefix set-path'] (some-> set-path (ctob/split-set-prefix))
|
(let [[set-prefix set-path'] (some-> set-path (ctob/split-set-prefix))
|
||||||
|
@ -191,6 +189,7 @@
|
||||||
:editing? editing?
|
:editing? editing?
|
||||||
:on-toggle on-toggle
|
:on-toggle on-toggle
|
||||||
:on-edit on-edit
|
:on-edit on-edit
|
||||||
|
:on-edit-reset on-edit-reset
|
||||||
:on-edit-submit on-edit-submit}]
|
:on-edit-submit on-edit-submit}]
|
||||||
set-group?
|
set-group?
|
||||||
[:& sets-tree-set-group
|
[:& sets-tree-set-group
|
||||||
|
@ -202,6 +201,7 @@
|
||||||
:tree-depth tree-depth
|
:tree-depth tree-depth
|
||||||
:editing? editing?
|
:editing? editing?
|
||||||
:on-edit on-edit
|
:on-edit on-edit
|
||||||
|
:on-edit-reset on-edit-reset
|
||||||
:on-edit-submit on-edit-submit}])
|
:on-edit-submit on-edit-submit}])
|
||||||
(when children?
|
(when children?
|
||||||
(for [[set-path set-node] set-node
|
(for [[set-path set-node] set-node
|
||||||
|
@ -218,6 +218,7 @@
|
||||||
:active? active?
|
:active? active?
|
||||||
:editing? editing?
|
:editing? editing?
|
||||||
:on-edit on-edit
|
:on-edit on-edit
|
||||||
|
:on-edit-reset on-edit-reset
|
||||||
:on-edit-submit on-edit-submit}]))]))
|
:on-edit-submit on-edit-submit}]))]))
|
||||||
|
|
||||||
(mf/defc controlled-sets-list
|
(mf/defc controlled-sets-list
|
||||||
|
@ -231,7 +232,7 @@
|
||||||
on-select
|
on-select
|
||||||
context]
|
context]
|
||||||
:as _props}]
|
:as _props}]
|
||||||
(let [{:keys [editing? new? on-edit on-create on-reset] :as ctx} (or context (sets-context/use-context))]
|
(let [{:keys [editing? new? on-edit on-reset] :as ctx} (or context (sets-context/use-context))]
|
||||||
[:ul {:class (stl/css :sets-list)}
|
[:ul {:class (stl/css :sets-list)}
|
||||||
(if (and
|
(if (and
|
||||||
(= origin "theme-modal")
|
(= origin "theme-modal")
|
||||||
|
@ -251,6 +252,7 @@
|
||||||
:on-toggle on-toggle-token-set
|
:on-toggle on-toggle-token-set
|
||||||
:editing? editing?
|
:editing? editing?
|
||||||
:on-edit on-edit
|
:on-edit on-edit
|
||||||
|
:on-edit-reset on-reset
|
||||||
:on-edit-submit on-update-token-set}]
|
:on-edit-submit on-update-token-set}]
|
||||||
(when new?
|
(when new?
|
||||||
[:& sets-tree-set
|
[:& sets-tree-set
|
||||||
|
|
Loading…
Add table
Reference in a new issue