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

Font Import URLs fail to load #123

@gpsamson

Description

@gpsamson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions