-
Notifications
You must be signed in to change notification settings - Fork 585
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
Remove font loading in GlobalStyle
#54
Comments
Conditional loading wouldn’t fix the problem of reloading and flicker (due to rerender), right? |
@qoalu no def not. My thought process was that the app consuming the design system would have to then setup their font loading manually in a way that made sense for their dev environment/framework/library. This was just a way to give them the opportunity to do that. |
I was contemplating a similar approach in our design system. Would be interested to see what other options people come up with. Another idea is to make a side-effect, outside the react lifecycle |
Nice. What do you mean by side-effect? |
Something like useEffect and creating a node with a certain id in the dom (using portal maybe) |
I did some research 🧐on your problem and I've found the following: There was a long discussion about the same problem you experience at styled-components. The gist of it is the following:
Possible solutions were suggested:
Hope I could help a bit. 🙂 |
Nice summary @kristof0425 . I wonder if this means that we should just avoid loading the font in our design system alltogether and let the client applications each handle it individually. Or is there benefit to conditionally loading it as a prop as mentioned here: Anyone have opinions? |
I looked at IMHO, I would avoid loading the font and let it be handled by the client. I don't see the benefit of loading it conditionally as the re-requesting problem would still persist when the condition is met. |
Just an bit of extra colour here -- https://github.com/tmeasday/next-safari-reproduction/blob/master/README.md is a repo that reprouduces a problem we've seen due to the use of this This is quite a nasty issue affecting our production app (occassionally server rendered pages just appear basically empty), and I'd say a pretty good reason we shouldn't recommend anyone uses the |
This isn't a complete fix for #54, but it is a step forward, as it allows users to safely do: ```js import { createGlobalStyle } from 'styled-components'; import { global } from '@storybook/design-system'; const CustomGlobalStyle = createGlobalStyle` body { ${global.bodyStyles} } }` ``` In their own code to avoid the `@import`.
As a simple first step I did this: #76 I was thinking about adding the |
🚀 Issue was released in v1.0.0 🚀 |
Remove the font loading of Nunito Sans here or potentially configure the
GlobalStyle
to conditionally load it.Currently, design system consumer app frameworks could re-render layout components (Gatsby is an example of a framework that does this) on each page change. This causes the font to be requested on every page change and also a flickering of fonts when that happens.
It might be easiest to just pass a prop to
GlobalStyle
like this:...but other ideas are welcomed as well.
The text was updated successfully, but these errors were encountered: