Skip to content

Commit 85f04db

Browse files
crisbetoandrewseguin
authored andcommitted
build: set up tooling to ensure consistent prefixes for CSS classes (#13563)
Enables the `selector-class-pattern` Stylelint rule and fixes everything that wasn't consistent. Fixes #13545.
1 parent b2e2dde commit 85f04db

File tree

38 files changed

+121
-125
lines changed

38 files changed

+121
-125
lines changed

guides/creating-a-custom-form-field-control.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MyTel {
2121
}
2222

2323
@Component({
24-
selector: 'my-tel-input',
24+
selector: 'example-tel-input',
2525
template: `
2626
<div [formGroup]="parts">
2727
<input class="area" formControlName="area" size="3">
@@ -134,7 +134,7 @@ element and just generate a unique ID for it.
134134
```ts
135135
static nextId = 0;
136136

137-
@HostBinding() id = `my-tel-input-${MyTelInput.nextId++}`;
137+
@HostBinding() id = `example-tel-input-${MyTelInput.nextId++}`;
138138
```
139139

140140
#### `placeholder`
@@ -313,11 +313,11 @@ errorState = false;
313313
This property allows us to specify a unique string for the type of control in form field. The
314314
`<mat-form-field>` will add an additional class based on this type that can be used to easily apply
315315
special styles to a `<mat-form-field>` that contains a specific type of control. In this example
316-
we'll use `my-tel-input` as our control type which will result in the form field adding the class
317-
`mat-form-field-my-tel-input`.
316+
we'll use `example-tel-input` as our control type which will result in the form field adding the
317+
class `mat-form-field-example-tel-input`.
318318

319319
```ts
320-
controlType = 'my-tel-input';
320+
controlType = 'example-tel-input';
321321
```
322322

323323
#### `setDescribedByIds(ids: string[])`
@@ -356,7 +356,7 @@ do is place it inside of a `<mat-form-field>`
356356

357357
```html
358358
<mat-form-field>
359-
<my-tel-input></my-tel-input>
359+
<example-tel-input></example-tel-input>
360360
</mat-form-field>
361361
```
362362

@@ -366,7 +366,7 @@ the error state).
366366

367367
```html
368368
<mat-form-field>
369-
<my-tel-input placeholder="Phone number" required></my-tel-input>
369+
<example-tel-input placeholder="Phone number" required></example-tel-input>
370370
<mat-icon matPrefix>phone</mat-icon>
371371
<mat-hint>Include area code</mat-hint>
372372
</mat-form-field>

src/demo-app/demo-app/demo-app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class DemoApp {
114114
}
115115

116116
toggleTheme() {
117-
const darkThemeClass = 'unicorn-dark-theme';
117+
const darkThemeClass = 'demo-unicorn-dark-theme';
118118

119119
this.dark = !this.dark;
120120

src/demo-app/drag-drop/drag-drop-demo.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div>
2-
<div class="list">
2+
<div class="demo-list">
33
<h2>To do</h2>
44
<div
55
cdkDrop
@@ -15,7 +15,7 @@ <h2>To do</h2>
1515
</div>
1616
</div>
1717

18-
<div class="list">
18+
<div class="demo-list">
1919
<h2>Done</h2>
2020
<div
2121
cdkDrop
@@ -33,7 +33,7 @@ <h2>Done</h2>
3333
</div>
3434

3535
<div>
36-
<div class="list horizontal">
36+
<div class="demo-list demo-list-horizontal">
3737
<h2>Horizontal list</h2>
3838
<div
3939
cdkDrop
@@ -49,9 +49,9 @@ <h2>Horizontal list</h2>
4949
</div>
5050
</div>
5151

52-
<div class="list">
52+
<div class="demo-list">
5353
<h2>Free dragging</h2>
54-
<div cdkDrag class="free-draggable" [cdkDragLockAxis]="axisLock">Drag me around</div>
54+
<div cdkDrag class="demo-free-draggable" [cdkDragLockAxis]="axisLock">Drag me around</div>
5555
</div>
5656

5757
<div>

src/demo-app/drag-drop/drag-drop-demo.scss

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.list {
1+
.demo-list {
22
width: 500px;
33
max-width: 100%;
44
margin-bottom: 25px;
@@ -10,20 +10,20 @@
1010
margin-right: 0;
1111
margin-left: 25px;
1212
}
13+
}
1314

14-
&.horizontal {
15-
width: 1000px;
16-
margin-right: 0;
17-
margin-left: 0;
18-
}
15+
.demo-list-horizontal {
16+
width: 1000px;
17+
margin-right: 0;
18+
margin-left: 0;
1919
}
2020

2121
.cdk-drop {
2222
border: solid 1px #ccc;
2323
min-height: 60px;
2424
display: block;
2525

26-
.horizontal & {
26+
.demo-list-horizontal & {
2727
display: flex;
2828
flex-direction: row;
2929
}
@@ -42,7 +42,7 @@
4242
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
4343
}
4444

45-
.horizontal & {
45+
.demo-list-horizontal & {
4646
border: none;
4747
border-right: solid 1px #ccc;
4848
flex-grow: 1;
@@ -72,10 +72,6 @@
7272
opacity: 0;
7373
}
7474

75-
.wrapper {
76-
border: solid 1px red;
77-
}
78-
7975
.cdk-drag-handle {
8076
cursor: move;
8177

@@ -88,7 +84,7 @@ pre {
8884
white-space: normal;
8985
}
9086

91-
.free-draggable {
87+
.demo-free-draggable {
9288
width: 200px;
9389
height: 200px;
9490
border: solid 1px #ccc;

src/demo-app/screen-type/screen-type-demo.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<h2>Screen Type</h2>
22

33
<mat-grid-list cols="6" rowHeight="1:2">
4-
<mat-grid-tile [class.active]="(isHandset | async)?.matches"
4+
<mat-grid-tile [class.demo-tile-active]="(isHandset | async)?.matches"
55
colspan="2">
66
<mat-icon>smartphone</mat-icon>
77
<p>Handset</p>
88
</mat-grid-tile>
9-
<mat-grid-tile [class.active]="(isTablet | async)?.matches"
9+
<mat-grid-tile [class.demo-tile-active]="(isTablet | async)?.matches"
1010
colspan="2">
1111
<mat-icon>tablet_android</mat-icon>
1212
<p>Tablet</p>
1313
</mat-grid-tile>
14-
<mat-grid-tile [class.active]="(isWeb | async)?.matches"
14+
<mat-grid-tile [class.demo-tile-active]="(isWeb | async)?.matches"
1515
colspan="2">
1616
<mat-icon>laptop</mat-icon>
1717
<p>Web</p>
1818
</mat-grid-tile>
19-
<mat-grid-tile [class.active]="(isPortrait | async)?.matches"
19+
<mat-grid-tile [class.demo-tile-active]="(isPortrait | async)?.matches"
2020
colspan="3">
2121
<mat-icon>stay_current_portrait</mat-icon>
2222
<p>Portrait</p>
2323
</mat-grid-tile>
24-
<mat-grid-tile [class.active]="(isLandscape | async)?.matches"
24+
<mat-grid-tile [class.demo-tile-active]="(isLandscape | async)?.matches"
2525
colspan="3">
2626
<mat-icon>stay_current_landscape</mat-icon>
2727
<p>Landscape</p>

src/demo-app/screen-type/screen-type-demo.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
.mat-figure {
1111
flex-direction: column;
1212
}
13+
}
1314

14-
&.active {
15-
background: rgba(0, 0, 0, 0.12);
16-
}
15+
.demo-tile-active {
16+
background: rgba(0, 0, 0, 0.12);
1717
}
1818

1919
h2 {

src/demo-app/theme.scss

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ $dark-theme: mat-dark-theme($dark-primary, $dark-accent, $dark-warn);
2424

2525
// Include the alternative theme styles inside of a block with a CSS class. You can make this
2626
// CSS class whatever you want. In this example, any component inside of an element with
27-
// `.unicorn-dark-theme` will be affected by this alternate dark theme instead of the default theme.
28-
.unicorn-dark-theme {
27+
// `.demo-unicorn-dark-theme` will be affected by this alternate dark theme instead of the
28+
// default theme.
29+
.demo-unicorn-dark-theme {
2930
@include angular-material-theme($dark-theme);
3031
}

src/e2e-app/block-scroll-strategy/block-scroll-strategy-e2e.css

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
.spacer {
1+
.demo-spacer {
22
background: #3f51b5;
33
margin-bottom: 10px;
44
}
55

6-
.spacer.vertical {
6+
.demo-spacer-vertical {
77
width: 100px;
88
height: 3000px;
99
}
1010

11-
.spacer.horizontal {
11+
.demo-spacer-horizontal {
1212
width: 3000px;
1313
height: 100px;
1414
}
1515

16-
.scroller {
16+
.demo-scroller {
1717
width: 100px;
1818
height: 100px;
1919
overflow: auto;
@@ -22,7 +22,7 @@
2222
left: 200px;
2323
}
2424

25-
.scroller-spacer {
25+
.demo-scroller-spacer {
2626
width: 200px;
2727
height: 200px;
2828
background: #ff4081;

src/e2e-app/block-scroll-strategy/block-scroll-strategy-e2e.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<button id="enable" (click)="scrollStrategy.enable()">Enable scroll blocking</button>
33
<button id="disable" (click)="scrollStrategy.disable()">Disable scroll blocking</button>
44
</p>
5-
<div class="spacer vertical"></div>
5+
<div class="demo-spacer demo-spacer-vertical"></div>
66
<!-- this one needs a tabindex so protractor can trigger key presses inside it -->
7-
<div class="scroller" id="scroller" tabindex="-1">
8-
<div class="scroller-spacer"></div>
7+
<div class="demo-scroller" id="scroller" tabindex="-1">
8+
<div class="demo-scroller-spacer"></div>
99
</div>
10-
<div class="spacer horizontal"></div>
10+
<div class="demo-spacer demo-spacer-horizontal"></div>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.button-row button,
2-
.button-row a {
1+
.example-button-row button,
2+
.example-button-row a {
33
margin-right: 8px;
44
}

src/material-examples/button-types/button-types-example.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h3>Basic Buttons</h3>
2-
<div class="button-row">
2+
<div class="example-button-row">
33
<button mat-button>Basic</button>
44
<button mat-button color="primary">Primary</button>
55
<button mat-button color="accent">Accent</button>
@@ -9,7 +9,7 @@ <h3>Basic Buttons</h3>
99
</div>
1010

1111
<h3>Raised Buttons</h3>
12-
<div class="button-row">
12+
<div class="example-button-row">
1313
<button mat-raised-button>Basic</button>
1414
<button mat-raised-button color="primary">Primary</button>
1515
<button mat-raised-button color="accent">Accent</button>
@@ -19,7 +19,7 @@ <h3>Raised Buttons</h3>
1919
</div>
2020

2121
<h3>Stroked Buttons</h3>
22-
<div class="button-row">
22+
<div class="example-button-row">
2323
<button mat-stroked-button>Basic</button>
2424
<button mat-stroked-button color="primary">Primary</button>
2525
<button mat-stroked-button color="accent">Accent</button>
@@ -29,7 +29,7 @@ <h3>Stroked Buttons</h3>
2929
</div>
3030

3131
<h3>Flat Buttons</h3>
32-
<div class="button-row">
32+
<div class="example-button-row">
3333
<button mat-flat-button>Basic</button>
3434
<button mat-flat-button color="primary">Primary</button>
3535
<button mat-flat-button color="accent">Accent</button>
@@ -39,7 +39,7 @@ <h3>Flat Buttons</h3>
3939
</div>
4040

4141
<h3>Icon Buttons</h3>
42-
<div class="button-row">
42+
<div class="example-button-row">
4343
<button mat-icon-button>
4444
<mat-icon aria-label="Example icon-button with a heart icon">favorite</mat-icon>
4545
</button>
@@ -58,7 +58,7 @@ <h3>Icon Buttons</h3>
5858
</div>
5959

6060
<h3>Fab Buttons</h3>
61-
<div class="button-row">
61+
<div class="example-button-row">
6262
<button mat-fab>Basic</button>
6363
<button mat-fab color="primary">Primary</button>
6464
<button mat-fab color="accent">Accent</button>
@@ -71,7 +71,7 @@ <h3>Fab Buttons</h3>
7171
</div>
7272

7373
<h3>Mini Fab Buttons</h3>
74-
<div class="button-row">
74+
<div class="example-button-row">
7575
<button mat-mini-fab>Basic</button>
7676
<button mat-mini-fab color="primary">Primary</button>
7777
<button mat-mini-fab color="accent">Accent</button>
@@ -81,4 +81,4 @@ <h3>Mini Fab Buttons</h3>
8181
<mat-icon aria-label="Example icon-button with a heart icon">favorite</mat-icon>
8282
</button>
8383
<a mat-mini-fab routerLink=".">Link</a>
84-
</div>
84+
</div>

src/material-examples/cdk-drag-drop-axis-lock/cdk-drag-drop-axis-lock-example.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.box {
1+
.example-box {
22
width: 200px;
33
height: 200px;
44
border: solid 1px #ccc;
@@ -19,7 +19,7 @@
1919
0 1px 5px 0 rgba(0, 0, 0, 0.12);
2020
}
2121

22-
.box:active {
22+
.example-box:active {
2323
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
2424
0 8px 10px 1px rgba(0, 0, 0, 0.14),
2525
0 3px 14px 2px rgba(0, 0, 0, 0.12);
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<div class="box" cdkDragLockAxis="y" cdkDrag>
1+
<div class="example-box" cdkDragLockAxis="y" cdkDrag>
22
I can only be dragged up/down
33
</div>
44

5-
<div class="box" cdkDragLockAxis="x" cdkDrag>
5+
<div class="example-box" cdkDragLockAxis="x" cdkDrag>
66
I can only be dragged left/right
77
</div>

0 commit comments

Comments
 (0)