0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-20 05:34:23 -05:00

Rename selected-token-set-id -> selected-token-set-path

This commit is contained in:
Florian Schroedl 2024-11-27 10:48:11 +01:00
parent f2c6109dd9
commit 44105c2be2
8 changed files with 32 additions and 32 deletions

View file

@ -88,20 +88,20 @@
(let [workspace-data (deref refs/workspace-data)]
(get (:tokens workspace-data) id)))
(defn set-selected-token-set-id
(defn set-selected-token-set-path
[id]
(ptk/reify ::set-selected-token-set-id
(ptk/reify ::set-selected-token-set-path
ptk/UpdateEvent
(update [_ state]
(wtts/assoc-selected-token-set-id state id))))
(wtts/assoc-selected-token-set-path state id))))
(defn set-selected-token-set-id-from-name
(defn set-selected-token-set-path-from-name
[token-set-name]
(ptk/reify ::set-selected-token-set-id-from-name
(ptk/reify ::set-selected-token-set-path-from-name
ptk/UpdateEvent
(update [_ state]
(->> (ctob/set-name->prefixed-set-name token-set-name)
(wtts/assoc-selected-token-set-id state)))))
(wtts/assoc-selected-token-set-path state)))))
(defn create-token-theme [token-theme]
(let [new-token-theme token-theme]
@ -165,7 +165,7 @@
(let [changes (-> (pcb/empty-changes it)
(pcb/add-token-set new-token-set))]
(rx/of
(set-selected-token-set-id-from-name (:name new-token-set))
(set-selected-token-set-path-from-name (:name new-token-set))
(dch/commit-changes changes)))))))
(defn update-token-set [set-name token-set]
@ -177,7 +177,7 @@
changes (-> (pcb/empty-changes it)
(pcb/update-token-set token-set prev-token-set))]
(rx/of
(set-selected-token-set-id-from-name (:name token-set))
(set-selected-token-set-path-from-name (:name token-set))
(dch/commit-changes changes))))))
(defn toggle-token-set [{:keys [token-set-name]}]
@ -210,7 +210,7 @@
(ctob/get-sets)
(first)
(:name)
(set-selected-token-set-id-from-name))
(set-selected-token-set-path-from-name))
changes (-> (pcb/empty-changes it)
(pcb/with-library-data data)
(pcb/set-tokens-lib lib))]
@ -276,7 +276,7 @@
(pcb/update-token (pcb/empty-changes) (:name token-set) token prev-token)
(pcb/add-token (pcb/empty-changes) (:name token-set) token)))]
(rx/of
(set-selected-token-set-id-from-name token-set-name)
(set-selected-token-set-path-from-name token-set-name)
(dch/commit-changes changes))))))
(defn delete-token

View file

@ -490,8 +490,8 @@
(def workspace-token-themes-no-hidden
(l/derived #(remove ctob/hidden-temporary-theme? %) workspace-token-themes))
(def workspace-selected-token-set-id
(l/derived wtts/get-selected-token-set-id st/state))
(def workspace-selected-token-set-path
(l/derived wtts/get-selected-token-set-path st/state))
(def workspace-token-set-group-selected?
(l/derived wtts/token-group-selected? st/state))

View file

@ -204,10 +204,10 @@
(generic-attribute-actions #{:x} "X" (assoc context-data :on-update-shape wtch/update-shape-position))
(generic-attribute-actions #{:y} "Y" (assoc context-data :on-update-shape wtch/update-shape-position))))}))
(defn default-actions [{:keys [token selected-token-set-id]}]
(defn default-actions [{:keys [token selected-token-set-path]}]
(let [{:keys [modal]} (wtty/get-token-properties token)]
[{:title "Delete Token"
:action #(st/emit! (dt/delete-token (ctob/prefixed-set-full-path->set-name-name selected-token-set-id) (:name token)))}
:action #(st/emit! (dt/delete-token (ctob/prefixed-set-full-path->set-name-name selected-token-set-path) (:name token)))}
{:title "Duplicate Token"
:action #(st/emit! (dt/duplicate-token (:name token)))}
{:title "Edit Token"
@ -220,7 +220,7 @@
:position :right
:fields fields
:action "edit"
:selected-token-set-id selected-token-set-id
:selected-token-set-path selected-token-set-path
:token token})))}]))
(defn selection-actions [{:keys [type token] :as context-data}]
@ -311,11 +311,11 @@
selected-shapes (into [] (keep (d/getf objects)) selected)
token-name (:token-name mdata)
token (mf/deref (refs/workspace-selected-token-set-token token-name))
selected-token-set-id (mf/deref refs/workspace-selected-token-set-id)]
selected-token-set-path (mf/deref refs/workspace-selected-token-set-path)]
[:ul {:class (stl/css :context-list)}
[:& menu-tree {:submenu-offset width
:token token
:selected-token-set-id selected-token-set-id
:selected-token-set-path selected-token-set-path
:selected-shapes selected-shapes}]]))
(mf/defc token-context-menu

View file

@ -204,7 +204,7 @@ Token names should only contain letters and digits separated by . characters.")}
(mf/defc form
{::mf/wrap-props false}
[{:keys [token token-type action selected-token-set-id]}]
[{:keys [token token-type action selected-token-set-path]}]
(let [token (or token {:type token-type})
token-properties (wtty/get-token-properties token)
color? (wtt/color-token? token)
@ -348,11 +348,11 @@ Token names should only contain letters and digits separated by . characters.")}
(modal/hide!))))))))
on-delete-token
(mf/use-fn
(mf/deps selected-token-set-id)
(mf/deps selected-token-set-path)
(fn [e]
(dom/prevent-default e)
(modal/hide!)
(st/emit! (dt/delete-token (ctob/prefixed-set-full-path->set-name-name selected-token-set-id) (:name token)))))
(st/emit! (dt/delete-token (ctob/prefixed-set-full-path->set-name-name selected-token-set-path) (:name token)))))
on-cancel
(mf/use-fn

View file

@ -42,7 +42,7 @@
(mf/defc token-update-create-modal
{::mf/wrap-props false}
[{:keys [x y position token token-type action selected-token-set-id] :as _args}]
[{:keys [x y position token token-type action selected-token-set-path] :as _args}]
(let [wrapper-style (use-viewport-position-style x y position)
close-modal (mf/use-fn
(fn []
@ -57,7 +57,7 @@
:aria-label (tr "labels.close")}]
[:& form {:token token
:action action
:selected-token-set-id selected-token-set-id
:selected-token-set-path selected-token-set-path
:token-type token-type}]]))
;; Modals ----------------------------------------------------------------------

View file

@ -25,7 +25,7 @@
(st/emit! (wdt/toggle-token-set {:token-set-name token-set-name})))
(defn on-select-token-set-click [tree-path]
(st/emit! (wdt/set-selected-token-set-id tree-path)))
(st/emit! (wdt/set-selected-token-set-path tree-path)))
(defn on-update-token-set [set-name token-set]
(st/emit! (wdt/update-token-set set-name token-set)))
@ -272,11 +272,11 @@
(mf/defc sets-list
[{:keys []}]
(let [token-sets (mf/deref refs/workspace-token-sets-tree)
selected-token-set-id (mf/deref refs/workspace-selected-token-set-id)
selected-token-set-path (mf/deref refs/workspace-selected-token-set-path)
token-set-selected? (mf/use-fn
(mf/deps token-sets selected-token-set-id)
(mf/deps token-sets selected-token-set-path)
(fn [tree-path]
(= tree-path selected-token-set-id)))
(= tree-path selected-token-set-path)))
active-token-set-names (mf/deref refs/workspace-active-set-names)
token-set-active? (mf/use-fn
(mf/deps active-token-set-names)

View file

@ -38,7 +38,7 @@
[{:keys [tree-path]}]
(let [{:keys [on-edit]} (sets-context/use-context)
edit-name (mf/use-fn #(on-edit tree-path))
delete-set (mf/use-fn #(st/emit! (wdt/delete-token-set-prefix-full-path tree-path)))]
delete-set (mf/use-fn #(st/emit! (wdt/delete-token-set-path tree-path)))]
[:ul {:class (stl/css :context-list)}
[:& menu-entry {:title (tr "labels.rename") :on-click edit-name}]
[:& menu-entry {:title (tr "labels.delete") :on-click delete-set}]]))

View file

@ -36,15 +36,15 @@
;; === Set selection
(defn get-selected-token-set-id [state]
(or (get-in state [:workspace-local :selected-token-set-id])
(defn get-selected-token-set-path [state]
(or (get-in state [:workspace-local :selected-token-set-path])
(some-> (get-workspace-tokens-lib state)
(ctob/get-sets)
(first)
(ctob/get-set-prefixed-path-string))))
(defn get-selected-token-set-node [state]
(when-let [path (some-> (get-selected-token-set-id state)
(when-let [path (some-> (get-selected-token-set-path state)
(ctob/split-token-set-path))]
(some-> (get-workspace-tokens-lib state)
(ctob/get-in-set-tree path))))
@ -66,5 +66,5 @@
(defn token-group-selected? [state]
(some? (get-selected-token-set-group state)))
(defn assoc-selected-token-set-id [state id]
(assoc-in state [:workspace-local :selected-token-set-id] id))
(defn assoc-selected-token-set-path [state id]
(assoc-in state [:workspace-local :selected-token-set-path] id))