nodejs.dev icon indicating copy to clipboard operation
nodejs.dev copied to clipboard

Feat: Move to SCSS modules in site

Open manishprivet opened this issue 3 years ago • 3 comments

Summary

Right now we're using normal scss files and class names for styling across the page. But it's starting to show it's side-effects as unrelated/unimported class names/styles are affecting certain pages.

One example can be found here: https://github.com/nodejs/nodejs.dev/pull/1448#issuecomment-865507441

Should we move to use SCSS modules instead? According to Gatsby, it might even give performance benefits while keeping styles scoped to a component.

https://www.gatsbyjs.com/docs/how-to/styling/css-modules/#when-to-use-css-modules

C.C. @nodejs/nodejs-dev

manishprivet avatar Jun 22 '21 04:06 manishprivet

@manishprivet do you think you could work on this Issue?

ovflowd avatar Jul 27 '22 16:07 ovflowd

What do you mean by scss modules? Is it the newer @use syntax https://css-tricks.com/introducing-sass-modules/

benhalverson avatar Jul 27 '22 23:07 benhalverson

@benhalverson It's about technic for scoping styles to components. This allows to use more generic class names without fear of affecting other components' styles that used same classes

rodion-arr avatar Jul 28 '22 22:07 rodion-arr

Yes, using CSS modules would prevent the styles that are created within file A from affecting other styles or global styles.

The styles defined within layout.scss and mobile.scss should be kept if they're global styles.

Any other style (eg.: component or page-specific style) should move to a new SCSS file, and they should be imported with named imports (import * as styles) so that they're not globally applied.

This is on my list of things to be done.

ovflowd avatar Aug 22 '22 00:08 ovflowd