Skip to content

Commit 4ddbde9

Browse files
crisbetojelbourn
authored andcommitted
feat(button): align with 2018 material design spec (#12537)
Aligns the button component with the latest Material design spec.
1 parent dc6688d commit 4ddbde9

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

src/lib/button/_button-base.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66

77
// Flat and raised button standards
88
$mat-button-padding: 0 16px !default;
9-
$mat-button-min-width: 88px !default;
9+
$mat-button-min-width: 64px !default;
1010
$mat-button-margin: 0 !default;
1111
$mat-button-line-height: 36px !default;
12-
$mat-button-border-radius: 2px !default;
12+
$mat-button-border-radius: 4px !default;
1313
$mat-button-focus-transition: opacity 200ms $swift-ease-in-out-timing-function,
1414
background-color 200ms $swift-ease-in-out-timing-function !default;
1515

16-
// Stroked Button standards
17-
$mat-stroked-button-line-height: $mat-button-line-height - 2;
1816
// Stroked button padding is 1px less horizontally than default/flat/raised
1917
// button's padding.
18+
$mat-stroked-button-line-height: $mat-button-line-height - 2;
2019
$mat-stroked-button-padding: 0 15px;
2120

2221
// Icon Button standards
@@ -64,7 +63,7 @@ $mat-mini-fab-padding: 8px !default;
6463

6564
&.cdk-keyboard-focused, &.cdk-program-focused {
6665
.mat-button-focus-overlay {
67-
opacity: 1;
66+
opacity: 0.12;
6867
}
6968
}
7069

src/lib/button/_button-theme.scss

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
$warn: map-get($theme, warn);
99

1010
&.mat-primary .mat-button-focus-overlay {
11-
background-color: mat-color($primary, 0.12);
11+
background-color: mat-color($primary);
1212
}
1313

1414
&.mat-accent .mat-button-focus-overlay {
15-
background-color: mat-color($accent, 0.12);
15+
background-color: mat-color($accent);
1616
}
1717

1818
&.mat-warn .mat-button-focus-overlay {
19-
background-color: mat-color($warn, 0.12);
19+
background-color: mat-color($warn);
2020
}
2121

2222
&[disabled] .mat-button-focus-overlay {
@@ -91,6 +91,16 @@
9191
@include _mat-button-ripple-color($theme, default);
9292
}
9393

94+
.mat-button-focus-overlay {
95+
background: map_get($foreground, base);
96+
}
97+
98+
// Note: this needs a bit extra specificity, because we're not guaranteed the inclusion
99+
// order of the theme styles and the button reset may end up resetting this as well.
100+
.mat-stroked-button:not(.mat-button-disabled) {
101+
border-color: mat-color($foreground, divider);
102+
}
103+
94104
.mat-flat-button, .mat-raised-button, .mat-fab, .mat-mini-fab {
95105
// Default font and background color when not using any color palette.
96106
color: mat-color($foreground, text);

src/lib/button/button.scss

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// Use the same visual treatment for hover as for focus.
2020
.mat-button:hover .mat-button-focus-overlay,
2121
.mat-stroked-button:hover .mat-button-focus-overlay {
22-
opacity: 1;
22+
opacity: 0.04;
2323
}
2424

2525
// Disable the hover styles on non-hover devices. Since this is more of a progressive
@@ -38,8 +38,7 @@
3838

3939
.mat-stroked-button {
4040
@include mat-overridable-elevation(0);
41-
42-
border: 1px solid currentColor;
41+
border: solid 1px currentColor;
4342
padding: $mat-stroked-button-padding;
4443
line-height: $mat-stroked-button-line-height;
4544
}
@@ -66,7 +65,6 @@
6665
height: $mat-icon-button-size;
6766

6867
flex-shrink: 0;
69-
7068
line-height: $mat-icon-button-size;
7169
border-radius: $mat-icon-button-border-radius;
7270

@@ -93,9 +91,6 @@
9391

9492
// Element that overlays the button to show focus and hover effects.
9593
.mat-button-focus-overlay {
96-
// The button spec calls for focus on raised buttons (and FABs) to be indicated with a
97-
// black, 12% opacity shade over the normal color (for both light and dark themes).
98-
background-color: rgba(black, 0.12);
9994
border-radius: inherit;
10095
opacity: 0;
10196

0 commit comments

Comments
 (0)