mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
Add docstring
This commit is contained in:
parent
e992bf0aa6
commit
5552295d61
1 changed files with 6 additions and 1 deletions
|
@ -5,9 +5,14 @@
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
(def parseable-token-value-regexp
|
(def parseable-token-value-regexp
|
||||||
|
"Regexp that can be used to parse a number value out of resolved token value.
|
||||||
|
This regexp also trims whitespace around the value."
|
||||||
#"^\s*(-?[0-9]+\.?[0-9]*)(px|%)?\s*$")
|
#"^\s*(-?[0-9]+\.?[0-9]*)(px|%)?\s*$")
|
||||||
|
|
||||||
(defn parse-token-value [value]
|
(defn parse-token-value
|
||||||
|
"Parses a resolved value and separates the unit from the value.
|
||||||
|
Returns a map of {:value `number` :unit `string`}."
|
||||||
|
[value]
|
||||||
(cond
|
(cond
|
||||||
(number? value) {:value value}
|
(number? value) {:value value}
|
||||||
(string? value) (when-let [[_ value unit] (re-find parseable-token-value-regexp value)]
|
(string? value) (when-let [[_ value unit] (re-find parseable-token-value-regexp value)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue