Skip to Content
Documentation

songstress/theme

A theme's colours as the apps read them.

See Themes.

What it exports is the SDK's own record of its public surface, which the SDK's tests hold to the code. Each type's fields, and every description, are read from the SDK's source when the site is built.

MAX_COLOR_LENGTH · ParsedColor · TRANSLUCENT_TOKENS · normalizeColor · normalizeLook · parseColor

It also exports, as the modules that declare them document them: THEME_TOKENS, ThemeColors, ThemeLook, ThemeToken.

MAX_COLOR_LENGTH

The longest colour a theme may write.

export declare const MAX_COLOR_LENGTH = 64;

ParsedColor

A colour, read.

Prop

Type

TRANSLUCENT_TOKENS

The tokens that may be translucent: every other colour of a theme is opaque.

export declare const TRANSLUCENT_TOKENS: readonly [
    "surface.hover",
    "border"
];

normalizeColor

A colour in its one form, #rrggbb or #rrggbbaa; nothing for a value that is not a colour.

export declare function normalizeColor(value: string): string | undefined;
ParameterTypeDescription
valuestringA colour as a theme writes it.

Returns string | undefined: Its one form, or undefined.

normalizeLook

A look with each colour in its one form, #rrggbb or #rrggbbaa, and nothing a look may not hold: a value that is not one of a theme's colours, a translucent one where its place is opaque, a token this version does not name, glow past the third. What is left out an app fills in, as it fills any token a look leaves out. Nothing, for a value with no colour left in it. A look that passed songstress/manifest's checks loses nothing here: it only changes form.

export declare function normalizeLook(look: unknown): ThemeLook | undefined;
ParameterTypeDescription
lookunknownA look as a theme file holds it.

Returns ThemeLook | undefined: The look in its one form, or undefined.

Refers to ThemeLook.

parseColor

Reads a colour as a theme writes it; nothing for a value that is not one of a theme's forms (SPEC.md, section 12): a name, currentColor, var(), a gradient, a part out of its range, more than 64 characters.

export declare function parseColor(value: string): ParsedColor | undefined;
ParameterTypeDescription
valuestringA colour as a theme writes it: hex, rgb(), rgba(), hsl() or hsla().

Returns ParsedColor | undefined: Its one form and its alpha, or undefined.

Example
import { parseColor } from 'songstress/theme'

parseColor('#FF464A') // { hex: '#ff464a', alpha: 1 }
parseColor('red') // undefined: a name is not one of a theme's forms

Refers to ParsedColor.