Constructor
new StyleProcessor()
Creates an instance of StyleProcessor.
- Source:
Members
cssVariables :Object.<string, string>
A map of CSS variable names to their values.
Type:
- Object.<string, string>
- Source:
globalStyles :string
The accumulated global stylesheet content.
Type:
- string
- Source:
rawGlobalCSS :Set.<string>
Raw global CSS rules added via addGlobalCSS.
Type:
- Set.<string>
- Source:
scopedStyles :string
Scoped CSS rules.
Type:
- string
- Source:
Methods
addGlobalCSS(css)
Adds raw global CSS rules to the stylesheet.
Parameters:
| Name | Type | Description |
|---|---|---|
css |
string | The raw CSS string. |
- Source:
addVariable(name, value)
Adds a global CSS variable to the processor.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The name of the variable (without the @ prefix). |
value |
string | The value of the variable. |
- Source:
applyVariables(cssContent) → {string}
Replaces CSS variables (e.g., @primary) with their values.
Parameters:
| Name | Type | Description |
|---|---|---|
cssContent |
string | The CSS content to process. |
- Source:
Returns:
The CSS content with variables replaced.
- Type
- string
getGlobalStyles() → {string}
Retrieves the accumulated global styles.
- Source:
Returns:
The complete CSS string for the application.
- Type
- string
getHash(cssContent, componentName) → {string}
Generates a unique hash for a CSS block.
Parameters:
| Name | Type | Description |
|---|---|---|
cssContent |
string | The CSS content. |
componentName |
string | The name of the component. |
- Source:
Returns:
The generated hash.
- Type
- string
process(html, desBlocksopt, componentNameopt) → {string}
Processes the CSS within an HTML template. It identifies @css attributes, scopes the rules with a unique hash, replaces variables, and updates the HTML.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
html |
string | The HTML template. |
||
desBlocks |
Object |
<optional> |
{} | Pre-defined style blocks from a .component.css file. |
componentName |
string |
<optional> |
"" | The name of the component for hash generation. |
- Source:
Returns:
The modified HTML.
- Type
- string
reset()
Resets the processor state, clearing all accumulated styles and variables.
- Source: