mirror of
https://github.com/penpot/penpot.git
synced 2025-07-23 17:17:13 +02:00
🐛 Fix stroke-width parsing on svg upload
And refactor a bit the stroke parsing function
This commit is contained in:
parent
f3bf04e1c9
commit
66e877ed40
3 changed files with 63 additions and 50 deletions
|
@ -8,6 +8,7 @@
|
|||
"Color conversion utils."
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.object :as obj]
|
||||
[app.util.strings :as ust]
|
||||
|
@ -176,14 +177,16 @@
|
|||
(= id :multiple)
|
||||
(= file-id :multiple)))
|
||||
|
||||
(defn color? [^string color-str]
|
||||
(and (not (nil? color-str))
|
||||
(seq color-str)
|
||||
(gcolor/isValidColor color-str)))
|
||||
(defn color?
|
||||
[color]
|
||||
(and (string? color)
|
||||
(gcolor/isValidColor color)))
|
||||
|
||||
(defn parse-color [^string color-str]
|
||||
(let [result (gcolor/parse color-str)]
|
||||
(str (.-hex ^js result))))
|
||||
(defn parse-color
|
||||
[color]
|
||||
(when (color? color)
|
||||
(let [result (gcolor/parse color)]
|
||||
(dm/str (.-hex ^js result)))))
|
||||
|
||||
(def color-names
|
||||
(obj/get-keys ^js gcolor/names))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue