-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add display type usecase docs to the website
- Loading branch information
Showing
4 changed files
with
99 additions
and
40 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
47 changes: 47 additions & 0 deletions
47
apps/for-everyone-website/src/components/TypeUsecase.astro
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,47 @@ | ||
--- | ||
import PreviewFrame from './utils/PreviewFrame.astro'; | ||
const tokens = await import(`@financial-times/o3-tooling-token/${Astro.props.brand}.js`); | ||
const usecases = Array.isArray(Astro.props.usecases) ? Astro.props.usecases : [Astro.props.usecases]; | ||
const TypeUsecaseTokens = Object.entries(tokens.default).filter(([key, value]) => key.includes(`o3-typography-use-case`) && usecases.includes(value.attributes?.subitem)).map(([key, value]) => { | ||
value.name = key; | ||
return value | ||
}); | ||
const TypeUsecaseTokensByItem = Object.groupBy(TypeUsecaseTokens, (token) => token.attributes?.subitem); | ||
--- | ||
|
||
{ | ||
|
||
|
||
Object.entries(TypeUsecaseTokensByItem).map(([key, tokens]) => { | ||
console.log(tokens); | ||
return <> | ||
<h3>{key}</h3> | ||
<p>{tokens[0].description}</p> | ||
|
||
<PreviewFrame html={`<span class="o3-typography-use-case-${key}">Make sense of all of it</span>`} mark={`class="o3-typography-use-case-${key}`} /> | ||
|
||
<table class="color-table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>CSS Custom Property</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{tokens.map(token => { | ||
return <tr> | ||
<td>{token.type}</td> | ||
<td>{token.css}</td> | ||
<td>{token.value}</td> | ||
</tr> | ||
})} | ||
</tbody> | ||
</table> | ||
</>; | ||
}) | ||
} |
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.