-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Split legacy MDX stories into CSF + MDX
- Loading branch information
1 parent
8a8c9ac
commit ee983d6
Showing
29 changed files
with
459 additions
and
361 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,34 @@ | ||
import {Canvas, Meta, ArgsTable} from '@storybook/blocks'; | ||
import * as ColorPreviewStories from './ColorPreview.stories'; | ||
|
||
import ColorPreview from './ColorPreview'; | ||
|
||
<Meta of={ColorPreviewStories} /> | ||
|
||
## Color preview | ||
|
||
Show a preview of what a color looks like. | ||
|
||
### Formats | ||
|
||
Any valid way to specify a CSS color is accepted. | ||
|
||
<Canvas of={ColorPreviewStories.HEX} /> | ||
<Canvas of={ColorPreviewStories.RGB} /> | ||
<Canvas of={ColorPreviewStories.RGBA} /> | ||
<Canvas of={ColorPreviewStories.HSLA} /> | ||
|
||
<ArgsTable of={ColorPreview} /> | ||
|
||
### `isColor` utility | ||
|
||
Use the `isColor` utility to check if a value is a valid CSS color before rendering this | ||
component. | ||
|
||
```jsx | ||
import ColorPreview, {isColor} from './ColorPreview'; | ||
|
||
const MyComponent = () => { | ||
return isColor('rgb(255, 0, 0)') ? <ColorPreview color="rgb(255, 0, 0)" /> : null; | ||
}; | ||
``` |
This file was deleted.
Oops, something went wrong.
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,43 @@ | ||
import {Meta, StoryObj} from '@storybook/react'; | ||
|
||
import ColorPreview from './ColorPreview'; | ||
|
||
const meta = { | ||
title: 'Private API/ColorPreview', | ||
component: ColorPreview, | ||
} satisfies Meta<typeof ColorPreview>; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const HEX: Story = { | ||
name: 'Hex', | ||
|
||
args: { | ||
color: '#FF0000', | ||
}, | ||
}; | ||
|
||
export const RGB: Story = { | ||
name: 'RGB', | ||
|
||
args: { | ||
color: 'rgb(0, 255, 0)', | ||
}, | ||
}; | ||
|
||
export const RGBA: Story = { | ||
name: 'RGBA', | ||
|
||
args: { | ||
color: 'rgba(0, 0, 255, 0.5)', | ||
}, | ||
}; | ||
|
||
export const HSLA: Story = { | ||
name: 'HSLA', | ||
|
||
args: { | ||
color: 'hsla(20, 80%, 75%, 1)', | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import React from 'react'; | ||
|
||
interface ColorPreviewProps { | ||
export interface ColorPreviewProps { | ||
color: string; | ||
} | ||
|
||
|
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,27 @@ | ||
import {useState} from 'react'; | ||
import {Canvas, Meta, ArgsTable} from '@storybook/blocks'; | ||
import ofDesignTokens from '@open-formulieren/design-tokens/dist/tokens.js'; | ||
import * as TokenEditorStories from './TokenEditor.stories'; | ||
|
||
import TokenEditor from './TokenEditor'; | ||
|
||
<Meta of={TokenEditorStories} /> | ||
|
||
## Token editor | ||
|
||
Given a style-dictionary tokens output (resolved state of all token files), show an | ||
editor to inspect and modify values of design tokens. | ||
|
||
The underlying components can be used to document components in your own storybook | ||
instance or even expose controls for theme builders. | ||
|
||
When changes are made in the editor, the new style-dictionary tree of the tokens is | ||
provided to the `onChange` callback prop. | ||
|
||
<Canvas of={TokenEditorStories.Default} /> | ||
|
||
<ArgsTable of={TokenEditor} /> | ||
|
||
## With a callback function to capture edits | ||
|
||
<Canvas of={TokenEditorStories.OnChangeCallback} /> |
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
import {useState} from 'react'; | ||
import {Meta, StoryObj, StoryFn} from '@storybook/react'; | ||
// @ts-expect-error | ||
import ofDesignTokens from '@open-formulieren/design-tokens/dist/tokens.js'; | ||
|
||
import TokenEditor from './TokenEditor'; | ||
import type {TopLevelContainer} from './types'; | ||
|
||
const meta = { | ||
title: 'Public API/TokenEditor', | ||
component: TokenEditor, | ||
} satisfies Meta<typeof TokenEditor>; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
name: 'Default', | ||
|
||
args: { | ||
tokens: ofDesignTokens, | ||
|
||
initialValues: { | ||
// TODO: look into better (recursive) type definitions | ||
// @ts-expect-error | ||
of: { | ||
button: { | ||
primary: { | ||
bg: { | ||
value: '#0177b2', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const callbackRender: StoryFn<typeof TokenEditor> = ({tokens, initialValues}) => { | ||
const [changeCounter, setChangeCounter] = useState(0); | ||
const [values, setValues] = useState(initialValues); | ||
|
||
const onChange = (newValues: TopLevelContainer) => { | ||
setValues(newValues); | ||
setChangeCounter(changeCounter + 1); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div style={{padding: '1em', marginBottom: '1em', background: '#eee'}}> | ||
<div>Changes received: {changeCounter}</div> | ||
<code> | ||
<pre>{JSON.stringify(values, null, 2)}</pre> | ||
</code> | ||
</div> | ||
<TokenEditor tokens={tokens} initialValues={initialValues} onChange={onChange} /> | ||
</> | ||
); | ||
}; | ||
|
||
export const OnChangeCallback: Story = { | ||
render: callbackRender, | ||
name: 'onChange callback', | ||
|
||
args: { | ||
tokens: ofDesignTokens, | ||
|
||
initialValues: { | ||
// TODO: look into better (recursive) type definitions | ||
// @ts-expect-error | ||
of: { | ||
button: { | ||
primary: { | ||
bg: { | ||
value: '#0177b2', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
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
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,12 @@ | ||
import {Canvas, Meta} from '@storybook/blocks'; | ||
import * as TokenFilterStories from './TokenFilter.stories'; | ||
|
||
import TokenFilter from './TokenFilter'; | ||
|
||
<Meta of={TokenFilterStories} /> | ||
|
||
## Token filter | ||
|
||
Provide filter controls to limit the tokens displayed. | ||
|
||
<Canvas of={TokenFilterStories.Default} /> |
Oops, something went wrong.