mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
Merge pull request #125 from tokens-studio/remember-token-section-state
Remember token section open/close state
This commit is contained in:
commit
e874ed5b6c
2 changed files with 15 additions and 4 deletions
|
@ -155,6 +155,13 @@
|
||||||
shape-after-token-3-is-applied)
|
shape-after-token-3-is-applied)
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
(defn set-token-type-section-open
|
||||||
|
[token-type open?]
|
||||||
|
(ptk/reify ::set-token-type-section-open
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(assoc-in state [:workspace-tokens :open-status token-type] open?))))
|
||||||
|
|
||||||
;; Token Context Menu Functions -------------------------------------------------
|
;; Token Context Menu Functions -------------------------------------------------
|
||||||
|
|
||||||
(defn show-token-context-menu
|
(defn show-token-context-menu
|
||||||
|
|
|
@ -16,8 +16,12 @@
|
||||||
[app.main.ui.workspace.sidebar.assets.common :as cmm]
|
[app.main.ui.workspace.sidebar.assets.common :as cmm]
|
||||||
[app.main.ui.workspace.tokens.core :as wtc]
|
[app.main.ui.workspace.tokens.core :as wtc]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
|
[okulary.core :as l]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
|
(def lens:token-type-open-status
|
||||||
|
(l/derived (l/in [:workspace-tokens :open-status]) st/state))
|
||||||
|
|
||||||
(mf/defc token-pill
|
(mf/defc token-pill
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[{:keys [on-click token highlighted? on-context-menu]}]
|
[{:keys [on-click token highlighted? on-context-menu]}]
|
||||||
|
@ -53,7 +57,8 @@
|
||||||
|
|
||||||
(mf/defc token-component
|
(mf/defc token-component
|
||||||
[{:keys [type tokens selected-shapes token-type-props]}]
|
[{:keys [type tokens selected-shapes token-type-props]}]
|
||||||
(let [open? (mf/use-state false)
|
(let [open? (mf/deref (-> (l/key type)
|
||||||
|
(l/derived lens:token-type-open-status)))
|
||||||
{:keys [modal attributes title]} token-type-props
|
{:keys [modal attributes title]} token-type-props
|
||||||
|
|
||||||
on-context-menu (mf/use-fn
|
on-context-menu (mf/use-fn
|
||||||
|
@ -66,8 +71,7 @@
|
||||||
|
|
||||||
on-toggle-open-click (mf/use-fn
|
on-toggle-open-click (mf/use-fn
|
||||||
(mf/deps open? tokens)
|
(mf/deps open? tokens)
|
||||||
#(when (seq tokens)
|
#(st/emit! (dt/set-token-type-section-open type (not open?))))
|
||||||
(swap! open? not)))
|
|
||||||
on-popover-open-click (mf/use-fn
|
on-popover-open-click (mf/use-fn
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(let [{:keys [key fields]} modal]
|
(let [{:keys [key fields]} modal]
|
||||||
|
@ -93,7 +97,7 @@
|
||||||
|
|
||||||
:title title
|
:title title
|
||||||
:assets-count tokens-count
|
:assets-count tokens-count
|
||||||
:open? @open?}
|
:open? open?}
|
||||||
[:& cmm/asset-section-block {:role :title-button}
|
[:& cmm/asset-section-block {:role :title-button}
|
||||||
[:button {:class (stl/css :action-button)
|
[:button {:class (stl/css :action-button)
|
||||||
:on-click on-popover-open-click}
|
:on-click on-popover-open-click}
|
||||||
|
|
Loading…
Add table
Reference in a new issue