Skip to content

Commit 6ed64b5

Browse files
committed
Merge branch 'button-changes' of https://github.com/catchspider2002/svelte-material-ui into catchspider2002-button-changes
Conflicts: packages/button/Button.svelte site/package-lock.json
2 parents 574ea92 + 5f834f2 commit 6ed64b5

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

packages/button/Button.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{variant === 'raised' ? 'mdc-button--raised' : ''}
99
{variant === 'unelevated' ? 'mdc-button--unelevated' : ''}
1010
{variant === 'outlined' ? 'mdc-button--outlined' : ''}
11+
{shape === 'rounded' ? 'smui-button-rounded' : ''}
1112
{dense ? 'mdc-button--dense' : ''}
1213
{color === 'secondary' ? 'smui-button--color-secondary' : ''}
1314
{context === 'card:action' ? 'mdc-card__action' : ''}
@@ -33,6 +34,7 @@
3334
{variant === 'raised' ? 'mdc-button--raised' : ''}
3435
{variant === 'unelevated' ? 'mdc-button--unelevated' : ''}
3536
{variant === 'outlined' ? 'mdc-button--outlined' : ''}
37+
{shape === 'rounded' ? 'smui-button-rounded' : ''}
3638
{dense ? 'mdc-button--dense' : ''}
3739
{color === 'secondary' ? 'smui-button--color-secondary' : ''}
3840
{context === 'card:action' ? 'mdc-card__action' : ''}
@@ -65,6 +67,7 @@
6567
export let ripple = true;
6668
export let color = 'primary';
6769
export let variant = 'text';
70+
export let shape;
6871
export let dense = false;
6972
export let href = null;
7073
export let action = 'close';
@@ -75,7 +78,7 @@
7578
7679
$: dialogExcludes = (context === 'dialog:action') ? ['action', 'default'] : [];
7780
78-
$: props = exclude($$props, ['use', 'class', 'ripple', 'color', 'variant', 'dense', 'href', ...dialogExcludes]);
81+
$: props = exclude($$props, ['use', 'class', 'ripple', 'color', 'variant', 'shape', 'dense', 'href', ...dialogExcludes]);
7982
8083
$: actionProp = (context === 'dialog:action' && action !== null) ? {'data-mdc-dialog-action': action} : {};
8184
$: 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: 7 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()) {

site/src/routes/demo/button.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
<Button color="secondary" on:click={() => clicked++}><Label>Trailing Icon</Label><Icon class="material-icons">favorite</Icon></Button>
3939
</div>
4040

41+
<div>
42+
Shaped button: <br />
43+
<Button on:click={() => clicked++} variant="unelevated" shape="rounded"><Label>Unelevated</Label></Button>
44+
<Button on:click={() => clicked++} variant="outlined" shape="rounded"><Label>Outlined</Label></Button>
45+
<Button on:click={() => clicked++} variant="unelevated" shape="rounded"><Icon class="material-icons">favorite</Icon><Label>Icon</Label></Button>
46+
<Button on:click={() => clicked++} variant="unelevated" shape="rounded"><Label>Trailing Icon</Label><Icon class="material-icons">favorite</Icon></Button>
47+
</div>
48+
4149
<div>
4250
Button groups: <br />
4351
<Group>

0 commit comments

Comments
 (0)