stoop
Version:
CSS-in-JS library with type inference, theme creation, and variants support.
44 lines (43 loc) • 1.96 kB
TypeScript
/**
* Theme token resolution utilities.
* Converts theme tokens to CSS variables for runtime theme switching.
* Uses cached token index for efficient lookups and theme comparison.
*/
import type { CSS, Theme, ThemeScale } from "../types";
/**
* Compares two themes for equality by structure and values.
* Excludes 'media' property from comparison since it's not a CSS variable scale.
*
* @param theme1 - First theme to compare
* @param theme2 - Second theme to compare
* @returns True if themes are equal, false otherwise
*/
export declare function themesAreEqual(theme1: Theme | null, theme2: Theme | null): boolean;
/**
* Converts a theme token string to a CSS variable reference.
*
* @param token - Token string (e.g., "$primary" or "$colors$primary")
* @param theme - Optional theme for token resolution
* @param property - Optional CSS property name for scale detection
* @param themeMap - Optional theme scale mappings
* @returns CSS variable reference string
*/
export declare function tokenToCSSVar(token: string, theme?: Theme, property?: string, themeMap?: Record<string, ThemeScale>): string;
/**
* Generates CSS custom properties from a theme object.
*
* @param theme - Theme object to convert to CSS variables
* @param prefix - Optional prefix for CSS variable names
* @returns CSS string with :root selector and CSS variables
*/
export declare function generateCSSVariables(theme: Theme, prefix?: string): string;
/**
* Recursively replaces theme tokens with CSS variable references in a CSS object.
*
* @param obj - CSS object to process
* @param theme - Optional theme for token resolution
* @param themeMap - Optional theme scale mappings
* @param property - Optional CSS property name for scale detection
* @returns CSS object with tokens replaced by CSS variables
*/
export declare function replaceThemeTokensWithVars(obj: CSS, theme?: Theme, themeMap?: Record<string, ThemeScale>, property?: string): CSS;