mirror of https://github.com/penpot/penpot.git
♻️ Cleanup code
This commit is contained in:
parent
af88ef186c
commit
d843c49c1c
|
|
@ -99,11 +99,11 @@ Some naming conventions:
|
|||
|
||||
(defn butlast-path
|
||||
"Remove the last item of the path."
|
||||
[path separator]
|
||||
(let [split (split-path path :separator separator)]
|
||||
[path]
|
||||
(let [split (split-path path)]
|
||||
(if (= 1 (count split))
|
||||
""
|
||||
(join-path (butlast split) :separator separator))))
|
||||
(join-path (butlast split)))))
|
||||
|
||||
(defn butlast-path-with-dots
|
||||
"Remove the last item of the path."
|
||||
|
|
|
|||
|
|
@ -462,16 +462,16 @@
|
|||
;; TOKEN UI OPS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn clean-paths
|
||||
(defn clean-tokens-paths
|
||||
[]
|
||||
(ptk/reify ::clean-paths
|
||||
(ptk/reify ::clean-tokens-paths
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-tokens :unfolded-token-paths] []))))
|
||||
|
||||
(defn toggle-path
|
||||
(defn toggle-token-path
|
||||
[path]
|
||||
(ptk/reify ::toggle-path
|
||||
(ptk/reify ::toggle-token-path
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-tokens :unfolded-token-paths]
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@
|
|||
(remove str/empty?)
|
||||
(remove nil?)
|
||||
(distinct)
|
||||
(filter #(= (cpn/butlast-path % "/") (:path filters))))
|
||||
(filter #(= (cpn/butlast-path %) (:path filters))))
|
||||
|
||||
groups (when-not search?
|
||||
(->> (sort (sequence xform components))
|
||||
|
|
@ -762,7 +762,7 @@
|
|||
on-go-back
|
||||
(mf/use-fn
|
||||
(mf/deps (:path filters))
|
||||
#(swap! filters* assoc :path (cpn/butlast-path (:path filters) "/")))
|
||||
#(swap! filters* assoc :path (cpn/butlast-path (:path filters))))
|
||||
|
||||
on-enter-group
|
||||
(mf/use-fn #(swap! filters* assoc :path %))
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@
|
|||
{:name name
|
||||
:value (:value valid-token)
|
||||
:description description}))
|
||||
(dwtl/toggle-path path)
|
||||
(dwtl/toggle-token-path path)
|
||||
(dwtp/propagate-workspace-tokens)
|
||||
(modal/hide!))))))))))]
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@
|
|||
(mf/deps type expandable?)
|
||||
(fn []
|
||||
(when expandable?
|
||||
(st/emit! (dwtl/toggle-path (name type))))))
|
||||
(st/emit! (dwtl/toggle-token-path (name type))))))
|
||||
|
||||
on-popover-open-click
|
||||
(mf/use-fn
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
(mf/deps (:path node) type)
|
||||
(fn []
|
||||
(let [path (str (name type) "." (:path node))]
|
||||
(st/emit! (dwtl/toggle-path path)))))]
|
||||
(st/emit! (dwtl/toggle-token-path path)))))]
|
||||
[:li {:class (stl/css :folder-node)}
|
||||
[:> layer-button* {:label (:name node)
|
||||
:expanded is-folder-expanded
|
||||
|
|
|
|||
Loading…
Reference in New Issue