Skip to content
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
9 changes: 8 additions & 1 deletion src/material-experimental/mdc-button/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ng_module(
],
),
assets = [
":button_high_contrast_scss",
":button_scss",
":fab_scss",
":icon-button_scss",
Expand Down Expand Up @@ -54,12 +55,18 @@ sass_binary(
],
deps = [
":button_base_scss_lib",
"//src/cdk/a11y:a11y_scss_lib",
"//src/material-experimental/mdc-helpers:mdc_helpers_scss_lib",
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib",
],
)

sass_binary(
name = "button_high_contrast_scss",
src = "button-high-contrast.scss",
include_paths = ["external/npm/node_modules"],
deps = ["//src/cdk/a11y:a11y_scss_lib"],
)

sass_binary(
name = "fab_scss",
src = "fab.scss",
Expand Down
19 changes: 19 additions & 0 deletions src/material-experimental/mdc-button/button-high-contrast.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@use '../../cdk/a11y';

// Add an outline to make buttons more visible in high contrast mode. Stroked buttons and FABs
// don't need a special look in high-contrast mode, because those already have an outline.
.mat-mdc-button:not(.mdc-button--outlined),
.mat-mdc-unelevated-button:not(.mdc-button--outlined),
.mat-mdc-raised-button:not(.mdc-button--outlined),
.mat-mdc-outlined-button:not(.mdc-button--outlined),
.mat-mdc-icon-button {
@include a11y.high-contrast(active, off) {
outline: solid 1px;
}
}

@include a11y.high-contrast(active, off) {
.mat-mdc-button-base:focus {
outline: solid 3px;
}
}
19 changes: 0 additions & 19 deletions src/material-experimental/mdc-button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@use '@material/button/variables' as mdc-button-variables;
@use '../../material/core/style/private';
@use '../mdc-helpers/mdc-helpers';
@use '../../cdk/a11y';
@use 'button-base';


Expand Down Expand Up @@ -42,24 +41,6 @@
}
}

// Add an outline to make buttons more visible in high contrast mode. Stroked buttons and FABs
// don't need a special look in high-contrast mode, because those already have an outline.
.mat-mdc-button:not(.mdc-button--outlined),
.mat-mdc-unelevated-button:not(.mdc-button--outlined),
.mat-mdc-raised-button:not(.mdc-button--outlined),
.mat-mdc-outlined-button:not(.mdc-button--outlined),
.mat-mdc-icon-button {
@include a11y.high-contrast(active, off) {
outline: solid 1px;
}
}

@include a11y.high-contrast(active, off) {
.mat-mdc-button-base:focus {
outline: solid 3px;
}
}

// Since the stroked button has has an actual border that reduces the available space for
// child elements such as the ripple container or focus overlay, an inherited border radius
// for the absolute-positioned child elements does not work properly. This is because the
Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
button[mat-stroked-button]
`,
templateUrl: 'button.html',
styleUrls: ['button.css'],
styleUrls: ['button.css', 'button-high-contrast.css'],
inputs: MAT_BUTTON_INPUTS,
host: MAT_BUTTON_HOST,
exportAs: 'matButton',
Expand Down Expand Up @@ -73,7 +73,7 @@ export class MatButton extends MatButtonBase {
host: MAT_ANCHOR_HOST,
inputs: MAT_ANCHOR_INPUTS,
templateUrl: 'button.html',
styleUrls: ['button.css'],
styleUrls: ['button.css', 'button-high-contrast.css'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-button/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
@Component({
selector: `button[mat-icon-button]`,
templateUrl: 'button.html',
styleUrls: ['icon-button.css'],
styleUrls: ['icon-button.css', 'button-high-contrast.css'],
inputs: MAT_BUTTON_INPUTS,
host: MAT_BUTTON_HOST,
exportAs: 'matButton',
Expand All @@ -61,7 +61,7 @@ export class MatIconButton extends MatButtonBase {
@Component({
selector: `a[mat-icon-button]`,
templateUrl: 'button.html',
styleUrls: ['icon-button.css'],
styleUrls: ['icon-button.css', 'button-high-contrast.css'],
inputs: MAT_ANCHOR_INPUTS,
host: MAT_ANCHOR_HOST,
exportAs: 'matButton, matAnchor',
Expand Down