Skip to content

Commit

Permalink
chore: Add display type usecase docs to the website
Browse files Browse the repository at this point in the history
  • Loading branch information
notlee committed Jan 13, 2025
1 parent 12adcdf commit f1b6b44
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 40 deletions.
2 changes: 1 addition & 1 deletion apps/for-everyone-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@financial-times/o3-editorial-typography": "^2.0.0",
"@financial-times/o3-figma-sb-links": "^0.0.0",
"@financial-times/o3-form": "^0.5.0",
"@financial-times/o3-foundation": "^2.0.0",
"@financial-times/o3-foundation": "^2.3.1",
"@financial-times/o3-social-sign-in": "^1.0.0",
"@financial-times/o3-tooling-token": "^0.0.0",
"@financial-times/o3-tooltip": "^2.0.0",
Expand Down
47 changes: 47 additions & 0 deletions apps/for-everyone-website/src/components/TypeUsecase.astro
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>
</>;
})
}
88 changes: 50 additions & 38 deletions apps/for-everyone-website/src/content/docs/guides/typography.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import '@financial-times/o3-editorial-typography/css/professional.css';
import '@financial-times/o3-editorial-typography/css/sustainable-views.css';
import '@financial-times/o3-editorial-typography/css/whitelabel.css';

import {Tabs, TabItem, Code} from '@astrojs/starlight/components';
import { Tabs, TabItem, Code } from '@astrojs/starlight/components';

import HeadingTypography from '../../../components/typography/Heading.astro';
import BodyTypography from '../../../components/typography/Body.astro';
Expand All @@ -43,18 +43,19 @@ import Caption from '../../../components/editorial-typography/Caption.astro';

import TypeScale from '../../../components/TypeScale.astro';
import TypeFamily from '../../../components/TypeFamily.astro';
import TypeUsecase from '../../../components/TypeUsecase.astro';

import {default as Example} from '../../../components/Example.astro';
import {default as Guideline} from '../../../components/Guideline.astro';
import { default as Example } from '../../../components/Example.astro';
import { default as Guideline } from '../../../components/Guideline.astro';

<TypeFamily brand={props.brand} />

<BrandedContent brands="core, professional, internal">
The FT typography uses the following typefaces to convey information to our
users in different aspects of the FT products. Metric, Financier Display and
Georgia.
</BrandedContent>

<TypeFamily brand={props.brand} />

### Metric

Metric is our primary typeface. Clear, contemporary and rational, Metric communicates with clarity best used for CTAs, body copy and headings across all sub-brands.
Expand Down Expand Up @@ -88,43 +89,15 @@ Metric is our primary typeface. Clear, contemporary and rational, Metric communi

</BrandedContent>

## Typographic Scale

We use multiple typographic scales for different font families. Our scale ranges from -3 to 10, depending on the font family. Consider scale 0 the baseline, with ascending and descending values in each direction. Avoid using styles below zero for long form content.
## Usecases

