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

Global variables vs. module variables #416

Open
csshugs opened this issue Apr 8, 2020 · 0 comments
Open

Global variables vs. module variables #416

csshugs opened this issue Apr 8, 2020 · 0 comments

Comments

@csshugs
Copy link
Member

csshugs commented Apr 8, 2020

As already mentioned in #411, I’d like to propose a new way to notate variables. This introduces a differentiation of “global” and “module” variables. E.g.:

// _settings.core.scss
$INUIT-SPACING:       24px !default;
$INUIT-SPACING-TINY:  12px !default;
$INUIT-SPACING-SMALL: 16px !default;
$INUIT-SPACING-LARGE: 48px !default;
$INUIT-SPACING-HUGE:  96px !default;



// _objects.box.scss
$inuit-box-padding:       $INUIT-SPACING !default;
$inuit-box-tiny-padding:  $INUIT-SPACING-TINY !default;
$inuit-box-small-padding: $INUIT-SPACING-SMALL !default;
$inuit-box-large-padding: $INUIT-SPACING-LARGE !default;
$inuit-box-huge-padding:  $INUIT-SPACING-HUGE !default;

.o-box {
  display: block;
  padding: $inuit-box-padding;
}

.o-box--flush {
  padding: 0;
}

.o-box--tiny {
  padding: $inuit-box-tiny-padding;
}

.o-box--small {
  padding: $inuit-box-small-padding;
}

.o-box--large {
  padding: $inuit-box-large-padding;
}

.o-box--huge {
  padding: $inuit-box-huge-padding;
}

What’s the benefit?

By making a differentiation in the notation, it is instantly clear what variables are global, i.e. potentially used anywhere else in the codebase and what variables are local, i.e. only used in the partial at hand.

This provides some kind of clarity and dependability of how to use and interact with variables.

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

No branches or pull requests

1 participant