Skip to content

Commit 5ce98af

Browse files
Hebiliciousclaude
andcommitted
refactor(motion): drop the exported easing preset
CSS Forge ships no other preset constants. The README shows the two curves written out in a motion config instead. Refs #83 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7afb2ef commit 5ce98af

9 files changed

Lines changed: 36 additions & 64 deletions

File tree

‎.changeset/issue-83-motion.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ Add a `motion` module for transition durations and easing curves.
77
- `motion.duration.<group>.value` and `motion.easing.<group>.value` emit `--motion-duration-<group>-<name>` and `--motion-easing-<group>-<name>`, referenced from primitives as `motion.duration.<group>.<name>` and `motion.easing.<group>.<name>`.
88
- A duration must be a non-negative number with `ms` or `s`, and an easing a CSS keyword, `cubic-bezier()` with x1 and x2 in [0, 1], `steps()` or `linear()`. Anything else fails generation with the token's path.
99
- A duration over 300ms warns (`motion-long-duration`), or over 500ms in a group with `settings.long: true` for modals and drawers. `ease-in` and ease-in shaped `cubic-bezier()` curves warn (`motion-ease-in`). Both go through `getDiagnostics` and the CLI's `cssforge: warning:` output.
10-
- `uiEasings` exports the two recommended curves, `out` and `inOut`, to spread into an easing group. Nothing is added unless a config spreads it.

‎README.md‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,10 +1697,9 @@ holds its tokens under `value`, emitted as `--motion-duration-<group>-<name>` an
16971697

16981698
Anything else fails the build with the token's configuration path.
16991699

1700-
`uiEasings`, exported from `@hebilicious/cssforge`, holds the two curves recommended for UI motion: `out`,
1701-
`cubic-bezier(0.23, 1, 0.32, 1)`, for things entering or reacting, and `inOut`,
1702-
`cubic-bezier(0.77, 0, 0.175, 1)`, for things moving on screen. Spread it into an easing
1703-
group; nothing is added unless you do.
1700+
Two curves work well for UI motion: an ease-out, `cubic-bezier(0.23, 1, 0.32, 1)`, for things
1701+
entering or reacting, and an ease-in-out, `cubic-bezier(0.77, 0, 0.175, 1)`, for things moving
1702+
on screen.
17041703

17051704
<!-- md:generate defineConfig
17061705
export default defineConfig({
@@ -1710,7 +1709,12 @@ export default defineConfig({
17101709
overlay: { value: { drawer: "400ms" }, settings: { long: true } },
17111710
},
17121711
easing: {
1713-
ui: { value: { ...uiEasings } },
1712+
ui: {
1713+
value: {
1714+
out: "cubic-bezier(0.23, 1, 0.32, 1)",
1715+
inOut: "cubic-bezier(0.77, 0, 0.175, 1)",
1716+
},
1717+
},
17141718
},
17151719
},
17161720
});
@@ -1724,7 +1728,12 @@ export default defineConfig({
17241728
overlay: { value: { drawer: "400ms" }, settings: { long: true } },
17251729
},
17261730
easing: {
1727-
ui: { value: { ...uiEasings } },
1731+
ui: {
1732+
value: {
1733+
out: "cubic-bezier(0.23, 1, 0.32, 1)",
1734+
inOut: "cubic-bezier(0.77, 0, 0.175, 1)",
1735+
},
1736+
},
17281737
},
17291738
},
17301739
});

‎packages/cssforge/README.md‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,10 +1697,9 @@ holds its tokens under `value`, emitted as `--motion-duration-<group>-<name>` an
16971697

16981698
Anything else fails the build with the token's configuration path.
16991699

1700-
`uiEasings`, exported from `@hebilicious/cssforge`, holds the two curves recommended for UI motion: `out`,
1701-
`cubic-bezier(0.23, 1, 0.32, 1)`, for things entering or reacting, and `inOut`,
1702-
`cubic-bezier(0.77, 0, 0.175, 1)`, for things moving on screen. Spread it into an easing
1703-
group; nothing is added unless you do.
1700+
Two curves work well for UI motion: an ease-out, `cubic-bezier(0.23, 1, 0.32, 1)`, for things
1701+
entering or reacting, and an ease-in-out, `cubic-bezier(0.77, 0, 0.175, 1)`, for things moving
1702+
on screen.
17041703