<Tabs syncKey="code">
<TabItem label="Metric2">
<TypeScale brand={props.brand} scaleFamily="metric2" />
</TabItem>
<BrandedContent brands="core, professional, sustainable-views, whitelabel">
<TabItem label="Financier Display">
<TypeScale brand={props.brand} scaleFamily="financier-display" />
</TabItem>
</BrandedContent>
<BrandedContent brands="sustainable-views">
<TabItem label="Financier Text">
<TypeScale brand={props.brand} scaleFamily="financier-text" />
</TabItem>
</BrandedContent>
<BrandedContent brands="core, professional, whitelabel">
<TabItem label="Georgia">
<TypeScale brand={props.brand} scaleFamily="georgia" />
</TabItem>
</BrandedContent>
</Tabs>
Typography use-cases provide low level typography styles for use in a variety of contexts. In addition to these general type style, Origami provides typography components which use these. For example the [display component](#) combines all three [display sizes](#display) at different breakpoints for a responsive heading.

## Font Weight
### Display

Font weight can be used to express hierarchy or urgency of information.
Display styles, as the largest text on the screen, are reserved for short, important text or numerals. These styles are responsive to screen sizes and use the Financier Display typeface. This font family should be used exclusively for editorial story headlines, such as teaser headlines or article toppers.

We recommend using our standard [UI typography](#ui-typography) <BrandedContent currentBrand={props.brand} brands="core, professional, sustainable-views, whitelabel">or [Editorial typography](#editorial-typography)</BrandedContent> styles where possible. For custom typography, align to these standard styles where possible. For example when using Metric2 for UI use `semibold` over other bold weights.
| Preview | Value | Token |
| --------------------------------------------------------------------------------------------------------------------- | ----- | ------------------------- |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-light)">light</span> | 300 | <Code code={`font-weight: var(--o3-font-weight-light);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-regular)">regular</span> | 400 | <Code code={`font-weight: var(--o3-font-weight-regular);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-medium)">medium</span> | 500 | <Code code={`font-weight: var(--o3-font-weight-medium);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-semibold)">semibold</span> | 700 | <Code code={`font-weight: var(--o3-font-weight-semibold);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-bold)">bold</span> | 800 | <Code code={`font-weight: var(--o3-font-weight-bold);`} lang="css" wrap={true}/> |
<TypeUsecase brand={props.brand} usecases={['display-sm', 'display-md', 'display-lg']} />


## UI Typography
Expand Down Expand Up @@ -319,3 +292,42 @@ Keeping typography consistent and sticking to logical hierarchies ensures that e
</Guideline>

</BrandedContent>


## Typographic Scale

We use multiple typographic scales for different font families. Our scale ranges from -3 to 10, depending on the font family. Consider scale 0 the baseline, with ascending and descending values in each direction. Avoid using styles below zero for long form content.

<Tabs syncKey="code">
<TabItem label="Metric2">
<TypeScale brand={props.brand} scaleFamily="metric2" />
</TabItem>
<BrandedContent brands="core, professional, sustainable-views, whitelabel">
<TabItem label="Financier Display">
<TypeScale brand={props.brand} scaleFamily="financier-display" />
</TabItem>
</BrandedContent>
<BrandedContent brands="sustainable-views">
<TabItem label="Financier Text">
<TypeScale brand={props.brand} scaleFamily="financier-text" />
</TabItem>
</BrandedContent>
<BrandedContent brands="core, professional, whitelabel">
<TabItem label="Georgia">
<TypeScale brand={props.brand} scaleFamily="georgia" />
</TabItem>
</BrandedContent>
</Tabs>

## Font Weight

Font weight can be used to express hierarchy or urgency of information.

We recommend using our standard [UI typography](#ui-typography) <BrandedContent currentBrand={props.brand} brands="core, professional, sustainable-views, whitelabel">or [Editorial typography](#editorial-typography)</BrandedContent> styles where possible. For custom typography, align to these standard styles where possible. For example when using Metric2 for UI use `semibold` over other bold weights.
| Preview | Value | Token |
| --------------------------------------------------------------------------------------------------------------------- | ----- | ------------------------- |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-light)">light</span> | 300 | <Code code={`font-weight: var(--o3-font-weight-light);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-regular)">regular</span> | 400 | <Code code={`font-weight: var(--o3-font-weight-regular);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-medium)">medium</span> | 500 | <Code code={`font-weight: var(--o3-font-weight-medium);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-semibold)">semibold</span> | 700 | <Code code={`font-weight: var(--o3-font-weight-semibold);`} lang="css" wrap={true}/> |
| <span style="font-family: var(--o3-font-family-metric) ; font-weight: var(--o3-font-weight-bold)">bold</span> | 800 | <Code code={`font-weight: var(--o3-font-weight-bold);`} lang="css" wrap={true}/> |
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f1b6b44

Please sign in to comment.