0
Fork 0
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:
alonso.torres 2023-11-14 16:32:13 +01:00
parent 89a09091db
commit 78332257aa
2 changed files with 4 additions and 2 deletions

View file

@ -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))))))

View file

@ -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")))
)