Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 56bf37d

Browse files
authored
feat(button): Implement stroked button (#1194)
closes #987
1 parent a8b9099 commit 56bf37d

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

demos/button.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,30 @@ <h1 class="mdc-typography--display2">Ripple Enabled</h1>
201201
</div>
202202
</fieldset>
203203

204+
<fieldset>
205+
<legend class="mdc-typography--title">Stroked Button</legend>
206+
<div>
207+
<button class="mdc-button mdc-button--stroked">
208+
Baseline
209+
</button>
210+
<button class="mdc-button mdc-button--stroked mdc-button--compact">
211+
Compact
212+
</button>
213+
<button class="mdc-button mdc-button--stroked mdc-button--dense">
214+
Dense
215+
</button>
216+
<button class="mdc-button mdc-button--stroked mdc-button--primary">
217+
Primary
218+
</button>
219+
<button class="mdc-button mdc-button--stroked mdc-button--accent">
220+
Secondary
221+
</button>
222+
<a href="javascript:void(0)" class="mdc-button mdc-button--stroked">
223+
Link
224+
</a>
225+
</div>
226+
</fieldset>
227+
204228
<h1 class="mdc-typography--display2">CSS Only</h1>
205229
<fieldset>
206230
<legend class="mdc-typography--title">Text Button</legend>
@@ -273,6 +297,30 @@ <h1 class="mdc-typography--display2">CSS Only</h1>
273297
</a>
274298
</div>
275299
</fieldset>
300+
301+
<fieldset>
302+
<legend class="mdc-typography--title">Stroked Button</legend>
303+
<div>
304+
<button class="mdc-button mdc-button--stroked" data-demo-no-js>
305+
Baseline
306+
</button>
307+
<button class="mdc-button mdc-button--stroked mdc-button--compact" data-demo-no-js>
308+
Compact
309+
</button>
310+
<button class="mdc-button mdc-button--stroked mdc-button--dense" data-demo-no-js>
311+
Dense
312+
</button>
313+
<button class="mdc-button mdc-button--stroked mdc-button--primary" data-demo-no-js>
314+
Primary
315+
</button>
316+
<button class="mdc-button mdc-button--stroked mdc-button--accent" data-demo-no-js>
317+
Secondary
318+
</button>
319+
<a href="javascript:void(0)" class="mdc-button mdc-button--stroked" data-demo-no-js>
320+
Link
321+
</a>
322+
</div>
323+
</fieldset>
276324
</section>
277325
</main>
278326

packages/mdc-button/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ semantically correct.
7171
</button>
7272
```
7373

74+
#### Stroked Button
75+
76+
```html
77+
<button class="mdc-button mdc-button--stroked">
78+
Stroked button
79+
</button>
80+
```
81+
7482
### Button state
7583

7684
#### Disabled
@@ -138,6 +146,7 @@ The provided modifiers are:
138146
| --------------------- | ------------------------------------------------------- |
139147
| `mdc-button--raised` | A contained button that is elevated upon the surface. |
140148
| `mdc-button--unelevated` | A contained button that is flush with the surface. |
149+
| `mdc-button--stroked` | A contained button that is flush with the surface and has a visible border. |
141150
| `mdc-button--dense` | Compresses the button text to make it slightly smaller. |
142151
| `mdc-button--compact` | Reduces the amount of horizontal padding in the button. |
143152
| `mdc-button--primary` | Colors the button with the primary color. |

packages/mdc-button/mdc-button.scss

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@
9494
}
9595
}
9696

97+
.mdc-button--stroked {
98+
@include mdc-theme-prop(border-color, text-primary-on-light);
99+
100+
border-width: 2px;
101+
border-style: solid;
102+
line-height: 32px;
103+
104+
@include mdc-theme-dark(".mdc-button") {
105+
@include mdc-theme-prop(border-color, text-primary-on-dark);
106+
}
107+
108+
// postcss-bem-linter: ignore
109+
&.mdc-button--dense {
110+
line-height: 27px; // To accommodate odd font size of dense button
111+
}
112+
}
113+
97114
.mdc-button--compact {
98115
padding: 0 8px;
99116
}
@@ -134,6 +151,14 @@
134151
@include mdc-theme-prop(background-color, $theme-style);
135152
@include mdc-theme-prop(color, text-primary-on-#{$theme-style});
136153
}
154+
// postcss-bem-linter: ignore
155+
&.mdc-button--stroked {
156+
@include mdc-theme-prop(border-color, $theme-style);
157+
158+
@include mdc-theme-dark(".mdc-button") {
159+
@include mdc-theme-prop(border-color, $theme-style);
160+
}
161+
}
137162
}
138163
}
139164

@@ -168,4 +193,15 @@
168193
}
169194
}
170195
}
196+
197+
.mdc-button--stroked {
198+
fieldset:disabled &,
199+
&:disabled {
200+
border-color: rgba(black, .38);
201+
202+
@include mdc-theme-dark(".mdc-button") {
203+
@include mdc-theme-prop(border-color, text-disabled-on-dark);
204+
}
205+
}
206+
}
171207
// postcss-bem-linter: end

0 commit comments

Comments
 (0)