-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-factor and streamline the SCSS basics.
This is a major overhaul and refactoring of all the basics. It moves shared items out of the individual stories, and into mixins, variables and other base files. One of the major things is that it streamlines typography: It introduces a variables.typography.scss file, that defines all the typographies, and a @include typography($VARIABLE) to use them. This way, we can keep track of typographies, and have a single place to look when we make new modules. This way, we also have an easy way of quality-secure against figma. All of this is the first step. There is still a lot of stuff that needs to be fixed. To begin with, I've made sure that all existing classes still work. E.g. '.text-h1' will still compile to the same, but in SCSS we cant use %text-h1 anymore. A future step is to look through all the stuff I've marked as 'legacy', and tweak/remove/edit the classes throughout dpl-cms, react and other places.
- Loading branch information
Showing
126 changed files
with
1,886 additions
and
1,994 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# SCSS strategy | ||
|
||
In December 2023, we have aimed to streamline the way we write SCSS. | ||
Some of these rules have not been applied on previous code, but moving forward, | ||
this is what we aim to do. | ||
|
||
## BEM naming convention | ||
|
||
### Examples of do's and dont's | ||
|
||
Assuming we have a Counter block: | ||
- Styling must be placed in a correspondingly named file `counter.scss` | ||
- `.counter__title` ✅ | ||
- `&__title` ❌ (`&__` should be avoided, to avoid massive indention.) | ||
- `.counter-title` ❌ (Must start with `.FILE-NAME__`) | ||
- `.counter__title__text` ❌ (Only one level) | ||
|
||
#### Variants, modifiers and JS | ||
|
||
Sometimes you may want to target stuff using JS. This should be done with a | ||
specific `.js-XXX` class. That way, it is easier to manage when refactoring, | ||
and to signal that altering this class may have "invisible" consequences. | ||
|
||
Sometimes, you'll want to send data via JS to CSS. This is done using | ||
modifier classes - A snake-case class, usually starting with verbs - e.g. | ||
`.is-active`, `.has-many-items` | ||
|
||
Sometimes you'll want to add variants to CSS-only classes. This can be done | ||
using **variant classes** - e.g. `.counter--large`, `.counter__title--large`. | ||
**These classes must not be set alone.** E.g. `.counter__title--large` must not | ||
exist on an element without also having `.counter__title`. | ||
|
||
A quick guide: | ||
|
||
| | JS | CSS | | ||
|------------------|----|-----| | ||
| .js-counter | 🟢 | 🔴 | | ||
| .is-active | 🟢 | 🟢 | | ||
| .has-numbers | 🟢 | 🟢 | | ||
| .counter | 🔴 | 🟢 | | ||
| .counter__title | 🔴 | 🟢 | | ||
| .counter--active | 🔴 | 🟢 | | ||
|
||
## Mixins, placeholder and variables | ||
|
||
Shared tooling is saved in [src/styles/scss/tools](../src/styles/scss/tools), | ||
NOT in individual stories. | ||
|
||
### Typography | ||
|
||
Typography is defined in | ||
[src/styles/scss/tools/variables.typography.scss](../src/styles/scss/tools/variables.typography.scss). | ||
These variables, all starting with `$typo__`, can be used, using a mixin, | ||
`@include typography($typo__h2);` in stories. | ||
Generally speaking, font styling should be avoided directly in stories, rather | ||
adding new variants in the `variables.typography.scss` file. | ||
This way, we can better keep track of what is available, and avoid duplicate | ||
styling in the future. | ||
|
||
## Legacy classes | ||
|
||
In the future, we want to apply these rules to old code too. Until then, | ||
the old classes are supported using the files in [src/styles/scss/legacy](../src/styles/scss/legacy). | ||
|
||
These classes should **not be used in new components** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.article { | ||
background-color: $c-global-primary; | ||
background-color: $color__global-primary; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.event-page { | ||
background-color: $c-global-primary; | ||
background-color: $color__global-primary; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.