css_class_generation.ts

CSS class generation utilities.

Produces CSS output from class definitions, handles interpretation of dynamic classes, and provides collection management for extracted classes.

Declarations
#

13 declarations

view source

CssClassDefinition
#

CssClassDefinitionBase
#

CssClassDefinitionComposition
#

CssClassDefinitionDeclaration
#

CssClassDefinitionInterpreter
#

css_class_generation.ts view source

CssClassDefinitionInterpreter

Interpreter for dynamic CSS class generation based on pattern matching.

inheritance

pattern

type RegExp

interpret

type (matched: RegExpMatchArray, ctx: CssClassInterpreterContext) => string | null

CssClassDefinitionRuleset
#

CssClassDefinitionStatic
#

CssClassInterpreterContext
#

css_class_generation.ts view source

CssClassInterpreterContext

Context passed to CSS class interpreters. Provides access to logging, diagnostics collection, and the class registry.

log

Optional logger for warnings/errors

type Logger

diagnostics

Diagnostics array to collect warnings and errors

type Array<InterpreterDiagnostic>

class_definitions

All known CSS class definitions (token + composite classes)

type Record<string, CssClassDefinition | undefined>

css_properties

Valid CSS properties for literal validation, or null to skip validation

type Set<string> | null

escape_css_selector
#

css_class_generation.ts view source

(name: string): string

Escapes special characters in a CSS class name for use in a selector. CSS selectors require escaping of characters like :, %, (, ), etc.

name

type string

returns

string

examples

escape_css_selector('display:flex') // 'display\\:flex' escape_css_selector('opacity:80%') // 'opacity\\:80\\%' escape_css_selector('nth-child(2n)') // 'nth-child\\(2n\\)'

extract_primary_property
#

css_class_generation.ts view source

(declaration: string): string | null

Extracts the CSS property name from a single-property declaration string. Returns null for multi-property declarations (composites with multiple semicolons).

declaration

type string

returns

string | null

examples

extract_primary_property('border-radius: var(--border_radius_sm);') // 'border-radius' extract_primary_property('display: flex; align-items: center;') // null

generate_classes_css
#

GenerateClassesCssOptions
#

css_class_generation.ts view source

GenerateClassesCssOptions

class_names

type Iterable<string>

class_definitions

type Record<string, CssClassDefinition | undefined>

interpreters

type Array<CssClassDefinitionInterpreter>

css_properties

Valid CSS properties for literal validation, or null to skip validation

type Set<string> | null

log

type Logger

class_locations

type Map<string, Array<SourceLocation> | null>

explicit_classes

Classes that were explicitly annotated (via @fuz-classes or additional_classes). Unresolved explicit classes produce warnings.

type Set<string> | null

GenerateClassesCssResult
#

css_class_generation.ts view source

GenerateClassesCssResult

Result from CSS class generation.

css

type string

diagnostics

type Array<GenerationDiagnostic>

variables_used

CSS variables used by the generated classes (without -- prefix)

type Set<string>

Depends on
#

Imported by
#