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

Commit 09f6c9d

Browse files
committed
updating with suggestions and scss hinting
1 parent b4ec2e2 commit 09f6c9d

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

css/class-naming-conventions/readme.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ Sometimes a component modifier will affect its sub-components. There are a few m
124124
```
125125

126126

127-
#### Nested inside the component
128-
Nest the `c-component__sub-component` elements inside the `c-component` SCSS.
127+
#### 1. Nested inside the component
128+
Nest the `.c-component__sub-component` elements inside the `.c-component` SCSS.
129+
130+
This method works well when a modifier requires simple changes to a small number of sub-components.
129131

130132
```scss
131133
.c-blog-post {
@@ -137,11 +139,13 @@ Nest the `c-component__sub-component` elements inside the `c-component` SCSS.
137139
}
138140
}
139141
}
140-
```
142+
```
141143

142144

143-
#### Below the component as a selector chain
144-
Use a selector chain with `.c-component.c--modifier`, and nest the `c-component__sub-component` elements within it.
145+
#### 2. Root level as a selector chain
146+
Use a selector chain with `.c-component.c--modifier`, and nest the `.c-component__sub-component` elements within it.
147+
148+
This method works especially well when a component has multiple modifiers or state classes that can be coupled with it.
145149

146150
```scss
147151
.c-blog-post.c--featured {
@@ -153,8 +157,8 @@ Use a selector chain with `.c-component.c--modifier`, and nest the `c-component_
153157
}
154158
```
155159

156-
When using the above methods in larger files, add a comment to the `c-component__sub-component` like so:
157-
```
160+
When using the above methods in larger files, add a comment to the `.c-component__sub-component` like so:
161+
```scss
158162
// Blog Post Title
159163
// ---
160164
//
@@ -166,9 +170,11 @@ When using the above methods in larger files, add a comment to the `c-component_
166170
}
167171
```
168172

169-
#### Nested inside the sub-component
173+
#### 3. Nested inside the sub-component
170174
Nest the modifier code inside the subcomponent using `.c-component.c--modifier &`.
171175

176+
This method works well when a root-level modifier affects multiple sub-components, or when you are working with complicated/intricate sub-components.
177+
172178
```scss
173179
.c-blog-post__title {
174180
...
@@ -179,8 +185,8 @@ Nest the modifier code inside the subcomponent using `.c-component.c--modifier &
179185
}
180186
```
181187

182-
When using the above method in larger files, add a comment to the `c-component` like so:
183-
```
188+
When using the above method in larger files, add a comment to the `.c-component` like so:
189+
```scss
184190
// Blog Post
185191
// ===
186192
.c-blog-post {

0 commit comments

Comments
 (0)