Skip to content

Commit

Permalink
feat(motion): add duration tokens to motion
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack committed Feb 11, 2021
1 parent ce5a810 commit b42aac7
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/motion/__tests__/__snapshots__/motion-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`@carbon/motion @carbon/motion/scss/motion.scss 1`] = `
Array [
"fast-01",
"fast-02",
"moderate-01",
"moderate-02",
"slow-01",
"slow-02",
"carbon--easings",
]
`;

exports[`@carbon/motion Public API 1`] = `
Object {
"easings": Object {
"entrance": Object {
"expressive": "cubic-bezier(0, 0, 0.3, 1)",
"productive": "cubic-bezier(0, 0, 0.38, 0.9)",
},
"exit": Object {
"expressive": "cubic-bezier(0.4, 0.14, 1, 1)",
"productive": "cubic-bezier(0.2, 0, 1, 0.9)",
},
"standard": Object {
"expressive": "cubic-bezier(0.4, 0.14, 0.3, 1)",
"productive": "cubic-bezier(0.2, 0, 0.38, 0.9)",
},
},
"fast01": "70ms",
"fast02": "110ms",
"moderate01": "150ms",
"moderate02": "240ms",
"motion": [Function],
"slow01": "400ms",
"slow02": "700ms",
"unstable_tokens": Array [
"fast01",
"fast02",
"moderate01",
"moderate02",
"slow01",
"slow02",
],
}
`;
30 changes: 30 additions & 0 deletions packages/motion/__tests__/motion-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*
* @jest-environment node
*/

import { SassRenderer } from '@carbon/test-utils/scss';
import * as CarbonMotion from '../src';

const { render } = SassRenderer.create(__dirname);

describe('@carbon/motion', () => {
test('Public API', () => {
expect(CarbonMotion).toMatchSnapshot();
});

test('@carbon/motion/scss/motion.scss', async () => {
const { getValue } = await render(`
@use 'sass:meta';
@use '../scss/motion';
$_: get-value(meta.module-variables('motion'));
`);
const variables = getValue(0);
expect(Object.keys(variables)).toMatchSnapshot();
});
});
24 changes: 24 additions & 0 deletions packages/motion/scss/motion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@
// LICENSE file in the root directory of this source tree.
//

/// @access public
/// @group @carbon/motion
$fast-01: 70ms !default;

/// @access public
/// @group @carbon/motion
$fast-02: 110ms !default;

/// @access public
/// @group @carbon/motion
$moderate-01: 150ms !default;

/// @access public
/// @group @carbon/motion
$moderate-02: 240ms !default;

/// @access public
/// @group @carbon/motion
$slow-01: 400ms !default;

/// @access public
/// @group @carbon/motion
$slow-02: 700ms !default;

/// Common component easings
/// @type Map
/// @access public
Expand Down
16 changes: 16 additions & 0 deletions packages/motion/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
* LICENSE file in the root directory of this source tree.
*/

export const fast01 = '70ms';
export const fast02 = '110ms';
export const moderate01 = '150ms';
export const moderate02 = '240ms';
export const slow01 = '400ms';
export const slow02 = '700ms';

export const unstable_tokens = [
'fast01',
'fast02',
'moderate01',
'moderate02',
'slow01',
'slow02',
];

export const easings = {
standard: {
productive: 'cubic-bezier(0.2, 0, 0.38, 0.9)',
Expand Down

0 comments on commit b42aac7

Please sign in to comment.