Skip to content

Commit 2671e56

Browse files
amysortommalerba
authored andcommitted
build: add form-field example to mdc-migration integration test
1 parent 09d034b commit 2671e56

File tree

14 files changed

+127
-0
lines changed

14 files changed

+127
-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
@@ -1,4 +1,5 @@
11
<chips-example></chips-example>
2+
<form-field-example></form-field-example>
23
<input-example></input-example>
34
<menu-example></menu-example>
45
<paginator-example></paginator-example>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ 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';
1414
import {ChipsComponent} from './components/chips/chips.component';
15+
import {FormFieldComponent} from './components/form-field/form-field.component';
1516
import {InputComponent} from './components/input/input.component';
1617
import {MenuComponent} from './components/menu/menu.component';
1718
import {PaginatorComponent} from './components/paginator/paginator.component';
@@ -22,6 +23,7 @@ import {ProgressBarComponent} from './components/progress-bar/progress-bar.compo
2223
declarations: [
2324
AppComponent,
2425
ChipsComponent,
26+
FormFieldComponent,
2527
InputComponent,
2628
MenuComponent,
2729
PaginatorComponent,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h2>Form field example</h2>
2+
<mat-form-field hintLabel="Max 10 characters" appearance="fill">
3+
<mat-label>Enter some input</mat-label>
4+
<input matInput #input maxlength="10" placeholder="Ex. Nougat">
5+
<mat-hint align="end">{{input.value?.length || 0}}/10</mat-hint>
6+
</mat-form-field>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.mat-mdc-form-field {
2+
padding: 4px;
3+
4+
.mat-mdc-form-field-hint {
5+
color: darkred;
6+
}
7+
}
8+
9+
10+
/* TODO: The following rule targets internal classes of form-field that may no longer apply for the MDC version. */
11+
12+
.mat-mdc-form-field
13+
.mat-form-field-wrapper {
14+
padding: 16px;
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {ComponentFixture, TestBed} from '@angular/core/testing';
2+
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
3+
import {MatFormFieldModule} from '@angular/material/form-field';
4+
import {MatInputModule} from '@angular/material/input';
5+
import {FormFieldComponent} from './form-field.component';
6+
7+
describe('FormFieldComponent', () => {
8+
let component: FormFieldComponent;
9+
let fixture: ComponentFixture<FormFieldComponent>;
10+
11+
beforeEach(async () => {
12+
await TestBed.configureTestingModule({
13+
imports: [BrowserAnimationsModule, MatFormFieldModule, MatInputModule],
14+
declarations: [FormFieldComponent],
15+
}).compileComponents();
16+
});
17+
18+
beforeEach(() => {
19+
fixture = TestBed.createComponent(FormFieldComponent);
20+
component = fixture.componentInstance;
21+
fixture.detectChanges();
22+
});
23+
24+
it('should create', () => {
25+
expect(component).toBeTruthy();
26+
});
27+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {Component, OnInit} from '@angular/core';
2+
3+
@Component({
4+
selector: 'form-field-example',
5+
templateUrl: './form-field.component.html',
6+
styleUrls: ['./form-field.component.scss'],
7+
})
8+
export class FormFieldComponent implements OnInit {
9+
constructor() {}
10+
11+
ngOnInit(): void {}
12+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ $sample-project-theme: mat.define-light-theme((
3030

3131
@include mat.mdc-chips-theme($sample-project-theme);
3232
@include mat.mdc-chips-typography($sample-project-theme);
33+
@include mat.mdc-form-field-theme($sample-project-theme);
34+
@include mat.mdc-form-field-typography($sample-project-theme);
3335
@include mat.mdc-menu-theme($sample-project-theme);
3436
@include mat.mdc-menu-typography($sample-project-theme);
3537
@include mat.mdc-input-theme($sample-project-theme);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<chips-example></chips-example>
2+
<form-field-example></form-field-example>
23
<input-example></input-example>
34
<menu-example></menu-example>
45
<paginator-example></paginator-example>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {MatPaginatorModule} from '@angular/material/paginator';
1212
import {MatProgressBarModule} from '@angular/material/progress-bar';
1313
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
1414
import {ChipsComponent} from './components/chips/chips.component';
15+
import {FormFieldComponent} from './components/form-field/form-field.component';
1516
import {InputComponent} from './components/input/input.component';
1617
import {MenuComponent} from './components/menu/menu.component';
1718
import {PaginatorComponent} from './components/paginator/paginator.component';
@@ -22,6 +23,7 @@ import {ProgressBarComponent} from './components/progress-bar/progress-bar.compo
2223
declarations: [
2324
AppComponent,
2425
ChipsComponent,
26+
FormFieldComponent,
2527
InputComponent,
2628
MenuComponent,
2729
PaginatorComponent,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h2>Form field example</h2>
2+
<mat-form-field hintLabel="Max 10 characters" appearance="fill">
3+
<mat-label>Enter some input</mat-label>
4+
<input matInput #input maxlength="10" placeholder="Ex. Nougat">
5+
<mat-hint align="end">{{input.value?.length || 0}}/10</mat-hint>
6+
</mat-form-field>

0 commit comments

Comments
 (0)