generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storybook): automate component design tokens (#140)
- Loading branch information
Showing
15 changed files
with
741 additions
and
76 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
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,45 @@ | ||
// @ts-expect-error no definition file | ||
import { ComponentTokensSection } from '@nl-design-system-unstable/theme-toolkit'; | ||
import type { StoryObj } from '@storybook/react'; | ||
|
||
type DesignToken = { | ||
comment?: string; | ||
name?: string; | ||
path?: string; | ||
value: string | number; | ||
}; | ||
|
||
type Props = { | ||
component: string; | ||
definition: DesignTokenTree; | ||
tokens: string | number; | ||
}; | ||
|
||
interface DesignTokenTree { | ||
[index: string]: DesignToken | DesignTokenTree; | ||
} | ||
|
||
export const createDesignTokensStory = (meta: any): StoryObj => { | ||
const designTokenStory: StoryObj<Props> = { | ||
args: { | ||
tokens: meta.parameters.tokens, | ||
definition: meta.parameters.tokensDefinition, | ||
component: meta.parameters.tokensPrefix, | ||
}, | ||
parameters: { | ||
chromatic: { | ||
disableSnapShot: true, | ||
}, | ||
docs: { | ||
source: { | ||
code: '', | ||
}, | ||
}, | ||
}, | ||
render: (({ tokens, definition, component }: Props) => { | ||
return <ComponentTokensSection tokens={tokens} definition={definition} component={component} />; | ||
}) as any, | ||
}; | ||
|
||
return designTokenStory; | ||
}; |
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,2 @@ | ||
export * from './createDesignTokensStory'; | ||
export * from './createVisualRegressionStory'; |
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
164 changes: 164 additions & 0 deletions
164
packages/storybook/src/web-components/button-login/tokens.json
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,164 @@ | ||
{ | ||
"lux": { | ||
"button-login": { | ||
"active": { | ||
"background-color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"border-color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
} | ||
}, | ||
"background-color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"border-color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"border-radius": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"border-width": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"hover": { | ||
"background-color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"border-color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"color": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
} | ||
} | ||
}, | ||
"icon": { | ||
"size": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
} | ||
}, | ||
"margin-inline": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"min-block-size": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"min-inline-size": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"padding-block-end": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"padding-block-start": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"padding-inline-end": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
}, | ||
"padding-inline-start": { | ||
"$extensions": { | ||
"nl.nldesignsystem.css.property": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.