parent
fbacd1133d
commit
68dd40ef27
@ -1,30 +0,0 @@
|
||||
import { DENSITIES, type Density } from '$libs/density';
|
||||
import type { PrefsDimension } from '$libs/prefs';
|
||||
|
||||
export interface DensityDimensionOptions {
|
||||
readonly catalog?: readonly Density[];
|
||||
readonly default?: Density;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated UIX visual density belongs to `ActiveEidos`, not to the
|
||||
* standard prefs preset. Keep this only for legacy/custom app schemas
|
||||
* outside UIX.
|
||||
*/
|
||||
export function densityDimension(
|
||||
options: DensityDimensionOptions = {}
|
||||
): PrefsDimension<Density> {
|
||||
const catalog = options.catalog ?? DENSITIES;
|
||||
const fallback = options.default ?? 'comfortable';
|
||||
return {
|
||||
defaultValue: fallback,
|
||||
validate(value) {
|
||||
if (typeof value !== 'string') return { ok: false, reason: 'unsupported_density' };
|
||||
if (!catalog.includes(value as Density)) {
|
||||
return { ok: false, reason: 'unsupported_density' };
|
||||
}
|
||||
return { ok: true, value: value as Density };
|
||||
},
|
||||
catalog: () => catalog
|
||||
};
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
import type { PrefsDimension } from '$libs/prefs';
|
||||
import {
|
||||
resolveTheme,
|
||||
THEMES_INTENT,
|
||||
type ThemeEffective,
|
||||
type ThemeIntent
|
||||
} from '$libs/theme';
|
||||
|
||||
export interface ThemeDimensionOptions {
|
||||
/**
|
||||
* Allowed intent values. Defaults to the full `THEMES_INTENT`
|
||||
* (`'light' | 'dark' | 'system'`). Apps that don't want users to
|
||||
* follow the OS pass `['light', 'dark']`.
|
||||
*/
|
||||
readonly intents?: readonly ThemeIntent[];
|
||||
/**
|
||||
* Final fallback applied when neither intent nor `env.colorScheme`
|
||||
* provide a value. Must be a `ThemeEffective`.
|
||||
*/
|
||||
readonly default?: ThemeEffective;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated UIX visual mode belongs to `ActiveEidos`, not to the standard
|
||||
* prefs preset. Keep this only for legacy/custom app schemas outside UIX.
|
||||
*
|
||||
* `TIntent` includes `'system'`, `TEffective` does not: `resolve` folds
|
||||
* `'system'` into a concrete `'light' | 'dark'` using `env.colorScheme`.
|
||||
*/
|
||||
export function themeDimension(
|
||||
options: ThemeDimensionOptions = {}
|
||||
): PrefsDimension<ThemeIntent, ThemeEffective> {
|
||||
const intents = options.intents ?? THEMES_INTENT;
|
||||
const fallback = options.default ?? 'light';
|
||||
return {
|
||||
defaultValue: fallback,
|
||||
validate(value) {
|
||||
if (typeof value !== 'string') return { ok: false, reason: 'unsupported_theme' };
|
||||
if (!intents.includes(value as ThemeIntent)) {
|
||||
return { ok: false, reason: 'unsupported_theme' };
|
||||
}
|
||||
return { ok: true, value: value as ThemeIntent };
|
||||
},
|
||||
resolve(intent, env) {
|
||||
return resolveTheme(intent, env.colorScheme, fallback);
|
||||
},
|
||||
catalog: () => intents
|
||||
};
|
||||
}
|
||||
Loading…
Reference in new issue