Skip to content

Commit 1e2c8d5

Browse files
committed
feat: mini and button sizes for icon button
1 parent bab3fec commit 1e2c8d5

File tree

8 files changed

+59
-19
lines changed

8 files changed

+59
-19
lines changed

packages/icon-button/IconButton.svelte

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
'mdc-icon-button--on': !isUninitializedValue(pressed) && pressed,
2424
'mdc-icon-button--touch': touch,
2525
'mdc-icon-button--display-flex': displayFlex,
26+
'smui-icon-button--size-button': size === 'button',
27+
'mdc-icon-button--reduced-size': size === 'mini' || size === 'button',
2628
'mdc-card__action': context === 'card:action',
2729
'mdc-card__action--icon': context === 'card:action',
2830
'mdc-top-app-bar__navigation-icon': context === 'top-app-bar:navigation',
@@ -97,6 +99,7 @@
9799
export let ariaLabelOff: string | undefined = undefined;
98100
export let touch = false;
99101
export let displayFlex = true;
102+
export let size: 'normal' | 'mini' | 'button' = 'normal';
100103
export let href: string | undefined = undefined;
101104
export let action:
102105
| 'close'

packages/icon-button/IconButton.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export declare class IconButtonComponentDev<
2424
| 'ariaLabelOff'
2525
| 'touch'
2626
| 'displayFlex'
27+
| 'size'
2728
| 'href'
2829
| 'action'
2930
| 'component'

packages/icon-button/_mixins.scss

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@use '@material/feature-targeting/index' as feature-targeting;
2+
@use '@material/icon-button/icon-button-theme';
3+
4+
$button-icon-height: 18px !default;
5+
$button-height: 36px !default;
6+
7+
@mixin core-styles($query: feature-targeting.all()) {
8+
.mdc-icon-button.smui-icon-button--size-button {
9+
@include icon-button-theme.icon-size($button-icon-height);
10+
@include icon-button-theme.size($button-height);
11+
}
12+
}

packages/icon-button/_style.scss

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@use '@material/icon-button/mdc-icon-button';
22
@use '@smui/ripple/style' as ripple-style;
3+
@use './mixins' as mixins;
4+
5+
@include mixins.core-styles;
36

47
// Prevent pointer giving focus inside.
58
.mdc-icon-button svg {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div style="display: flex; align-items: center;">
2+
<IconButton class="material-icons" on:click={() => clicked++} size="normal">
3+
<Icon component={Svg} viewBox="0 0 24 24">
4+
<path fill="currentColor" d={mdiWrench} />
5+
</Icon>
6+
</IconButton> (normal = standard icon button size)
7+
</div>
8+
<div style="display: flex; align-items: center;">
9+
<IconButton class="material-icons" on:click={() => clicked++} size="mini">
10+
<Icon component={Svg} viewBox="0 0 24 24">
11+
<path fill="currentColor" d={mdiWrench} />
12+
</Icon>
13+
</IconButton> (mini = same size as mini FAB)
14+
</div>
15+
<div style="display: flex; align-items: center;">
16+
<IconButton class="material-icons" on:click={() => clicked++} size="button">
17+
<Icon component={Svg} viewBox="0 0 24 24">
18+
<path fill="currentColor" d={mdiWrench} />
19+
</Icon>
20+
</IconButton> (button = same height as button)
21+
</div>
22+
23+
<pre class="status">Clicked: {clicked}</pre>
24+
25+
<script lang="ts">
26+
import { mdiWrench } from '@mdi/js';
27+
import IconButton, { Icon } from '@smui/icon-button';
28+
import { Svg } from '@smui/common/elements';
29+
30+
let clicked = 0;
31+
</script>

packages/site/src/routes/demo/icon-button/index.svelte

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<Demo component={Touch} file="icon-button/_Touch.svelte">
1919
Increased touch target
2020
</Demo>
21+
22+
<Demo component={Sizes} file="icon-button/_Sizes.svelte">
23+
Different sizes
24+
</Demo>
2125
</section>
2226

2327
<script lang="ts">
@@ -27,4 +31,5 @@
2731
import Toggle from './_Toggle.svelte';
2832
import Svgs from './_Svgs.svelte';
2933
import Touch from './_Touch.svelte';
34+
import Sizes from './_Sizes.svelte';
3035
</script>

packages/snackbar/_mixins.scss

-10
This file was deleted.

packages/snackbar/_style.scss

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
// TODO: check if this is still required
2-
// @use '@material/theme/theme-color';
3-
// @use '@material/snackbar/index' as snackbar with (
4-
// $action-ink-color: theme-color.prop-value(primary)
5-
// );
6-
@use '@material/snackbar/mdc-snackbar';
7-
@use './mixins';
1+
@use '@material/theme/theme-color';
2+
@use '@material/snackbar/index' as snackbar with
3+
($action-ink-color: theme-color.prop-value(primary));
84

9-
// @include snackbar.core-styles;
10-
@include mixins.core-styles;
5+
@include snackbar.core-styles;

0 commit comments

Comments
 (0)