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

Nested CSS font-family not working as expected #371

Open
onmax opened this issue Oct 31, 2024 · 3 comments
Open

Nested CSS font-family not working as expected #371

onmax opened this issue Oct 31, 2024 · 3 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@onmax
Copy link

onmax commented Oct 31, 2024

Description

Using nuxt fonts to set different fonts for specific CSS classes works perfectly for single-level classes, but when trying to apply a font to nested CSS classes, it does not load as expected.

For example, Lato works fine for .lato, but Nunito fails to apply in nested elements like .nunito p:

<template>
  <div class="lato">
    'Lato works!'

    <div class="nunito">
      <p>'Nunito does not work :('</p>
    </div>
  </div>
</template>

<style scoped>
.lato {
  font-family: 'Lato';
}

.nunito {
  p {
    font-family: 'Nunito';
  }
}
</style>

Reproduction steps

  1. Apply a font family using nuxt fonts to a nested CSS class selector.

Note that the font only applies to single-level selectors, not nested ones like .nunito p.

Expected behaviour

Both fonts should be applied according to the CSS structure, with Lato on the outer div and Nunito on the inner <p> element.

Reproduction link

Stackblitz repro

@onmax
Copy link
Author

onmax commented Oct 31, 2024

I assume that the AST does not walk through nested CSS correctly here.

If it is ok, I could make a PR if one of the maintainers agrees with this change :)

Thanks for this great module!

@onmax
Copy link
Author

onmax commented Oct 31, 2024

I could also add a new test for Nested CSS here

@danielroe
Copy link
Member

that would be great - thank you 🙏

@danielroe danielroe added bug Something isn't working good first issue Good for newcomers labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants