Skip to content

Commit

Permalink
add overview table for docs (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
langermank authored Apr 26, 2023
1 parent fac9106 commit 90d6261
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 21 deletions.
75 changes: 65 additions & 10 deletions docs/storybook/stories/Typography/Functional.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ export const FontFamily = () => {
return <p>{row.value}</p>
},
},
{
header: 'Source value',
field: 'original',
rowHeader: true,
width: 'growCollapse',
renderCell: row => {
return <p>{row.original.value}</p>
},
},
]}
/>
</Table.Container>
Expand Down Expand Up @@ -159,7 +150,6 @@ export const Display = () => {
<TypographyDemo container id="type" fontShorthand="text-display-shorthand">
Display
</TypographyDemo>

<DataTable
aria-labelledby="type"
data={filteredData}
Expand Down Expand Up @@ -957,3 +947,68 @@ export const InlineCodeBlock = () => {
</Table.Container>
)
}

export const Overview = () => {
const data = getTokensByName(sizeTokens, 'text').map(token => {
return {
id: token.name,
...token,
}
})

const filteredData = data.filter(item => item.id.includes('shorthand'))

return (
<Table.Container>
<Table.Title as="h1" id="type">
Overview
</Table.Title>
<DataTable
aria-labelledby="type"
data={filteredData}
columns={[
{
header: 'Sample',
field: 'name',
rowHeader: true,
width: 'auto',
renderCell: row => {
return (
<TypographyDemo fontShorthand={row.name}>
{row.name.split('-')[1]}
{row.name.includes('large')
? ' large'
: row.name.includes('small')
? ' small'
: row.name.includes('medium')
? ' medium'
: undefined}
</TypographyDemo>
)
},
},
{
header: 'Description',
field: 'comment',
rowHeader: true,
width: 'growCollapse',
renderCell: row => {
return (
<p
style={{
fontSize: 'var(--text-body-size-medium)',
lineHeight: 'var(--text-body-lineHeight-medium)',
fontWeight: 'var(--base-text-weight-normal',
marginBottom: '0',
}}
>
{row.comment}
</p>
)
},
},
]}
/>
</Table.Container>
)
}
33 changes: 22 additions & 11 deletions src/tokens/functional/typography/typography.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"lineHeight": "{text.display.lineHeight}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Hero-style text for brand to product transition pages. Utilize Title (large) styles on narrow viewports."
}
},
"title": {
Expand Down Expand Up @@ -88,7 +89,8 @@
"lineHeight": "{text.title.lineHeight.large}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Page headings for user-created objects, such as issues or pull requests. Utilize title (medium) styles on narrow viewports."
},
"medium": {
"$value": {
Expand All @@ -97,7 +99,8 @@
"lineHeight": "{text.title.lineHeight.medium}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Default page title. The 32px-equivalent line-height matches with button and other medium control heights. Great for page header composition."
},
"small": {
"$value": {
Expand All @@ -106,7 +109,8 @@
"lineHeight": "{text.title.lineHeight.small}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Uses the same size as body (large) with a heavier weight of semibold (600)."
}
}
},
Expand All @@ -129,7 +133,8 @@
"lineHeight": "{text.subtitle.lineHeight}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Page sections/sub headings, or less important object names in page titles (automated action titles, for example). Same line-height as title (medium)."
}
},
"body": {
Expand Down Expand Up @@ -170,7 +175,8 @@
"lineHeight": "{text.body.lineHeight.large}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "User-generated content, markdown rendering."
},
"medium": {
"$value": {
Expand All @@ -179,7 +185,8 @@
"lineHeight": "{text.body.lineHeight.medium}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Default UI font. Most commonly used for body text."
},
"small": {
"$value": {
Expand All @@ -188,7 +195,8 @@
"lineHeight": "{text.body.lineHeight.small}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Small body text for discrete UI applications, such as helper, footnote text. Should be used sparingly across pages. Line-height matches Body (medium) at 20px."
}
}
},
Expand All @@ -211,7 +219,8 @@
"lineHeight": "{text.caption.lineHeight}",
"fontFamily": "{fontStack.sansSerif}"
},
"$type": "typography"
"$type": "typography",
"$description": "Compact small font with a smaller line height of 16px. Use it for single-line scenarios, as the small sizing doesn’t pass accessibility requirements."
}
},
"codeBlock": {
Expand All @@ -232,7 +241,8 @@
"lineHeight": "{text.codeBlock.lineHeight}",
"fontFamily": "{fontStack.monospace}"
},
"$type": "typography"
"$type": "typography",
"$description": "Default style for rendering code blocks."
}
},
"codeInline": {
Expand All @@ -250,7 +260,8 @@
"fontSize": "{text.codeInline.size}",
"fontFamily": "{fontStack.monospace}"
},
"$type": "typography"
"$type": "typography",
"$description": "Inline code blocks using em units to inherit size from its parent."
}
}
}
Expand Down

0 comments on commit 90d6261

Please sign in to comment.