UNPKG

theme-vir

Version:
123 lines (122 loc) 4.74 kB
import { type PartialWithUndefined, type RequiredAndNotNull } from '@augment-vir/common'; import { ContrastLevelName } from '@electrovir/color'; import { type CssVarDefinitions, type SingleCssVarDefinition } from 'lit-css-vars'; import { type ColorInitValue } from './color-theme-init.js'; import { type NoRefColorInit } from './color-theme.js'; /** @category Internal */ export type ColorPaletteVars = CssVarDefinitions<Record<`${string}-${string}-${number}`, any>>; /** @category Internal */ export type PaletteColor = { suffix: string | undefined; prefix: string; colorName: string; definition: SingleCssVarDefinition; cssVarName: string; }; /** @category Internal */ export type ColorGroups = Record<string, PaletteColor[]>; /** * Black and white color values. * * @category Internal */ export declare const defaultOmittedColorGroupColorValues: string[]; /** @category Internal */ export declare function groupColors(colors: Readonly<ColorPaletteVars>, /** * Color values to omit from the grouping. Defaults to * {@link defaultOmittedColorGroupColorValues}. * * @default defaultOmittedColorGroupColorValues */ omittedColorValues?: ReadonlyArray<string>): ColorGroups; /** @category Internal */ export declare function extractPaletteColor(color: Readonly<SingleCssVarDefinition>): PaletteColor; /** @category Internal */ export declare function extractParam<const T extends PropertyKey>(possibleParams: ReadonlyArray<PropertyKey> | Readonly<Record<PropertyKey, boolean>>, { mapFrom, mapTo, }: Readonly<PartialWithUndefined<{ mapTo: Record<string, T>; mapFrom: Record<T, any>; }>>): T[]; /** @category Internal */ export type ArrayOrSelectParam<T extends PropertyKey> = ReadonlyArray<T> | Readonly<Partial<Record<T, boolean>>>; /** @category Internal */ export declare const defaultLightThemePair: RequiredAndNotNull<NoRefColorInit>; /** @category Internal */ export declare const defaultContrastLevels: Readonly<ArrayOrSelectParam<ContrastLevelName>>; /** * Extra contrast levels generated by {@link buildColorTheme} beyond the standard `ContrastLevelName` * values. `highest-contrast` always picks the palette color with the most contrast against the * fixed color; `lowest-contrast` always picks the closest. * * @category Internal */ export declare enum ExtremeContrastLevel { HighestContrast = "highest-contrast", LowestContrast = "lowest-contrast" } /** * Options for {@link buildColorTheme}. * * @category Internal */ export type BuildLowLevelColorThemeOptions = PartialWithUndefined<{ /** * Theme var prefix. * * @default 'vir' */ prefix: string; /** * The default theme colors for {@link defineColorTheme}. Defaults to * {@link defaultLightThemePair}. * * @default defaultLightThemePair */ defaultTheme: RequiredAndNotNull<NoRefColorInit>; /** * All font weights to cross colors with. Defaults to {@link defaultContrastLevels}. * * @default defaultContrastLevels */ crossContrastLevels: Readonly<ArrayOrSelectParam<ContrastLevelName>>; /** * Color values to omit from the grouping. Defaults to * {@link defaultOmittedColorGroupColorValues}. * * @default defaultOmittedColorGroupColorValues */ omittedColorValues: ReadonlyArray<string>; }>; /** * Creates a color theme from a color palette. * * @category Color Theme */ export declare function buildColorTheme(colorPalette: Readonly<ColorPaletteVars>, { omittedColorValues, crossContrastLevels, prefix, }?: Readonly<BuildLowLevelColorThemeOptions>): { defaultLight: import("./color-theme.js").ColorTheme<Record<`${Lowercase<string>}-${Lowercase<string>}`, ((Required<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "foreground">> & Partial<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "background">>) | (Required<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "background">> & Partial<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "foreground">>)) & {}>>; darkOverride: import("./color-theme-init.js").ColorThemeOverride<Record<`${Lowercase<string>}-${Lowercase<string>}`, ((Required<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "foreground">> & Partial<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "background">>) | (Required<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "background">> & Partial<Pick<{ foreground: ColorInitValue; background: ColorInitValue; }, "foreground">>)) & {}>>; };