mirror of
https://github.com/penpot/penpot.git
synced 2025-05-22 13:06:12 +02:00
✨ Simplify implementation of d/name
This commit is contained in:
parent
cac785f3e1
commit
afd373ffee
2 changed files with 12 additions and 13 deletions
|
@ -716,20 +716,19 @@
|
||||||
|
|
||||||
(defn name
|
(defn name
|
||||||
"Improved version of name that won't fail if the input is not a keyword"
|
"Improved version of name that won't fail if the input is not a keyword"
|
||||||
([maybe-keyword] (name maybe-keyword nil))
|
[maybe-keyword]
|
||||||
([maybe-keyword default-value]
|
|
||||||
(cond
|
(cond
|
||||||
|
(nil? maybe-keyword)
|
||||||
|
nil
|
||||||
|
|
||||||
(keyword? maybe-keyword)
|
(keyword? maybe-keyword)
|
||||||
(c/name maybe-keyword)
|
(c/name maybe-keyword)
|
||||||
|
|
||||||
(string? maybe-keyword)
|
(string? maybe-keyword)
|
||||||
maybe-keyword
|
maybe-keyword
|
||||||
|
|
||||||
(nil? maybe-keyword) default-value
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(or default-value
|
(str maybe-keyword)))
|
||||||
(str maybe-keyword)))))
|
|
||||||
|
|
||||||
(defn prefix-keyword
|
(defn prefix-keyword
|
||||||
"Given a keyword and a prefix will return a new keyword with the prefix attached
|
"Given a keyword and a prefix will return a new keyword with the prefix attached
|
||||||
|
|
|
@ -209,12 +209,12 @@
|
||||||
[:div {:class (stl/css :contraints-selects)}
|
[:div {:class (stl/css :contraints-selects)}
|
||||||
[:div {:class (stl/css :horizontal-select)}
|
[:div {:class (stl/css :horizontal-select)}
|
||||||
[:& select
|
[:& select
|
||||||
{:default-value (d/name constraints-h "scale")
|
{:default-value (d/nilv (d/name constraints-h) "scale")
|
||||||
:options options-h
|
:options options-h
|
||||||
:on-change on-constraint-h-select-changed}]]
|
:on-change on-constraint-h-select-changed}]]
|
||||||
[:div {:class (stl/css :vertical-select)}
|
[:div {:class (stl/css :vertical-select)}
|
||||||
[:& select
|
[:& select
|
||||||
{:default-value (d/name constraints-v "scale")
|
{:default-value (d/nilv (d/name constraints-v) "scale")
|
||||||
:options options-v
|
:options options-v
|
||||||
:on-change on-constraint-v-select-changed}]]
|
:on-change on-constraint-v-select-changed}]]
|
||||||
(when first-level?
|
(when first-level?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue