From b0adc581dbcc20e2f1fd8eb428b6415cf3ec30de Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Sat, 26 Dec 2020 18:06:04 +0200 Subject: [PATCH] fix(material-experimental/mdc-snack-bar): use MDC-based button Switches the MDC-based snack bar to use the MDC-based button. In general we should be using the MDC versions of components together, when possible. --- src/material-experimental/mdc-snack-bar/BUILD.bazel | 6 +++++- .../mdc-snack-bar/_snack-bar-theme.scss | 6 ++++++ src/material-experimental/mdc-snack-bar/module.ts | 2 +- src/material-experimental/mdc-snack-bar/snack-bar.spec.ts | 6 +++--- src/material-experimental/mdc-snack-bar/testing/BUILD.bazel | 1 + 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/material-experimental/mdc-snack-bar/BUILD.bazel b/src/material-experimental/mdc-snack-bar/BUILD.bazel index b4e1dfd266b6..50b41bbdd324 100644 --- a/src/material-experimental/mdc-snack-bar/BUILD.bazel +++ b/src/material-experimental/mdc-snack-bar/BUILD.bazel @@ -22,6 +22,7 @@ ng_module( module_name = "@angular/material-experimental/mdc-snack-bar", deps = [ "//src:dev_mode_types", + "//src/material-experimental/mdc-button", "//src/material-experimental/mdc-core", "//src/material/snack-bar", "@npm//@angular/core", @@ -76,7 +77,10 @@ ng_test_library( ng_web_test_suite( name = "unit_tests", - static_files = ["@npm//:node_modules/@material/snackbar/dist/mdc.snackbar.js"], + static_files = [ + "@npm//:node_modules/@material/snackbar/dist/mdc.snackbar.js", + "@npm//:node_modules/@material/ripple/dist/mdc.ripple.js", + ], deps = [ ":unit_test_sources", "//src/material-experimental:mdc_require_config.js", diff --git a/src/material-experimental/mdc-snack-bar/_snack-bar-theme.scss b/src/material-experimental/mdc-snack-bar/_snack-bar-theme.scss index 41627a109da5..7d247bbd3dc2 100644 --- a/src/material-experimental/mdc-snack-bar/_snack-bar-theme.scss +++ b/src/material-experimental/mdc-snack-bar/_snack-bar-theme.scss @@ -28,6 +28,12 @@ @include mdc-snackbar-core-styles($query: $mat-theme-styles-query); } + // Usually this color is provided by the `mdc-snackbar-core-styles` mixin, but our styles + // to handle unthemed buttons have a higher specificity so we have to re-provide it here. + .mat-mdc-snack-bar-container .mat-mdc-snack-bar-action.mdc-snackbar__action { + color: $mdc-snackbar-action-ink-color; + } + $mdc-snackbar-fill-color: $orig-mdc-snackbar-fill-color !global; $mdc-snackbar-label-ink-color: $orig-mdc-snackbar-label-ink-color !global; $mdc-snackbar-dismiss-ink-color: $orig-mdc-snackbar-dismiss-ink-color !global; diff --git a/src/material-experimental/mdc-snack-bar/module.ts b/src/material-experimental/mdc-snack-bar/module.ts index 70de7103aa51..8c1a8d6b0706 100644 --- a/src/material-experimental/mdc-snack-bar/module.ts +++ b/src/material-experimental/mdc-snack-bar/module.ts @@ -10,7 +10,7 @@ import {OverlayModule} from '@angular/cdk/overlay'; import {PortalModule} from '@angular/cdk/portal'; import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {MatButtonModule} from '@angular/material/button'; +import {MatButtonModule} from '@angular/material-experimental/mdc-button'; import {MatCommonModule} from '@angular/material-experimental/mdc-core'; import {MatSimpleSnackBar} from './simple-snack-bar'; diff --git a/src/material-experimental/mdc-snack-bar/snack-bar.spec.ts b/src/material-experimental/mdc-snack-bar/snack-bar.spec.ts index c7bd0574f4c3..2c9f81026b44 100644 --- a/src/material-experimental/mdc-snack-bar/snack-bar.spec.ts +++ b/src/material-experimental/mdc-snack-bar/snack-bar.spec.ts @@ -201,7 +201,7 @@ describe('MatSnackBar', () => { expect(messageElement.textContent) .toContain(simpleMessage, `Expected the snack bar message to be '${simpleMessage}'`); - let buttonElement = overlayContainerElement.querySelector('button.mat-button')!; + let buttonElement = overlayContainerElement.querySelector('button.mat-mdc-button')!; expect(buttonElement.tagName) .toBe('BUTTON', 'Expected snack bar action label to be a