mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 14:26:38 +02:00
✨ Normalize token name on creation
This commit is contained in:
parent
a9e8d8f8f7
commit
559dcabf0e
2 changed files with 26 additions and 9 deletions
|
@ -251,6 +251,12 @@
|
||||||
[name]
|
[name]
|
||||||
(split-path name set-separator))
|
(split-path name set-separator))
|
||||||
|
|
||||||
|
(defn normalize-set-name
|
||||||
|
[name]
|
||||||
|
(->> (split-token-set-name name)
|
||||||
|
(map str/trim)
|
||||||
|
(str/join set-separator)))
|
||||||
|
|
||||||
(defn get-token-set-path [token-set]
|
(defn get-token-set-path [token-set]
|
||||||
(let [path (get-path token-set set-separator)]
|
(let [path (get-path token-set set-separator)]
|
||||||
(add-token-set-paths-prefix path)))
|
(add-token-set-paths-prefix path)))
|
||||||
|
|
|
@ -136,15 +136,26 @@
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [token-set' (-> token-set
|
(let [token-set'
|
||||||
(update :name #(if (empty? %)
|
;; FIXME: wtf is this?
|
||||||
set-name
|
(update token-set :name #(if (empty? %)
|
||||||
(ctob/join-set-path [% set-name]))))
|
set-name
|
||||||
data (dsh/lookup-file-data state)
|
(ctob/join-set-path [% set-name])))
|
||||||
token-set-name (:name token-set')
|
|
||||||
changes (-> (pcb/empty-changes it)
|
token-set'
|
||||||
(pcb/with-library-data data)
|
(update token-set' :name ctob/normalize-set-name)
|
||||||
(pcb/set-token-set token-set-name false token-set'))]
|
|
||||||
|
data
|
||||||
|
(dsh/lookup-file-data state)
|
||||||
|
|
||||||
|
token-set-name
|
||||||
|
(:name token-set')
|
||||||
|
|
||||||
|
changes
|
||||||
|
(-> (pcb/empty-changes it)
|
||||||
|
(pcb/with-library-data data)
|
||||||
|
(pcb/set-token-set token-set-name false token-set'))]
|
||||||
|
|
||||||
(rx/of (set-selected-token-set-name token-set-name)
|
(rx/of (set-selected-token-set-name token-set-name)
|
||||||
(dch/commit-changes changes))))))
|
(dch/commit-changes changes))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue