Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Font Import URLs fail to load #123

Open
gpsamson opened this issue May 29, 2021 · 1 comment
Open

Font Import URLs fail to load #123

gpsamson opened this issue May 29, 2021 · 1 comment

Comments

@gpsamson
Copy link

Describe the bug

Overriding the theme's font.importUrls does not work because emotion expects imports before other rules. This is the exact error being logged:

`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.

I suspect the solution here is to update the bumbag/Provider/GlobalStyles so that import URLs are included before any other global styling. I've attempted to test the fix in my fork (gpsamson@6ae1e48) but I'm having issues importing the package into my project, so I'm unsure if this would actually fix it.

Opening this issue to get feedback from core contributors before proposing a fix. Maybe you'll have a better testing workflow than me.

To Reproduce

  1. Create a basic React app using bumbag
  2. Override the default theme:
const theme = {
  fonts: {
    importUrls: [
      'https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap'
    ],
    heading: "'Poppins', system-ui, sans-serif"
  }
}

...

<BumbagProvider theme={theme}>
  1. Open Devtools and inspect the global styles and console

Expected behavior

External fonts are imported within global styles.

Screenshots

stacktrace:
image

@gpsamson
Copy link
Author

As a stop-gap, I've just imported the fonts within the HTML file so this is by no means urgent.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant