@und-ui/tokens 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +345 -2
- package/dist/android/values/und_colors.xml +91 -0
- package/dist/android/values/und_dimens.xml +93 -0
- package/dist/android/values-night/und_colors.xml +91 -0
- package/dist/css/base.css +2335 -0
- package/dist/css/motion.css +223 -0
- package/dist/css/themes/kesar.css +68 -0
- package/dist/css/themes/mitti.css +84 -0
- package/dist/css/themes/neem.css +84 -0
- package/dist/css/themes/raat.css +507 -0
- package/dist/css/themes/sutra.css +109 -0
- package/dist/css/themes/ujala.css +67 -0
- package/dist/css/tokens.css +3167 -0
- package/dist/dart/und_tokens.dart +3223 -0
- package/dist/js/contexts.d.ts +2 -0
- package/dist/js/contexts.js +3 -0
- package/dist/js/index.d.ts +1883 -0
- package/dist/js/index.js +2230 -0
- package/dist/json/flat/kesar.dark.json +737 -0
- package/dist/json/flat/kesar.darkMore.json +737 -0
- package/dist/json/flat/kesar.light.json +737 -0
- package/dist/json/flat/kesar.lightMore.json +737 -0
- package/dist/json/flat/mitti.dark.json +737 -0
- package/dist/json/flat/mitti.darkMore.json +737 -0
- package/dist/json/flat/mitti.light.json +737 -0
- package/dist/json/flat/mitti.lightMore.json +737 -0
- package/dist/json/flat/neem.dark.json +737 -0
- package/dist/json/flat/neem.darkMore.json +737 -0
- package/dist/json/flat/neem.light.json +737 -0
- package/dist/json/flat/neem.lightMore.json +737 -0
- package/dist/json/flat/raat.dark.json +737 -0
- package/dist/json/flat/raat.darkMore.json +737 -0
- package/dist/json/flat/sutra.dark.json +738 -0
- package/dist/json/flat/sutra.darkMore.json +738 -0
- package/dist/json/flat/sutra.light.json +738 -0
- package/dist/json/flat/sutra.lightMore.json +738 -0
- package/dist/json/flat/ujala.dark.json +737 -0
- package/dist/json/flat/ujala.darkMore.json +737 -0
- package/dist/json/flat/ujala.light.json +737 -0
- package/dist/json/flat/ujala.lightMore.json +737 -0
- package/dist/json/nested/kesar.dark.json +885 -0
- package/dist/json/nested/kesar.darkMore.json +885 -0
- package/dist/json/nested/kesar.light.json +885 -0
- package/dist/json/nested/kesar.lightMore.json +885 -0
- package/dist/json/nested/mitti.dark.json +885 -0
- package/dist/json/nested/mitti.darkMore.json +885 -0
- package/dist/json/nested/mitti.light.json +885 -0
- package/dist/json/nested/mitti.lightMore.json +885 -0
- package/dist/json/nested/neem.dark.json +885 -0
- package/dist/json/nested/neem.darkMore.json +885 -0
- package/dist/json/nested/neem.light.json +885 -0
- package/dist/json/nested/neem.lightMore.json +885 -0
- package/dist/json/nested/raat.dark.json +885 -0
- package/dist/json/nested/raat.darkMore.json +885 -0
- package/dist/json/nested/sutra.dark.json +886 -0
- package/dist/json/nested/sutra.darkMore.json +886 -0
- package/dist/json/nested/sutra.light.json +886 -0
- package/dist/json/nested/sutra.lightMore.json +886 -0
- package/dist/json/nested/ujala.dark.json +885 -0
- package/dist/json/nested/ujala.darkMore.json +885 -0
- package/dist/json/nested/ujala.light.json +885 -0
- package/dist/json/nested/ujala.lightMore.json +885 -0
- package/dist/kotlin/UndTokens.kt +2870 -0
- package/dist/lib/build/contexts.d.ts +13 -0
- package/dist/lib/build/contexts.js +20 -0
- package/dist/lib/build/css-values.d.ts +31 -0
- package/dist/lib/build/css-values.js +191 -0
- package/dist/lib/build/formats/css.d.ts +43 -0
- package/dist/lib/build/formats/css.js +380 -0
- package/dist/lib/build/formats/dart.d.ts +9 -0
- package/dist/lib/build/formats/dart.js +342 -0
- package/dist/lib/build/formats/js.d.ts +29 -0
- package/dist/lib/build/formats/js.js +297 -0
- package/dist/lib/build/formats/kotlin.d.ts +8 -0
- package/dist/lib/build/formats/kotlin.js +232 -0
- package/dist/lib/build/formats/react-native.d.ts +2 -0
- package/dist/lib/build/formats/react-native.js +208 -0
- package/dist/lib/build/formats/style-dictionary.d.ts +8 -0
- package/dist/lib/build/formats/style-dictionary.js +163 -0
- package/dist/lib/build/formats/swift.d.ts +8 -0
- package/dist/lib/build/formats/swift.js +395 -0
- package/dist/lib/build/formats/tailwind.d.ts +9 -0
- package/dist/lib/build/formats/tailwind.js +105 -0
- package/dist/lib/build/index.d.ts +12 -0
- package/dist/lib/build/index.js +133 -0
- package/dist/lib/build/materialize.d.ts +102 -0
- package/dist/lib/build/materialize.js +170 -0
- package/dist/lib/build/native-model.d.ts +46 -0
- package/dist/lib/build/native-model.js +177 -0
- package/dist/lib/color/contrast.d.ts +24 -0
- package/dist/lib/color/contrast.js +95 -0
- package/dist/lib/color/convert.d.ts +39 -0
- package/dist/lib/color/convert.js +91 -0
- package/dist/lib/color/pairs.d.ts +29 -0
- package/dist/lib/color/pairs.js +90 -0
- package/dist/lib/color/palette.d.ts +118 -0
- package/dist/lib/color/palette.js +199 -0
- package/dist/lib/color/scales.d.ts +18 -0
- package/dist/lib/color/scales.js +115 -0
- package/dist/lib/dtcg/engine.d.ts +75 -0
- package/dist/lib/dtcg/engine.js +395 -0
- package/dist/lib/dtcg/format-json.d.ts +1 -0
- package/dist/lib/dtcg/format-json.js +59 -0
- package/dist/lib/dtcg/types.d.ts +124 -0
- package/dist/lib/dtcg/types.js +54 -0
- package/dist/lib/index.d.ts +20 -0
- package/dist/lib/index.js +14 -0
- package/dist/lib/motion/spring.d.ts +40 -0
- package/dist/lib/motion/spring.js +129 -0
- package/dist/lib/source/generate.d.ts +28 -0
- package/dist/lib/source/generate.js +468 -0
- package/dist/lib/themes/definitions.d.ts +43 -0
- package/dist/lib/themes/definitions.js +140 -0
- package/dist/react-native/index.d.ts +130 -0
- package/dist/react-native/index.js +15 -0
- package/dist/react-native/tokens.d.ts +2 -0
- package/dist/react-native/tokens.js +4413 -0
- package/dist/scss/_variables.scss +738 -0
- package/dist/scss/_vars.scss +857 -0
- package/dist/scss/kesar.dark.scss +738 -0
- package/dist/scss/kesar.darkMore.scss +738 -0
- package/dist/scss/kesar.light.scss +738 -0
- package/dist/scss/kesar.lightMore.scss +738 -0
- package/dist/scss/mitti.dark.scss +738 -0
- package/dist/scss/mitti.darkMore.scss +738 -0
- package/dist/scss/mitti.light.scss +738 -0
- package/dist/scss/mitti.lightMore.scss +738 -0
- package/dist/scss/neem.dark.scss +738 -0
- package/dist/scss/neem.darkMore.scss +738 -0
- package/dist/scss/neem.light.scss +738 -0
- package/dist/scss/neem.lightMore.scss +738 -0
- package/dist/scss/raat.dark.scss +738 -0
- package/dist/scss/raat.darkMore.scss +738 -0
- package/dist/scss/sutra.dark.scss +739 -0
- package/dist/scss/sutra.darkMore.scss +739 -0
- package/dist/scss/sutra.light.scss +739 -0
- package/dist/scss/sutra.lightMore.scss +739 -0
- package/dist/scss/ujala.dark.scss +738 -0
- package/dist/scss/ujala.darkMore.scss +738 -0
- package/dist/scss/ujala.light.scss +738 -0
- package/dist/scss/ujala.lightMore.scss +738 -0
- package/dist/swift/UndTokens.swift +4117 -0
- package/dist/tailwind/und.css +586 -0
- package/package.json +84 -3
- package/tokens/contrast/more.tokens.json +46 -0
- package/tokens/density/comfortable.tokens.json +64 -0
- package/tokens/density/compact.tokens.json +68 -0
- package/tokens/density/touch.tokens.json +64 -0
- package/tokens/modes/dark.tokens.json +197 -0
- package/tokens/modes/light.tokens.json +166 -0
- package/tokens/motion/reduced.tokens.json +119 -0
- package/tokens/primitives/color.dark.tokens.json +2001 -0
- package/tokens/primitives/color.light.tokens.json +2077 -0
- package/tokens/primitives/dimension.tokens.json +181 -0
- package/tokens/primitives/motion.tokens.json +41 -0
- package/tokens/primitives/spring.tokens.json +138 -0
- package/tokens/primitives/typography.tokens.json +107 -0
- package/tokens/semantic/bridge.tokens.json +52 -0
- package/tokens/semantic/color.tokens.json +129 -0
- package/tokens/semantic/layout.tokens.json +84 -0
- package/tokens/semantic/motion.tokens.json +111 -0
- package/tokens/semantic/scale.tokens.json +66 -0
- package/tokens/semantic/typography.tokens.json +281 -0
- package/tokens/themes/kesar.tokens.json +105 -0
- package/tokens/themes/mitti.tokens.json +123 -0
- package/tokens/themes/neem.tokens.json +123 -0
- package/tokens/themes/raat.tokens.json +104 -0
- package/tokens/themes/sutra.tokens.json +126 -0
- package/tokens/themes/ujala.tokens.json +96 -0
- package/tokens/transparency/reduced.tokens.json +30 -0
- package/tokens/und.resolver.json +83 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DTCG 2025.10 types used by UND UI (Format module + Color module).
|
|
3
|
+
* https://www.designtokens.org/tr/2025.10/format/
|
|
4
|
+
* https://www.designtokens.org/tr/2025.10/color/
|
|
5
|
+
*/
|
|
6
|
+
export const EXT = 'com.urnextdoor.und';
|
|
7
|
+
export const DTCG_TYPES = [
|
|
8
|
+
'color',
|
|
9
|
+
'dimension',
|
|
10
|
+
'fontFamily',
|
|
11
|
+
'fontWeight',
|
|
12
|
+
'duration',
|
|
13
|
+
'cubicBezier',
|
|
14
|
+
'number',
|
|
15
|
+
'strokeStyle',
|
|
16
|
+
'border',
|
|
17
|
+
'transition',
|
|
18
|
+
'shadow',
|
|
19
|
+
'gradient',
|
|
20
|
+
'typography',
|
|
21
|
+
];
|
|
22
|
+
export const COLOR_SPACES = [
|
|
23
|
+
'srgb',
|
|
24
|
+
'srgb-linear',
|
|
25
|
+
'hsl',
|
|
26
|
+
'hwb',
|
|
27
|
+
'lab',
|
|
28
|
+
'lch',
|
|
29
|
+
'oklab',
|
|
30
|
+
'oklch',
|
|
31
|
+
'display-p3',
|
|
32
|
+
'a98-rgb',
|
|
33
|
+
'prophoto-rgb',
|
|
34
|
+
'rec2020',
|
|
35
|
+
'xyz-d65',
|
|
36
|
+
'xyz-d50',
|
|
37
|
+
];
|
|
38
|
+
export function isBridge(token) {
|
|
39
|
+
return undExt(token).bridge === true;
|
|
40
|
+
}
|
|
41
|
+
export function isReference(v) {
|
|
42
|
+
return typeof v === 'string' && /^\{[^{}]+\}$/.test(v);
|
|
43
|
+
}
|
|
44
|
+
export function refPath(ref) {
|
|
45
|
+
return ref.slice(1, -1);
|
|
46
|
+
}
|
|
47
|
+
export function isToken(node) {
|
|
48
|
+
return typeof node === 'object' && node !== null && '$value' in node;
|
|
49
|
+
}
|
|
50
|
+
/** UND extension payload of a raw DTCG token (`$extensions`) or a flattened token (`extensions`). */
|
|
51
|
+
export function undExt(token) {
|
|
52
|
+
const ext = token.$extensions ?? token.extensions;
|
|
53
|
+
return ext?.[EXT] ?? {};
|
|
54
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @und-ui/tokens/generator: the reproducible maths behind the tokens.
|
|
3
|
+
* Palette generation (OKLCH, P3 and sRGB fitting), contrast checks (WCAG 2.x
|
|
4
|
+
* blocking, APCA advisory), spring physics, theme seeds and the DTCG engine.
|
|
5
|
+
*/
|
|
6
|
+
export { apcaContrast, compositeOver, relativeLuminance, wcagContrast, WCAG_AA, APCA_TARGETS, } from './color/contrast.js';
|
|
7
|
+
export { fitColor, hexToOklch, oklchToHex, parseOklch } from './color/convert.js';
|
|
8
|
+
export type { FittedColor, OklchTriple } from './color/convert.js';
|
|
9
|
+
export { CHROMA_FACTORS, LIGHTNESS, NEUTRAL_CHROMA_FACTORS, STEPS, createCommunityAccent, generateScale, hexOf, solveAlpha, } from './color/palette.js';
|
|
10
|
+
export type { AlphaColor, GeneratedScale, Mode, ScaleSpec, Step } from './color/palette.js';
|
|
11
|
+
export { ALL_SCALES, CORE_SCALES, STATUS_SCALES, THEME_NEUTRALS } from './color/scales.js';
|
|
12
|
+
export { PAIRS, evaluateContext, evaluatePair } from './color/pairs.js';
|
|
13
|
+
export type { Pair, PairResult } from './color/pairs.js';
|
|
14
|
+
export { SPRINGS, settleTime, springPhysics, springPosition, springToCubicBezier, springToLinear, } from './motion/spring.js';
|
|
15
|
+
export type { SpringPhysics, SpringSpec } from './motion/spring.js';
|
|
16
|
+
export { DEFAULT_THEME, THEMES, themeByName } from './themes/definitions.js';
|
|
17
|
+
export type { ThemeDefinition, ThemeName } from './themes/definitions.js';
|
|
18
|
+
export { TokenFiles, contextSources, flattenFile, mergeFiles, resolveContext, resolveTokens, } from './dtcg/engine.js';
|
|
19
|
+
export type { Context, FlatToken, ResolvedToken, ResolverDoc } from './dtcg/engine.js';
|
|
20
|
+
export { EXT } from './dtcg/types.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @und-ui/tokens/generator: the reproducible maths behind the tokens.
|
|
3
|
+
* Palette generation (OKLCH, P3 and sRGB fitting), contrast checks (WCAG 2.x
|
|
4
|
+
* blocking, APCA advisory), spring physics, theme seeds and the DTCG engine.
|
|
5
|
+
*/
|
|
6
|
+
export { apcaContrast, compositeOver, relativeLuminance, wcagContrast, WCAG_AA, APCA_TARGETS, } from './color/contrast.js';
|
|
7
|
+
export { fitColor, hexToOklch, oklchToHex, parseOklch } from './color/convert.js';
|
|
8
|
+
export { CHROMA_FACTORS, LIGHTNESS, NEUTRAL_CHROMA_FACTORS, STEPS, createCommunityAccent, generateScale, hexOf, solveAlpha, } from './color/palette.js';
|
|
9
|
+
export { ALL_SCALES, CORE_SCALES, STATUS_SCALES, THEME_NEUTRALS } from './color/scales.js';
|
|
10
|
+
export { PAIRS, evaluateContext, evaluatePair } from './color/pairs.js';
|
|
11
|
+
export { SPRINGS, settleTime, springPhysics, springPosition, springToCubicBezier, springToLinear, } from './motion/spring.js';
|
|
12
|
+
export { DEFAULT_THEME, THEMES, themeByName } from './themes/definitions.js';
|
|
13
|
+
export { TokenFiles, contextSources, flattenFile, mergeFiles, resolveContext, resolveTokens, } from './dtcg/engine.js';
|
|
14
|
+
export { EXT } from './dtcg/types.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface SpringSpec {
|
|
2
|
+
name: string;
|
|
3
|
+
/** Period of the undamped spring, seconds. */
|
|
4
|
+
response: number;
|
|
5
|
+
/** Damping ratio (zeta). */
|
|
6
|
+
dampingRatio: number;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SpringPhysics {
|
|
10
|
+
mass: 1;
|
|
11
|
+
stiffness: number;
|
|
12
|
+
damping: number;
|
|
13
|
+
/** SwiftUI `bounce` (iOS 17+ `spring(duration:bounce:)`), approximated as 1 - zeta. */
|
|
14
|
+
bounce: number;
|
|
15
|
+
/** Peak overshoot as a fraction of the distance (0.045 = 4.5%). */
|
|
16
|
+
overshoot: number;
|
|
17
|
+
/** Time until the curve stays within +-0.1% of the target, ms. */
|
|
18
|
+
settleMs: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function springPhysics(spec: SpringSpec): SpringPhysics;
|
|
21
|
+
/** Position x(t) of a unit step response (from 0 to 1), t in seconds. */
|
|
22
|
+
export declare function springPosition(spec: SpringSpec, t: number): number;
|
|
23
|
+
/** Settle time (seconds) for a +-tolerance band, found by scanning backwards at 1 ms. */
|
|
24
|
+
export declare function settleTime(spec: SpringSpec, tolerance?: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* CSS `linear()` approximation of the spring over its settle time.
|
|
27
|
+
* Returns the easing function and the matching duration in ms.
|
|
28
|
+
*/
|
|
29
|
+
export declare function springToLinear(spec: SpringSpec, points?: number): {
|
|
30
|
+
easing: string;
|
|
31
|
+
durationMs: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Cubic-bezier fallback for browsers without `linear()`.
|
|
35
|
+
* Critically and over-damped springs map to a strong decelerate curve; springs
|
|
36
|
+
* with overshoot map to a back-out curve whose y2 approximates the overshoot.
|
|
37
|
+
*/
|
|
38
|
+
export declare function springToCubicBezier(spec: SpringSpec): [number, number, number, number];
|
|
39
|
+
/** Spring presets (report section 4.4). */
|
|
40
|
+
export declare const SPRINGS: readonly SpringSpec[];
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spring maths (report section 4.4).
|
|
3
|
+
*
|
|
4
|
+
* Springs are defined perceptually as response (period of the undamped spring,
|
|
5
|
+
* seconds) and damping ratio zeta, converted with mass = 1:
|
|
6
|
+
* stiffness k = (2*pi / response)^2
|
|
7
|
+
* damping c = 4*pi*zeta / response
|
|
8
|
+
* SwiftUI bounce ~= 1 - zeta (zeta <= 1)
|
|
9
|
+
* The step response x(t) for a unit move from 0 to 1 with zero initial
|
|
10
|
+
* velocity is solved analytically for under-, critically and over-damped cases.
|
|
11
|
+
*/
|
|
12
|
+
import { round } from '../color/convert.js';
|
|
13
|
+
export function springPhysics(spec) {
|
|
14
|
+
const stiffness = ((2 * Math.PI) / spec.response) ** 2;
|
|
15
|
+
const damping = (4 * Math.PI * spec.dampingRatio) / spec.response;
|
|
16
|
+
return {
|
|
17
|
+
mass: 1,
|
|
18
|
+
stiffness: round(stiffness, 1),
|
|
19
|
+
damping: round(damping, 2),
|
|
20
|
+
bounce: round(Math.max(0, 1 - spec.dampingRatio), 2),
|
|
21
|
+
overshoot: round(overshoot(spec), 4),
|
|
22
|
+
settleMs: Math.round(settleTime(spec) * 1000),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Position x(t) of a unit step response (from 0 to 1), t in seconds. */
|
|
26
|
+
export function springPosition(spec, t) {
|
|
27
|
+
const w0 = (2 * Math.PI) / spec.response;
|
|
28
|
+
const z = spec.dampingRatio;
|
|
29
|
+
if (z < 1) {
|
|
30
|
+
const wd = w0 * Math.sqrt(1 - z * z);
|
|
31
|
+
const e = Math.exp(-z * w0 * t);
|
|
32
|
+
return 1 - e * (Math.cos(wd * t) + ((z * w0) / wd) * Math.sin(wd * t));
|
|
33
|
+
}
|
|
34
|
+
if (z === 1) {
|
|
35
|
+
return 1 - Math.exp(-w0 * t) * (1 + w0 * t);
|
|
36
|
+
}
|
|
37
|
+
const s = Math.sqrt(z * z - 1);
|
|
38
|
+
const r1 = -w0 * (z - s);
|
|
39
|
+
const r2 = -w0 * (z + s);
|
|
40
|
+
// x = 1 + A e^{r1 t} + B e^{r2 t}, x(0)=0, x'(0)=0
|
|
41
|
+
const A = r2 / (r1 - r2);
|
|
42
|
+
const B = -r1 / (r1 - r2);
|
|
43
|
+
return 1 + A * Math.exp(r1 * t) + B * Math.exp(r2 * t);
|
|
44
|
+
}
|
|
45
|
+
function overshoot(spec) {
|
|
46
|
+
const z = spec.dampingRatio;
|
|
47
|
+
if (z >= 1)
|
|
48
|
+
return 0;
|
|
49
|
+
return Math.exp((-Math.PI * z) / Math.sqrt(1 - z * z));
|
|
50
|
+
}
|
|
51
|
+
/** Settle time (seconds) for a +-tolerance band, found by scanning backwards at 1 ms. */
|
|
52
|
+
export function settleTime(spec, tolerance = 0.001) {
|
|
53
|
+
const dt = 0.0005;
|
|
54
|
+
const limit = 10;
|
|
55
|
+
let last = 0;
|
|
56
|
+
for (let t = 0; t <= limit; t += dt) {
|
|
57
|
+
if (Math.abs(springPosition(spec, t) - 1) > tolerance)
|
|
58
|
+
last = t;
|
|
59
|
+
}
|
|
60
|
+
return last + dt;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* CSS `linear()` approximation of the spring over its settle time.
|
|
64
|
+
* Returns the easing function and the matching duration in ms.
|
|
65
|
+
*/
|
|
66
|
+
export function springToLinear(spec, points = 40) {
|
|
67
|
+
const settle = settleTime(spec);
|
|
68
|
+
const values = [];
|
|
69
|
+
for (let i = 0; i < points; i++) {
|
|
70
|
+
const t = (settle * i) / (points - 1);
|
|
71
|
+
const x = i === points - 1 ? 1 : springPosition(spec, t);
|
|
72
|
+
values.push(formatNum(round(x, 3)));
|
|
73
|
+
}
|
|
74
|
+
return { easing: `linear(${values.join(', ')})`, durationMs: Math.round(settle * 1000) };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Cubic-bezier fallback for browsers without `linear()`.
|
|
78
|
+
* Critically and over-damped springs map to a strong decelerate curve; springs
|
|
79
|
+
* with overshoot map to a back-out curve whose y2 approximates the overshoot.
|
|
80
|
+
*/
|
|
81
|
+
export function springToCubicBezier(spec) {
|
|
82
|
+
const o = overshoot(spec);
|
|
83
|
+
if (o < 0.005)
|
|
84
|
+
return [0.2, 0, 0, 1];
|
|
85
|
+
// y2 > 1 produces overshoot; scale roughly with the physical overshoot.
|
|
86
|
+
return [0.2, 0, 0, round(1 + Math.min(0.6, o * 6), 2)];
|
|
87
|
+
}
|
|
88
|
+
function formatNum(n) {
|
|
89
|
+
return Number.isInteger(n) ? String(n) : String(n).replace(/^0\./, '0.').replace(/^-0\./, '-0.');
|
|
90
|
+
}
|
|
91
|
+
/** Spring presets (report section 4.4). */
|
|
92
|
+
export const SPRINGS = [
|
|
93
|
+
{
|
|
94
|
+
name: 'snap',
|
|
95
|
+
response: 0.25,
|
|
96
|
+
dampingRatio: 1.0,
|
|
97
|
+
description: 'Press-down, toggles, checkbox tick',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'smooth',
|
|
101
|
+
response: 0.4,
|
|
102
|
+
dampingRatio: 1.0,
|
|
103
|
+
description: 'Default. Layout moves, accordions, popover position',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'snappy',
|
|
107
|
+
response: 0.35,
|
|
108
|
+
dampingRatio: 0.85,
|
|
109
|
+
description: 'Press-release, segmented control thumb, tab indicator',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'gentle',
|
|
113
|
+
response: 0.6,
|
|
114
|
+
dampingRatio: 1.0,
|
|
115
|
+
description: 'Sheets and drawers settling, large surfaces',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'bouncy',
|
|
119
|
+
response: 0.5,
|
|
120
|
+
dampingRatio: 0.7,
|
|
121
|
+
description: 'Expressive character: like, reaction, FAB morph',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'expressive',
|
|
125
|
+
response: 0.55,
|
|
126
|
+
dampingRatio: 0.6,
|
|
127
|
+
description: 'Celebrations only (never core navigation)',
|
|
128
|
+
},
|
|
129
|
+
];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FittedColor, OklchTriple } from '../color/convert.js';
|
|
2
|
+
import type { GeneratedScale, Mode } from '../color/palette.js';
|
|
3
|
+
import type { ThemeDefinition } from '../themes/definitions.js';
|
|
4
|
+
type Obj = Record<string, unknown>;
|
|
5
|
+
export declare function oklchColor(f: FittedColor, alpha?: number): Obj;
|
|
6
|
+
export declare function generateScales(): GeneratedScale[];
|
|
7
|
+
/**
|
|
8
|
+
* Raise a glass alpha until fg.default keeps >= 4.5:1 over the worst-case
|
|
9
|
+
* backdrops (pure black and pure white) for every theme neutral in the mode.
|
|
10
|
+
*/
|
|
11
|
+
export declare function solveGlassAlpha(mode: Mode, bg: OklchTriple, alpha: number, scales: GeneratedScale[]): number;
|
|
12
|
+
export interface GlassDecision {
|
|
13
|
+
mode: Mode;
|
|
14
|
+
material: string;
|
|
15
|
+
reportAlpha: number;
|
|
16
|
+
alpha: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const RESOLVER_PATH = "und.resolver.json";
|
|
19
|
+
export declare const BASE_SOURCES: readonly ["primitives/dimension.tokens.json", "primitives/typography.tokens.json", "primitives/motion.tokens.json", "primitives/spring.tokens.json", "semantic/scale.tokens.json", "semantic/color.tokens.json", "semantic/layout.tokens.json", "semantic/typography.tokens.json", "semantic/motion.tokens.json", "semantic/bridge.tokens.json"];
|
|
20
|
+
export declare const MODE_SOURCES: Record<Mode, readonly string[]>;
|
|
21
|
+
export declare function themeSources(theme: ThemeDefinition): string[];
|
|
22
|
+
export interface GeneratedSource {
|
|
23
|
+
files: Record<string, Obj>;
|
|
24
|
+
scales: GeneratedScale[];
|
|
25
|
+
glass: GlassDecision[];
|
|
26
|
+
}
|
|
27
|
+
export declare function generateSource(): GeneratedSource;
|
|
28
|
+
export {};
|