Avoid global styles to break components
See original GitHub issueBug Report
Describe the bug
In docz-theme-default
some global styles are applied which are reaching components and breaking the styles on some scenarios:
*, *:before, *:after {
box-sizing: border-box;
}
All my components will receive box-sizing: border-box;
.
These global rules could be easily avoided by using the box-sizing
properties on the necessary elements directly.
A clear and concise description of what the bug is.
docz-theme-default
global styles are leaking to consumer components.
To Reproduce I guess this is self explanatory.
Expected behavior
Styles from docz-theme-default
should not impact on consumer components.
I can provide a PR for this if maintainers think this is a valid issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Global Styles Should be Avoided - Ben Lorantfy - Medium
Global styles should be avoided for the same reasons global variables are avoided. There's many alternatives available that enable local styling ...
Read more >angular - How to stop global styles from affecting my component
It should be possible because Angular provides a hierarchy for the stylesheets where the global style sheet is on top of everything ...
Read more >Avoid global styles in your Angular projects
Avoid global styles in your Angular projects · break encapsulation · poor readability · break information hiding · namespace pollution.
Read more >Global styles should be avoided | Lorantfy Inc.
Breaks encapsulation Global styles are not encapsulated. This means if you change a global style, it can have global impacts. You'd have to ......
Read more >Scoping CSS using Shadow DOM - Bits and Pieces
If you want to style your component using a global CSS stylesheet, you should avoid using Shadow DOM in that particular component, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Agreed … since this lib doesn’t make any attempt to isolate styles between the component previews and the outer theme then the very least that should happen is that global styles aren’t used in the theme.
The theme additionally includes normalize.css which can also have a global effect on component styles. It essentially forces you to use normalize.css in your apps too, since otherwise there’s no guarantee components will render consistently in docz vs. your app. It’s a shame because normalize is pretty bloated, and no longer really appropriate as a modern css reset.
Much better to make the theme CSS more robust and isolated, and reset theme elements individually as needed.
I removed normalize.css from theme default and the classes and styles applied to Playground are fixed too!