17051704
<!-- md:generate defineConfig
17061705
export default defineConfig({
@@ -1710,7 +1709,12 @@ export default defineConfig({
17101709
overlay: { value: { drawer: "400ms" }, settings: { long: true } },
17111710
},
17121711
easing: {
1713-
ui: { value: { ...uiEasings } },
1712+
ui: {
1713+
value: {
1714+
out: "cubic-bezier(0.23, 1, 0.32, 1)",
1715+
inOut: "cubic-bezier(0.77, 0, 0.175, 1)",
1716+
},
1717+
},
17141718
},
17151719
},
17161720
});
@@ -1724,7 +1728,12 @@ export default defineConfig({
17241728
overlay: { value: { drawer: "400ms" }, settings: { long: true } },
17251729
},
17261730
easing: {
1727-
ui: { value: { ...uiEasings } },
1731+
ui: {
1732+
value: {
1733+
out: "cubic-bezier(0.23, 1, 0.32, 1)",
1734+
inOut: "cubic-bezier(0.77, 0, 0.175, 1)",
1735+
},
1736+
},
17281737
},
17291738
},
17301739
});

‎packages/cssforge/scripts/update-readme.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function wrapSource(tsSource: string): string {
4848
tsSource,
4949
);
5050
const srcModUrl = pathToFileURL(join(PACKAGE_ROOT, "src", "mod.ts")).href;
51-
const importLine = `import { defineConfig, uiEasings } from "${srcModUrl}";\n`;
51+
const importLine = `import { defineConfig } from "${srcModUrl}";\n`;
5252

