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

Commit 9be5c6b

Browse files
committed
updating commenting suggestions and merging method 1 and 2
1 parent 09f6c9d commit 9be5c6b

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

css/class-naming-conventions/readme.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ These are used to modify components or subcomponents. They are always chained to
112112

113113
### Component modifiers that affect subcomponents
114114

115-
Sometimes a component modifier will affect its sub-components. There are a few methods you can use to accomplish this. Try to pick one and stick to it throughout the project, adding comments as needed.
115+
Sometimes a component modifier will affect its sub-components. There are several methods you can use to accomplish this. As much as possible, stick to one method in your project.
116116

117117
```html
118118
<div class="c-blog-post c--featured">
@@ -124,10 +124,10 @@ Sometimes a component modifier will affect its sub-components. There are a few m
124124
```
125125

126126

127-
#### 1. Nested inside the component
127+
#### 1. Styles grouped with modifier
128128
Nest the `.c-component__sub-component` elements inside the `.c-component` SCSS.
129129

130-
This method works well when a modifier requires simple changes to a small number of sub-components.
130+
This method allows you to quickly update or edit the styles for all elements affected by a modifier.
131131

132132
```scss
133133
.c-blog-post {
@@ -141,11 +141,8 @@ This method works well when a modifier requires simple changes to a small number
141141
}
142142
```
143143

144+
*or*
144145

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.
149146

150147
```scss
151148
.c-blog-post.c--featured {
@@ -157,23 +154,22 @@ This method works especially well when a component has multiple modifiers or sta
157154
}
158155
```
159156

160-
When using the above methods in larger files, add a comment to the `.c-component__sub-component` like so:
157+
In larger files, adding a comment in the `.c-component__sub-component` notes can be helpful:
161158
```scss
162159
// Blog Post Title
163160
// ---
164161
//
165-
// Modifier styles can be found in:
166-
// .c-blog-post.c--featured
162+
// Modified by .c-blog-post.c--featured
167163

168164
.c-blog-post__title {
169165
...
170166
}
171167
```
172168

173-
#### 3. Nested inside the sub-component
174-
Nest the modifier code inside the subcomponent using `.c-component.c--modifier &`.
169+
#### 2. Styles grouped with sub-component
170+
Nest the modifier code inside the sub-component using `.c-component.c--modifier &`.
175171

176-
This method works well when a root-level modifier affects multiple sub-components, or when you are working with complicated/intricate sub-components.
172+
This method makes it easier to visualize the differences between a sub-component and its modified states.
177173

178174
```scss
179175
.c-blog-post__title {
@@ -185,7 +181,7 @@ This method works well when a root-level modifier affects multiple sub-component
185181
}
186182
```
187183

188-
When using the above method in larger files, add a comment to the `.c-component` like so:
184+
In larger files, adding a comment in the `.c--modifier` notes can be helpful:
189185
```scss
190186
// Blog Post
191187
// ===
@@ -195,8 +191,7 @@ When using the above method in larger files, add a comment to the `.c-component`
195191
// Featured Post
196192
// ---
197193
//
198-
// Also modifies:
199-
// .c-blog-post__title
194+
// Also modifies .c-blog-post__title
200195

201196
.c--featured {
202197
...

0 commit comments

Comments
 (0)