-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add motion base tokens to storybook (#1148)
- Loading branch information
1 parent
47194a7
commit e36ad5e
Showing
1 changed file
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react' | ||
// eslint-disable-next-line import/extensions | ||
import baseMotionTokens from '../../../../dist/docs/base/motion/motion.json' | ||
import {DataTable, Table} from '@primer/react/drafts' | ||
import {InlineCode} from '../StorybookComponents/InlineCode/InlineCode' | ||
import {getTokensByName} from '../utilities/getTokensByName' | ||
|
||
export default { | ||
title: 'Motion/Base', | ||
parameters: { | ||
controls: {hideNoControlsWarning: true}, | ||
tags: ['snapshotLight'], | ||
}, | ||
} | ||
|
||
export const Base = () => { | ||
const data = getTokensByName(baseMotionTokens, 'base').map(token => { | ||
return { | ||
id: token.name, | ||
...token, | ||
} | ||
}) | ||
|
||
return ( | ||
<> | ||
<Table.Container> | ||
<h2 id="weight">Base duration</h2> | ||
<DataTable | ||
aria-labelledby="weight" | ||
data={data | ||
.filter(item => item.type === 'duration') | ||
.sort((a, b) => a.name.replace('base-duration-', '') - b.name.replace('base-duration-', ''))} | ||
columns={[ | ||
{ | ||
header: 'Token', | ||
field: 'name', | ||
rowHeader: true, | ||
renderCell: row => { | ||
return <InlineCode value={row.name} copyClipboard /> | ||
}, | ||
}, | ||
{ | ||
header: 'Output value', | ||
field: 'value', | ||
rowHeader: true, | ||
renderCell: row => { | ||
return <p>{row.value}</p> | ||
}, | ||
}, | ||
{ | ||
header: 'Source value', | ||
field: 'original', | ||
rowHeader: true, | ||
renderCell: row => { | ||
return <p>{row.original.$value}</p> | ||
}, | ||
}, | ||
]} | ||
/> | ||
</Table.Container> | ||
<Table.Container> | ||
<h2 id="easing">Base easing</h2> | ||
<DataTable | ||
aria-labelledby="easing" | ||
data={data.filter(item => item.type === 'cubicBezier')} | ||
columns={[ | ||
{ | ||
header: 'Token', | ||
field: 'name', | ||
rowHeader: true, | ||
renderCell: row => { | ||
return <InlineCode value={row.name} copyClipboard /> | ||
}, | ||
}, | ||
{ | ||
header: 'Output value', | ||
field: 'value', | ||
rowHeader: true, | ||
renderCell: row => { | ||
return <p>{JSON.stringify(row.value)}</p> | ||
}, | ||
}, | ||
{ | ||
header: 'Source value', | ||
field: 'original', | ||
rowHeader: true, | ||
renderCell: row => { | ||
return <p>{JSON.stringify(row.original.$value)}</p> | ||
}, | ||
}, | ||
]} | ||
/> | ||
</Table.Container> | ||
</> | ||
) | ||
} |