@noxlovette/material 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/material-claude-skill.js +31 -0
- package/claude-skill/material-design/SKILL.md +68 -0
- package/claude-skill/material-design/references/accessibility-checklist.md +29 -0
- package/claude-skill/material-design/references/component-patterns.md +55 -0
- package/claude-skill/material-design/references/motion-guide.md +163 -0
- package/claude-skill/material-design/references/tokens-and-styles.md +68 -0
- package/dist/animation/Shapes.stories.svelte +60 -0
- package/dist/animation/Shapes.stories.svelte.d.ts +3 -0
- package/dist/animation/TransitionPatterns.stories.svelte +32 -20
- package/dist/animation/containerTransform.d.ts +11 -0
- package/dist/animation/containerTransform.js +11 -0
- package/dist/animation/enterExit.d.ts +9 -0
- package/dist/animation/enterExit.js +6 -3
- package/dist/animation/index.d.ts +1 -0
- package/dist/animation/index.js +1 -0
- package/dist/animation/shapeMorph.svelte.d.ts +52 -0
- package/dist/animation/shapeMorph.svelte.js +112 -0
- package/dist/animation/shapesAnimatableSmall.d.ts +28 -22
- package/dist/animation/shapesAnimatableSmall.js +32 -23
- package/dist/animation/sharedAxisTransition.d.ts +22 -0
- package/dist/animation/sharedAxisTransition.js +25 -1
- package/dist/animation/skeleton.d.ts +6 -1
- package/dist/animation/skeleton.js +6 -1
- package/dist/components/badge/Badge.mdx +70 -0
- package/dist/components/badge/Badge.stories.svelte +38 -20
- package/dist/components/badge/Badge.svelte +12 -5
- package/dist/components/badge/theme.d.ts +30 -7
- package/dist/components/badge/theme.js +24 -4
- package/dist/components/badge/types.d.ts +18 -4
- package/dist/components/buttons/Button.mdx +85 -0
- package/dist/components/buttons/Button.stories.svelte +62 -27
- package/dist/components/buttons/Button.svelte +29 -25
- package/dist/components/buttons/Button.svelte.d.ts +11 -9
- package/dist/components/buttons/ButtonIcon.mdx +52 -0
- package/dist/components/buttons/ButtonIcon.stories.svelte +72 -48
- package/dist/components/buttons/ButtonIcon.svelte +58 -36
- package/dist/components/buttons/ButtonIcon.svelte.d.ts +9 -7
- package/dist/components/buttons/FAB.mdx +84 -0
- package/dist/components/buttons/FAB.stories.svelte +103 -24
- package/dist/components/buttons/FAB.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/FAB.svelte +353 -29
- package/dist/components/buttons/FAB.svelte.d.ts +11 -6
- package/dist/components/buttons/FABMenu.svelte +27 -8
- package/dist/components/buttons/FABMenu.svelte.d.ts +7 -3
- package/dist/components/buttons/FABMenuItem.svelte +20 -16
- package/dist/components/buttons/FABMenuItem.svelte.d.ts +3 -3
- package/dist/components/buttons/Toggle.stories.svelte +31 -23
- package/dist/components/buttons/Toggle.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/Toggle.svelte +28 -25
- package/dist/components/buttons/Toggle.svelte.d.ts +5 -5
- package/dist/components/buttons/button-group/ButtonGroup.mdx +39 -0
- package/dist/components/buttons/button-group/ButtonGroup.stories.svelte +62 -43
- package/dist/components/buttons/button-group/ButtonGroup.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/button-group/ButtonGroup.svelte +102 -8
- package/dist/components/buttons/button-group/ButtonGroup.svelte.d.ts +6 -7
- package/dist/components/buttons/button-group/theme.d.ts +45 -15
- package/dist/components/buttons/button-group/theme.js +13 -8
- package/dist/components/buttons/button-group/types.d.ts +13 -7
- package/dist/components/buttons/connected/ConnectedButtonGroup.mdx +43 -0
- package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte +56 -74
- package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/connected/ConnectedButtonGroup.svelte +16 -4
- package/dist/components/buttons/connected/ConnectedButtonGroup.svelte.d.ts +4 -4
- package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte +35 -8
- package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte.d.ts +2 -3
- package/dist/components/buttons/connected/theme.d.ts +33 -18
- package/dist/components/buttons/connected/theme.js +32 -9
- package/dist/components/buttons/connected/types.d.ts +36 -9
- package/dist/components/buttons/shapeMorph.d.ts +26 -0
- package/dist/components/buttons/shapeMorph.js +142 -0
- package/dist/components/buttons/split-button/SplitButton.mdx +48 -0
- package/dist/components/buttons/split-button/SplitButton.stories.svelte +9 -14
- package/dist/components/buttons/split-button/SplitButton.svelte +65 -48
- package/dist/components/buttons/split-button/SplitButton.svelte.d.ts +6 -11
- package/dist/components/buttons/split-button/theme.d.ts +110 -17
- package/dist/components/buttons/split-button/theme.js +74 -16
- package/dist/components/buttons/split-button/types.d.ts +24 -18
- package/dist/components/buttons/theme.d.ts +422 -230
- package/dist/components/buttons/theme.js +286 -380
- package/dist/components/buttons/types.d.ts +130 -125
- package/dist/components/cards/Card.mdx +44 -0
- package/dist/components/cards/Card.stories.svelte +11 -11
- package/dist/components/cards/theme.js +5 -5
- package/dist/components/chips/Chip.mdx +68 -0
- package/dist/components/chips/Chip.stories.svelte +4 -4
- package/dist/components/chips/theme.js +3 -3
- package/dist/components/containers/action-rail/ActionRail.stories.svelte +1 -0
- package/dist/components/containers/action-rail/theme.js +1 -1
- package/dist/components/containers/bottom-sheet/BottomSheet.mdx +64 -0
- package/dist/components/containers/bottom-sheet/BottomSheet.stories.svelte +108 -12
- package/dist/components/containers/bottom-sheet/BottomSheet.svelte +179 -109
- package/dist/components/containers/bottom-sheet/BottomSheet.svelte.d.ts +10 -5
- package/dist/components/containers/bottom-sheet/index.d.ts +1 -0
- package/dist/components/containers/bottom-sheet/index.js +1 -0
- package/dist/components/containers/bottom-sheet/theme.d.ts +45 -0
- package/dist/components/containers/bottom-sheet/theme.js +42 -0
- package/dist/components/containers/bottom-sheet/types.d.ts +37 -5
- package/dist/components/containers/carousel/Carousel.mdx +80 -0
- package/dist/components/containers/carousel/Carousel.stories.svelte +131 -0
- package/dist/components/containers/carousel/Carousel.stories.svelte.d.ts +4 -0
- package/dist/components/containers/carousel/Carousel.svelte +194 -0
- package/dist/components/containers/carousel/Carousel.svelte.d.ts +25 -0
- package/dist/components/containers/carousel/index.d.ts +3 -0
- package/dist/components/containers/{stack → carousel}/index.js +1 -2
- package/dist/components/containers/carousel/keylines.d.ts +32 -0
- package/dist/components/containers/carousel/keylines.js +88 -0
- package/dist/components/containers/carousel/theme.d.ts +162 -0
- package/dist/components/containers/carousel/theme.js +67 -0
- package/dist/components/containers/carousel/types.d.ts +52 -0
- package/dist/components/containers/context-menu/ContextMenu.stories.svelte +1 -0
- package/dist/components/containers/context-menu/ContextMenu.svelte +2 -2
- package/dist/components/containers/context-menu/ContextMenu.svelte.d.ts +1 -1
- package/dist/components/containers/context-menu/theme.js +10 -10
- package/dist/components/containers/dialogue/Dialogue.mdx +65 -0
- package/dist/components/containers/dialogue/Dialogue.stories.svelte +4 -4
- package/dist/components/containers/dialogue/Dialogue.svelte +1 -1
- package/dist/components/containers/dialogue/theme.js +3 -3
- package/dist/components/containers/divider/Divider.stories.svelte +2 -1
- package/dist/components/containers/divider/Divider.svelte +2 -2
- package/dist/components/containers/divider/theme.d.ts +6 -6
- package/dist/components/containers/divider/theme.js +2 -2
- package/dist/components/containers/index.d.ts +1 -1
- package/dist/components/containers/index.js +1 -1
- package/dist/components/containers/link-preview/theme.js +2 -2
- package/dist/components/containers/list/List.svelte +18 -0
- package/dist/components/containers/list/List.svelte.d.ts +4 -0
- package/dist/components/containers/list/ListItem.mdx +100 -0
- package/dist/components/containers/list/ListItem.stories.svelte +177 -42
- package/dist/components/containers/list/ListItem.stories.svelte.d.ts +2 -17
- package/dist/components/containers/list/ListItem.svelte +92 -37
- package/dist/components/containers/list/ListItem.svelte.d.ts +1 -1
- package/dist/components/containers/list/context.d.ts +6 -0
- package/dist/components/containers/list/context.js +4 -0
- package/dist/components/containers/list/index.d.ts +1 -0
- package/dist/components/containers/list/index.js +1 -0
- package/dist/components/containers/list/theme.d.ts +487 -12
- package/dist/components/containers/list/theme.js +140 -13
- package/dist/components/containers/list/types.d.ts +39 -5
- package/dist/components/containers/menu/Menu.mdx +52 -0
- package/dist/components/containers/menu/Menu.stories.svelte +14 -14
- package/dist/components/containers/menu/Menu.svelte +1 -1
- package/dist/components/containers/menu/MenuGroup.svelte +1 -1
- package/dist/components/containers/menu/MenuGroup.svelte.d.ts +1 -1
- package/dist/components/containers/menu/menu-item/MenuItem.svelte +1 -1
- package/dist/components/containers/menu/theme.js +8 -8
- package/dist/components/containers/pane/DraggablePane.stories.svelte +4 -3
- package/dist/components/containers/pane/DraggablePane.svelte +2 -2
- package/dist/components/containers/pane/Pane.stories.svelte +11 -10
- package/dist/components/containers/pane/Pane.svelte +24 -2
- package/dist/components/containers/pane/PaneGrid.stories.svelte +19 -18
- package/dist/components/containers/pane/PaneGrid.svelte +3 -2
- package/dist/components/containers/pane/PaneGrid.svelte.d.ts +2 -1
- package/dist/components/containers/pane/PaneHandle.svelte +48 -2
- package/dist/components/containers/pane/PaneHandle.svelte.d.ts +4 -0
- package/dist/components/containers/pane/resizeStore.svelte.d.ts +10 -1
- package/dist/components/containers/pane/resizeStore.svelte.js +13 -2
- package/dist/components/containers/pane/theme.js +129 -45
- package/dist/components/containers/pane/types.d.ts +3 -2
- package/dist/components/containers/popover/Popover.mdx +45 -0
- package/dist/components/containers/popover/Popover.stories.svelte +1 -1
- package/dist/components/containers/popover/Popover.svelte +1 -1
- package/dist/components/containers/popover/theme.js +3 -3
- package/dist/components/containers/scroll-area/theme.js +2 -2
- package/dist/components/containers/side-sheet/SideSheet.mdx +71 -0
- package/dist/components/containers/side-sheet/SideSheet.stories.svelte +113 -17
- package/dist/components/containers/side-sheet/SideSheet.svelte +113 -66
- package/dist/components/containers/side-sheet/SideSheet.svelte.d.ts +8 -7
- package/dist/components/containers/side-sheet/index.d.ts +1 -0
- package/dist/components/containers/side-sheet/index.js +1 -0
- package/dist/components/containers/side-sheet/theme.d.ts +108 -0
- package/dist/components/containers/side-sheet/theme.js +72 -0
- package/dist/components/containers/side-sheet/types.d.ts +35 -7
- package/dist/components/date/DateField.stories.svelte +4 -3
- package/dist/components/date/DateField.svelte +49 -26
- package/dist/components/date/DateField.svelte.d.ts +2 -0
- package/dist/components/date/DateRangeField.stories.svelte +4 -3
- package/dist/components/date/DateRangeField.svelte +54 -31
- package/dist/components/date/DateRangeField.svelte.d.ts +2 -0
- package/dist/components/date/calendarMotion.d.ts +9 -0
- package/dist/components/date/calendarMotion.js +23 -0
- package/dist/components/date/theme.d.ts +7 -7
- package/dist/components/date/theme.js +34 -30
- package/dist/components/forms/checkbox/Checkbox.mdx +35 -0
- package/dist/components/forms/checkbox/Checkbox.stories.svelte +2 -2
- package/dist/components/forms/checkbox/Checkbox.svelte +1 -1
- package/dist/components/forms/checkbox/theme.js +3 -3
- package/dist/components/forms/command/Command.stories.svelte +1 -0
- package/dist/components/forms/command/theme.js +9 -9
- package/dist/components/forms/pin/theme.js +4 -4
- package/dist/components/forms/radio-group/RadioGroup.svelte +1 -1
- package/dist/components/forms/radio-group/theme.js +5 -5
- package/dist/components/forms/search/Search.mdx +38 -0
- package/dist/components/forms/search/Search.stories.svelte +19 -9
- package/dist/components/forms/search/Search.svelte +40 -17
- package/dist/components/forms/search/Search.svelte.d.ts +2 -2
- package/dist/components/forms/search/theme.d.ts +45 -12
- package/dist/components/forms/search/theme.js +13 -8
- package/dist/components/forms/search/types.d.ts +18 -12
- package/dist/components/forms/select/Select.mdx +53 -0
- package/dist/components/forms/select/Select.stories.svelte +4 -4
- package/dist/components/forms/select/Select.svelte +10 -2
- package/dist/components/forms/select/SelectItem.svelte +1 -1
- package/dist/components/forms/select/theme.js +12 -12
- package/dist/components/forms/slider/Slider.mdx +85 -0
- package/dist/components/forms/slider/Slider.stories.svelte +7 -7
- package/dist/components/forms/slider/Slider.svelte +46 -28
- package/dist/components/forms/slider/theme.d.ts +14 -0
- package/dist/components/forms/slider/theme.js +28 -17
- package/dist/components/forms/slider/types.d.ts +3 -2
- package/dist/components/forms/switch/Switch.mdx +38 -0
- package/dist/components/forms/switch/Switch.stories.svelte +3 -3
- package/dist/components/forms/switch/theme.js +6 -6
- package/dist/components/forms/textfield/Textfield.mdx +53 -0
- package/dist/components/forms/textfield/Textfield.stories.svelte +6 -6
- package/dist/components/forms/textfield/Textfield.svelte +1 -0
- package/dist/components/forms/textfield/theme.d.ts +3 -0
- package/dist/components/forms/textfield/theme.js +22 -19
- package/dist/components/forms/toggle-group/theme.js +2 -2
- package/dist/components/forms/tooltip/Tooltip.stories.svelte +1 -0
- package/dist/components/forms/tooltip/theme.js +3 -3
- package/dist/components/misc/Avatar.stories.svelte +5 -4
- package/dist/components/misc/ThemeSettings.svelte +9 -9
- package/dist/components/misc/ThemeSwitcher.svelte +3 -3
- package/dist/components/misc/theme.js +4 -4
- package/dist/components/nav/appbar/AppBar.mdx +71 -0
- package/dist/components/nav/appbar/AppBar.stories.svelte +93 -3
- package/dist/components/nav/appbar/AppBar.stories.svelte.d.ts +2 -17
- package/dist/components/nav/appbar/AppBar.svelte +90 -37
- package/dist/components/nav/appbar/AppBar.svelte.d.ts +9 -2
- package/dist/components/nav/appbar/theme.d.ts +85 -18
- package/dist/components/nav/appbar/theme.js +159 -23
- package/dist/components/nav/appbar/types.d.ts +46 -9
- package/dist/components/nav/breadcrumb/Breadcrumb.stories.svelte +1 -0
- package/dist/components/nav/breadcrumb/theme.js +5 -5
- package/dist/components/nav/navbar/Navbar.mdx +38 -0
- package/dist/components/nav/navbar/Navbar.svelte +1 -1
- package/dist/components/nav/navbar/NavbarItem.svelte +12 -9
- package/dist/components/nav/navbar/theme.js +6 -6
- package/dist/components/nav/rail/Rail.mdx +73 -0
- package/dist/components/nav/rail/Rail.stories.svelte +3 -7
- package/dist/components/nav/rail/Rail.svelte +1 -0
- package/dist/components/nav/rail/RailItem.svelte +12 -9
- package/dist/components/nav/rail/theme.js +13 -13
- package/dist/components/nav/rail/types.d.ts +4 -1
- package/dist/components/nav/tabs/TabHolder.svelte +29 -3
- package/dist/components/nav/tabs/TabHolder.svelte.d.ts +3 -1
- package/dist/components/nav/tabs/Tabs.mdx +62 -0
- package/dist/components/nav/tabs/Tabs.stories.svelte +1 -1
- package/dist/components/nav/tabs/theme.js +4 -4
- package/dist/components/pill/Pill.mdx +32 -0
- package/dist/components/pill/Pill.stories.svelte +1 -1
- package/dist/components/pill/theme.d.ts +1 -1
- package/dist/components/pill/theme.js +1 -1
- package/dist/components/progress/LinearProgress.svelte +1 -1
- package/dist/components/progress/Progress.mdx +50 -0
- package/dist/components/progress/Progress.stories.svelte +6 -6
- package/dist/components/snackbar/Snackbar.mdx +52 -0
- package/dist/components/snackbar/Snackbar.stories.svelte +5 -5
- package/dist/components/snackbar/Snackbar.svelte +1 -1
- package/dist/components/snackbar/theme.d.ts +3 -3
- package/dist/components/snackbar/theme.js +4 -4
- package/dist/components/table/Table.stories.svelte +1 -0
- package/dist/components/table/TableHeader.svelte +1 -1
- package/dist/components/table/theme.js +3 -3
- package/dist/components/time/TimeField.stories.svelte +3 -2
- package/dist/components/time/TimeField.svelte +14 -8
- package/dist/components/time/TimeField.svelte.d.ts +6 -0
- package/dist/components/time/TimepickerInput.svelte +9 -5
- package/dist/components/time/theme.js +5 -5
- package/dist/components/time/types.d.ts +11 -1
- package/dist/components/toolbar/Toolbar.stories.svelte +1 -0
- package/dist/components/toolbar/Toolbar.svelte +1 -1
- package/dist/components/toolbar/Toolbar.svelte.d.ts +1 -1
- package/dist/components/toolbar/theme.js +14 -14
- package/dist/components/typography/Typography.mdx +67 -0
- package/dist/components/typography/body/Body.stories.svelte +2 -1
- package/dist/components/typography/body/theme.d.ts +15 -12
- package/dist/components/typography/body/theme.js +19 -4
- package/dist/components/typography/body/types.d.ts +2 -1
- package/dist/components/typography/display/Display.stories.svelte +2 -1
- package/dist/components/typography/display/theme.d.ts +15 -12
- package/dist/components/typography/display/theme.js +19 -4
- package/dist/components/typography/display/types.d.ts +2 -1
- package/dist/components/typography/headline/Headline.stories.svelte +2 -1
- package/dist/components/typography/headline/theme.d.ts +15 -12
- package/dist/components/typography/headline/theme.js +19 -4
- package/dist/components/typography/headline/types.d.ts +2 -1
- package/dist/components/typography/kbd/Kbd.stories.svelte +2 -1
- package/dist/components/typography/kbd/theme.d.ts +4 -4
- package/dist/components/typography/kbd/theme.js +2 -2
- package/dist/components/typography/label/Label.stories.svelte +2 -1
- package/dist/components/typography/label/theme.d.ts +15 -12
- package/dist/components/typography/label/theme.js +19 -4
- package/dist/components/typography/label/types.d.ts +2 -1
- package/dist/components/typography/title/Title.stories.svelte +2 -1
- package/dist/components/typography/title/theme.d.ts +15 -12
- package/dist/components/typography/title/theme.js +19 -4
- package/dist/components/typography/title/types.d.ts +2 -1
- package/dist/index.css +1 -0
- package/dist/styles/component.css +78 -175
- package/dist/styles/elevation.css +9 -0
- package/dist/styles/spacing.css +29 -0
- package/dist/styles/typescale.css +635 -20
- package/dist/utils/Layer.svelte +1 -1
- package/dist/utils/icon/Icon.svelte +8 -6
- package/dist/utils/icon/loadingShapes.js +11 -10
- package/package.json +19 -15
- package/dist/components/containers/stack/HStack.svelte +0 -23
- package/dist/components/containers/stack/HStack.svelte.d.ts +0 -5
- package/dist/components/containers/stack/VStack.svelte +0 -23
- package/dist/components/containers/stack/VStack.svelte.d.ts +0 -5
- package/dist/components/containers/stack/index.d.ts +0 -4
- package/dist/components/containers/stack/theme.d.ts +0 -66
- package/dist/components/containers/stack/theme.js +0 -26
- package/dist/components/containers/stack/types.d.ts +0 -12
- /package/dist/components/containers/{stack → carousel}/types.js +0 -0
|
@@ -1,188 +1,193 @@
|
|
|
1
1
|
import type { AnchorButtonAttributes, IconProps } from '../../utils/index.js';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Responsive } from '../containers/pane/theme.js';
|
|
5
|
+
import type { ButtonSize, FABColor } from './theme.js';
|
|
5
6
|
export type HTMLButtonOrAnchorAttributes = HTMLButtonAttributes & HTMLAnchorAttributes;
|
|
6
|
-
export type
|
|
7
|
+
export type ButtonProps = AnchorButtonAttributes & {
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* - '
|
|
13
|
-
* -
|
|
9
|
+
* Colour style, from most to least emphasis:
|
|
10
|
+
* - `filled`: final or unblocking actions, such as Save or Confirm.
|
|
11
|
+
* - `tonal`: important actions that sit a step below filled.
|
|
12
|
+
* - `elevated`: only when the button must stand apart from a patterned background.
|
|
13
|
+
* - `outlined`: actions that need attention but aren't primary, and ways out of a flow.
|
|
14
|
+
* - `text`: optional actions, such as Learn more.
|
|
15
|
+
* @default 'filled'
|
|
14
16
|
*/
|
|
15
|
-
variant?:
|
|
17
|
+
variant?: 'elevated' | 'filled' | 'tonal' | 'outlined' | 'text';
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
* Height 32, 40, 56, 96 or 136dp. XS and S keep a 48dp target area.
|
|
20
|
+
* @default 'sm'
|
|
18
21
|
*/
|
|
19
|
-
|
|
22
|
+
size?: ButtonSize;
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
size?: ButtonMDVariants['size'];
|
|
24
|
-
/**
|
|
25
|
-
* The shape of the button corners.
|
|
26
|
-
* - 'round': Fully rounded corners.
|
|
27
|
-
* - 'square': Slightly rounded corners.
|
|
28
|
-
*/
|
|
29
|
-
shape?: ButtonMDVariants['shape'];
|
|
30
|
-
/**
|
|
31
|
-
* The label or content to display inside the button.
|
|
24
|
+
* Resting corner shape. Both morph to the same smaller radius while pressed.
|
|
25
|
+
* @default 'round'
|
|
32
26
|
*/
|
|
27
|
+
shape?: 'round' | 'square';
|
|
28
|
+
/** The label. */
|
|
33
29
|
children?: Snippet;
|
|
34
|
-
/**
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
/** Whether the button is currently in a selected state (e.g. for toggle buttons). */
|
|
37
|
-
selected?: boolean;
|
|
38
|
-
/** Whether the button behaves as a selection control (scopes selected styling). */
|
|
39
|
-
usage?: ButtonMDVariants['usage'];
|
|
40
|
-
/**
|
|
41
|
-
* Configuration for the leading icon.
|
|
42
|
-
*/
|
|
30
|
+
/** A leading icon, sized for the button. */
|
|
43
31
|
iconProps?: IconProps;
|
|
44
|
-
/**
|
|
45
|
-
* The URL to link to. If provided, the button will render as an `<a>` tag.
|
|
46
|
-
*/
|
|
32
|
+
/** Renders an `<a>` instead of a `<button>`. */
|
|
47
33
|
href?: string;
|
|
48
|
-
/** The `formaction` attribute for
|
|
34
|
+
/** The `formaction` attribute, for a submit button. */
|
|
49
35
|
formaction?: string;
|
|
50
|
-
/**
|
|
36
|
+
/** Disables the button. On a link, removes it from the tab order and sets `aria-disabled`. */
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/** Replaces the icon (or the label, with no icon) with a loading indicator. */
|
|
51
39
|
loading?: boolean;
|
|
52
40
|
};
|
|
53
|
-
|
|
41
|
+
/** @deprecated Use `ButtonProps`. */
|
|
42
|
+
export type ButtonMDProps = ButtonProps;
|
|
43
|
+
export type ToggleProps = HTMLButtonAttributes & {
|
|
54
44
|
/**
|
|
55
|
-
*
|
|
45
|
+
* Colour style. Unselected and selected colours differ per style; there is no text toggle.
|
|
46
|
+
* @default 'filled'
|
|
56
47
|
*/
|
|
57
|
-
variant?:
|
|
48
|
+
variant?: 'elevated' | 'filled' | 'tonal' | 'outlined';
|
|
49
|
+
/** @default 'sm' */
|
|
50
|
+
size?: ButtonSize;
|
|
58
51
|
/**
|
|
59
|
-
*
|
|
52
|
+
* Resting shape while unselected. Selecting swaps it: round becomes square, square becomes
|
|
53
|
+
* round.
|
|
54
|
+
* @default 'round'
|
|
60
55
|
*/
|
|
61
|
-
|
|
56
|
+
shape?: 'round' | 'square';
|
|
57
|
+
/** Whether the toggle is selected. Bindable. */
|
|
58
|
+
pressed?: boolean;
|
|
59
|
+
/** Called when the selected state changes. */
|
|
60
|
+
onPressedChange?: (pressed: boolean) => void;
|
|
61
|
+
/** The label. */
|
|
62
|
+
children?: Snippet;
|
|
63
|
+
/** A leading icon, sized for the button. */
|
|
64
|
+
iconProps?: IconProps;
|
|
65
|
+
/** Disables the toggle. */
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
/** Replaces the icon (or the label, with no icon) with a loading indicator. */
|
|
68
|
+
loading?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** @deprecated Use `ToggleProps`. */
|
|
71
|
+
export type ToggleMDProps = ToggleProps;
|
|
72
|
+
export type ButtonIconProps = AnchorButtonAttributes & {
|
|
62
73
|
/**
|
|
63
|
-
*
|
|
74
|
+
* Colour style. `standard` has no container until hovered, focused or pressed; use it for
|
|
75
|
+
* icon buttons in app bars, fields and other dense places.
|
|
76
|
+
* @default 'filled'
|
|
64
77
|
*/
|
|
65
|
-
|
|
78
|
+
variant?: 'filled' | 'tonal' | 'outlined' | 'standard';
|
|
66
79
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* - 'narrow': Narrower width.
|
|
70
|
-
* - 'wide': Wider width.
|
|
80
|
+
* Height 32, 40, 56, 96 or 136dp. XS and S keep a 48dp target area.
|
|
81
|
+
* @default 'sm'
|
|
71
82
|
*/
|
|
72
|
-
|
|
83
|
+
size?: ButtonSize;
|
|
73
84
|
/**
|
|
74
|
-
*
|
|
85
|
+
* Container width around the icon. Use `narrow` and `wide` to fit a layout, for example in a
|
|
86
|
+
* button group.
|
|
87
|
+
* @default 'default'
|
|
75
88
|
*/
|
|
76
|
-
|
|
89
|
+
width?: 'narrow' | 'default' | 'wide';
|
|
77
90
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* - 'toggle': Toggleable icon button.
|
|
91
|
+
* Resting corner shape. A selected toggle swaps it.
|
|
92
|
+
* @default 'round'
|
|
81
93
|
*/
|
|
82
|
-
|
|
94
|
+
shape?: 'round' | 'square';
|
|
83
95
|
/**
|
|
84
|
-
*
|
|
96
|
+
* `toggle` makes a two-state icon button with `aria-pressed`. Its icon fills while selected.
|
|
97
|
+
* @default 'default'
|
|
85
98
|
*/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
|
|
99
|
+
variation?: 'default' | 'toggle';
|
|
100
|
+
/** Toggle only: whether it is selected. Bindable. */
|
|
101
|
+
pressed?: boolean;
|
|
102
|
+
/** Toggle only: called when the selected state changes. */
|
|
103
|
+
onPressedChange?: (pressed: boolean) => void;
|
|
104
|
+
/** The icon. */
|
|
105
|
+
iconProps: IconProps;
|
|
89
106
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
107
|
+
* Tooltip text, shown on hover and focus. Also the accessible name when no `aria-label` is
|
|
108
|
+
* given, so an icon button should have one or the other.
|
|
92
109
|
*/
|
|
93
110
|
tooltipContent?: string;
|
|
94
|
-
/**
|
|
111
|
+
/** Classes for the tooltip trigger. */
|
|
95
112
|
triggerClass?: string;
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
/**
|
|
113
|
+
/** Tooltip side. @default 'top' */
|
|
114
|
+
triggerSide?: 'top' | 'right' | 'bottom' | 'left';
|
|
115
|
+
/** Tooltip alignment. @default 'center' */
|
|
116
|
+
triggerAlign?: 'start' | 'center' | 'end';
|
|
117
|
+
/** Renders an `<a>` instead of a `<button>` (not for toggles). */
|
|
99
118
|
href?: string;
|
|
100
|
-
/** The `formaction` attribute for
|
|
119
|
+
/** The `formaction` attribute, for a submit button. */
|
|
101
120
|
formaction?: string;
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
onPressedChange?: (pressed: boolean) => void;
|
|
106
|
-
/** Whether the button is in a loading state. Displays a loading indicator instead of the icon. */
|
|
121
|
+
/** Disables the button. */
|
|
122
|
+
disabled?: boolean;
|
|
123
|
+
/** Replaces the icon with a loading indicator. */
|
|
107
124
|
loading?: boolean;
|
|
108
|
-
/** The side of the tooltip relative to the button. */
|
|
109
|
-
triggerSide?: 'top' | 'right' | 'bottom' | 'left';
|
|
110
|
-
/** The alignment of the tooltip relative to the button. */
|
|
111
|
-
triggerAlign?: 'start' | 'center' | 'end';
|
|
112
125
|
};
|
|
113
|
-
export type FABProps =
|
|
126
|
+
export type FABProps = AnchorButtonAttributes & {
|
|
114
127
|
/**
|
|
115
|
-
*
|
|
128
|
+
* Container and icon colours. `primary-container` is the default; `primary`, `secondary` and
|
|
129
|
+
* `tertiary` are the stronger Expressive styles. With `withMenu`, the colour family also picks
|
|
130
|
+
* the menu's colour set.
|
|
131
|
+
* @default 'primary-container'
|
|
116
132
|
*/
|
|
117
|
-
|
|
133
|
+
color?: FABColor;
|
|
118
134
|
/**
|
|
119
|
-
*
|
|
135
|
+
* 56dp `regular`, 80dp `medium` or 96dp `large`. `small` (40dp) is the baseline small FAB,
|
|
136
|
+
* which M3 no longer recommends; it has no extended form.
|
|
137
|
+
* @default 'regular'
|
|
120
138
|
*/
|
|
121
|
-
size?:
|
|
122
|
-
/** Whether the FAB is disabled. */
|
|
123
|
-
disabled?: boolean;
|
|
139
|
+
size?: 'small' | 'regular' | 'medium' | 'large';
|
|
124
140
|
/**
|
|
125
|
-
*
|
|
141
|
+
* Shows `label` beside the icon: the extended FAB. The two transform into each other with the
|
|
142
|
+
* space available, so this is responsive; the label slides open and closed. Inside a `Rail` it
|
|
143
|
+
* follows the rail: a FAB while collapsed, an extended FAB while expanded. Pass `false` to keep
|
|
144
|
+
* a FAB, or toggle it yourself, for example to collapse while the page scrolls.
|
|
145
|
+
* @default { small: false, medium: true } (outside a rail)
|
|
126
146
|
*/
|
|
127
|
-
expanded?: boolean
|
|
128
|
-
/** The
|
|
147
|
+
expanded?: Responsive<boolean>;
|
|
148
|
+
/** The extended FAB's label. Also names the collapsed FAB for assistive technology. */
|
|
129
149
|
label?: string;
|
|
130
|
-
/**
|
|
131
|
-
* Whether the FAB should toggle a menu when clicked.
|
|
132
|
-
* If true, use `children` to provide `FABMenuItem` components.
|
|
133
|
-
*/
|
|
150
|
+
/** Opens a FAB menu of `FABMenuItem` children. The FAB turns into its close button. */
|
|
134
151
|
withMenu?: boolean;
|
|
135
|
-
/**
|
|
152
|
+
/** The icon. */
|
|
136
153
|
iconProps: IconProps;
|
|
137
|
-
/**
|
|
154
|
+
/** Replaces the icon with a loading indicator. */
|
|
138
155
|
loading?: boolean;
|
|
139
|
-
/**
|
|
156
|
+
/** Renders an `<a>` instead of a `<button>` (not with `withMenu`). */
|
|
140
157
|
href?: string;
|
|
141
|
-
/** The `formaction` attribute for
|
|
158
|
+
/** The `formaction` attribute, for a submit button. */
|
|
142
159
|
formaction?: string;
|
|
160
|
+
/** Disables the FAB. */
|
|
161
|
+
disabled?: boolean;
|
|
162
|
+
/** With `withMenu`: up to six `FABMenuItem`s. */
|
|
163
|
+
children?: Snippet;
|
|
143
164
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
165
|
+
* A surface the FAB opens into with a container transform: the FAB's container grows into it
|
|
166
|
+
* from the FAB's corner, and shrinks back on Escape, an outside click, or `close()`. Keep the
|
|
167
|
+
* FAB's icon in it (for example on its main row) so the icon persists through the transform.
|
|
168
|
+
* Not with `withMenu` or `href`.
|
|
146
169
|
*/
|
|
147
|
-
|
|
170
|
+
surface?: Snippet<[{
|
|
171
|
+
close: () => void;
|
|
172
|
+
}]>;
|
|
173
|
+
/** Whether the `surface` is open. Bindable. */
|
|
174
|
+
surfaceOpen?: boolean;
|
|
148
175
|
};
|
|
149
176
|
export type FABMenuProps = HTMLAttributes<HTMLDivElement> & {
|
|
150
|
-
/**
|
|
151
|
-
* The menu items. Use `FABMenuItem` components.
|
|
152
|
-
*/
|
|
177
|
+
/** The menu items. Use `FABMenuItem` components. */
|
|
153
178
|
children: Snippet;
|
|
154
179
|
};
|
|
155
|
-
export type FABMenuItemProps =
|
|
156
|
-
/**
|
|
157
|
-
* The visual variant of the menu item.
|
|
158
|
-
*/
|
|
159
|
-
variant?: FABMenuItemVariants['variant'];
|
|
160
|
-
/** Whether the menu item is disabled (skipped by keyboard navigation). */
|
|
180
|
+
export type FABMenuItemProps = AnchorButtonAttributes & {
|
|
181
|
+
/** Disables the item; keyboard navigation skips it. */
|
|
161
182
|
disabled?: boolean;
|
|
162
|
-
/**
|
|
183
|
+
/** Replaces the icon with a loading indicator. */
|
|
163
184
|
loading?: boolean;
|
|
164
|
-
/**
|
|
165
|
-
* The content of the menu item (usually a text label).
|
|
166
|
-
*/
|
|
185
|
+
/** The label. */
|
|
167
186
|
children: Snippet;
|
|
168
|
-
/**
|
|
187
|
+
/** The leading icon. */
|
|
169
188
|
iconProps: IconProps;
|
|
170
|
-
/**
|
|
189
|
+
/** Renders an `<a>` instead of a `<button>`. */
|
|
171
190
|
href?: string;
|
|
172
|
-
/** The `formaction` attribute for
|
|
191
|
+
/** The `formaction` attribute, for a submit button. */
|
|
173
192
|
formaction?: string;
|
|
174
193
|
};
|
|
175
|
-
export type ToggleMDProps = Pick<ButtonMDVariants, 'size' | 'shape'> & HTMLButtonAttributes & {
|
|
176
|
-
/** Whether the toggle is currently pressed/selected. Bindable. */
|
|
177
|
-
pressed?: boolean;
|
|
178
|
-
/** Callback when pressed state changes. */
|
|
179
|
-
onPressedChange?: (pressed: boolean) => void;
|
|
180
|
-
/** Label or content inside the toggle. */
|
|
181
|
-
children?: Snippet;
|
|
182
|
-
/** Optional leading icon. */
|
|
183
|
-
iconProps?: IconProps;
|
|
184
|
-
/** Whether the toggle is disabled. */
|
|
185
|
-
disabled?: boolean;
|
|
186
|
-
/** Whether the toggle is in a loading state. */
|
|
187
|
-
loading?: boolean;
|
|
188
|
-
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Meta, Title, Subtitle, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as CardStories from './Card.stories.svelte';
|
|
3
|
+
|
|
4
|
+
<Meta of={CardStories} />
|
|
5
|
+
|
|
6
|
+
<Title />
|
|
7
|
+
|
|
8
|
+
<Subtitle>Cards group related content and actions about a single subject.</Subtitle>
|
|
9
|
+
|
|
10
|
+
[M3 spec](https://m3.material.io/components/cards/specs) ·
|
|
11
|
+
`import { Card } from '@noxlovette/material';`
|
|
12
|
+
|
|
13
|
+
<Canvas of={CardStories.Playground} />
|
|
14
|
+
|
|
15
|
+
<Controls of={CardStories.Playground} />
|
|
16
|
+
|
|
17
|
+
## Types
|
|
18
|
+
|
|
19
|
+
`type` picks one of the three M3 treatments: `elevated`, `filled` or `outlined`. A card is a
|
|
20
|
+
container, not a template: title, media and actions are whatever you put in `children`.
|
|
21
|
+
|
|
22
|
+
<Canvas of={CardStories.Types} />
|
|
23
|
+
|
|
24
|
+
## Clickable cards
|
|
25
|
+
|
|
26
|
+
With `href`, the card renders a real `<a>`. `hoverable` then defaults to on, and so does it
|
|
27
|
+
when `onselect` or `ondelete` is set, so the card gets the state layer. Don't nest another link
|
|
28
|
+
inside a link card. For a card that holds its own buttons, use the selectable pattern below.
|
|
29
|
+
|
|
30
|
+
```svelte
|
|
31
|
+
<Card href="/details" type="outlined">
|
|
32
|
+
<h3>Go to details</h3>
|
|
33
|
+
</Card>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
<Canvas of={CardStories.HoverableLink} />
|
|
37
|
+
|
|
38
|
+
<Canvas of={CardStories.SelectableWithNestedButton} />
|
|
39
|
+
|
|
40
|
+
## Accessibility
|
|
41
|
+
|
|
42
|
+
- **Native link.** Link cards are a real `<a>`, so they work with the keyboard and assistive
|
|
43
|
+
tech without extra handlers.
|
|
44
|
+
- **Focus.** Interactive cards draw the M3 focus indicator on keyboard focus.
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
href={args.href}
|
|
48
48
|
class="max-w-sm"
|
|
49
49
|
>
|
|
50
|
-
<p class="md-sys-typescale-title-medium mb-
|
|
50
|
+
<p class="md-sys-typescale-title-medium mb-spacing-50">Card title</p>
|
|
51
51
|
<p class="text-md-sys-color-on-surface-variant text-sm">
|
|
52
52
|
Supporting text describing the card's content.
|
|
53
53
|
</p>
|
|
@@ -56,19 +56,19 @@
|
|
|
56
56
|
</Story>
|
|
57
57
|
|
|
58
58
|
<Story name="Types" asChild>
|
|
59
|
-
<div class="flex flex-wrap
|
|
59
|
+
<div class="gap-spacing-200 p-spacing-300 flex flex-wrap">
|
|
60
60
|
<Card type="elevated" class="w-56">
|
|
61
|
-
<p class="md-sys-typescale-title-medium mb-
|
|
61
|
+
<p class="md-sys-typescale-title-medium mb-spacing-50">Elevated</p>
|
|
62
62
|
<p class="text-md-sys-color-on-surface-variant text-sm">Shadow separates from background.</p>
|
|
63
63
|
</Card>
|
|
64
64
|
<Card type="filled" class="w-56">
|
|
65
|
-
<p class="md-sys-typescale-title-medium mb-
|
|
65
|
+
<p class="md-sys-typescale-title-medium mb-spacing-50">Filled</p>
|
|
66
66
|
<p class="text-md-sys-color-on-surface-variant text-sm">
|
|
67
67
|
Solid background, subtle separation.
|
|
68
68
|
</p>
|
|
69
69
|
</Card>
|
|
70
70
|
<Card type="outlined" class="w-56">
|
|
71
|
-
<p class="md-sys-typescale-title-medium mb-
|
|
71
|
+
<p class="md-sys-typescale-title-medium mb-spacing-50">Outlined</p>
|
|
72
72
|
<p class="text-md-sys-color-on-surface-variant text-sm">Boundary line, least separation.</p>
|
|
73
73
|
</Card>
|
|
74
74
|
</div>
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
|
|
77
77
|
<Story name="Hoverable Link" asChild>
|
|
78
78
|
<Card href="#" class="max-w-sm">
|
|
79
|
-
<p class="md-sys-typescale-title-medium mb-
|
|
79
|
+
<p class="md-sys-typescale-title-medium mb-spacing-50">Clickable card</p>
|
|
80
80
|
<p class="text-md-sys-color-on-surface-variant text-sm">
|
|
81
81
|
Rendered as an anchor when <code>href</code> is provided; hoverable defaults to true.
|
|
82
82
|
</p>
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
</Story>
|
|
85
85
|
|
|
86
86
|
<Story name="Selectable" asChild>
|
|
87
|
-
<div class="flex flex-wrap
|
|
87
|
+
<div class="gap-spacing-200 p-spacing-300 flex flex-wrap">
|
|
88
88
|
{#each items as item (item.id)}
|
|
89
89
|
<Card
|
|
90
90
|
type="outlined"
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
if (selectedId === item.id) selectedId = null;
|
|
97
97
|
}}
|
|
98
98
|
>
|
|
99
|
-
<p class="md-sys-typescale-title-medium mb-
|
|
99
|
+
<p class="md-sys-typescale-title-medium mb-spacing-50">{item.title}</p>
|
|
100
100
|
<p class="text-md-sys-color-on-surface-variant text-sm">{item.body}</p>
|
|
101
101
|
</Card>
|
|
102
102
|
{/each}
|
|
@@ -104,15 +104,15 @@
|
|
|
104
104
|
</Story>
|
|
105
105
|
|
|
106
106
|
<Story name="Selectable With Nested Button" asChild>
|
|
107
|
-
<div class="flex flex-wrap
|
|
107
|
+
<div class="gap-spacing-200 p-spacing-300 flex flex-wrap">
|
|
108
108
|
<Card
|
|
109
109
|
type="outlined"
|
|
110
110
|
class="w-64"
|
|
111
111
|
onselect={() => console.log('card selected')}
|
|
112
112
|
ondelete={() => console.log('card deleted')}
|
|
113
113
|
>
|
|
114
|
-
<p class="md-sys-typescale-title-medium mb-
|
|
115
|
-
<p class="text-md-sys-color-on-surface-variant mb-
|
|
114
|
+
<p class="md-sys-typescale-title-medium mb-spacing-50">Card with an action</p>
|
|
115
|
+
<p class="text-md-sys-color-on-surface-variant mb-spacing-150 text-sm">
|
|
116
116
|
Clicking the card selects it. The button below calls
|
|
117
117
|
<code>event.stopPropagation()</code> so it doesn't also trigger selection.
|
|
118
118
|
</p>
|
|
@@ -2,7 +2,7 @@ import { tv } from 'tailwind-variants';
|
|
|
2
2
|
export const card = tv({
|
|
3
3
|
slots: {
|
|
4
4
|
base: 'relative flex flex-col rounded-lg disabled:opacity-[0.38] disabled:bg-md-sys-color-surface-variant state-layer before:rounded-lg transition-shadow md-sys-motion-effects',
|
|
5
|
-
icon: 'size-
|
|
5
|
+
icon: 'size-spacing-300 text-[24px] text-md-sys-color-primary'
|
|
6
6
|
},
|
|
7
7
|
variants: {
|
|
8
8
|
type: {
|
|
@@ -11,10 +11,10 @@ export const card = tv({
|
|
|
11
11
|
outlined: 'bg-md-sys-color-surface outline-1 outline-md-sys-color-outline-variant'
|
|
12
12
|
},
|
|
13
13
|
padding: {
|
|
14
|
-
none: { base: 'p-0' },
|
|
15
|
-
sm: { base: 'p-
|
|
16
|
-
md: { base: 'p-
|
|
17
|
-
lg: { base: 'p-
|
|
14
|
+
none: { base: 'p-spacing-0' },
|
|
15
|
+
sm: { base: 'p-spacing-150' },
|
|
16
|
+
md: { base: 'p-spacing-200' },
|
|
17
|
+
lg: { base: 'p-spacing-300' }
|
|
18
18
|
},
|
|
19
19
|
hoverable: {
|
|
20
20
|
true: ''
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Meta, Title, Subtitle, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as ChipStories from './Chip.stories.svelte';
|
|
3
|
+
|
|
4
|
+
<Meta of={ChipStories} />
|
|
5
|
+
|
|
6
|
+
<Title />
|
|
7
|
+
|
|
8
|
+
<Subtitle>
|
|
9
|
+
Chips help people enter information, make selections, filter content, or trigger actions.
|
|
10
|
+
</Subtitle>
|
|
11
|
+
|
|
12
|
+
[M3 spec](https://m3.material.io/components/chips/specs) ·
|
|
13
|
+
`import { Chip } from '@noxlovette/material';`
|
|
14
|
+
|
|
15
|
+
<Canvas of={ChipStories.Playground} />
|
|
16
|
+
|
|
17
|
+
<Controls of={ChipStories.Playground} />
|
|
18
|
+
|
|
19
|
+
## Choosing a variant
|
|
20
|
+
|
|
21
|
+
`variant` sets both the look and the element the chip renders:
|
|
22
|
+
|
|
23
|
+
| Variant | Use for | Renders |
|
|
24
|
+
| ------------ | --------------------------------------------------------------- | ------------------------------------------------------ |
|
|
25
|
+
| `assist` | A smart or automated action, like adding an event to a calendar | `<button>` (or `<a>` with `href`); icon tinted primary |
|
|
26
|
+
| `filter` | Filtering content by tags or descriptive words | A toggle; a checkmark replaces the icon when selected |
|
|
27
|
+
| `input` | A piece of information the user entered (a contact, a value) | A plain container; `onRemove` adds a remove button |
|
|
28
|
+
| `suggestion` | A generated suggestion that narrows intent | Like `assist`, without the tinted icon |
|
|
29
|
+
|
|
30
|
+
`elevated` swaps the flat, outlined container for a shadowed one on every variant except `input`,
|
|
31
|
+
which the spec keeps flat. For a static label with no interaction (a status or a count), use
|
|
32
|
+
`Pill` instead.
|
|
33
|
+
|
|
34
|
+
<Canvas of={ChipStories.Assist} />
|
|
35
|
+
|
|
36
|
+
<Canvas of={ChipStories.Filter} />
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<Chip variant="filter" bind:selected={wifiOnly}>Wifi</Chip>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
<Canvas of={ChipStories.Input} />
|
|
43
|
+
|
|
44
|
+
Render one input chip per entry, and remove the entry from your own array in `onRemove`:
|
|
45
|
+
|
|
46
|
+
```svelte
|
|
47
|
+
{#each recipients as name}
|
|
48
|
+
<Chip
|
|
49
|
+
variant="input"
|
|
50
|
+
iconProps={{ name: 'person' }}
|
|
51
|
+
onRemove={() => (recipients = recipients.filter((r) => r !== name))}
|
|
52
|
+
>
|
|
53
|
+
{name}
|
|
54
|
+
</Chip>
|
|
55
|
+
{/each}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
<Canvas of={ChipStories.Suggestion} />
|
|
59
|
+
|
|
60
|
+
## Accessibility
|
|
61
|
+
|
|
62
|
+
- **Roles.** Assist and suggestion chips are real buttons or links. Filter chips are toggles
|
|
63
|
+
whose `aria-pressed` reflects `selected`. An input chip's remove button is its own focusable
|
|
64
|
+
`<button>`, never nested inside another interactive element.
|
|
65
|
+
- **Disabled.** Assist, filter and suggestion chips use the native `disabled` attribute. An input
|
|
66
|
+
chip's container is a `<div>`, so it gets `aria-disabled`, and its remove button a real
|
|
67
|
+
`disabled`.
|
|
68
|
+
- **Contrast.** Every state pairs a container with its `on-*` role, so text keeps AA contrast.
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<Story name="Playground">Chip</Story>
|
|
29
29
|
|
|
30
30
|
<Story name="Assist" asChild>
|
|
31
|
-
<div class="flex flex-wrap items-center
|
|
31
|
+
<div class="gap-spacing-200 p-spacing-300 flex flex-wrap items-center">
|
|
32
32
|
<Chip variant="assist" iconProps={{ name: 'calendar_today' }}>Set reminder</Chip>
|
|
33
33
|
<Chip variant="assist" elevated iconProps={{ name: 'calendar_today' }}>Set reminder</Chip>
|
|
34
34
|
<Chip variant="assist" disabled iconProps={{ name: 'calendar_today' }}>Set reminder</Chip>
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
</Story>
|
|
37
37
|
|
|
38
38
|
<Story name="Filter" asChild>
|
|
39
|
-
<div class="flex flex-wrap items-center
|
|
39
|
+
<div class="gap-spacing-200 p-spacing-300 flex flex-wrap items-center">
|
|
40
40
|
<Chip variant="filter" bind:selected={filterSelected}>Filter chip</Chip>
|
|
41
41
|
<Chip variant="filter" iconProps={{ name: 'star' }}>Starred</Chip>
|
|
42
42
|
<Chip variant="filter" elevated selected>Elevated selected</Chip>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
</Story>
|
|
46
46
|
|
|
47
47
|
<Story name="Input" asChild>
|
|
48
|
-
<div class="flex flex-wrap items-center
|
|
48
|
+
<div class="gap-spacing-200 p-spacing-300 flex flex-wrap items-center">
|
|
49
49
|
<Chip variant="input" iconProps={{ name: 'person' }} onRemove={() => {}}>Ada Lovelace</Chip>
|
|
50
50
|
<Chip variant="input" onRemove={() => {}}>No avatar</Chip>
|
|
51
51
|
<Chip variant="input" selected iconProps={{ name: 'person' }} onRemove={() => {}}>Selected</Chip
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
</Story>
|
|
57
57
|
|
|
58
58
|
<Story name="Suggestion" asChild>
|
|
59
|
-
<div class="flex flex-wrap items-center
|
|
59
|
+
<div class="gap-spacing-200 p-spacing-300 flex flex-wrap items-center">
|
|
60
60
|
<Chip variant="suggestion">Try this</Chip>
|
|
61
61
|
<Chip variant="suggestion" elevated>Elevated</Chip>
|
|
62
62
|
<Chip variant="suggestion" disabled>Disabled</Chip>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { tv } from 'tailwind-variants';
|
|
2
2
|
export const chip = tv({
|
|
3
3
|
slots: {
|
|
4
|
-
base: 'md-component-button-base group inline-flex h-
|
|
4
|
+
base: 'md-component-button-base group inline-flex h-spacing-400 max-w-max items-center justify-center gap-spacing-100 rounded-sm before:rounded-sm px-spacing-200 md-sys-typescale-label-large',
|
|
5
5
|
icon: 'shrink-0',
|
|
6
6
|
label: '',
|
|
7
|
-
trailing: 'relative -mr-
|
|
8
|
-
checkIcon: 'size-
|
|
7
|
+
trailing: 'relative -mr-spacing-100 ml-spacing-50 inline-flex size-[18px] shrink-0 items-center justify-center rounded-full',
|
|
8
|
+
checkIcon: 'size-spacing-200 shrink-0'
|
|
9
9
|
},
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|