parseColor
Parses `#rgb`, `#rrggbb`, `rgb()`/`rgba()`, `hsl()`/`hsla()` (commas or spaces, optional `/` or `,` alpha, which is ignored) and bare HSL triplets like `"160 84% 39%"`. Anything else, including out-of-range channels: `null`. Never throws.
packages/ui/src/components/layout/brand-theme.ts
@marktiderman/genesis-ui/layoutimport { parseColor } from "@marktiderman/genesis-ui/layout";react-docgen-typescript.parseColor
Parses `#rgb`, `#rrggbb`, `rgb()`/`rgba()`, `hsl()`/`hsla()` (commas or spaces, optional `/` or `,` alpha, which is ignored) and bare HSL triplets like `"160 84% 39%"`. Anything else, including out-of-range channels: `null`. Never throws.
No declared props.
relativeLuminance
WCAG 2 relative luminance, 0 (black) to 1 (white).
| Prop | Type | Default | Description |
|---|---|---|---|
| b* | number | — | |
| g* | number | — | |
| r* | number | — |
contrastRatio
WCAG 2 contrast ratio between two colours, 1 to 21.
No declared props.
rgbToHsl
sRGB to HSL: hue 0-360, saturation and lightness 0-100.
| Prop | Type | Default | Description |
|---|---|---|---|
| b* | number | — | |
| g* | number | — | |
| r* | number | — |
hslToRgb
HSL (hue 0-360, saturation and lightness 0-100) to sRGB, channels rounded to 8 bits.
| Prop | Type | Default | Description |
|---|---|---|---|
| h* | number | — | |
| l* | number | — | |
| s* | number | — |
toHslTriplet
The Genesis token shape: `"160 84% 39%"`, for `hsl(var(--x))`.
| Prop | Type | Default | Description |
|---|---|---|---|
| b* | number | — | |
| g* | number | — | |
| r* | number | — |
accessibleAccent
The contrast fallback. Returns the accent unchanged when its emitted triplet reaches `minRatio` against `background` (white by default); otherwise the same (rounded) hue and saturation at the highest lightness, to 0.1%, whose emitted triplet does. Every check runs on the value that is actually emitted, after rounding. It always ends: lightness 0 is black, 21:1 on white.
No declared props.
brandThemeStyle
The CSS variables for a brand's accent, for a page root's `style`. Empty when the brand has no valid accent, so the page keeps Genesis's primary.
No declared props.
MIN_TEXT_CONTRAST
WCAG AA for normal-size text.
No declared props.