Skip to content
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

Sass Module Refactor #8899

Closed
47 of 48 tasks
Tracked by #9162
joshblack opened this issue Jun 14, 2021 · 2 comments
Closed
47 of 48 tasks
Tracked by #9162

Sass Module Refactor #8899

joshblack opened this issue Jun 14, 2021 · 2 comments
Milestone

Comments

@joshblack
Copy link
Contributor

joshblack commented Jun 14, 2021

This issue currently tracks our efforts refactoring our codebase to Dart Sass using Sass modules.

Components

@joshblack joshblack added the Epic label Jun 14, 2021
@joshblack
Copy link
Contributor Author

joshblack commented Jun 14, 2021

Reference

Migration process

  • Find the component SCSS file from packages/components
  • Create an _index.scss file for this component over in packages/styles/scss/components/<component>/_index.scss
  • Copy over on the *.scss files, ignore the JS/HBS/md files for the most part, into this folder
  • Update the _<component>.scss file with the following changes:
    • Remove the import-once import
    • Remove the exports mixin that is used
    • Update _index.scss to @use '<component>'; and include the mixin afterwards
@use 'example-component';

@include example-component.example-component;
  • Update the imports of the file from @import to @use
    • css--reset -> utilities/component-reset
    • Duration tokens coming from _motion.scss and have a name change
    • rem and em helpers come from ../utilities/convert
    • carbon--spacing -> spacing
    • carbon--breakpoint -> breakpoint
    • Update tokens to use CSS Custom Properties
  • Update scss/components/_index.scss entrypoint
  • Update any calculations on tokens to use calc()

Common migrations

$prefix

+@use '../../config' as *;

type-style

+@use '../../type';

...

.#{$prefix}--component {
-  @include type-style('body-short-01');
+  @include type.type-style('body-short-01');
}

Button reset

-@import '../../globals/scss/helper-mixins';
+@use '../../utilities/button-reset';

Component reset

-@import '../../globals/scss/css--reset';
+@use '../../utilities/component-reset';

Tokens

-@import '../../globals/scss/vars';
+@use '../../theme' as *;

duration--* / component-tokens

-@import '../../globals/scss/vars';
@use '../../motion' as *;

...

.#{$prefix}--my-component {
-  transition: color $duration--fast-01 motion(standard, productive);
+  transition: color $duration-fast-01 motion(standard, productive);
}

helper mixins

-@import '../../globals/scss/helper-mixins';

// Focus outline
+@use '../../utilities/focus-outline' as *;

spacing

-@import '../../globals/scss/vars';
+@use '../../spacing' as *;

rem

+@use '../../utilities/convert' as *;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants