mirror of
https://github.com/penpot/penpot.git
synced 2025-01-06 14:50:20 -05:00
Remember token section open/close state
This commit is contained in:
parent
162e7b6c58
commit
eca1334266
2 changed files with 15 additions and 4 deletions
|
@ -155,6 +155,13 @@
|
|||
shape-after-token-3-is-applied)
|
||||
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 -------------------------------------------------
|
||||
|
||||
(defn show-token-context-menu
|
||||
|
|
|
@ -16,8 +16,12 @@
|
|||
[app.main.ui.workspace.sidebar.assets.common :as cmm]
|
||||
[app.main.ui.workspace.tokens.core :as wtc]
|
||||
[app.util.dom :as dom]
|
||||
[okulary.core :as l]
|
||||
[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/wrap-props false}
|
||||
[{:keys [on-click token highlighted? on-context-menu]}]
|
||||
|
@ -53,7 +57,8 @@
|
|||
|
||||
(mf/defc token-component
|
||||
[{: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
|
||||
|
||||
on-context-menu (mf/use-fn
|
||||
|
@ -66,8 +71,7 @@
|
|||
|
||||
on-toggle-open-click (mf/use-fn
|
||||
(mf/deps open? tokens)
|
||||
#(when (seq tokens)
|
||||
(swap! open? not)))
|
||||
#(st/emit! (dt/set-token-type-section-open type (not open?))))
|
||||
on-popover-open-click (mf/use-fn
|
||||
(fn [event]
|
||||
(let [{:keys [key fields]} modal]
|
||||
|
@ -93,7 +97,7 @@
|
|||
|
||||
:title title
|
||||
:assets-count tokens-count
|
||||
:open? @open?}
|
||||
:open? open?}
|
||||
[:& cmm/asset-section-block {:role :title-button}
|
||||
[:button {:class (stl/css :action-button)
|
||||
:on-click on-popover-open-click}
|
||||
|
|
Loading…
Reference in a new issue