mirror of
https://github.com/penpot/penpot.git
synced 2025-01-06 14:50:20 -05:00
🐛 Fix problem with color inputs
This commit is contained in:
parent
89a09091db
commit
78332257aa
2 changed files with 4 additions and 2 deletions
|
@ -183,7 +183,7 @@
|
|||
"yellowgreen" "#9acd32"})
|
||||
|
||||
(def ^:private hex-color-re
|
||||
#"\#[0-9a-fA-F]{3,6}")
|
||||
#"\#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})")
|
||||
|
||||
(def ^:private rgb-color-re
|
||||
#"(?:|rgb)\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)")
|
||||
|
@ -431,7 +431,8 @@
|
|||
(defn parse
|
||||
[color]
|
||||
(when (string? color)
|
||||
(if (valid-hex-color? color)
|
||||
(if (or (valid-hex-color? color)
|
||||
(valid-hex-color? (dm/str "#" color)))
|
||||
(normalize-hex color)
|
||||
(or (some-> (parse-rgb color) (rgb->hex))
|
||||
(get names (str/lower color))))))
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
(t/is (false? (colors/valid-hex-color? "#")))
|
||||
(t/is (false? (colors/valid-hex-color? "#qqqqqq")))
|
||||
(t/is (true? (colors/valid-hex-color? "#aaa")))
|
||||
(t/is (false? (colors/valid-hex-color? "#aaaa")))
|
||||
(t/is (true? (colors/valid-hex-color? "#fabada")))
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue