Skip to content

Commit

Permalink
feat: add shape props for button to create rounded buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
catchspider2002 committed Nov 9, 2019
1 parent 7fb3b8b commit a94cf69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/button/Button.svelte
Expand Up @@ -6,6 +6,7 @@
class:mdc-button--raised={variant === 'raised'}
class:mdc-button--unelevated={variant === 'unelevated'}
class:mdc-button--outlined={variant === 'outlined'}
class:smui-button-rounded={shape === 'rounded'}
class:mdc-button--dense={dense}
class:smui-button--color-secondary={color === 'secondary'}
class:mdc-card__action={context === 'card:action'}
Expand All @@ -28,6 +29,7 @@
class:mdc-button--raised={variant === 'raised'}
class:mdc-button--unelevated={variant === 'unelevated'}
class:mdc-button--outlined={variant === 'outlined'}
class:smui-button-rounded={shape === 'rounded'}
class:mdc-button--dense={dense}
class:smui-button--color-secondary={color === 'secondary'}
class:mdc-card__action={context === 'card:action'}
Expand Down Expand Up @@ -59,6 +61,7 @@
export let ripple = true;
export let color = 'primary';
export let variant = 'text';
export let shape;
export let dense = false;
export let href = null;
export let action = 'close';
Expand All @@ -69,7 +72,7 @@
$: dialogExcludes = (context === 'dialog:action') ? ['action', 'default'] : [];
$: props = exclude($$props, ['use', 'class', 'ripple', 'color', 'variant', 'dense', 'href', ...dialogExcludes]);
$: props = exclude($$props, ['use', 'class', 'ripple', 'color', 'variant', 'shape', 'dense', 'href', ...dialogExcludes]);
$: actionProp = (context === 'dialog:action' && action !== null) ? {'data-mdc-dialog-action': action} : {};
$: defaultProp = (context === 'dialog:action' && defaultAction) ? {'data-mdc-dialog-button-default': ''} : {};
Expand Down
1 change: 1 addition & 0 deletions packages/button/README.md
Expand Up @@ -47,6 +47,7 @@ A button.
* `ripple`: `true` - Whether to implement a ripple for when the component is interacted with.
* `color`: `'primary'` - The button's color. ('primary' or 'secondary')
* `variant`: `'text'` - The button's style variant. ('text', 'raised', 'unelevated', or 'outlined')
* `shape`: `''` - The button's shape. If the shape property is set to rounded, it creates a rounded button instead of a regular button. ('rounded')
* `dense`: `false` - Whether to style the button as dense.
* `href`: `null` - If the `href` property is set, the button will use an anchor element, instead of a button element.
* `action`: `'close'` - Used in the context of a dialog. This sets the button's action.
Expand Down
8 changes: 8 additions & 0 deletions packages/button/_mixins.scss
Expand Up @@ -4,6 +4,13 @@
@mixin smui-button-core-styles($query: mdc-feature-all()) {
@include smui-button-without-ripple($query);
@include smui-button-ripple($query);
@include smui-button-rounded($query);
}

@mixin smui-button-rounded($query: mdc-feature-all()) {
.smui-button-rounded {
@include mdc-button-shape-radius(999px);
}
}

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

&.mdc-button--raised,
&.mdc-button--unelevated {
Expand Down

0 comments on commit a94cf69

Please sign in to comment.