Skip to content

@jsvision/core / rolesFromAliases

Function: rolesFromAliases()

rolesFromAliases(c): Theme

Defined in: color/roles.ts:38

Build a complete Theme from a resolved 16-token ThemeColors set.

Every one of the theme's roles (and its structural extras — the desktop pattern, window/dialog border/title/icon) is assigned from the alias that best matches its intent, so the result is internally consistent by construction. The return type is Theme, so the compiler guarantees no role is forgotten. This is the expansion step inside createTheme; call it directly only when you already hold a ThemeColors object.

Parameters

c

ThemeColors

The 16 resolved semantic aliases.

Returns

Theme

A full theme with every role populated from the aliases.

Example

ts
import { rolesFromAliases } from '@jsvision/core';

const theme = rolesFromAliases({
  foreground: '#e0e0e0', foregroundMuted: '#a0a0a0', foregroundDisabled: '#707070',
  foregroundOnAccent: '#ffffff', background: '#101010', backgroundRaised: '#202020',
  backgroundSunken: '#0a0a0a', backgroundSelected: '#303030', accent: '#3b82f6',
  accentMuted: '#2563eb', border: '#404040', borderMuted: '#303030', danger: '#ef4444',
  warning: '#f59e0b', success: '#22c55e', info: '#0ea5e9',
});
theme.button.bg; // '#3b82f6' — the accent alias