Skip to content

Commit f44c861

Browse files
authored
feat: providing auto width for buttons (#898)
* feat: providing auto width for buttons * Update _buttons.md * Update button.hbs * Update 10-button-width.hbs
1 parent 02a93b0 commit f44c861

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{!-- TODO: let's not use those modifier classes, but inherit their meaning via CSS correctly and introduce sample classes for the styleguide --}}
2+
<p>
3+
{{> elements-button variant='brand-primary' value='(Default) Auto width'}}
4+
<!-- [html-validate-disable-next no-inline-style -- we're doing inline-styling for simplification here] -->
5+
<span style="width: 500px;display:inline-block;">{{> elements-button variant='brand-primary' value='Width full' width='full' }}</span>
6+
</p>

source/_patterns/01-elements/buttons/_buttons.md

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ Extend one of the size SCSS placeholders in case that you don't want the default
2525

2626
You could set the different button sizes via the `data-size` attribute, the default is "regular" and in that case is optional.
2727

28+
### Width
29+
30+
Regularly, our buttons shouldn't increase to it's horizontally available space, but only the one determined by it's included textual content.
31+
32+
#### SCSS (recommended)
33+
34+
Extend the width SCSS placeholders in case that you don't want the default (`auto`): `%width-Full`
35+
36+
#### HTML attribute
37+
38+
You could set the button width to increase to it's full available space via the `data-width="full"` attribute, the default is `auto` and in that case is optional.
39+
2840
## Usability
2941

3042
> Buttons should be used in situations where users might need to:

source/_patterns/01-elements/buttons/button.hbs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{{#if disabled }} disabled{{/if }}
88
{{#if icon}} data-icon="{{ icon }}"{{/if}}
99
{{#if icon-after}} data-icon-after="{{ icon-after }}"{{/if}}
10-
{{#if label}} aria-label="{{ label }}"{{/if }}>
10+
{{#if label}} aria-label="{{ label }}"{{/if }}
11+
{{#if width }} data-width="{{ width }}"{{/if }}>
1112
{{{ value }}}
1213
</button>

source/_patterns/01-elements/buttons/button.scss

+9
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,13 @@
216216
&:disabled {
217217
color: unquote($button---color + "80");
218218
}
219+
220+
// width
221+
&%width-Full {
222+
inline-size: 100%;
223+
}
224+
225+
&[data-width="full"] {
226+
@extend %width-Full;
227+
}
219228
}

0 commit comments

Comments
 (0)