LiveStyle.Compiler (LiveStyle v0.12.0)
View SourceCompiler utilities for LiveStyle.
This module provides functions for working with compiled LiveStyle output, including CSS generation and class resolution.
CSS Generation
css = LiveStyle.Compiler.generate_css()
# => "@layer live_style { .x1234{display:flex} ... }"Class Resolution (useful for testing)
# Get attrs for a module's styles
attrs = LiveStyle.Compiler.get_css(MyComponent, [:button])
# Get class string only
class = LiveStyle.Compiler.get_css_class(MyComponent, [:button])
Summary
Functions
Generates CSS from all registered styles.
Gets CSS attrs from a module that uses LiveStyle.
Gets the class string from a module that uses LiveStyle.
Functions
@spec generate_css() :: String.t()
Generates CSS from all registered styles.
Reads the manifest and generates the complete CSS output. Useful for testing and build tooling.
Example
css = LiveStyle.Compiler.generate_css()
# => "@layer live_style { .x1234{display:flex} ... }"
@spec get_css(module(), list()) :: LiveStyle.Attrs.t()
@spec get_css(module(), atom()) :: LiveStyle.Attrs.t()
Gets CSS attrs from a module that uses LiveStyle.
Useful for testing and introspection.
Example
defmodule MyComponent do
use LiveStyle
class :button, display: "flex"
end
# In tests:
%LiveStyle.Attrs{class: class} = LiveStyle.Compiler.get_css(MyComponent, [:button])
@spec get_css_class(module(), list()) :: String.t()
@spec get_css_class(module(), atom()) :: String.t()
Gets the class string from a module that uses LiveStyle.
Useful for testing and introspection.
Example
defmodule MyComponent do
use LiveStyle
class :button, display: "flex"
end
# In tests:
class = LiveStyle.Compiler.get_css_class(MyComponent, [:button])