Skip to content

Commit

Permalink
working on motion
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Nov 20, 2024
1 parent 241a8fa commit a455405
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-birds-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/primitives': minor
---

Adding motion tokens
10 changes: 7 additions & 3 deletions scripts/buildTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const getStyleDictionaryConfig: StyleDictionaryConfigGenerator = (
source, // build the special formats
include,
log: {
warnings: 'warn', // 'warn' | 'error' | 'disabled'
verbosity: 'verbose', // 'default' | 'silent' | 'verbose'
warnings: 'disabled', // 'warn' | 'error' | 'disabled'
verbosity: 'silent', // 'default' | 'silent' | 'verbose'
errors: {
brokenReferences: 'throw', // 'throw' | 'console'
},
Expand Down Expand Up @@ -157,7 +157,11 @@ export const buildDesignTokens = async (buildOptions: ConfigGeneratorOptions): P
const extendedSD = await PrimerStyleDictionary.extend(
getStyleDictionaryConfig(
`functional/motion/motion`,
[`src/tokens/functional/motion/*.json5`],
[
`src/tokens/functional/motion/*.json5`,
`src/tokens/base/motion/timing.json5`,
`src/tokens/base/motion/easing.json5`,
],
[`src/tokens/base/motion/*.json5`],
buildOptions,
{
Expand Down
4 changes: 4 additions & 0 deletions src/PrimerStyleDictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ PrimerStyleDictionary.registerTransform({
...floatToPixelUnitless,
})

PrimerStyleDictionary.registerTransform({
...cubicBezierToCss,
})

PrimerStyleDictionary.registerTransform({
...dimensionToRem,
})
Expand Down
1 change: 0 additions & 1 deletion src/schemas/designToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const designToken = z.record(
durationToken,
stringToken,
]),
// referenceToken,
designToken,
])
}),
Expand Down
26 changes: 26 additions & 0 deletions src/tokens/base/motion/easing.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
base: {
easing: {
linear: {
$value: [0, 0, 1, 1],
$type: 'cubicBezier',
$description: 'Ideal for non-movement properties, like opacity or background color.',
},
easeIn: {
$value: [0.4, 0.1, 0.75, 0.95],
$type: 'cubicBezier',
$description: 'Ideal for movement that starts on the page and ends off the page.',
},
easeOut: {
$value: [0, 0, 0.3, 0.95],
$type: 'cubicBezier',
$description: 'Ideal for movement that starts off the page and ends on the page.',
},
easeInOut: {
$value: [0.4, 0.1, 0.3, 1],
$type: 'cubicBezier',
$description: 'Ideal for movement that starts and ends on the page.',
},
},
},
}
46 changes: 46 additions & 0 deletions src/tokens/base/motion/timing.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
base: {
duration: {
'0': {
$value: '0ms',
$type: 'duration',
},
'75': {
$value: '75ms',
$type: 'duration',
},
'200': {
$value: '200ms',
$type: 'duration',
},
'300': {
$value: '300ms',
$type: 'duration',
},
'400': {
$value: '400ms',
$type: 'duration',
},
'500': {
$value: '500ms',
$type: 'duration',
},
'600': {
$value: '600ms',
$type: 'duration',
},
'700': {
$value: '700ms',
$type: 'duration',
},
'800': {
$value: '800ms',
$type: 'duration',
},
'900': {
$value: '900ms',
$type: 'duration',
},
},
},
}
25 changes: 25 additions & 0 deletions src/tokens/functional/motion/motion.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
duration: {},
easing: {
entrance: {
$value: '{base.easing.easeOut}',
$type: 'cubicBezier',
$description: 'Ideal for movement that starts off the page and ends on the page.',
},
exit: {
$value: '{base.easing.easeIn}',
$type: 'cubicBezier',
$description: 'Ideal for movement that starts on the page and ends off the page.',
},
move: {
$value: '{base.easing.easeInOut}',
$type: 'cubicBezier',
$description: 'Ideal for movement that starts and ends on the page.',
},
static: {
$value: '{base.easing.linear}',
$type: 'cubicBezier',
$description: 'Ideal for non-movement properties, like opacity or background color.',
},
},
}

0 comments on commit a455405

Please sign in to comment.