Skip to content

Search the guides, deployment pages, and API reference.

ThemeResult

import type { ThemeResult } from "@pitlane/theme";

The object createTheme returns: the typed token accessor, the raw resolver, the <Theme /> component, and the two derivation methods.

Type Parameters

T

T

Properties

Theme

readonly Theme: ThemeComponent<T>;

The component that installs the custom properties.


token

readonly token: TokenTree<T>;

A typed mirror of the token tree whose leaves are branded var() reference strings. A s.scale() leaf is callable.

Methods

extend()

extend<schema, tokens>(patch): ThemeResult<Merged<T, {
schema: schema;
tokens: tokens;
}>>;

Deep-merges a patch onto this theme and returns a new one. A leaf replaces wholesale; every other node recurses.

The callback form receives this theme's accessor, so a patch can reference what it extends.

Type Parameters

schema

schema extends object

tokens

tokens extends object

Parameters

patch

| ExtendPatch<T, schema, tokens> | ((base: TokenTree<T>) => ExtendPatch<T, schema, tokens>)

The tokens and schema to merge, or a callback returning them: a ThemePatch whose schema and tokens types are kept exactly. schema is optional when the patch only adds tokens to namespaces the theme already types. modes may override any token of the merged tree, including tokens the patch itself does not declare.

Returns

ThemeResult<Merged<T, { schema: schema; tokens: tokens; }>>

A new theme

Throws

ThemeError when the patch holds no tokens group


raw()

raw(ref): string;

Resolves a token reference to its concrete base value, following references to the end.

Parameters

ref

| AnyToken | UntypedToken

A token reference minted by this theme

Returns

string

The serialized base value

Throws

ThemeError when the reference was not minted here


select()

select<P>(projection): ThemeResult<P>;

Replaces this theme with a projection of it. The callback receives this theme's accessor; every value in the projection is a reference into it, and the new path decides the new custom property name, so a projection may also reshape and rename.

Type Parameters

P

P extends ThemeInit

Parameters

projection

(base: TokenTree<T>) => P

A callback returning the schema and tokens to keep

Returns

ThemeResult<P>

A new theme

Throws

ThemeError when the projection holds no tokens group