@xenosystem/elements 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/activity.d.ts +11 -0
- package/dist/elements/activity.js +22 -0
- package/dist/elements/contact.d.ts +12 -0
- package/dist/elements/contact.js +26 -0
- package/dist/elements/film.d.ts +11 -0
- package/dist/elements/film.js +25 -0
- package/dist/elements/hash.d.ts +10 -0
- package/dist/elements/hash.js +22 -0
- package/dist/elements/mail.d.ts +11 -0
- package/dist/elements/mail.js +23 -0
- package/dist/tokens/dtcg.d.ts +74 -0
- package/dist/tokens/dtcg.js +136 -0
- package/dist/tokens/index.d.ts +3 -0
- package/dist/tokens/index.js +3 -0
- package/dist/tokens/oklch.d.ts +73 -0
- package/dist/tokens/oklch.js +206 -0
- package/dist/tokens/platform-theme.d.ts +71 -0
- package/dist/tokens/platform-theme.js +164 -0
- package/dist/tokens.dtcg.json +393 -0
- package/package.json +4 -2
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perceptual OKLCH + APCA (W3 0.0.98G-4g) Parametric Theme Engine.
|
|
3
|
+
*
|
|
4
|
+
* Derives an entire XENO surface/ink/border/semantic ramp mathematically from 3 perceptual knobs
|
|
5
|
+
* (`mode`, `warmthHue`, `chroma`, plus optional `contrast` tier), guaranteeing BOTH:
|
|
6
|
+
* - WCAG 2.2 AA (>= 4.5:1 standard, >= 7.0:1 high-contrast)
|
|
7
|
+
* - APCA Lc (|Lc| >= 75 primary text, |Lc| >= 60 secondary reading text)
|
|
8
|
+
* by construction — eliminating hand-tuned dark/light/high-contrast drift forever.
|
|
9
|
+
*
|
|
10
|
+
* Zero external dependencies. Runs identically in Node, Web, Electron, and MCP.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { wcagContrastRatio } from './dtcg.js';
|
|
15
|
+
function clamp01(v) {
|
|
16
|
+
return Math.max(0, Math.min(1, v));
|
|
17
|
+
}
|
|
18
|
+
function linearToSrgbByte(c) {
|
|
19
|
+
const clamped = clamp01(c);
|
|
20
|
+
const s = clamped <= 0.0031308 ? 12.92 * clamped : 1.055 * Math.pow(clamped, 1 / 2.4) - 0.055;
|
|
21
|
+
return Math.round(clamp01(s) * 255);
|
|
22
|
+
}
|
|
23
|
+
function parseHexRgbBytes(hex) {
|
|
24
|
+
const clean = hex.trim().replace(/^#/, '');
|
|
25
|
+
return [
|
|
26
|
+
parseInt(clean.slice(0, 2), 16),
|
|
27
|
+
parseInt(clean.slice(2, 4), 16),
|
|
28
|
+
parseInt(clean.slice(4, 6), 16),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
/** Exact OKLCH (L in [0..1], C >= 0, H in degrees) → sRGB 6-digit hex converter. */
|
|
32
|
+
export function oklchToHex(l, c, hDeg) {
|
|
33
|
+
const hRad = (hDeg * Math.PI) / 180;
|
|
34
|
+
const a = c * Math.cos(hRad);
|
|
35
|
+
const b = c * Math.sin(hRad);
|
|
36
|
+
const l_ = l + 0.3963377774 * a + 0.2158037573 * b;
|
|
37
|
+
const m_ = l - 0.1055613458 * a - 0.0638541728 * b;
|
|
38
|
+
const s_ = l - 0.0894841775 * a - 1.291485548 * b;
|
|
39
|
+
const l3 = l_ * l_ * l_;
|
|
40
|
+
const m3 = m_ * m_ * m_;
|
|
41
|
+
const s3 = s_ * s_ * s_;
|
|
42
|
+
const rLin = +4.0767416621 * l3 - 3.3077115913 * m3 + 0.2309699292 * s3;
|
|
43
|
+
const gLin = -1.2684380046 * l3 + 2.6097574011 * m3 - 0.3413193965 * s3;
|
|
44
|
+
const bLin = -0.0041960863 * l3 - 0.7034186147 * m3 + 1.707614701 * s3;
|
|
45
|
+
const toHex = (n) => linearToSrgbByte(n).toString(16).padStart(2, '0');
|
|
46
|
+
return `#${toHex(rLin)}${toHex(gLin)}${toHex(bLin)}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* APCA W3 (0.0.98G-4g) perceptual lightness contrast (`Lc`).
|
|
50
|
+
* Positive = dark text on light background; negative = light text on dark background.
|
|
51
|
+
* Reading targets: `|Lc| >= 75` for primary UI text, `|Lc| >= 60` for secondary reading text.
|
|
52
|
+
*/
|
|
53
|
+
export function apcaContrast(textHex, bgHex) {
|
|
54
|
+
const toY = (hex) => {
|
|
55
|
+
const [r, g, b] = parseHexRgbBytes(hex);
|
|
56
|
+
const y = 0.2126729 * Math.pow(r / 255, 2.4) +
|
|
57
|
+
0.7151522 * Math.pow(g / 255, 2.4) +
|
|
58
|
+
0.072175 * Math.pow(b / 255, 2.4);
|
|
59
|
+
return y > 0.022 ? y : y + Math.pow(0.022 - y, 1.414);
|
|
60
|
+
};
|
|
61
|
+
const yTxt = toY(textHex);
|
|
62
|
+
const yBg = toY(bgHex);
|
|
63
|
+
if (Math.abs(yBg - yTxt) < 0.0005)
|
|
64
|
+
return 0;
|
|
65
|
+
let sapc = 0;
|
|
66
|
+
if (yBg > yTxt) {
|
|
67
|
+
sapc = (Math.pow(yBg, 0.56) - Math.pow(yTxt, 0.57)) * 1.14;
|
|
68
|
+
return sapc < 0.1 ? 0 : Number(((sapc - 0.027) * 100).toFixed(1));
|
|
69
|
+
}
|
|
70
|
+
sapc = (Math.pow(yBg, 0.65) - Math.pow(yTxt, 0.62)) * 1.14;
|
|
71
|
+
return sapc > -0.1 ? 0 : Number(((sapc + 0.027) * 100).toFixed(1));
|
|
72
|
+
}
|
|
73
|
+
/** Auto-nudge OKLCH lightness along the safe direction until both WCAG and APCA targets pass. */
|
|
74
|
+
function solveInkHex(startL, chroma, hue, backgrounds, direction, minWcag, minApca) {
|
|
75
|
+
let l = clamp01(startL);
|
|
76
|
+
for (let i = 0; i < 60; i++) {
|
|
77
|
+
const hex = oklchToHex(l, chroma, hue);
|
|
78
|
+
const passes = backgrounds.every((bg) => wcagContrastRatio(hex, bg) >= minWcag && Math.abs(apcaContrast(hex, bg)) >= minApca);
|
|
79
|
+
if (passes)
|
|
80
|
+
return hex;
|
|
81
|
+
l = clamp01(l + direction * 0.012);
|
|
82
|
+
}
|
|
83
|
+
return direction > 0 ? '#ffffff' : '#000000';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Compile a mathematically contrast-verified XENO theme from 3 perceptual OKLCH knobs.
|
|
87
|
+
*/
|
|
88
|
+
export function generateOklchTheme(input) {
|
|
89
|
+
const spec = {
|
|
90
|
+
mode: input.mode,
|
|
91
|
+
warmthHue: input.warmthHue ?? 65,
|
|
92
|
+
chroma: Math.max(0, Math.min(0.03, input.chroma ?? 0.008)),
|
|
93
|
+
contrast: input.contrast ?? 'standard',
|
|
94
|
+
};
|
|
95
|
+
const isDark = spec.mode === 'dark';
|
|
96
|
+
const isHigh = spec.contrast === 'high';
|
|
97
|
+
const isOled = isDark && spec.contrast === 'oled';
|
|
98
|
+
const h = spec.warmthHue;
|
|
99
|
+
const c = isOled ? spec.chroma * 0.5 : spec.chroma;
|
|
100
|
+
// Perceptual lightness ladder (canvas -> surface -> viewport -> elevated -> control)
|
|
101
|
+
const canvas = isDark
|
|
102
|
+
? oklchToHex(isOled ? 0.0 : isHigh ? 0.14 : 0.185, isOled ? 0 : c * 0.7, h)
|
|
103
|
+
: oklchToHex(isHigh ? 0.91 : 0.928, c * 1.1, h);
|
|
104
|
+
const surface = isDark
|
|
105
|
+
? oklchToHex(isOled ? 0.13 : isHigh ? 0.18 : 0.22, c * 0.8, h)
|
|
106
|
+
: oklchToHex(isHigh ? 0.96 : 0.968, c * 0.8, h);
|
|
107
|
+
const viewport = isDark
|
|
108
|
+
? oklchToHex(isOled ? 0.165 : isHigh ? 0.21 : 0.252, c * 0.85, h)
|
|
109
|
+
: '#ffffff';
|
|
110
|
+
const elevated = isDark
|
|
111
|
+
? oklchToHex(isOled ? 0.2 : isHigh ? 0.24 : 0.278, c * 0.9, h)
|
|
112
|
+
: '#ffffff';
|
|
113
|
+
const control = isDark
|
|
114
|
+
? oklchToHex(isOled ? 0.24 : isHigh ? 0.27 : 0.3, c * 0.95, h)
|
|
115
|
+
: oklchToHex(isHigh ? 0.915 : 0.93, c * 1.0, h);
|
|
116
|
+
const border = isDark
|
|
117
|
+
? oklchToHex(isHigh ? 0.48 : 0.318, c * 0.9, h)
|
|
118
|
+
: oklchToHex(isHigh ? 0.62 : 0.892, c * 1.0, h);
|
|
119
|
+
const borderSubtle = isDark
|
|
120
|
+
? oklchToHex(isHigh ? 0.38 : 0.295, c * 0.8, h)
|
|
121
|
+
: oklchToHex(isHigh ? 0.72 : 0.912, c * 0.9, h);
|
|
122
|
+
const dir = isDark ? 1 : -1;
|
|
123
|
+
const primaryWcag = isHigh ? 7.0 : 4.5;
|
|
124
|
+
const primaryApca = isHigh ? 90 : 75;
|
|
125
|
+
const secondaryWcag = isHigh ? 7.0 : 4.5;
|
|
126
|
+
const secondaryApca = isHigh ? 75 : 60;
|
|
127
|
+
const text = solveInkHex(isDark ? 0.94 : 0.23, c * 0.6, h, [viewport, surface, control], dir, primaryWcag, primaryApca);
|
|
128
|
+
const active = solveInkHex(isDark ? 0.86 : 0.29, c * 0.7, h, [viewport, surface], dir, primaryWcag, 70);
|
|
129
|
+
const mutedText = solveInkHex(isDark ? 0.73 : 0.41, c * 0.9, h, [viewport, surface, control], dir, secondaryWcag, secondaryApca);
|
|
130
|
+
const muted = oklchToHex(isDark ? 0.58 : 0.53, c * 1.0, h);
|
|
131
|
+
const onAccent = solveInkHex(isDark ? 0.2 : 0.98, c * 0.5, h, [text], isDark ? -1 : 1, 7.0, 75);
|
|
132
|
+
const ok = oklchToHex(isDark ? 0.72 : 0.58, 0.13, 145);
|
|
133
|
+
const warn = oklchToHex(isDark ? 0.74 : 0.68, 0.13, 75);
|
|
134
|
+
const danger = oklchToHex(isDark ? 0.65 : 0.55, 0.15, 25);
|
|
135
|
+
const info = oklchToHex(isDark ? 0.72 : 0.55, 0.13, 250);
|
|
136
|
+
const textOnViewportWcag = wcagContrastRatio(text, viewport);
|
|
137
|
+
const textOnViewportApca = Math.abs(apcaContrast(text, viewport));
|
|
138
|
+
const mutedOnSurfaceWcag = wcagContrastRatio(mutedText, surface);
|
|
139
|
+
const mutedOnSurfaceApca = Math.abs(apcaContrast(mutedText, surface));
|
|
140
|
+
const mutedOnControlWcag = wcagContrastRatio(mutedText, control);
|
|
141
|
+
const mutedOnControlApca = Math.abs(apcaContrast(mutedText, control));
|
|
142
|
+
return Object.freeze({
|
|
143
|
+
spec,
|
|
144
|
+
canvas,
|
|
145
|
+
surface,
|
|
146
|
+
viewport,
|
|
147
|
+
elevated,
|
|
148
|
+
control,
|
|
149
|
+
border,
|
|
150
|
+
borderSubtle,
|
|
151
|
+
text,
|
|
152
|
+
active,
|
|
153
|
+
mutedText,
|
|
154
|
+
muted,
|
|
155
|
+
onAccent,
|
|
156
|
+
ok,
|
|
157
|
+
warn,
|
|
158
|
+
danger,
|
|
159
|
+
info,
|
|
160
|
+
audit: Object.freeze({
|
|
161
|
+
textOnViewportWcag,
|
|
162
|
+
textOnViewportApca,
|
|
163
|
+
mutedOnSurfaceWcag,
|
|
164
|
+
mutedOnSurfaceApca,
|
|
165
|
+
mutedOnControlWcag,
|
|
166
|
+
mutedOnControlApca,
|
|
167
|
+
allPass: textOnViewportWcag >= primaryWcag &&
|
|
168
|
+
textOnViewportApca >= primaryApca &&
|
|
169
|
+
mutedOnSurfaceWcag >= secondaryWcag &&
|
|
170
|
+
mutedOnSurfaceApca >= secondaryApca &&
|
|
171
|
+
mutedOnControlWcag >= secondaryWcag &&
|
|
172
|
+
mutedOnControlApca >= secondaryApca,
|
|
173
|
+
}),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/** Convert a generated OKLCH theme directly into `--xeno-*` CSS custom property assignments. */
|
|
177
|
+
export function themeToCssVars(theme) {
|
|
178
|
+
return {
|
|
179
|
+
'--xeno-canvas': theme.canvas,
|
|
180
|
+
'--xeno-surface': theme.surface,
|
|
181
|
+
'--xeno-panel-header': theme.surface,
|
|
182
|
+
'--xeno-viewport': theme.viewport,
|
|
183
|
+
'--xeno-elevated': theme.elevated,
|
|
184
|
+
'--xeno-control': theme.control,
|
|
185
|
+
'--xeno-field': theme.spec.mode === 'light' ? '#ffffff' : theme.control,
|
|
186
|
+
'--xeno-raised': theme.spec.mode === 'light' ? '#ffffff' : theme.control,
|
|
187
|
+
'--xeno-border': theme.border,
|
|
188
|
+
'--xeno-border-subtle': theme.borderSubtle,
|
|
189
|
+
'--xeno-text': theme.text,
|
|
190
|
+
'--xeno-active': theme.active,
|
|
191
|
+
'--xeno-muted-text': theme.mutedText,
|
|
192
|
+
'--xeno-muted': theme.muted,
|
|
193
|
+
'--xeno-on-accent': theme.onAccent,
|
|
194
|
+
'--xeno-ok': theme.ok,
|
|
195
|
+
'--xeno-warn': theme.warn,
|
|
196
|
+
'--xeno-danger': theme.danger,
|
|
197
|
+
'--xeno-info': theme.info,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export const OKLCH_PRESETS = Object.freeze({
|
|
201
|
+
warmDark: generateOklchTheme({ mode: 'dark', warmthHue: 65, chroma: 0.008, contrast: 'standard' }),
|
|
202
|
+
warmLight: generateOklchTheme({ mode: 'light', warmthHue: 65, chroma: 0.008, contrast: 'standard' }),
|
|
203
|
+
highContrastDark: generateOklchTheme({ mode: 'dark', warmthHue: 65, chroma: 0.004, contrast: 'high' }),
|
|
204
|
+
highContrastLight: generateOklchTheme({ mode: 'light', warmthHue: 65, chroma: 0.004, contrast: 'high' }),
|
|
205
|
+
oledDark: generateOklchTheme({ mode: 'dark', warmthHue: 65, chroma: 0.005, contrast: 'oled' }),
|
|
206
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical XENO Platform 21-Stop Brightness Theme Engine & Mode Palette.
|
|
3
|
+
*
|
|
4
|
+
* Lifted directly from `xeno-platform`'s proven brightness line (`0` Dark → `50` Dim → `100` Light
|
|
5
|
+
* in 5% steps) into Rung 1 (`@xenosystem/elements/tokens`) so every XENO console (`compute`,
|
|
6
|
+
* `chat`, `storage`, `spawn`, `workflow`, `research`, and `xeno-platform` itself) shares ONE
|
|
7
|
+
* continuous theme engine with mathematically verified WCAG 2.2 AA contrast at every stop.
|
|
8
|
+
*/
|
|
9
|
+
export type PlatformThemePreference = 'system' | 'custom' | 'dark' | 'dim' | 'light';
|
|
10
|
+
export type ResolvedPlatformTheme = 'dark' | 'dim' | 'light';
|
|
11
|
+
/** Five-percent slider step producing 21 discrete semantic palettes (0..100). */
|
|
12
|
+
export declare const PLATFORM_BRIGHTNESS_STEP = 5;
|
|
13
|
+
export declare const PLATFORM_THEME_OPTIONS: readonly [{
|
|
14
|
+
readonly id: "dark";
|
|
15
|
+
readonly label: "Dark";
|
|
16
|
+
readonly position: 0;
|
|
17
|
+
}, {
|
|
18
|
+
readonly id: "dim";
|
|
19
|
+
readonly label: "Dim";
|
|
20
|
+
readonly position: 50;
|
|
21
|
+
}, {
|
|
22
|
+
readonly id: "light";
|
|
23
|
+
readonly label: "Light";
|
|
24
|
+
readonly position: 100;
|
|
25
|
+
}];
|
|
26
|
+
export interface PlatformSurfacePalette {
|
|
27
|
+
readonly canvas: string;
|
|
28
|
+
readonly surface: string;
|
|
29
|
+
readonly elevated: string;
|
|
30
|
+
readonly control: string;
|
|
31
|
+
readonly controlStrong: string;
|
|
32
|
+
readonly text: string;
|
|
33
|
+
readonly muted: string;
|
|
34
|
+
readonly border: string;
|
|
35
|
+
readonly hover: string;
|
|
36
|
+
readonly overlay: string;
|
|
37
|
+
}
|
|
38
|
+
export interface PlatformRuntimeTokens extends PlatformSurfacePalette {
|
|
39
|
+
readonly position: number;
|
|
40
|
+
readonly closestTheme: ResolvedPlatformTheme;
|
|
41
|
+
readonly isLight: boolean;
|
|
42
|
+
readonly plate: string;
|
|
43
|
+
readonly rail: string;
|
|
44
|
+
readonly surfaceText: string;
|
|
45
|
+
readonly surfaceMuted: string;
|
|
46
|
+
}
|
|
47
|
+
/** All 21 semantic palettes along the XENO Platform brightness line (0 = Dark, 50 = Dim, 100 = Light). */
|
|
48
|
+
export declare const PLATFORM_BRIGHTNESS_PALETTES: readonly PlatformSurfacePalette[];
|
|
49
|
+
export declare function platformContrastRatio(hexA: string, hexB: string): number;
|
|
50
|
+
export declare function normalizePlatformBrightness(position: number): number;
|
|
51
|
+
export declare function getPlatformThemePosition(theme: ResolvedPlatformTheme): number;
|
|
52
|
+
export declare function getClosestPlatformTheme(position: number): ResolvedPlatformTheme;
|
|
53
|
+
export declare function getPlatformThemeTokens(position: number): PlatformRuntimeTokens;
|
|
54
|
+
/**
|
|
55
|
+
* Emit the complete `--xeno-*` CSS custom-property map for any position (`0..100`) on
|
|
56
|
+
* the XENO Platform brightness line. Apply directly as `style={buildPlatformThemeCssVars(brightness)}`
|
|
57
|
+
* on any `.xeno[data-layout="platform"]` container.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildPlatformThemeCssVars(position: number): Record<string, string>;
|
|
60
|
+
export type PlatformModeId = 'xeno' | 'dev' | 'studio' | 'office' | 'social' | 'corpo' | 'tools' | 'research';
|
|
61
|
+
export interface PlatformModeSpec {
|
|
62
|
+
readonly id: PlatformModeId;
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly color: string;
|
|
65
|
+
readonly summary: string;
|
|
66
|
+
readonly productCount: number;
|
|
67
|
+
readonly shortcut: string;
|
|
68
|
+
}
|
|
69
|
+
/** The 8 canonical XENO Platform modes and their locked brand accent hues. */
|
|
70
|
+
export declare const PLATFORM_MODES: readonly PlatformModeSpec[];
|
|
71
|
+
export declare function getPlatformMode(id: PlatformModeId): PlatformModeSpec;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical XENO Platform 21-Stop Brightness Theme Engine & Mode Palette.
|
|
3
|
+
*
|
|
4
|
+
* Lifted directly from `xeno-platform`'s proven brightness line (`0` Dark → `50` Dim → `100` Light
|
|
5
|
+
* in 5% steps) into Rung 1 (`@xenosystem/elements/tokens`) so every XENO console (`compute`,
|
|
6
|
+
* `chat`, `storage`, `spawn`, `workflow`, `research`, and `xeno-platform` itself) shares ONE
|
|
7
|
+
* continuous theme engine with mathematically verified WCAG 2.2 AA contrast at every stop.
|
|
8
|
+
*/
|
|
9
|
+
/** Five-percent slider step producing 21 discrete semantic palettes (0..100). */
|
|
10
|
+
export const PLATFORM_BRIGHTNESS_STEP = 5;
|
|
11
|
+
export const PLATFORM_THEME_OPTIONS = [
|
|
12
|
+
{ id: 'dark', label: 'Dark', position: 0 },
|
|
13
|
+
{ id: 'dim', label: 'Dim', position: 50 },
|
|
14
|
+
{ id: 'light', label: 'Light', position: 100 },
|
|
15
|
+
];
|
|
16
|
+
const stop = (canvas, surface, elevated, control, controlStrong, text, muted, border, hover, overlay) => ({
|
|
17
|
+
canvas,
|
|
18
|
+
surface,
|
|
19
|
+
elevated,
|
|
20
|
+
control,
|
|
21
|
+
controlStrong,
|
|
22
|
+
text,
|
|
23
|
+
muted,
|
|
24
|
+
border,
|
|
25
|
+
hover,
|
|
26
|
+
overlay,
|
|
27
|
+
});
|
|
28
|
+
/** All 21 semantic palettes along the XENO Platform brightness line (0 = Dark, 50 = Dim, 100 = Light). */
|
|
29
|
+
export const PLATFORM_BRIGHTNESS_PALETTES = [
|
|
30
|
+
stop('#0a0a0a', '#171717', '#262626', '#1f1f1f', '#333333', '#fafafa', '#a3a3a3', '#242424', '#333333', '#171717'),
|
|
31
|
+
stop('#0c0c0d', '#19191a', '#282829', '#222224', '#38383a', '#fafafa', '#a4a4a4', '#272728', '#38383a', '#19191a'),
|
|
32
|
+
stop('#0e0e0f', '#1b1b1c', '#2a2a2b', '#252527', '#3c3c3e', '#fafafa', '#a6a6a6', '#2a2a2b', '#3c3c3e', '#1b1b1c'),
|
|
33
|
+
stop('#101011', '#1d1d1e', '#2c2c2d', '#28282a', '#404042', '#fafafa', '#a8a8a8', '#2d2d2e', '#404042', '#1d1d1e'),
|
|
34
|
+
stop('#121213', '#1f1f20', '#2e2e2f', '#2b2b2d', '#444446', '#fafafa', '#aaaaaa', '#303031', '#444446', '#1f1f20'),
|
|
35
|
+
stop('#141415', '#212122', '#303031', '#2e2e30', '#48484a', '#fafafa', '#acacac', '#333334', '#48484a', '#212122'),
|
|
36
|
+
stop('#161617', '#232324', '#323233', '#313133', '#4c4c4e', '#fafafa', '#aeaeae', '#363637', '#4c4c4e', '#232324'),
|
|
37
|
+
stop('#181819', '#252526', '#343435', '#343436', '#4e4e50', '#fafafa', '#b0b0b0', '#39393a', '#4e4e50', '#252526'),
|
|
38
|
+
stop('#1a1a1b', '#272728', '#363637', '#373739', '#505052', '#f8f8f8', '#b2b2b2', '#3c3c3d', '#505052', '#272728'),
|
|
39
|
+
stop('#1c1c1d', '#29292a', '#383839', '#3a3a3c', '#525254', '#f7f7f7', '#b4b4b4', '#3f3f40', '#525254', '#29292a'),
|
|
40
|
+
// Stop 10 (position 50) — canonical Dim
|
|
41
|
+
stop('#181a1e', '#24272c', '#30343a', '#2b2f36', '#424751', '#f4f5f7', '#aeb2b8', '#3c4047', '#424751', '#24272c'),
|
|
42
|
+
stop('#1b1d22', '#272a30', '#34383f', '#2f333b', '#474d57', '#f4f5f7', '#b2b6bd', '#41464e', '#474d57', '#272a30'),
|
|
43
|
+
stop('#1e2126', '#2b2e35', '#383c44', '#333740', '#4d535e', '#f5f6f8', '#b6bbc2', '#464b53', '#4d535e', '#2b2e35'),
|
|
44
|
+
stop('#21242a', '#2f333a', '#3c4149', '#373b44', '#525965', '#f5f6f8', '#bbc0c7', '#4b5059', '#525965', '#2f333a'),
|
|
45
|
+
stop('#25282e', '#33373f', '#41464f', '#3c414a', '#585f6b', '#f6f7f8', '#c0c5cc', '#505660', '#585f6b', '#33373f'),
|
|
46
|
+
stop('#282b31', '#383c44', '#464b55', '#414650', '#5e6672', '#f7f8fa', '#c5cad0', '#565d67', '#5e6672', '#383c44'),
|
|
47
|
+
stop('#30343b', '#41464d', '#505661', '#4a505b', '#676f7b', '#f8f9fa', '#d0d4d9', '#626a74', '#676f7b', '#41464d'),
|
|
48
|
+
stop('#3b4048', '#4b515b', '#5d6470', '#545b67', '#747c88', '#fafafa', '#e0e2e6', '#707782', '#747c88', '#4b515b'),
|
|
49
|
+
stop('#414956', '#4d5562', '#59616f', '#58606e', '#6f7988', '#fafafa', '#dfe4ec', '#59616f', '#6f7988', '#4d5562'),
|
|
50
|
+
stop('#d7d9dd', '#e1e3e6', '#eceef0', '#f1f2f3', '#f6f7f8', '#0a0a0a', '#4b4e54', '#c9ccd1', '#e8eaed', '#e1e3e6'),
|
|
51
|
+
// Stop 20 (position 100) — canonical Light
|
|
52
|
+
stop('#e9e6e1', '#f3f1ed', '#ffffff', '#f2f0ec', '#e4e1db', '#181716', '#5c5853', '#d6d2cb', '#e8e5df', '#ffffff'),
|
|
53
|
+
];
|
|
54
|
+
function relativeLuminance(hex) {
|
|
55
|
+
const channels = [1, 3, 5].map((idx) => parseInt(hex.slice(idx, idx + 2), 16) / 255);
|
|
56
|
+
const [r, g, b] = channels.map((c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
|
|
57
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
58
|
+
}
|
|
59
|
+
export function platformContrastRatio(hexA, hexB) {
|
|
60
|
+
const l1 = relativeLuminance(hexA);
|
|
61
|
+
const l2 = relativeLuminance(hexB);
|
|
62
|
+
const lighter = Math.max(l1, l2);
|
|
63
|
+
const darker = Math.min(l1, l2);
|
|
64
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
65
|
+
}
|
|
66
|
+
function accessibleTextPair(ground, preferredText, preferredMuted) {
|
|
67
|
+
const light = '#fafafa';
|
|
68
|
+
const dark = '#0a0a0a';
|
|
69
|
+
const fallback = platformContrastRatio(light, ground) >= platformContrastRatio(dark, ground) ? light : dark;
|
|
70
|
+
const text = platformContrastRatio(preferredText, ground) >= 4.5 ? preferredText : fallback;
|
|
71
|
+
const muted = platformContrastRatio(preferredMuted, ground) >= 4.5 ? preferredMuted : text;
|
|
72
|
+
return { text, muted };
|
|
73
|
+
}
|
|
74
|
+
export function normalizePlatformBrightness(position) {
|
|
75
|
+
const safe = Number.isFinite(position) ? position : 0;
|
|
76
|
+
return Math.round(Math.min(100, Math.max(0, safe)) / PLATFORM_BRIGHTNESS_STEP) * PLATFORM_BRIGHTNESS_STEP;
|
|
77
|
+
}
|
|
78
|
+
export function getPlatformThemePosition(theme) {
|
|
79
|
+
return PLATFORM_THEME_OPTIONS.find((o) => o.id === theme)?.position ?? 0;
|
|
80
|
+
}
|
|
81
|
+
export function getClosestPlatformTheme(position) {
|
|
82
|
+
const norm = normalizePlatformBrightness(position);
|
|
83
|
+
return PLATFORM_THEME_OPTIONS.reduce((best, opt) => Math.abs(opt.position - norm) < Math.abs(best.position - norm) ? opt : best).id;
|
|
84
|
+
}
|
|
85
|
+
export function getPlatformThemeTokens(position) {
|
|
86
|
+
const norm = normalizePlatformBrightness(position);
|
|
87
|
+
const idx = Math.min(PLATFORM_BRIGHTNESS_PALETTES.length - 1, Math.max(0, Math.round(norm / PLATFORM_BRIGHTNESS_STEP)));
|
|
88
|
+
const base = PLATFORM_BRIGHTNESS_PALETTES[idx];
|
|
89
|
+
const isLight = relativeLuminance(base.canvas) > 0.45;
|
|
90
|
+
// Plate surface sits between canvas and rail in Dark (#111111 at stop 0) and Dim (#202328 at stop 50), crisp #ffffff at Light stop 100.
|
|
91
|
+
const plate = norm === 0 ? '#111111' : norm === 50 ? '#202328' : norm === 100 ? '#ffffff' : base.surface;
|
|
92
|
+
const { text, muted } = accessibleTextPair(plate, base.text, base.muted);
|
|
93
|
+
const surfacePair = accessibleTextPair(base.controlStrong, base.text, base.muted);
|
|
94
|
+
return {
|
|
95
|
+
...base,
|
|
96
|
+
position: norm,
|
|
97
|
+
closestTheme: getClosestPlatformTheme(norm),
|
|
98
|
+
isLight,
|
|
99
|
+
plate,
|
|
100
|
+
rail: base.surface,
|
|
101
|
+
text,
|
|
102
|
+
muted,
|
|
103
|
+
surfaceText: surfacePair.text,
|
|
104
|
+
surfaceMuted: surfacePair.muted,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Emit the complete `--xeno-*` CSS custom-property map for any position (`0..100`) on
|
|
109
|
+
* the XENO Platform brightness line. Apply directly as `style={buildPlatformThemeCssVars(brightness)}`
|
|
110
|
+
* on any `.xeno[data-layout="platform"]` container.
|
|
111
|
+
*/
|
|
112
|
+
export function buildPlatformThemeCssVars(position) {
|
|
113
|
+
const t = getPlatformThemeTokens(position);
|
|
114
|
+
return {
|
|
115
|
+
'--xeno-canvas': t.canvas,
|
|
116
|
+
'--xeno-rail-bg': t.rail,
|
|
117
|
+
'--xeno-rail-stroke': t.border,
|
|
118
|
+
'--xeno-surface': t.plate,
|
|
119
|
+
'--xeno-viewport': t.plate,
|
|
120
|
+
'--xeno-panel-header': t.plate,
|
|
121
|
+
'--xeno-elevated': t.elevated,
|
|
122
|
+
'--xeno-control': t.control,
|
|
123
|
+
'--xeno-field': t.canvas,
|
|
124
|
+
'--xeno-raised': t.elevated,
|
|
125
|
+
'--xeno-hover': t.isLight ? 'rgba(24, 23, 22, 0.05)' : 'rgba(255, 255, 255, 0.06)',
|
|
126
|
+
'--xeno-hover-strong': t.controlStrong,
|
|
127
|
+
'--xeno-border': t.border,
|
|
128
|
+
'--xeno-border-subtle': t.isLight ? 'rgba(24, 23, 22, 0.09)' : 'rgba(255, 255, 255, 0.08)',
|
|
129
|
+
'--xeno-border-strong': t.isLight ? 'rgba(24, 23, 22, 0.18)' : 'rgba(255, 255, 255, 0.15)',
|
|
130
|
+
'--xeno-plate-border': t.isLight
|
|
131
|
+
? t.border
|
|
132
|
+
: `color-mix(in srgb, ${t.text} 8.5%, ${t.canvas})`,
|
|
133
|
+
'--xeno-shell-border': t.isLight
|
|
134
|
+
? 'rgba(24, 23, 22, 0.22)'
|
|
135
|
+
: `color-mix(in srgb, ${t.text} 15%, ${t.canvas})`,
|
|
136
|
+
'--xeno-text': t.text,
|
|
137
|
+
'--xeno-muted-text': t.muted,
|
|
138
|
+
'--xeno-dim-text': t.muted,
|
|
139
|
+
'--xeno-muted': t.muted,
|
|
140
|
+
'--xeno-active': t.text,
|
|
141
|
+
'--xeno-on-accent': t.isLight ? '#ffffff' : t.canvas,
|
|
142
|
+
'--xeno-accent': t.text,
|
|
143
|
+
'--xeno-accent-text': t.isLight ? '#ffffff' : t.canvas,
|
|
144
|
+
'--xeno-accent-hover': t.isLight ? '#2f2d2a' : '#e5e5e5',
|
|
145
|
+
'--xeno-success-text': t.isLight ? '#059669' : '#34d399',
|
|
146
|
+
'--xeno-warning-text': t.isLight ? '#b45309' : '#fbbf24',
|
|
147
|
+
'--xeno-danger': t.isLight ? '#dc2626' : '#ef4444',
|
|
148
|
+
'--xeno-danger-text': t.isLight ? '#b91c1c' : '#f87171',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** The 8 canonical XENO Platform modes and their locked brand accent hues. */
|
|
152
|
+
export const PLATFORM_MODES = [
|
|
153
|
+
{ id: 'xeno', name: 'XENO', color: '#E8E8E3', summary: 'All products & unified workspace', productCount: 24, shortcut: 'Alt+0' },
|
|
154
|
+
{ id: 'dev', name: 'Dev', color: '#68d36f', summary: 'Compute, Agents, Workflows, SDKs & Spawn', productCount: 13, shortcut: 'Alt+1' },
|
|
155
|
+
{ id: 'studio', name: 'Studio', color: '#e875c6', summary: 'Pixel, Motion, Sound & Creator pipelines', productCount: 6, shortcut: 'Alt+2' },
|
|
156
|
+
{ id: 'office', name: 'Office', color: '#52a9fe', summary: 'Docs, Mail, Calendar & Storage drives', productCount: 5, shortcut: 'Alt+3' },
|
|
157
|
+
{ id: 'social', name: 'Social', color: '#25cbb7', summary: 'Publishing, Community & Campaigns', productCount: 4, shortcut: 'Alt+4' },
|
|
158
|
+
{ id: 'corpo', name: 'Corpo', color: '#f8ac3d', summary: 'Workforce, Customers, Billing & Ops', productCount: 6, shortcut: 'Alt+5' },
|
|
159
|
+
{ id: 'tools', name: 'Tools', color: '#ad8dfd', summary: 'MCP, CLI utilities, Box & Extensions', productCount: 5, shortcut: 'Alt+6' },
|
|
160
|
+
{ id: 'research', name: 'Research', color: '#e3d25b', summary: 'Corpus, Notebooks & Deep Synthesis', productCount: 4, shortcut: 'Alt+7' },
|
|
161
|
+
];
|
|
162
|
+
export function getPlatformMode(id) {
|
|
163
|
+
return PLATFORM_MODES.find((m) => m.id === id) ?? PLATFORM_MODES[0];
|
|
164
|
+
}
|