Skip to content

Commit a94cf69

Browse files
feat: add shape props for button to create rounded buttons
1 parent 7fb3b8b commit a94cf69

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

packages/button/Button.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class:mdc-button--raised={variant === 'raised'}
77
class:mdc-button--unelevated={variant === 'unelevated'}
88
class:mdc-button--outlined={variant === 'outlined'}
9+
class:smui-button-rounded={shape === 'rounded'}
910
class:mdc-button--dense={dense}
1011
class:smui-button--color-secondary={color === 'secondary'}
1112
class:mdc-card__action={context === 'card:action'}
@@ -28,6 +29,7 @@
2829
class:mdc-button--raised={variant === 'raised'}
2930
class:mdc-button--unelevated={variant === 'unelevated'}
3031
class:mdc-button--outlined={variant === 'outlined'}
32+
class:smui-button-rounded={shape === 'rounded'}
3133
class:mdc-button--dense={dense}
3234
class:smui-button--color-secondary={color === 'secondary'}
3335
class:mdc-card__action={context === 'card:action'}
@@ -59,6 +61,7 @@
5961
export let ripple = true;
6062
export let color = 'primary';
6163
export let variant = 'text';
64+
export let shape;
6265
export let dense = false;
6366
export let href = null;
6467
export let action = 'close';
@@ -69,7 +72,7 @@
6972
7073
$: dialogExcludes = (context === 'dialog:action') ? ['action', 'default'] : [];
7174
72-
$: props = exclude($$props, ['use', 'class', 'ripple', 'color', 'variant', 'dense', 'href', ...dialogExcludes]);
75+
$: props = exclude($$props, ['use', 'class', 'ripple', 'color', 'variant', 'shape', 'dense', 'href', ...dialogExcludes]);
7376
7477
$: actionProp = (context === 'dialog:action' && action !== null) ? {'data-mdc-dialog-action': action} : {};
7578
$: defaultProp = (context === 'dialog:action' && defaultAction) ? {'data-mdc-dialog-button-default': ''} : {};

packages/button/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ A button.
4747
* `ripple`: `true` - Whether to implement a ripple for when the component is interacted with.
4848
* `color`: `'primary'` - The button's color. ('primary' or 'secondary')
4949
* `variant`: `'text'` - The button's style variant. ('text', 'raised', 'unelevated', or 'outlined')
50+
* `shape`: `''` - The button's shape. If the shape property is set to rounded, it creates a rounded button instead of a regular button. ('rounded')
5051
* `dense`: `false` - Whether to style the button as dense.
5152
* `href`: `null` - If the `href` property is set, the button will use an anchor element, instead of a button element.
5253
* `action`: `'close'` - Used in the context of a dialog. This sets the button's action.

packages/button/_mixins.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
@mixin smui-button-core-styles($query: mdc-feature-all()) {
55
@include smui-button-without-ripple($query);
66
@include smui-button-ripple($query);
7+
@include smui-button-rounded($query);
8+
}
9+
10+
@mixin smui-button-rounded($query: mdc-feature-all()) {
11+
.smui-button-rounded {
12+
@include mdc-button-shape-radius(999px);
13+
}
714
}
815

916
@mixin smui-button-without-ripple($query: mdc-feature-all()) {
@@ -25,6 +32,7 @@
2532
@mixin smui-button-ripple($query: mdc-feature-all()) {
2633
.smui-button--color-secondary {
2734
@include mdc-states(secondary, false, $query);
35+
// @include mdc-button-shape-radius(999px);
2836

2937
&.mdc-button--raised,
3038
&.mdc-button--unelevated {

0 commit comments

Comments
 (0)