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
Copy file name to clipboardExpand all lines: README.md
+151-78
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ Configure your text editor to adhere to the above. At the bare minimum configure
84
84
85
85
#### Sublime Text
86
86
87
-
If you use Sublime Text editor (and you should) then install [this package](https://github.com/SublimeText/TrailingSpaces) and use these settings in your **Settings - User** file which can be found here: **Sublime Text -> Preferences -> Settings User**:
87
+
If you use Sublime Text editor then install [this package](https://github.com/SublimeText/TrailingSpaces) and use these settings in your **Settings - User** file which can be found here: **Sublime Text -> Preferences -> Settings User**:
88
88
89
89
```
90
90
"tab_size": 2,
@@ -128,83 +128,90 @@ For reference here is an anatomy of a rule set:
128
128
### Formatting rules
129
129
130
130
- Class names to use BEM notation, see [Naming Conventions -> BEM](#bem), where BEM isn't used then hyphen delimited class names are to be used.
131
-
- Use one discrete selector per line in multi-selector rule sets, e.g.
131
+
- Use one discrete selector per line in multi-selector rule sets.
132
132
133
-
```
133
+
**Good**
134
+
```scss
134
135
.error,
135
136
.success {
136
137
...
137
138
}
138
139
```
139
-
*not*
140
-
```
140
+
141
+
**Bad**
142
+
```scss
141
143
.error, .success {
142
144
...
143
145
}
144
146
```
145
-
- Include a single space before the opening brace of a rule set, e.g.
146
-
147
-
```
147
+
- Include a single space before the opening brace of a rule set.
148
+
149
+
**Good**
150
+
```scss
148
151
.error,
149
152
.success {
150
153
...
151
154
}
152
155
```
153
-
*not*
154
-
```
156
+
157
+
**Bad**
158
+
```scss
155
159
.error,
156
160
.success{
157
161
...
158
162
}
159
163
```
160
-
- Place the closing brace of a rule set in the same column as the first character of the rule set, e.g.
164
+
- Place the closing brace of a rule set in the same column as the first character of the rule set.
161
165
162
-
```
166
+
**Good**
167
+
```scss
163
168
.error,
164
169
.success {
165
170
...
166
171
}
167
172
```
168
-
*not*
169
-
```
173
+
174
+
**Bad**
175
+
```scss
170
176
.error,
171
177
.success {
172
178
...}
173
179
```
174
-
- Properties within rule sets should each reside on their own line except for single-line declaration rule sets, e.g.
- Where allowed, avoid specifying units for zero-values, e.g. `margin: 0;`*not*`margin: 0px;`.
237
-
- Commas in lists should be followed by a space, e.g. `color: rgba(0, 0, 0, 0.1);`*not*`color: rgba(0,0,0,0.1);`.
238
-
- Include a space before `!important` keyword, e.g. `padding: 10px !important;`*not*`padding: 10px!important;`.
239
-
- Property values; `@extend`, `@include`, and `@import` directives; and variable declarations should always end with a semicolon, e.g. `color: #fff;`*not*`color: #fff`.
240
-
- Parentheses should not be padded with spaces, e.g. `@include box-shadow(0 2px 2px rgba(0, 0, 0, .2));`*not*`@include box-shadow( 0 2px 2px rgba( 0, 0, 0, .2 ) );`.
241
-
- When a decimal mark is needed always include the zero, e.g. `0.25rem`*not*`.25rem`.
242
-
- Don't write trailing zeros for numeric values with a decimal point, e.g. `margin: 0.5em;`*not*`margin: 0.500em;`.
243
-
- URLs should not contain protocols or domain names, e.g. `background: url('assets/image.png');`*not*`background: url('https://example.com/assets/image.png');`.
Here we can see that `.widget__heading` must be a child of `.widget` as we have indented the `.widget__heading` rule set one level deeper than `.widget`, as it is in the DOM. This is useful information to developers that can now be gleaned just by a glance at the indentation of our rule sets.
262
351
263
352
### Declarationorder
264
353
265
-
Declarations should be ordered in relevance, **NOT**alphabetically.
354
+
Declarationsshouldbeorderedalphabetically.
266
355
267
356
Example:
268
357
269
358
```
270
359
.selector {
271
-
/* Positioning */
272
-
position: absolute;
273
-
z-index: 10;
274
-
top: 0;
275
-
right: 0;
360
+
background-color: #000;
276
361
bottom: 0;
277
-
left: 0;
278
-
279
-
/* Display & Box Model */
280
-
display: inline-block;
281
-
overflow: hidden;
282
362
box-sizing: border-box;
283
-
width: 100px;
284
-
height: 100px;
285
-
padding: 10px;
286
-
border: 10px solid #333;
287
-
margin: 10px;
288
-
289
-
/* Other */
290
-
background-color: #000;
291
363
color: #fff;
364
+
display: inline-block;
292
365
font-family: sans-serif;
293
366
font-size: 1em;
367
+
height: 100px;
294
368
text-align: right;
369
+
width: 100px;
295
370
}
296
371
```
297
372
298
-
*Comments do not need to be used to label each group of declarations like above*.
299
-
300
373
### Exceptions and slight deviations
301
374
302
375
Long, comma-separated property values—such as collections of gradients or shadows can be arranged across multiple lines in an effort to improve readability and produce more useful diffs. Each value after the first should be indented so that it starts at the same level as the first value e.g.
0 commit comments