diff options
-rw-r--r-- | src/css/values.nim | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/css/values.nim b/src/css/values.nim index 5d8cc2fb..c786e47e 100644 --- a/src/css/values.nim +++ b/src/css/values.nim @@ -337,16 +337,25 @@ func propertyType(s: string): CSSPropertyType = func valueType(prop: CSSPropertyType): CSSValueType = return ValueTypes[prop] +func `$`*(length: CSSLength): string = + if length.auto: + return "auto" + return $length.num & ($length.unit).split('_')[1..^1].join("_").tolower() + +func `$`*(content: CSSContent): string = + if content.s != "": + return "url(" & content.s & ")" + return "none" + func `$`*(val: CSSComputedValue): string = result = ($val.t).toLowerAscii().split('_')[1..^1].join('-') & ": " case val.v of VALUE_COLOR: result &= $val.color of VALUE_IMAGE: - if val.image.s != "": - result &= "url(" & val.image.s & ")" - else: - result &= "none" + result &= $val.image + of VALUE_LENGTH: + result &= $val.length else: discard macro `{}`*(vals: CSSComputedValues, s: string): untyped = |