5353
let normalized = tsSource.trim();
5454
if (!hasDefaultExport) {

‎packages/cssforge/src/mod.ts‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { generateCSS, generateStyleDictionaryJSON, getDiagnostics } from "./gene
1313
import { InvalidNameError } from "./helpers.ts";
1414
import { loadConfig } from "./loader.ts";
1515
import { processColors } from "./modules/colors.ts";
16-
import { processMotion, uiEasings } from "./modules/motion.ts";
16+
import { processMotion } from "./modules/motion.ts";
1717
import { processPrimitives } from "./modules/primitive.ts";
1818
import { processSpacing } from "./modules/spacing.ts";
1919
import { processTypography } from "./modules/typography.ts";
@@ -72,15 +72,6 @@ export {
7272
* @returns The diagnostics, in module order.
7373
*/
7474
getDiagnostics,
75-
/**
76-
* The two easing curves recommended for UI motion, to spread into an
77-
* easing group's `value`. They are not added unless a config spreads them.
78-
* @example
79-
* ```ts
80-
* defineConfig({ motion: { easing: { ui: { value: { ...uiEasings } } } } });
81-
* ```
82-
*/
83-
uiEasings,
8475
/**
8576
* Thrown when a configuration name cannot produce a valid CSS custom property
8677
* name or reference. Catch it with `instanceof` to handle a name validation

‎packages/cssforge/src/modules/motion.ts‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,6 @@ export interface MotionConfig {
3737
};
3838
}
3939

40-
/**
41-
* The two easing curves recommended for UI motion, to spread into an
42-
* easing group's `value`. They are not added unless a config spreads them.
43-
* @example
44-
* ```ts
45-
* defineConfig({ motion: { easing: { ui: { value: { ...uiEasings } } } } });
46-
* ```
47-
*/
48-
export const uiEasings = Object.freeze({
49-
out: "cubic-bezier(0.23, 1, 0.32, 1)",
50-
inOut: "cubic-bezier(0.77, 0, 0.175, 1)",
51-
} as const);
52-
5340
const MAX_UI_DURATION_MS = 300;
5441
const MAX_LONG_DURATION_MS = 500;
5542

@@ -223,7 +210,7 @@ const formatMs = (ms: number) => `${Number(ms.toFixed(3))}ms`;
223210
* ui: { value: { press: "120ms", dropdown: "200ms" } },
224211
* overlay: { value: { modal: "400ms" }, settings: { long: true } },
225212
* },
226-
* easing: { ui: { value: { ...uiEasings } } },
213+
* easing: { ui: { value: { out: "cubic-bezier(0.23, 1, 0.32, 1)" } } },
227214
* });
228215
* ```
229216
*/
@@ -300,7 +287,7 @@ export function processMotion(motion: MotionConfig): Output {
300287
(value, path) => {
301288
const points = readEasing(value, path);
302289
if (!points || !isEaseInShaped(points)) return undefined;
303-
return `Motion easing ${path} is ease-in shaped: it starts slow and ends fast, which reads as lag on UI. Use an ease-out curve such as ${uiEasings.out}, or ${uiEasings.inOut} for movement on screen.`;
290+
return `Motion easing ${path} is ease-in shaped: it starts slow and ends fast, which reads as lag on UI. Use an ease-out curve such as cubic-bezier(0.23, 1, 0.32, 1), or an ease-in-out curve such as cubic-bezier(0.77, 0, 0.175, 1) for movement on screen.`;
304291
},
305292
);
306293

‎packages/cssforge/tests/motion.test.ts‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
generateStyleDictionaryJSON,
66
getDiagnostics,
77
processMotion,
8-
uiEasings,
98
} from "../src/mod.ts";
109
import { assert, assertEquals, assertThrows, Deno } from "./vitest-compat.ts";
1110

@@ -359,22 +358,3 @@ Deno.test("motion - ease-out, ease-in-out and linear curves do not warn", () =>
359358
assertEquals(getDiagnostics(easing(value)), [], value);
360359
}
361360
});
362-
363-
Deno.test("motion - uiEasings is a preset spread into an easing group", () => {
364-
assertEquals(
365-
{ ...uiEasings },
366-
{ out: "cubic-bezier(0.23, 1, 0.32, 1)", inOut: "cubic-bezier(0.77, 0, 0.175, 1)" },
367-
);
368-
369-
const config = motion({ easing: { ui: { value: { ...uiEasings } } } });
370-
const css = generateCSS(config);
371-
assert(css.includes("--motion-easing-ui-out: cubic-bezier(0.23, 1, 0.32, 1);"), css);
372-
assert(css.includes("--motion-easing-ui-inOut: cubic-bezier(0.77, 0, 0.175, 1);"), css);
373-
assertEquals(getDiagnostics(config), []);
374-
});
375-
376-
Deno.test("motion - the preset is not injected without an easing group", () => {
377-
const css = generateCSS(duration("120ms"));
378-
assert(!css.includes("--motion-easing"), css);
379-
assert(!css.includes("cubic-bezier"), css);
380-
});

‎skills/cssforge/references/source-schema-map.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ color output settings.
8787
- Warnings: `motion-long-duration` per duration over the threshold and `motion-ease-in` per
8888
`ease-in` or ease-in shaped `cubic-bezier()` (slope at the start below 1 and at the end
8989
above 1), with the token path as `path`.
90-
- `uiEasings` (`out`, `inOut`) is an exported preset to spread into an easing group's
91-
`value`; nothing is added unless spread.
9290

9391
## Derived colors
9492

@@ -116,7 +114,7 @@ color output settings.
116114

117115
## Exposed API entrypoint
118116

119-
- `packages/cssforge/src/mod.ts` exports `defineConfig`, `generateCSS`, `getDiagnostics`, `uiEasings`, the processing helpers,
117+
- `packages/cssforge/src/mod.ts` exports `defineConfig`, `generateCSS`, `getDiagnostics`, the processing helpers,
120118
and the config and token types (`CSSForgeConfig`, `MotionConfig`, `MotionDurationSettings`, `ColorFormatConfig`, `ColorMix`, `HexFormatOutputs`,
121119
`RgbFormatOutputs`, `ColorSettings`, `ColorThemesSettings`, `LightDarkSettings`,
122120
`LightDarkColorScheme`, `ColorFormat`, `HexColorValues`, `RgbColorValues`,

‎skills/cssforge/references/token-patterns.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ All patterns below are derived from README configuration examples.
3131
## Motion
3232

3333
- Durations under `motion.duration.<group>.value` in `ms` or `s`; easings under
34-
`motion.easing.<group>.value`. Spread `uiEasings` into an easing group for the two
35-
recommended curves.
34+
`motion.easing.<group>.value`.
3635
- Durations over 300ms warn unless the group sets `settings.long` (modals, drawers: 500ms).
3736
`ease-in` and ease-in shaped `cubic-bezier()` curves warn.
3837

0 commit comments

Comments
 (0)