From 5552295d61fe43ed59f5f0f79ef9b8e2db13fb85 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Fri, 9 Aug 2024 17:37:36 +0200 Subject: [PATCH] Add docstring --- frontend/src/app/main/ui/workspace/tokens/token.cljs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/token.cljs b/frontend/src/app/main/ui/workspace/tokens/token.cljs index aabfdf412..9c0efd356 100644 --- a/frontend/src/app/main/ui/workspace/tokens/token.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/token.cljs @@ -5,9 +5,14 @@ [cuerdas.core :as str])) (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*$") -(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 (number? value) {:value value} (string? value) (when-let [[_ value unit] (re-find parseable-token-value-regexp value)]