mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 07:37:35 +02:00
🚧 Don't expose state
This commit is contained in:
parent
12f72c8ca9
commit
1c209f49fc
1 changed files with 14 additions and 11 deletions
|
@ -248,7 +248,7 @@
|
||||||
(ctob/activate-theme tlib (:group theme) (:name theme))))
|
(ctob/activate-theme tlib (:group theme) (:name theme))))
|
||||||
|
|
||||||
(mf/defc edit-create-theme*
|
(mf/defc edit-create-theme*
|
||||||
[{:keys [state change-view theme on-save is-editing]}]
|
[{:keys [change-view theme on-save is-editing has-prev-view]}]
|
||||||
(let [ordered-token-sets (mf/deref refs/workspace-ordered-token-sets)
|
(let [ordered-token-sets (mf/deref refs/workspace-ordered-token-sets)
|
||||||
token-sets (mf/deref refs/workspace-token-sets-tree)
|
token-sets (mf/deref refs/workspace-token-sets-tree)
|
||||||
|
|
||||||
|
@ -256,8 +256,6 @@
|
||||||
current-theme (deref current-theme*)
|
current-theme (deref current-theme*)
|
||||||
lib (make-lib-with-theme current-theme ordered-token-sets)
|
lib (make-lib-with-theme current-theme ordered-token-sets)
|
||||||
|
|
||||||
has-back-button? (contains? #{:empty-themes :themes-overview} (:prev-type state))
|
|
||||||
|
|
||||||
;; Form / Modal handlers
|
;; Form / Modal handlers
|
||||||
on-back (mf/use-fn
|
on-back (mf/use-fn
|
||||||
(mf/deps change-view)
|
(mf/deps change-view)
|
||||||
|
@ -339,7 +337,7 @@
|
||||||
|
|
||||||
[:form {:on-submit on-save-form :class (stl/css :edit-theme-form)}
|
[:form {:on-submit on-save-form :class (stl/css :edit-theme-form)}
|
||||||
[:div {:class (stl/css :edit-theme-wrapper)}
|
[:div {:class (stl/css :edit-theme-wrapper)}
|
||||||
(when has-back-button?
|
(when has-prev-view
|
||||||
[:button {:on-click on-back
|
[:button {:on-click on-back
|
||||||
:class (stl/css :back-btn)
|
:class (stl/css :back-btn)
|
||||||
:type "button"}
|
:type "button"}
|
||||||
|
@ -374,11 +372,15 @@
|
||||||
:on-save-form on-save-form
|
:on-save-form on-save-form
|
||||||
:disabled? disabled?}]]]]]]))
|
:disabled? disabled?}]]]]]]))
|
||||||
|
|
||||||
|
(defn has-prev-view [prev-view-type]
|
||||||
|
(contains? #{:empty-themes :themes-overview} prev-view-type))
|
||||||
|
|
||||||
(mf/defc edit-theme
|
(mf/defc edit-theme
|
||||||
[{:keys [state change-view]}]
|
[{:keys [state change-view]}]
|
||||||
(let [{:keys [theme-path]} state
|
(let [{:keys [theme-path]} state
|
||||||
[_ theme-group theme-name] theme-path
|
[_ theme-group theme-name] theme-path
|
||||||
theme (mf/deref (refs/workspace-token-theme theme-group theme-name))
|
theme (mf/deref (refs/workspace-token-theme theme-group theme-name))
|
||||||
|
has-prev-view (has-prev-view (:prev-type state))
|
||||||
|
|
||||||
on-save
|
on-save
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -387,11 +389,11 @@
|
||||||
(st/emit! (wdt/update-token-theme [(:group theme) (:name theme)] theme'))))]
|
(st/emit! (wdt/update-token-theme [(:group theme) (:name theme)] theme'))))]
|
||||||
|
|
||||||
[:> edit-create-theme*
|
[:> edit-create-theme*
|
||||||
{:state state
|
{:change-view change-view
|
||||||
:change-view change-view
|
|
||||||
:theme theme
|
:theme theme
|
||||||
:on-save on-save
|
:on-save on-save
|
||||||
:is-editing true}]))
|
:is-editing true
|
||||||
|
:has-prev-view has-prev-view}]))
|
||||||
|
|
||||||
(mf/defc create-theme
|
(mf/defc create-theme
|
||||||
[{:keys [state change-view]}]
|
[{:keys [state change-view]}]
|
||||||
|
@ -400,13 +402,14 @@
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [theme]
|
(fn [theme]
|
||||||
(st/emit! (ptk/event ::ev/event {::ev/name "create-tokens-theme"})
|
(st/emit! (ptk/event ::ev/event {::ev/name "create-tokens-theme"})
|
||||||
(wdt/create-token-theme theme))))]
|
(wdt/create-token-theme theme))))
|
||||||
|
has-prev-view (has-prev-view (:prev-type state))]
|
||||||
|
|
||||||
[:> edit-create-theme*
|
[:> edit-create-theme*
|
||||||
{:state state
|
{:change-view change-view
|
||||||
:change-view change-view
|
|
||||||
:theme theme
|
:theme theme
|
||||||
:on-save on-save}]))
|
:on-save on-save
|
||||||
|
:has-prev-view has-prev-view}]))
|
||||||
|
|
||||||
(mf/defc themes-modal-body*
|
(mf/defc themes-modal-body*
|
||||||
{::mf/private true}
|
{::mf/private true}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue