Skip to content

Commit 44051d2

Browse files
committed
feat(button-toggle): align with 2018 material design spec
Aligns the button toggle component with the latest Material design spec.
1 parent 877de56 commit 44051d2

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

src/lib/button-toggle/_button-toggle-theme.scss

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,48 @@
55
@mixin mat-button-toggle-theme($theme) {
66
$foreground: map-get($theme, foreground);
77
$background: map-get($theme, background);
8+
$divider-color: mat-color($foreground, divider);
89

910
.mat-button-toggle {
10-
color: mat-color($foreground, hint-text);
11+
color: mat-color($foreground, text);
12+
background: mat-color($background, card);
1113

1214
.mat-button-toggle-focus-overlay {
13-
background-color: mat-color($background, focused-button);
15+
background-color: mat-color($background, focused-button, 1);
16+
}
17+
18+
.mat-button-toggle-group & + & {
19+
border-left: solid 1px $divider-color;
20+
}
21+
22+
[dir='rtl'] .mat-button-toggle-group & + & {
23+
border-left: none;
24+
border-right: solid 1px $divider-color;
25+
}
26+
27+
.mat-button-toggle-vertical & + & {
28+
border-left: none;
29+
border-right: none;
30+
border-top: solid 1px $divider-color;
1431
}
1532
}
1633

1734
.mat-button-toggle-checked {
1835
background-color: mat-color($background, selected-button);
19-
color: mat-color($foreground, secondary-text);
2036
}
2137

2238
.mat-button-toggle-disabled {
23-
background-color: mat-color($background, disabled-button-toggle);
2439
color: mat-color($foreground, disabled-button);
2540

2641
&.mat-button-toggle-checked {
2742
background-color: mat-color($background, selected-disabled-button);
2843
}
2944
}
45+
46+
.mat-button-toggle-standalone,
47+
.mat-button-toggle-group {
48+
border: solid 1px $divider-color;
49+
}
3050
}
3151

3252
@mixin mat-button-toggle-typography($config) {

src/lib/button-toggle/button-toggle.scss

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,19 @@
33
@import '../core/style/layout-common';
44
@import '../../cdk/a11y/a11y';
55

6-
$mat-button-toggle-padding: 0 16px !default;
7-
$mat-button-toggle-height: 36px !default;
8-
$mat-button-toggle-border-radius: 2px !default;
6+
$mat-button-toggle-padding: 0 12px !default;
7+
$mat-button-toggle-height: 48px !default;
8+
$mat-button-toggle-border-radius: 4px !default;
99

1010
.mat-button-toggle-standalone,
1111
.mat-button-toggle-group {
12-
@include mat-elevation(2);
1312
position: relative;
1413
display: inline-flex;
1514
flex-direction: row;
16-
1715
border-radius: $mat-button-toggle-border-radius;
18-
1916
cursor: pointer;
2017
white-space: nowrap;
2118
overflow: hidden;
22-
23-
@include cdk-high-contrast {
24-
outline: solid 1px;
25-
}
2619
}
2720

2821
.mat-button-toggle-vertical {
@@ -44,19 +37,16 @@ $mat-button-toggle-border-radius: 2px !default;
4437
position: relative;
4538
-webkit-tap-highlight-color: transparent;
4639

40+
&:hover .mat-button-toggle-focus-overlay {
41+
opacity: 0.04;
42+
}
43+
4744
// Similar to components like the checkbox, slide-toggle and radio, we cannot show the focus
4845
// overlay for `.cdk-program-focused` because mouse clicks on the <label> element would be always
4946
// treated as programmatic focus.
5047
// TODO(paul): support `program` as well. See https://github.com/angular/material2/issues/9889
51-
&.cdk-keyboard-focused {
52-
.mat-button-toggle-focus-overlay {
53-
opacity: 1;
54-
55-
// In high contrast mode `opacity: 1` will show the overlay as solid so we fall back 0.5.
56-
@include cdk-high-contrast {
57-
opacity: 0.5;
58-
}
59-
}
48+
&.cdk-keyboard-focused .mat-button-toggle-focus-overlay {
49+
opacity: 0.12;
6050
}
6151
}
6252

0 commit comments

Comments
 (0)