You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: css/sass-best-practices/readme.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ As a rule of thumb, try to avoid `@extend`.
61
61
62
62
The main problem with `@extend` is that it is easy to bloat your code by using it. When first starting to use it, the code can be very innocent in appearance, such as:
63
63
64
-
```
64
+
```scss
65
65
// SCSS code
66
66
.c-button {}
67
67
@@ -76,7 +76,7 @@ The main problem with `@extend` is that it is easy to bloat your code by using i
76
76
77
77
That does appear pretty innocent. However, what happens if we do this:
78
78
79
-
```
79
+
```scss
80
80
// SCSS code
81
81
.c-button {}
82
82
@@ -101,7 +101,7 @@ Whoa! See what happened? Notice the extra selector that got compiled that we pro
101
101
102
102
So there is a workaround for the problem we described above: __never directly extend a standard class__. Instead, __only extend placeholder classes__. Let's see what that looks like using the same example from above:
103
103
104
-
```
104
+
```scss
105
105
// SCSS code
106
106
.c-button, %c-button {} // Notice that this is a placeholder class
107
107
@@ -130,7 +130,7 @@ __Scenario 1__: There are situations where you want to have default styles on el
130
130
131
131
This is how we deal with this scenario using `@extend`:
132
132
133
-
```
133
+
```scss
134
134
// In `/vellum`
135
135
// ---
136
136
@@ -167,7 +167,7 @@ __Scenario 2__: This scenario is very specific to Mobify and here is why... as y
167
167
168
168
What are the consequences of not being able to control parts of the DOM? It means we might not be able to add classes to the DOM reliably, which means that we can't apply our styles as easily as we would like. Instead, we are forced to write some gnarly selectors to ensure these situations can work. Let's use BazaarVoice again as our example:
169
169
170
-
```
170
+
```scss
171
171
[id="BVRRContainer"] {
172
172
173
173
.BVRRSortSelectWidget {
@@ -238,7 +238,7 @@ The second aspect of comments are the comments themselves! There are three types
238
238
239
239
1. General Comments
240
240
241
-
```
241
+
```scss
242
242
// My Component
243
243
// ============
244
244
//
@@ -255,7 +255,7 @@ Direct comments are those that apply to a single line of code as denoted by the
255
255
256
256
Be aware that these notes typically only refer to the code directly beneath it, as far as just before the next section (i.e. the next sub-component). That next section could have it's own Direct Notes, but they will only apply to that section despite using the same numbers.
257
257
258
-
```
258
+
```scss
259
259
// My Component
260
260
// ============
261
261
//
@@ -295,7 +295,7 @@ So Note A will always refer to the same note.
295
295
296
296
This is a rare use case, but can be useful sometimes when you have the same set of changes that need to be applied across more than one section of code.
297
297
298
-
```
298
+
```scss
299
299
// My Component
300
300
// ============
301
301
//
@@ -337,7 +337,7 @@ Do note that variables without modifiers are implicitly the base version of that
337
337
338
338
For color gradients, we follow a convention that looks like `{modifier}-{name}-{number}` where the number _roughly_ corresponds to some property level of that color, such as the greyscale level.
0 commit comments