Skip to content

Commit 902f259

Browse files
allan-chencopybara-github
authored andcommitted
feat(button): outlined button styles w/ dedicated outline node
PiperOrigin-RevId: 397829718
1 parent 73cea87 commit 902f259

File tree

4 files changed

+93
-3
lines changed

4 files changed

+93
-3
lines changed

components/button/lib/_button.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
vertical-align: middle;
6767
background: transparent;
6868
text-decoration: none;
69-
transition: elevation-theme.transition-value();
7069

7170
&::-moz-focus-inner {
7271
padding: 0;

components/button/lib/_outlined-button-theme.scss

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,76 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
// stylelint-disable selector-class-pattern --
8+
// Selector '.mdc-*' should only be used in this project.
9+
10+
@use '@material/shape/shape';
11+
@use '@material/theme/state';
12+
13+
@use './button-theme';
14+
15+
$_selectors: button-theme.$selectors;
16+
717
/// TODO: variant-specific theme + theme styles mixins.
18+
19+
@mixin _shape-radius($radius) {
20+
.mdc-button__outline {
21+
@include shape.radius($radius);
22+
}
23+
}
24+
25+
@mixin _outline-color($colors) {
26+
@include state.default($_selectors) {
27+
@include _set-outline-color(state.get-default-state($colors));
28+
}
29+
30+
@include state.hover($_selectors) {
31+
@include _set-outline-color(state.get-hover-state($colors));
32+
}
33+
34+
@include state.focus($_selectors) {
35+
@include _set-outline-color(state.get-focus-state($colors));
36+
}
37+
38+
@include state.pressed($_selectors) {
39+
@include _set-outline-color(state.get-pressed-state($colors));
40+
}
41+
42+
@include state.disabled($_selectors) {
43+
@include _set-outline-color(state.get-disabled-state($colors));
44+
}
45+
}
46+
47+
@mixin _set-outline-color($color) {
48+
.mdc-button__outline {
49+
@include theme.property(border-color, $color);
50+
}
51+
}
52+
53+
@mixin _outline-width($widths) {
54+
@include state.default($_selectors) {
55+
@include _set-outline-width(state.get-default-state($widths));
56+
}
57+
58+
@include state.hover($_selectors) {
59+
@include _set-outline-width(state.get-hover-state($widths));
60+
}
61+
62+
@include state.focus($_selectors) {
63+
@include _set-outline-width(state.get-focus-state($widths));
64+
}
65+
66+
@include state.pressed($_selectors) {
67+
@include _set-outline-width(state.get-pressed-state($widths));
68+
}
69+
70+
@include state.disabled($_selectors) {
71+
@include _set-outline-width(state.get-disabled-state($widths));
72+
}
73+
}
74+
75+
@mixin _set-outline-width($width) {
76+
.mdc-button__outline {
77+
@include theme.property(border-width, $width);
78+
}
79+
}

components/button/lib/_outlined-button.scss

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,19 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
/// TODO: variant-specific static styles.
7+
// stylelint-disable selector-class-pattern --
8+
// Selector '.mdc-*' should only be used in this project.
9+
10+
@mixin static-styles() {
11+
.mdc-button__outline {
12+
@include outline;
13+
}
14+
}
15+
16+
@mixin outline() {
17+
position: absolute;
18+
width: 100%;
19+
height: 100%;
20+
border-style: solid;
21+
box-sizing: border-box;
22+
}

components/button/lib/outlined-styles.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
/// TODO: variant-specific concrete styles.
7+
@use './outlined-button';
8+
9+
@include outlined-button.static-styles;
10+
11+
/// TODO: variant-specific theme styles.

0 commit comments

Comments
 (0)