import { Nav } from '../../public/external/Nav'
<Nav />
Nav has inadvertently changed the background-color of header in our app because both Nav and App write to the global .header class
No, we were safe! This is because we used CSS Modules, Nav's styles did not overwrite any of our .btn styles, and vice versa.
:global .nav .btn {
right: 20px;
left: auto;
}
We use PostCSS in this workshop which gives us the ability to safely use CSS custom properties to create and use variables, amongst other things.
--primary-color-dark: #8E5E8F;
--primary-color-light: #E699E8;
--primary-color-lighter: #8E5E8F;
--secondary-color-dark: #55D750;
--secondary-color-light: #71DE6E;
Pros on Extracting CSS:
- CSS file can be cached by client and JS bundle size is smaller
- Less DOM updates during page load
- Avoid Flash of Unstyled Content (FOUC)
Cons of Extracting CSS:
- Additional HTTP request
- Takes longer to build
- Not HMR, bad for development