Skip to content

Commit

Permalink
fix(Motion): add v10 Motion tokens (#13805)
Browse files Browse the repository at this point in the history
* fix(Motion): add v10 motion tokens

* test(Motion): add v10 compat tests

---------

Co-authored-by: Andrea N. Cardona <cardona.n.andrea@gmail.com>
  • Loading branch information
tw15egan and andreancardona authored May 16, 2023
1 parent e33e8d3 commit 05fa295
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/motion/__tests__/__snapshots__/motion-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ Array [
"duration-moderate-02",
"duration-slow-01",
"duration-slow-02",
"fast-01",
"fast-02",
"moderate-01",
"moderate-02",
"slow-01",
"slow-02",
]
`;

exports[`@carbon/motion Public API 1`] = `
Object {
"durationFast01": "70ms",
"durationFast02": "110ms",
"durationModerate01": "150ms",
"durationModerate02": "240ms",
"durationSlow01": "400ms",
"durationSlow02": "700ms",
"easings": Object {
"entrance": Object {
"expressive": "cubic-bezier(0, 0, 0.3, 1)",
Expand Down Expand Up @@ -42,6 +54,12 @@ Object {
"moderate02",
"slow01",
"slow02",
"durationFast01",
"durationFast02",
"durationModerate01",
"durationModerate02",
"durationSlow01",
"durationSlow02",
],
}
`;
37 changes: 37 additions & 0 deletions packages/motion/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,40 @@ $duration-slow-01: 400ms;
/// @type Duration
/// @group @carbon/motion
$duration-slow-02: 700ms;

/// V10 backwards compatibility tokens
/// @access public
/// @deprecated
/// @type Duration
/// @group @carbon/motion
$fast-01: $duration-fast-01;

/// @access public
/// @deprecated
/// @type Duration
/// @group @carbon/motion
$fast-02: $duration-fast-02;

/// @access public
/// @deprecated
/// @type Duration
/// @group @carbon/motion
$moderate-01: $duration-moderate-01;

/// @access public
/// @deprecated
/// @type Duration
/// @group @carbon/motion
$moderate-02: $duration-moderate-02;

/// @access public
/// @deprecated
/// @type Duration
/// @group @carbon/motion
$slow-01: $duration-slow-01;

/// @access public
/// @deprecated
/// @type Duration
/// @group @carbon/motion
$slow-02: $duration-slow-02;
13 changes: 13 additions & 0 deletions packages/motion/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export const moderate01 = '150ms';
export const moderate02 = '240ms';
export const slow01 = '400ms';
export const slow02 = '700ms';
// V11 Tokens
export const durationFast01 = fast01;
export const durationFast02 = fast02;
export const durationModerate01 = moderate01;
export const durationModerate02 = moderate02;
export const durationSlow01 = slow01;
export const durationSlow02 = slow02;

export const unstable_tokens = [
'fast01',
Expand All @@ -19,6 +26,12 @@ export const unstable_tokens = [
'moderate02',
'slow01',
'slow02',
'durationFast01',
'durationFast02',
'durationModerate01',
'durationModerate02',
'durationSlow01',
'durationSlow02',
];

export const easings = {
Expand Down
17 changes: 17 additions & 0 deletions packages/styles/__tests__/compat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,21 @@ describe('@carbon/styles/scss/compat', () => {
`)
).resolves.not.toThrow();
});

it('should export v10 motion tokens', async () => {
await expect(
render(`
@use '../../motion' as motion;
div {
transition: all motion.$slow-01;
transition: all motion.$slow-02;
transition: all motion.$moderate-01;
transition: all motion.$moderate-02;
transition: all motion.$fast-01;
transition: all motion.$fast-02;
}
`)
).resolves.not.toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Object {
"productive": "cubic-bezier(0.2, 0, 0.38, 0.9)",
},
},
"fast-01": "70ms",
"fast-02": "110ms",
"moderate-01": "150ms",
"moderate-02": "240ms",
"slow-01": "400ms",
"slow-02": "700ms",
"standard-easing": "cubic-bezier(0.5, 0, 0.1, 1)",
"transition-base": "250ms",
"transition-expansion": "300ms",
Expand Down

0 comments on commit 05fa295

Please sign in to comment.