@rio-m3e/tokens 0.1.0 → 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/dist/index.d.ts +16 -3
- package/dist/index.js +24 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,12 @@ export declare const MOTION_TOKENS: readonly ["fast-spatial", "default-spatial",
|
|
|
40
40
|
* Effects tokens change color and opacity and never overshoot.
|
|
41
41
|
*/
|
|
42
42
|
type MotionToken = (typeof MOTION_TOKENS)[number];
|
|
43
|
+
/**
|
|
44
|
+
* The spatial tokens. Their springs are also available in the standard scheme whatever the
|
|
45
|
+
* theme's scheme, for motion the spec pins to it, such as the split button's menu icon.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SPATIAL_MOTION_TOKENS: readonly ["fast-spatial", "default-spatial", "slow-spatial"];
|
|
48
|
+
type SpatialMotionToken = (typeof SPATIAL_MOTION_TOKENS)[number];
|
|
43
49
|
interface MotionSpring {
|
|
44
50
|
/** 1 settles without overshoot; lower values bounce. */
|
|
45
51
|
dampingRatio: number;
|
|
@@ -57,7 +63,13 @@ export declare function getMotionSpring(scheme: MotionScheme, token: MotionToken
|
|
|
57
63
|
export declare function getMotionCurve(scheme: MotionScheme, token: MotionToken): MotionCurve;
|
|
58
64
|
/** `duration` and `easing` describe the curve; `damping` and `stiffness` the raw spring. */
|
|
59
65
|
type MotionVarPart = 'duration' | 'easing' | 'damping' | 'stiffness';
|
|
60
|
-
type MotionVar = `${typeof TOKEN_PREFIX}-motion-${MotionToken}` | `${typeof TOKEN_PREFIX}-motion-${MotionToken}-${MotionVarPart}
|
|
66
|
+
type MotionVar = `${typeof TOKEN_PREFIX}-motion-${MotionToken}` | `${typeof TOKEN_PREFIX}-motion-${MotionToken}-${MotionVarPart}` | StandardSpringVar;
|
|
67
|
+
type StandardSpringVar = `${typeof TOKEN_PREFIX}-motion-standard-${SpatialMotionToken}-${'damping' | 'stiffness'}`;
|
|
68
|
+
/**
|
|
69
|
+
* CSS variable for a spatial token's spring in the standard scheme, set whatever the theme's
|
|
70
|
+
* scheme is. In `@rio-m3e/core`, `readSpringParams(element, 'standard-fast-spatial')` reads it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function standardSpringVar(token: SpatialMotionToken, part: 'damping' | 'stiffness'): StandardSpringVar;
|
|
61
73
|
/**
|
|
62
74
|
* CSS variable name for a token. Without `part`, the variable holds `<duration> <easing>`
|
|
63
75
|
* and fits straight into `transition` or `animation`:
|
|
@@ -67,7 +79,8 @@ export declare function motionVar(token: MotionToken, part?: MotionVarPart): Mot
|
|
|
67
79
|
/**
|
|
68
80
|
* CSS variables for one scheme: the curve for CSS transitions, and the raw spring for the spring
|
|
69
81
|
* solver in `@rio-m3e/core`, which reads them from the element it animates. The names don't
|
|
70
|
-
* include the scheme.
|
|
82
|
+
* include the scheme. The standard scheme's spatial springs are added under their own names
|
|
83
|
+
* (`standardSpringVar`) whatever the scheme.
|
|
71
84
|
*/
|
|
72
85
|
export declare function createMotionVariables(scheme?: MotionScheme): Record<MotionVar, string>;
|
|
73
86
|
export declare const SHAPE_CORNERS: readonly ["none", "extra-small", "small", "medium", "large", "large-increased", "extra-large", "extra-large-increased", "extra-extra-large", "full"];
|
|
@@ -168,4 +181,4 @@ export declare function createThemeCss(options: ThemeOptions & {
|
|
|
168
181
|
* It doesn't touch `color-scheme`; set that yourself.
|
|
169
182
|
*/
|
|
170
183
|
export declare function applyTheme(target: HTMLElement, options: ThemeOptions): void;
|
|
171
|
-
export type { ColorRole, ColorScheme, ColorSchemeOptions, ColorVar, CustomizableShapeCorner, ElevationLevel, ElevationVar, FocusIndicatorPart, MotionCurve, MotionScheme, MotionSpring, MotionToken, MotionVar, MotionVarPart, SchemeVariant, ShapeCorner, ShapeOverrides, ShapeVar, StateLayerState, StateVar, ThemeOptions, ThemeVar, TypeStyle, TypeStyleOptions, TypeStyleSpec, Typeface, TypefaceOverrides, TypefaceVar, TypescalePart, TypescaleVar, TypographyVar };
|
|
184
|
+
export type { ColorRole, ColorScheme, ColorSchemeOptions, ColorVar, CustomizableShapeCorner, ElevationLevel, ElevationVar, FocusIndicatorPart, MotionCurve, MotionScheme, MotionSpring, MotionToken, MotionVar, MotionVarPart, SchemeVariant, ShapeCorner, ShapeOverrides, ShapeVar, SpatialMotionToken, StandardSpringVar, StateLayerState, StateVar, ThemeOptions, ThemeVar, TypeStyle, TypeStyleOptions, TypeStyleSpec, Typeface, TypefaceOverrides, TypefaceVar, TypescalePart, TypescaleVar, TypographyVar };
|
package/dist/index.js
CHANGED
|
@@ -5684,6 +5684,15 @@ const MOTION_TOKENS = [
|
|
|
5684
5684
|
"slow-effects"
|
|
5685
5685
|
];
|
|
5686
5686
|
/**
|
|
5687
|
+
* The spatial tokens. Their springs are also available in the standard scheme whatever the
|
|
5688
|
+
* theme's scheme, for motion the spec pins to it, such as the split button's menu icon.
|
|
5689
|
+
*/
|
|
5690
|
+
const SPATIAL_MOTION_TOKENS = [
|
|
5691
|
+
"fast-spatial",
|
|
5692
|
+
"default-spatial",
|
|
5693
|
+
"slow-spatial"
|
|
5694
|
+
];
|
|
5695
|
+
/**
|
|
5687
5696
|
* Jetpack Compose Material3 `ExpressiveMotionTokens` and `StandardMotionTokens`
|
|
5688
5697
|
* (token version v0_14_0, androidx 079e2e3). Pairs are [dampingRatio, stiffness].
|
|
5689
5698
|
*/
|
|
@@ -5816,6 +5825,13 @@ function getMotionCurve(scheme, token) {
|
|
|
5816
5825
|
};
|
|
5817
5826
|
}
|
|
5818
5827
|
/**
|
|
5828
|
+
* CSS variable for a spatial token's spring in the standard scheme, set whatever the theme's
|
|
5829
|
+
* scheme is. In `@rio-m3e/core`, `readSpringParams(element, 'standard-fast-spatial')` reads it.
|
|
5830
|
+
*/
|
|
5831
|
+
function standardSpringVar(token, part) {
|
|
5832
|
+
return `${TOKEN_PREFIX}-motion-standard-${token}-${part}`;
|
|
5833
|
+
}
|
|
5834
|
+
/**
|
|
5819
5835
|
* CSS variable name for a token. Without `part`, the variable holds `<duration> <easing>`
|
|
5820
5836
|
* and fits straight into `transition` or `animation`:
|
|
5821
5837
|
* `transition: transform var(--rio-motion-fast-spatial)`.
|
|
@@ -5826,7 +5842,8 @@ function motionVar(token, part) {
|
|
|
5826
5842
|
/**
|
|
5827
5843
|
* CSS variables for one scheme: the curve for CSS transitions, and the raw spring for the spring
|
|
5828
5844
|
* solver in `@rio-m3e/core`, which reads them from the element it animates. The names don't
|
|
5829
|
-
* include the scheme.
|
|
5845
|
+
* include the scheme. The standard scheme's spatial springs are added under their own names
|
|
5846
|
+
* (`standardSpringVar`) whatever the scheme.
|
|
5830
5847
|
*/
|
|
5831
5848
|
function createMotionVariables(scheme = "expressive") {
|
|
5832
5849
|
const vars = {};
|
|
@@ -5839,6 +5856,11 @@ function createMotionVariables(scheme = "expressive") {
|
|
|
5839
5856
|
vars[motionVar(token, "damping")] = String(dampingRatio);
|
|
5840
5857
|
vars[motionVar(token, "stiffness")] = String(stiffness);
|
|
5841
5858
|
}
|
|
5859
|
+
for (const token of SPATIAL_MOTION_TOKENS) {
|
|
5860
|
+
const { dampingRatio, stiffness } = getMotionSpring("standard", token);
|
|
5861
|
+
vars[standardSpringVar(token, "damping")] = String(dampingRatio);
|
|
5862
|
+
vars[standardSpringVar(token, "stiffness")] = String(stiffness);
|
|
5863
|
+
}
|
|
5842
5864
|
return vars;
|
|
5843
5865
|
}
|
|
5844
5866
|
// src/shape/shape.ts
|
|
@@ -6253,4 +6275,4 @@ function createThemeCss(options) {
|
|
|
6253
6275
|
function applyTheme(target, options) {
|
|
6254
6276
|
for (const [k, v] of Object.entries(createThemeVariables(options))) target.style.setProperty(k, v);
|
|
6255
6277
|
}
|
|
6256
|
-
export { COLOR_ROLES, ELEVATION_LEVELS, FOCUS_INDICATOR_PARTS, MOTION_SCHEMES, MOTION_TOKENS, SHAPE_CORNERS, STATE_LAYER_STATES, TOKEN_PREFIX, TYPE_STYLES, applyTheme, colorVar, createColorScheme, createElevationVariables, createMotionVariables, createShapeVariables, createStateVariables, createThemeCss, createThemeVariables, createTypographyVariables, elevationVar, focusIndicatorVar, getMotionCurve, getMotionSpring, getTypeStyle, motionVar, shapeVar, stateLayerOpacityVar, typefaceVar, typescaleVar };
|
|
6278
|
+
export { COLOR_ROLES, ELEVATION_LEVELS, FOCUS_INDICATOR_PARTS, MOTION_SCHEMES, MOTION_TOKENS, SHAPE_CORNERS, SPATIAL_MOTION_TOKENS, STATE_LAYER_STATES, TOKEN_PREFIX, TYPE_STYLES, applyTheme, colorVar, createColorScheme, createElevationVariables, createMotionVariables, createShapeVariables, createStateVariables, createThemeCss, createThemeVariables, createTypographyVariables, elevationVar, focusIndicatorVar, getMotionCurve, getMotionSpring, getTypeStyle, motionVar, shapeVar, standardSpringVar, stateLayerOpacityVar, typefaceVar, typescaleVar };
|