Skip to content

feat(material/button): Switch button implementation to use MDC #25381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/src/material/badge/** @jelbourn
/src/material/bottom-sheet/** @jelbourn @crisbeto
/src/material/button-toggle/** @andrewseguin
/src/material/button/** @andrewseguin
/src/material/legacy-button/** @andrewseguin
/src/material/legacy-card/** @andrewseguin
/src/material/legacy-checkbox/** @andrewseguin @devversion
/src/material/legacy-chips/** @andrewseguin
Expand Down Expand Up @@ -111,7 +111,7 @@
/src/material-experimental/* @andrewseguin
/src/material-experimental/column-resize/** @andrewseguin
/src/material/autocomplete/** @crisbeto
/src/material-experimental/mdc-button/** @andrewseguin
/src/material/button/** @andrewseguin
/src/material/card/** @mmalerba
/src/material/checkbox/** @mmalerba
/src/material/chips/** @mmalerba @crisbeto
Expand Down Expand Up @@ -319,7 +319,7 @@
/tools/public_api_guard/material/badge** @andrewseguin
/tools/public_api_guard/material/bottom-sheet** @andrewseguin @crisbeto
/tools/public_api_guard/material/button-toggle** @andrewseguin
/tools/public_api_guard/material/button** @andrewseguin
/tools/public_api_guard/material/legacy-button** @andrewseguin
/tools/public_api_guard/material/legacy-card** @andrewseguin
/tools/public_api_guard/material/legacy-checkbox** @andrewseguin @devversion
/tools/public_api_guard/material/chips** @andrewseguin
Expand Down
4 changes: 2 additions & 2 deletions .ng-dev/commit-message.mts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const commitMessage: CommitMessageConfig = {
'cdk/tree',
'google-maps',
'material-experimental/column-resize',
'material-experimental/mdc-button',
'material/button',
'material/card',
'material/checkbox',
'material-experimental/mdc-core',
Expand All @@ -65,7 +65,7 @@ export const commitMessage: CommitMessageConfig = {
'material/legacy-autocomplete',
'material/badge',
'material/bottom-sheet',
'material/button',
'material/legacy-button',
'material/button-toggle',
'material/legacy-card',
'material/legacy-checkbox',
Expand Down
4 changes: 2 additions & 2 deletions integration/yarn-pnp-compat/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';

import {AppComponent} from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, BrowserAnimationsModule, MatButtonModule],
imports: [BrowserModule, BrowserAnimationsModule, MatLegacyButtonModule],
providers: [],
bootstrap: [AppComponent],
})
Expand Down
2 changes: 1 addition & 1 deletion src/components-examples/cdk/text-field/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ng_module(
]),
deps = [
"//src/cdk/text-field",
"//src/material/button",
"//src/material/legacy-button",
"//src/material/legacy-input",
"//src/material/legacy-select",
],
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/cdk/text-field/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {TextFieldModule} from '@angular/cdk/text-field';
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatLegacyInputModule} from '@angular/material/legacy-input';
import {MatLegacySelectModule} from '@angular/material/legacy-select';
import {TextFieldAutofillDirectiveExample} from './text-field-autofill-directive/text-field-autofill-directive-example';
Expand All @@ -24,7 +24,7 @@ const EXAMPLES = [
imports: [
CommonModule,
TextFieldModule,
MatButtonModule,
MatLegacyButtonModule,
MatLegacyInputModule,
MatLegacySelectModule,
],
Expand Down
2 changes: 1 addition & 1 deletion src/components-examples/cdk/tree/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ng_module(
]),
deps = [
"//src/cdk/tree",
"//src/material/button",
"//src/material/icon",
"//src/material/legacy-button",
],
)

Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/cdk/tree/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CdkTreeModule} from '@angular/cdk/tree';
import {NgModule} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatIconModule} from '@angular/material/icon';
import {CdkTreeFlatExample} from './cdk-tree-flat/cdk-tree-flat-example';
import {CdkTreeNestedExample} from './cdk-tree-nested/cdk-tree-nested-example';
Expand All @@ -10,7 +10,7 @@ export {CdkTreeFlatExample, CdkTreeNestedExample};
const EXAMPLES = [CdkTreeFlatExample, CdkTreeNestedExample];

@NgModule({
imports: [CdkTreeModule, MatButtonModule, MatIconModule],
imports: [CdkTreeModule, MatLegacyButtonModule, MatIconModule],
declarations: EXAMPLES,
exports: EXAMPLES,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ng_module(
"**/*.css",
]),
deps = [
"//src/material-experimental/mdc-button",
"//src/material/button",
"//src/material/card",
],
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgModule} from '@angular/core';
import {MatButtonModule} from '@angular/material-experimental/mdc-button';
import {MatButtonModule} from '@angular/material/button';
import {MatCardModule} from '@angular/material/card';
import {MdcCardFancyExample} from './mdc-card-fancy/mdc-card-fancy-example';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ ng_module(
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material-experimental/mdc-table",
"//src/material/button",
"//src/material/button-toggle",
"//src/material/core",
"//src/material/icon",
"//src/material/legacy-button",
"//src/material/legacy-checkbox",
"//src/material/legacy-input",
"//src/material/paginator",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {MatRippleModule} from '@angular/material/core';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatIconModule} from '@angular/material/icon';
Expand Down Expand Up @@ -118,7 +118,7 @@ const EXAMPLES = [
@NgModule({
imports: [
CommonModule,
MatButtonModule,
MatLegacyButtonModule,
MatButtonToggleModule,
MatLegacyCheckboxModule,
MatIconModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ng_module(
]),
deps = [
"//src/material-experimental/popover-edit",
"//src/material/button",
"//src/material/icon",
"//src/material/legacy-button",
"//src/material/legacy-checkbox",
"//src/material/legacy-input",
"//src/material/legacy-list",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {MatPopoverEditModule} from '@angular/material-experimental/popover-edit';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatIconModule} from '@angular/material/icon';
import {MatLegacyInputModule} from '@angular/material/legacy-input';
Expand Down Expand Up @@ -31,7 +31,7 @@ const EXAMPLES = [
@NgModule({
imports: [
CommonModule,
MatButtonModule,
MatLegacyButtonModule,
MatLegacyCheckboxModule,
MatIconModule,
MatLegacyInputModule,
Expand Down
2 changes: 1 addition & 1 deletion src/components-examples/material/badge/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ng_module(
"//src/cdk/testing/testbed",
"//src/material/badge",
"//src/material/badge/testing",
"//src/material/button",
"//src/material/icon",
"//src/material/legacy-button",
"@npm//@angular/platform-browser",
"@npm//@angular/platform-browser-dynamic",
"@npm//@types/jasmine",
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/material/badge/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {NgModule} from '@angular/core';
import {MatBadgeModule} from '@angular/material/badge';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatIconModule} from '@angular/material/icon';
import {BadgeOverviewExample} from './badge-overview/badge-overview-example';
import {BadgeHarnessExample} from './badge-harness/badge-harness-example';
Expand All @@ -10,7 +10,7 @@ export {BadgeOverviewExample, BadgeHarnessExample};
const EXAMPLES = [BadgeOverviewExample, BadgeHarnessExample];

@NgModule({
imports: [MatBadgeModule, MatButtonModule, MatIconModule],
imports: [MatBadgeModule, MatLegacyButtonModule, MatIconModule],
declarations: EXAMPLES,
exports: EXAMPLES,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ng_module(
"//src/cdk/testing/testbed",
"//src/material/bottom-sheet",
"//src/material/bottom-sheet/testing",
"//src/material/button",
"//src/material/legacy-button",
"//src/material/legacy-list",
"@npm//@angular/platform-browser",
"@npm//@angular/platform-browser-dynamic",
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/material/bottom-sheet/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {NgModule} from '@angular/core';
import {MatBottomSheetModule} from '@angular/material/bottom-sheet';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatLegacyListModule} from '@angular/material/legacy-list';
import {
BottomSheetOverviewExample,
Expand All @@ -17,7 +17,7 @@ const EXAMPLES = [
];

@NgModule({
imports: [MatBottomSheetModule, MatButtonModule, MatLegacyListModule],
imports: [MatBottomSheetModule, MatLegacyButtonModule, MatLegacyListModule],
declarations: EXAMPLES,
exports: EXAMPLES,
})
Expand Down
8 changes: 4 additions & 4 deletions src/components-examples/material/button/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ ng_module(
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button",
"//src/material/button/testing",
"//src/material/divider",
"//src/material/icon",
"//src/material/legacy-button",
"//src/material/legacy-button/testing",
"@npm//@angular/platform-browser",
"@npm//@angular/platform-browser-dynamic",
"@npm//@types/jasmine",
Expand All @@ -41,8 +41,8 @@ ng_test_library(
":button",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button",
"//src/material/button/testing",
"//src/material/legacy-button",
"//src/material/legacy-button/testing",
"@npm//@angular/platform-browser-dynamic",
],
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatButtonHarness} from '@angular/material/button/testing';
import {MatLegacyButtonHarness} from '@angular/material/legacy-button/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {ButtonHarnessExample} from './button-harness-example';

describe('ButtonHarnessExample', () => {
Expand All @@ -11,7 +11,7 @@ describe('ButtonHarnessExample', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MatButtonModule],
imports: [MatLegacyButtonModule],
declarations: [ButtonHarnessExample],
}).compileComponents();
fixture = TestBed.createComponent(ButtonHarnessExample);
Expand All @@ -20,18 +20,20 @@ describe('ButtonHarnessExample', () => {
});

it('should load all button harnesses', async () => {
const buttons = await loader.getAllHarnesses(MatButtonHarness);
const buttons = await loader.getAllHarnesses(MatLegacyButtonHarness);
expect(buttons.length).toBe(1);
});

it('should load button with exact text', async () => {
const buttons = await loader.getAllHarnesses(MatButtonHarness.with({text: 'Basic button'}));
const buttons = await loader.getAllHarnesses(
MatLegacyButtonHarness.with({text: 'Basic button'}),
);
expect(buttons.length).toBe(1);
expect(await buttons[0].getText()).toBe('Basic button');
});

it('should click a button', async () => {
const button = await loader.getHarness(MatButtonHarness.with({text: 'Basic button'}));
const button = await loader.getHarness(MatLegacyButtonHarness.with({text: 'Basic button'}));
expect(fixture.componentInstance.clicked).toBe(false);
await button.click();
expect(fixture.componentInstance.clicked).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component} from '@angular/core';

/**
* @title Testing with MatButtonHarness
* @title Testing with MatLegacyButtonHarness
*/
@Component({
selector: 'button-harness-example',
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/material/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgModule} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatDividerModule} from '@angular/material/divider';
import {MatIconModule} from '@angular/material/icon';
import {ButtonOverviewExample} from './button-overview/button-overview-example';
Expand All @@ -11,7 +11,7 @@ export {ButtonOverviewExample, ButtonTypesExample, ButtonHarnessExample};
const EXAMPLES = [ButtonOverviewExample, ButtonTypesExample, ButtonHarnessExample];

@NgModule({
imports: [MatButtonModule, MatDividerModule, MatIconModule],
imports: [MatLegacyButtonModule, MatDividerModule, MatIconModule],
declarations: EXAMPLES,
exports: EXAMPLES,
})
Expand Down
6 changes: 3 additions & 3 deletions src/components-examples/material/card/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ ng_module(
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button",
"//src/material/button/testing",
"//src/material/divider",
"//src/material/legacy-button",
"//src/material/legacy-button/testing",
"//src/material/legacy-card",
"//src/material/legacy-card/testing",
"//src/material/legacy-progress-bar",
Expand All @@ -43,7 +43,7 @@ ng_test_library(
":card",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button/testing",
"//src/material/legacy-button/testing",
"//src/material/legacy-card",
"//src/material/legacy-card/testing",
"@npm//@angular/platform-browser-dynamic",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatButtonHarness} from '@angular/material/button/testing';
import {MatLegacyButtonHarness} from '@angular/material/legacy-button/testing';
import {MatLegacyCardHarness} from '@angular/material/legacy-card/testing';
import {HarnessLoader, parallel} from '@angular/cdk/testing';
import {MatLegacyCardModule} from '@angular/material/legacy-card';
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('CardHarnessExample', () => {

it('should act as a harness loader for user content', async () => {
const card = await loader.getHarness(MatLegacyCardHarness.with({title: 'Shiba Inu'}));
const footerSubcomponents = (await card.getAllHarnesses(MatButtonHarness)) ?? [];
const footerSubcomponents = (await card.getAllHarnesses(MatLegacyButtonHarness)) ?? [];
expect(footerSubcomponents.length).toBe(2);
});
});
9 changes: 7 additions & 2 deletions src/components-examples/material/card/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgModule} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatLegacyCardModule} from '@angular/material/legacy-card';
import {MatDividerModule} from '@angular/material/divider';
import {MatLegacyProgressBarModule} from '@angular/material/legacy-progress-bar';
Expand Down Expand Up @@ -32,7 +32,12 @@ const EXAMPLES = [
];

@NgModule({
imports: [MatButtonModule, MatLegacyCardModule, MatDividerModule, MatLegacyProgressBarModule],
imports: [
MatLegacyButtonModule,
MatLegacyCardModule,
MatDividerModule,
MatLegacyProgressBarModule,
],
declarations: EXAMPLES,
exports: EXAMPLES,
})
Expand Down
Loading