alpine icon indicating copy to clipboard operation
alpine copied to clipboard

Add font family overrides from typography module to Hero component

Open wdawson opened this issue 2 years ago • 2 comments

Problem

Alpine leverages the @nuxt-themes/typography module, which defines the available schema.

My understanding, based on how articles are rendered, is that the font.display is meant for headers. However, this token does not get applied to the title on the Hero component. Additionally, the description only receives this font-family style because it is a list. If you remove the list items, it also doesn't get overridden by the token, probably also because it doesn't have an element that the typography module picks up.

Solution

This is probably because there isn't an h1 element created as part of the Hero title. Perhaps that should be fixed, however, I noticed that someone could theoretically have a list as the title, where an h1 wouldn't be relevant.

Therefore I decided to add some fontFamily css to Hero.vue so that anything that is put in the content is appropriately tagged.

Please let me know if there's a different solution that would be better. I'm happy to learn more about this ecosystem 😄

Validation

Here is a screenshot of the playground after making the following changes to .starters/default/tokens.config.ts:

import { defineTheme } from 'pinceau'

export default defineTheme({ 
  typography: {
    font: {
      display: '{font.mono}',
      body: '{font.mono}',
    }
  }
})

Screenshot 2023-07-07 at 16 19 04

You can clearly see the monospace fonts now instead of the default sans-serif.

TODO

  • [ ] determine whether to update the version in package.json as part of this PR (I didn't see it in the contributing guidelines).

Other Notes

The same sort of thing is happening in Article headers, though in that case there is an h1 element that is added. I filed an issue with the typography repo to start: https://github.com/nuxt-themes/typography/issues/65

Also in this PR

  • README.md update for the latest playground location.

wdawson avatar Jul 07 '23 23:07 wdawson

This branch is running in CodeSandbox. Use the links below to review this PR faster.
CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders | Preview

codesandbox[bot] avatar Jul 07 '23 23:07 codesandbox[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
alpine ✅ Ready (Inspect) Visit Preview Jul 7, 2023 11:40pm

vercel[bot] avatar Jul 07 '23 23:07 vercel[bot]