LiveStyle.CSSValue (LiveStyle v0.12.0)
View SourceCSS value normalization and transformation.
Follows StyleX's transform-value.js and normalize-value.js approach.
Delegates property checks to LiveStyle.Property for centralized
compile-time generated lookups.
Regex patterns are compiled at module level for efficiency.
Summary
Functions
Normalizes a CSS value string.
Converts a value to its CSS string representation.
Converts an Elixir property key to CSS property name.
Functions
Normalizes a CSS value string.
Applies StyleX's normalize-value.js pipeline:
- Normalize whitespace
- Normalize timings (500ms -> .5s)
- Remove leading zeros (0.5 -> .5)
- Normalize zero dimensions (0px -> 0)
- Normalize empty string quotes ('' -> "")
Converts a value to its CSS string representation.
Examples
iex> LiveStyle.CSSValue.to_css(10, "padding")
"10px"
iex> LiveStyle.CSSValue.to_css(0.5, "opacity")
"0.5"
iex> LiveStyle.CSSValue.to_css("0.5s", "transition-duration")
".5s"
Converts an Elixir property key to CSS property name.
Examples
iex> LiveStyle.CSSValue.to_css_property(:background_color)
"background-color"
iex> LiveStyle.CSSValue.to_css_property("margin-top")
"margin-top"