Skip to content

Commit e826c54

Browse files
amysortommalerba
authored andcommitted
build: add select example to mdc-migration integration test
1 parent 2671e56 commit e826c54

File tree

14 files changed

+157
-0
lines changed

14 files changed

+157
-0
lines changed

integration/mdc-migration/golden/src/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
<paginator-example></paginator-example>
66
<progress-bar-example></progress-bar-example>
77
<progress-spinner-example></progress-spinner-example>
8+
<select-example></select-example>

integration/mdc-migration/golden/src/app/app.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import {MatMenuModule} from '@angular/material-experimental/mdc-menu';
1111
import {MatPaginatorModule} from '@angular/material-experimental/mdc-paginator';
1212
import {MatProgressBarModule} from '@angular/material-experimental/mdc-progress-bar';
1313
import {MatProgressSpinnerModule} from '@angular/material-experimental/mdc-progress-spinner';
14+
import {MatSelectModule} from '@angular/material-experimental/mdc-select';
1415
import {ChipsComponent} from './components/chips/chips.component';
1516
import {FormFieldComponent} from './components/form-field/form-field.component';
1617
import {InputComponent} from './components/input/input.component';
1718
import {MenuComponent} from './components/menu/menu.component';
1819
import {PaginatorComponent} from './components/paginator/paginator.component';
1920
import {ProgressSpinnerComponent} from './components/progress-spinner/progress-spinner.component';
2021
import {ProgressBarComponent} from './components/progress-bar/progress-bar.component';
22+
import {SelectComponent} from './components/select/select.component';
2123

2224
@NgModule({
2325
declarations: [
@@ -29,6 +31,7 @@ import {ProgressBarComponent} from './components/progress-bar/progress-bar.compo
2931
PaginatorComponent,
3032
ProgressBarComponent,
3133
ProgressSpinnerComponent,
34+
SelectComponent,
3235
],
3336
imports: [
3437
BrowserModule,
@@ -41,6 +44,7 @@ import {ProgressBarComponent} from './components/progress-bar/progress-bar.compo
4144
MatPaginatorModule,
4245
MatProgressBarModule,
4346
MatProgressSpinnerModule,
47+
MatSelectModule,
4448
],
4549
providers: [],
4650
bootstrap: [AppComponent],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<h2>Select example</h2>
2+
<mat-form-field class="select-example" appearance="fill">
3+
<mat-label>Favorite food</mat-label>
4+
<mat-select>
5+
<mat-option *ngFor="let food of foods" [value]="food.value">
6+
{{food.viewValue}}
7+
</mat-option>
8+
</mat-select>
9+
</mat-form-field>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.mat-mdc-select {
2+
padding: 4px;
3+
}
4+
5+
/* TODO: The following rule targets internal classes of select that may no longer apply for the MDC version. */
6+
7+
.select-example ::ng-deep.mat-select-value {
8+
color: darkblue;
9+
}
10+
11+
12+
.mat-mdc-select-panel {
13+
padding: 4px;
14+
15+
.mat-mdc-option {
16+
padding: 4px;
17+
}
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {ComponentFixture, TestBed} from '@angular/core/testing';
2+
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
3+
import {MatSelectModule} from '@angular/material/select';
4+
import {SelectComponent} from './select.component';
5+
6+
describe('SelectComponent', () => {
7+
let component: SelectComponent;
8+
let fixture: ComponentFixture<SelectComponent>;
9+
10+
beforeEach(async () => {
11+
await TestBed.configureTestingModule({
12+
imports: [BrowserAnimationsModule, MatSelectModule],
13+
declarations: [SelectComponent],
14+
}).compileComponents();
15+
});
16+
17+
beforeEach(() => {
18+
fixture = TestBed.createComponent(SelectComponent);
19+
component = fixture.componentInstance;
20+
fixture.detectChanges();
21+
});
22+
23+
it('should create', () => {
24+
expect(component).toBeTruthy();
25+
});
26+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {Component} from '@angular/core';
2+
3+
interface Food {
4+
value: string;
5+
viewValue: string;
6+
}
7+
8+
@Component({
9+
selector: 'select-example',
10+
templateUrl: './select.component.html',
11+
styleUrls: ['./select.component.scss'],
12+
})
13+
export class SelectComponent {
14+
foods: Food[] = [
15+
{value: 'steak-0', viewValue: 'Steak'},
16+
{value: 'pizza-1', viewValue: 'Pizza'},
17+
{value: 'tacos-2', viewValue: 'Tacos'},
18+
];
19+
}

integration/mdc-migration/golden/src/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ $sample-project-theme: mat.define-light-theme((
4242
@include mat.mdc-progress-bar-typography($sample-project-theme);
4343
@include mat.mdc-progress-spinner-theme($sample-project-theme);
4444
@include mat.mdc-progress-spinner-typography($sample-project-theme);
45+
@include mat.mdc-select-theme($sample-project-theme);
46+
@include mat.mdc-select-typography($sample-project-theme);
47+
@include mat.mdc-core-theme($sample-project-theme);
48+
@include mat.mdc-core-typography($sample-project-theme);
4549

4650
/* You can add global styles to this file, and also import other style files */
4751

integration/mdc-migration/sample-project/src/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
<paginator-example></paginator-example>
66
<progress-bar-example></progress-bar-example>
77
<progress-spinner-example></progress-spinner-example>
8+
<select-example></select-example>

integration/mdc-migration/sample-project/src/app/app.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import {MatMenuModule} from '@angular/material/menu';
1111
import {MatPaginatorModule} from '@angular/material/paginator';
1212
import {MatProgressBarModule} from '@angular/material/progress-bar';
1313
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
14+
import {MatSelectModule} from '@angular/material/select';
1415
import {ChipsComponent} from './components/chips/chips.component';
1516
import {FormFieldComponent} from './components/form-field/form-field.component';
1617
import {InputComponent} from './components/input/input.component';
1718
import {MenuComponent} from './components/menu/menu.component';
1819
import {PaginatorComponent} from './components/paginator/paginator.component';
1920
import {ProgressSpinnerComponent} from './components/progress-spinner/progress-spinner.component';
2021
import {ProgressBarComponent} from './components/progress-bar/progress-bar.component';
22+
import {SelectComponent} from './components/select/select.component';
2123

2224
@NgModule({
2325
declarations: [
@@ -29,6 +31,7 @@ import {ProgressBarComponent} from './components/progress-bar/progress-bar.compo
2931
PaginatorComponent,
3032
ProgressBarComponent,
3133
ProgressSpinnerComponent,
34+
SelectComponent,
3235
],
3336
imports: [
3437
BrowserModule,
@@ -41,6 +44,7 @@ import {ProgressBarComponent} from './components/progress-bar/progress-bar.compo
4144
MatPaginatorModule,
4245
MatProgressBarModule,
4346
MatProgressSpinnerModule,
47+
MatSelectModule,
4448
],
4549
providers: [],
4650
bootstrap: [AppComponent],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<h2>Select example</h2>
2+
<mat-form-field class="select-example" appearance="fill">
3+
<mat-label>Favorite food</mat-label>
4+
<mat-select>
5+
<mat-option *ngFor="let food of foods" [value]="food.value">
6+
{{food.viewValue}}
7+
</mat-option>
8+
</mat-select>
9+
</mat-form-field>

0 commit comments

Comments
 (0)