Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 199f28c

Browse files
committed
Merge pull request #49 from mobify/extending-order
Extending order documentation added
2 parents 2a61d8c + a5791da commit 199f28c

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2.3.5
2+
- Add Sass documentation about placeholders and `@extends`
13
2.3.4
24
- Patch CSSComb and scss-lint rules for compatibility
35
- LeadingZero aligned to enabled

css/sass-best-practices/readme.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ As mentioned earlier, we use [Sass](http://sass-lang.com/) using the `SCSS` synt
1111
* [`@extends`](#extends)
1212
* [Pitfalls](#pitfalls)
1313
* [Workaround](#workaround)
14-
* [Caveats](#caveats)
14+
* [Declaration Order And Placeholder Class Names](#declaration-order-and-placeholder-class-names)
1515
* [Genuine Usecases](#genuine-usecases)
1616
* [Filename Naming Convention](#filename-naming-convention)
1717
* [Note on Partials](#note-on-partials)
@@ -123,6 +123,46 @@ Also notice how we still included the original `.c-button` class in the SCSS. Af
123123

124124
This technique is described in detail in Chris Lamb's article [Mastering Sass Extends and Placeholders](http://8gramgorilla.com/mastering-sass-extends-and-placeholders/).
125125

126+
### Declaration Order And Placeholder Class Names
127+
128+
The placeholder class always goes after the regular selectors. In other words, make the placeholder class the last selector in a chain of comma separated selectors.
129+
130+
In most cases, the placeholder class is named after the element or component class it is related to:
131+
132+
```
133+
h1,
134+
%h1 {
135+
...
136+
}
137+
138+
.c-component,
139+
%c-component {
140+
...
141+
}
142+
```
143+
144+
In some cases the placeholder class can be named more generally if it shares styles across multiple selectors (see more detailed example in the next section [Genuine Usecases](#genuine-usecases)):
145+
146+
```
147+
h1,
148+
h2,
149+
h3,
150+
h4,
151+
%heading {
152+
font-family: sans-serif;
153+
text-transform: uppercase;
154+
}
155+
```
156+
157+
If the placeholder selector is for a modifier class, use the following name convention:
158+
159+
```
160+
.c-component.c--modifier,
161+
%c-component--modifier {
162+
...
163+
}
164+
```
165+
126166

127167
### Genuine Usecases
128168

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobify-code-style",
3-
"version": "2.3.4",
3+
"version": "2.3.5",
44
"description": "Code style guide and linting tools for Mobify",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)