Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce web typography presets #1335

Merged
merged 62 commits into from
Apr 16, 2024
Merged

Conversation

jamesmockett
Copy link
Contributor

@jamesmockett jamesmockett commented Apr 4, 2024

What are you changing?

Why?

  • The design team have been using the typography presets in Figma for some time so this brings the code into alignment, and simplifies the process of translating between the two.
  • This has also been an opportunity to clean up our existing typography code which is fairly complex and difficult to update.

Additional details

Each preset encapsulates a complete typographic style and is exported as a variable. Unlike the current API the presets have no options as there should be no need to override their styles. Values for individual properties such as weight and line height are also no longer provided for the same reason.

textSans.medium()textSans17
textSans.medium({ fontWeight: 'bold' })textSansBold17
textSans.medium({ fontStyle: 'italic' })textSansItalic17
headline.xlarge({ fontWeight: 'light', fontStyle: 'italic' })headlineLightItalic50

Each preset is available as a CSS string and an object literal.

const h1 = css`
  ${headlineMedium50};
`;

const p = {
  ...textSans17Object,
};
export const headlineMedium50 = `
  font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif;
  font-size: 3.125rem;
  line-height: 1.15;
  font-weight: 500;
  font-style: normal;
  --source-text-decoration-thickness: 6px;
`;
export const textSans17Object = {
  fontFamily: 'GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif',
  fontSize: '1.0625rem',
  lineHeight: 1.3,
  fontWeight: 400,
  fontStyle: 'normal',
} as const;

## What are you changing?

- Adds built script to generate CSS for new [web typography
presets](https://theguardian.design/2a1e5182b/p/01555f-typography-presets/b/830670)
from the existing definitions in the design tokens package and export
these as individual variables from Source Foundations
- Updates some incorrect font sizes in the design tokens

```bash
pnpm nx run @guardian/source-foundations:build-type-presets
```

```json
"textSansBold15": {
  "$value": {
    "fontFamily": "{typography.fontFamily.textSans}",
    "fontSize": "{typography.fontSize.15}",
    "lineHeight": "{typography.lineHeight.regular}",
    "fontWeight": "{typography.fontWeight.bold}",
    "fontStyle": "normal"
  }
},
```

⬇️

```tsx
export const textSansBold15 = `
  font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.3;
  font-weight: 700;
  font-style: normal;
`;
```
@jamesmockett jamesmockett added the 🐥 Canaries Triggers canary releases of any packages with changesets waiting. label Apr 9, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

Note

The following canaries were published to NPM:

🐥

Copy link
Contributor

github-actions bot commented Apr 9, 2024

Note

The following canaries were published to NPM:

🐥

Copy link
Contributor

Note

The following canaries were published to NPM:

🐥

Copy link
Contributor

Note

The following canaries were published to NPM:

🐥

@jamesmockett jamesmockett removed the 🐥 Canaries Triggers canary releases of any packages with changesets waiting. label Apr 10, 2024
Copy link
Contributor

Note

The following canaries were published to NPM:

🐥

@jamesmockett jamesmockett added the 🐥 Canaries Triggers canary releases of any packages with changesets waiting. label Apr 16, 2024
Copy link
Contributor

Note

The following canaries were published to NPM:

🐥

@jamesmockett jamesmockett removed the 🐥 Canaries Triggers canary releases of any packages with changesets waiting. label Apr 16, 2024
Co-authored-by: Alex Sanders <alex@sndrs.dev>
@jamesmockett jamesmockett merged commit cfc13ae into main Apr 16, 2024
20 checks passed
@jamesmockett jamesmockett deleted the jm/type-preset-release-branch branch April 16, 2024 13:52
jamesmockett added a commit that referenced this pull request Apr 17, 2024
## What are you changing?

- Reinstates [`article` typography
presets](https://theguardian.design/2a1e5182b/p/01555f-typography-presets/b/830670/t/72b9c5)
which were removed from the original PR (#1335).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 npm Affects a @guardian package on NPM run_chromatic Runs chromatic when label is applied
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants