-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add tokens to storybook examples (#31)
Co-authored-by: Jaalah Ramos <jaalah.ramos@gmail.com>
- Loading branch information
1 parent
325759a
commit 4452651
Showing
19 changed files
with
367 additions
and
97 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,4 @@ | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,400;0,6..12,600;0,6..12,700;0,6..12,800;1,6..12,400;1,6..12,600;1,6..12,700;1,6..12,800&display=swap" rel="stylesheet"> | ||
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600;700&family=Nunito+Sans:ital,opsz,wght@0,6..12,400;0,6..12,600;0,6..12,700;0,6..12,800;1,6..12,400;1,6..12,600;1,6..12,700;1,6..12,800&display=swap" rel="stylesheet"> |
Binary file not shown.
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
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,28 +1,87 @@ | ||
import React from 'react'; | ||
import { TokenInfo } from './Info'; | ||
import { Font } from '../dist/index.js'; | ||
import { Border, Font } from '../dist/index.js'; | ||
|
||
export const Section = ({ colorObject, colorName, title }) => ( | ||
<div key={colorName}> | ||
<h2 | ||
style={{ | ||
fontFamily: Font.FontFamily.Brand | ||
}} | ||
> | ||
{title} | ||
</h2> | ||
interface SectionProps { | ||
concept?: string; | ||
stacked?: boolean; | ||
state?: string; | ||
title: string; | ||
type?: string; | ||
value: any; | ||
variant: string; | ||
} | ||
|
||
export const Section = ({ | ||
concept, | ||
stacked, | ||
state, | ||
title, | ||
type, | ||
value, | ||
variant | ||
}: SectionProps) => { | ||
const HeadingElement = stacked ? 'h3' : 'h2'; | ||
const isColorValueString = typeof value === 'string'; | ||
|
||
const renderValue = ( | ||
<TokenInfo type={type} color={value} variant={concept} value={variant} /> | ||
); | ||
|
||
const renderInfo = isColorValueString | ||
? renderValue | ||
: Object.entries(value).map(([key, value]) => { | ||
if (value instanceof Object) { | ||
return ( | ||
<Section | ||
concept={concept} | ||
key={key} | ||
stacked | ||
state={key} | ||
title={key} | ||
type={type} | ||
value={value} | ||
variant={variant} | ||
/> | ||
); | ||
} | ||
return ( | ||
<TokenInfo | ||
color={value as string} | ||
concept={concept} | ||
key={state} | ||
state={state} | ||
type={type} | ||
value={key} | ||
variant={variant} | ||
/> | ||
); | ||
}); | ||
|
||
return ( | ||
<div | ||
key={variant} | ||
style={{ | ||
display: 'grid', | ||
gap: '2rem', | ||
gridTemplateColumns: 'repeat(2, 1fr)' | ||
width: '100%' | ||
}} | ||
> | ||
{Object.entries(colorObject).map(([value, color]) => ( | ||
<div key={value}> | ||
<TokenInfo color={color} colorName={colorName} value={value} /> | ||
</div> | ||
))} | ||
<HeadingElement | ||
style={{ | ||
borderBottom: !stacked && `1px solid ${Border.Normal}`, | ||
fontFamily: Font.FontFamily.Brand | ||
}} | ||
> | ||
{title} | ||
</HeadingElement> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
width: '100%' | ||
}} | ||
> | ||
{renderInfo} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import React from 'react'; | ||
import { Action } from '../../dist/index.js'; | ||
import { Section } from '../Section.js'; | ||
|
||
export const AliasColors = () => ( | ||
export const AliasColors = ({ concept, conceptHeading }) => ( | ||
<> | ||
{Object.entries(Action).map(([colorName, colorObject]) => ( | ||
<Section | ||
colorName={colorName} | ||
colorObject={colorObject} | ||
key={colorName} | ||
title={`${colorName} Colors`} | ||
/> | ||
))} | ||
{Object.entries(concept).map(([key, colorObject]) => { | ||
return ( | ||
<Section | ||
concept={conceptHeading} | ||
key={key} | ||
title={key} | ||
type="alias" | ||
value={colorObject} | ||
variant={key} | ||
/> | ||
); | ||
})} | ||
</> | ||
); |
Oops, something went wrong.