gooee 0.52.0 → 1.0.1
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/README.md +10 -3
- package/package.json +6 -2
- package/scripts/add.js +181 -42
- package/src/base.css +3 -1
- package/src/components/Accordion/Accordion.module.css +7 -5
- package/src/components/Accordion/Accordion.tsx +13 -11
- package/src/components/Accordion/Accordion.vue +16 -15
- package/src/components/Accordion/AccordionItem.vue +8 -7
- package/src/components/Alert/Alert.module.css +9 -7
- package/src/components/Alert/Alert.tsx +25 -16
- package/src/components/Alert/Alert.vue +31 -27
- package/src/components/AlertDialog/AlertDialog.module.css +2 -0
- package/src/components/AlertDialog/AlertDialog.tsx +8 -7
- package/src/components/AlertDialog/AlertDialog.vue +25 -23
- package/src/components/AnimatedNumber/AnimatedNumber.module.css +5 -3
- package/src/components/AnimatedNumber/AnimatedNumber.tsx +6 -6
- package/src/components/AnimatedNumber/AnimatedNumber.vue +5 -5
- package/src/components/AspectRatio/AspectRatio.module.css +2 -0
- package/src/components/AspectRatio/AspectRatio.tsx +3 -3
- package/src/components/AspectRatio/AspectRatio.vue +5 -8
- package/src/components/Avatar/Avatar.module.css +10 -8
- package/src/components/Avatar/Avatar.tsx +4 -3
- package/src/components/Avatar/Avatar.vue +17 -19
- package/src/components/Avatar/index.ts +0 -2
- package/src/components/AvatarGroup/AvatarGroup.module.css +11 -9
- package/src/components/AvatarGroup/AvatarGroup.tsx +4 -4
- package/src/components/AvatarGroup/AvatarGroup.vue +13 -16
- package/src/components/Badge/Badge.module.css +6 -4
- package/src/components/Badge/Badge.tsx +3 -3
- package/src/components/Badge/Badge.vue +15 -14
- package/src/components/Breadcrumb/Breadcrumb.module.css +5 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +20 -12
- package/src/components/Breadcrumb/Breadcrumb.vue +33 -25
- package/src/components/Button/Button.module.css +16 -14
- package/src/components/Button/Button.tsx +6 -4
- package/src/components/Button/Button.vue +42 -33
- package/src/components/ButtonGroup/ButtonGroup.module.css +2 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/components/ButtonGroup/ButtonGroup.vue +9 -12
- package/src/components/Card/Card.module.css +6 -4
- package/src/components/Card/Card.tsx +6 -6
- package/src/components/Card/Card.vue +18 -21
- package/src/components/Center/Center.module.css +2 -0
- package/src/components/Center/Center.tsx +1 -1
- package/src/components/Center/Center.vue +18 -15
- package/src/components/Checkbox/Checkbox.module.css +10 -8
- package/src/components/Checkbox/Checkbox.tsx +15 -9
- package/src/components/Checkbox/Checkbox.vue +29 -31
- package/src/components/CheckboxGroup/CheckboxGroup.module.css +3 -1
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +4 -4
- package/src/components/CheckboxGroup/CheckboxGroup.vue +33 -30
- package/src/components/Cluster/Cluster.module.css +2 -0
- package/src/components/Cluster/Cluster.tsx +1 -1
- package/src/components/Cluster/Cluster.vue +21 -17
- package/src/components/CodeBlock/CodeBlock.module.css +12 -10
- package/src/components/CodeBlock/CodeBlock.tsx +18 -10
- package/src/components/CodeBlock/CodeBlock.vue +30 -27
- package/src/components/CodeBlock/highlight.ts +1 -1
- package/src/components/Collapsible/Collapsible.module.css +7 -5
- package/src/components/Collapsible/Collapsible.tsx +7 -6
- package/src/components/Collapsible/Collapsible.vue +30 -26
- package/src/components/Container/Container.module.css +2 -0
- package/src/components/Container/Container.tsx +1 -1
- package/src/components/Container/Container.vue +13 -12
- package/src/components/CopyButton/CopyButton.module.css +20 -18
- package/src/components/CopyButton/CopyButton.tsx +21 -14
- package/src/components/CopyButton/CopyButton.vue +41 -31
- package/src/components/Dial/Dial.module.css +26 -11
- package/src/components/Dial/Dial.tsx +18 -18
- package/src/components/Dial/Dial.vue +57 -60
- package/src/components/Dialog/Dialog.module.css +4 -2
- package/src/components/Dialog/Dialog.tsx +22 -13
- package/src/components/Dialog/Dialog.vue +34 -30
- package/src/components/Divider/Divider.module.css +5 -3
- package/src/components/Divider/Divider.tsx +6 -4
- package/src/components/Divider/Divider.vue +13 -16
- package/src/components/DropdownMenu/DropdownMenu.module.css +8 -6
- package/src/components/DropdownMenu/DropdownMenu.tsx +12 -9
- package/src/components/DropdownMenu/DropdownMenu.vue +25 -28
- package/src/components/EmptyState/EmptyState.module.css +6 -4
- package/src/components/EmptyState/EmptyState.tsx +6 -6
- package/src/components/EmptyState/EmptyState.vue +14 -17
- package/src/components/Fab/Fab.module.css +19 -17
- package/src/components/Fab/Fab.tsx +11 -9
- package/src/components/Fab/Fab.vue +29 -26
- package/src/components/Fieldset/Fieldset.module.css +2 -0
- package/src/components/Fieldset/Fieldset.tsx +4 -3
- package/src/components/Fieldset/Fieldset.vue +4 -4
- package/src/components/FormField/FormField.module.css +5 -3
- package/src/components/FormField/FormField.tsx +7 -7
- package/src/components/FormField/FormField.vue +4 -4
- package/src/components/Grid/Grid.module.css +2 -0
- package/src/components/Grid/Grid.tsx +1 -1
- package/src/components/Grid/Grid.vue +25 -22
- package/src/components/HoldToConfirm/HoldToConfirm.module.css +13 -11
- package/src/components/HoldToConfirm/HoldToConfirm.tsx +11 -9
- package/src/components/HoldToConfirm/HoldToConfirm.vue +37 -32
- package/src/components/IconButton/IconButton.module.css +7 -5
- package/src/components/IconButton/IconButton.tsx +2 -1
- package/src/components/IconButton/IconButton.vue +15 -14
- package/src/components/Input/Input.module.css +12 -10
- package/src/components/Input/Input.tsx +9 -7
- package/src/components/Input/Input.vue +45 -35
- package/src/components/InputGroup/InputGroup.module.css +8 -6
- package/src/components/InputGroup/InputGroup.tsx +5 -4
- package/src/components/InputGroup/InputGroup.vue +41 -36
- package/src/components/Kbd/Kbd.module.css +9 -7
- package/src/components/Kbd/Kbd.tsx +1 -1
- package/src/components/Kbd/Kbd.vue +1 -1
- package/src/components/Link/Link.module.css +4 -2
- package/src/components/Link/Link.tsx +4 -3
- package/src/components/Link/Link.vue +13 -16
- package/src/components/LivePill/LivePill.module.css +39 -37
- package/src/components/LivePill/LivePill.tsx +11 -10
- package/src/components/LivePill/LivePill.vue +38 -40
- package/src/components/Meter/Meter.module.css +5 -3
- package/src/components/Meter/Meter.tsx +9 -8
- package/src/components/Meter/Meter.vue +52 -43
- package/src/components/MorphButton/MorphButton.module.css +11 -9
- package/src/components/MorphButton/MorphButton.tsx +20 -10
- package/src/components/MorphButton/MorphButton.vue +29 -25
- package/src/components/NumberInput/NumberInput.module.css +7 -5
- package/src/components/NumberInput/NumberInput.tsx +11 -8
- package/src/components/NumberInput/NumberInput.vue +69 -57
- package/src/components/Pagination/Pagination.module.css +147 -5
- package/src/components/Pagination/Pagination.tsx +216 -41
- package/src/components/Pagination/Pagination.vue +201 -36
- package/src/components/Pagination/labels.ts +38 -0
- package/src/components/PasswordInput/PasswordInput.module.css +10 -8
- package/src/components/PasswordInput/PasswordInput.tsx +15 -7
- package/src/components/PasswordInput/PasswordInput.vue +20 -16
- package/src/components/PasswordInput/index.ts +1 -1
- package/src/components/PickerWheel/DateWheel.vue +20 -12
- package/src/components/PickerWheel/PickerWheel.module.css +15 -6
- package/src/components/PickerWheel/PickerWheel.tsx +70 -44
- package/src/components/PickerWheel/PickerWheel.vue +39 -38
- package/src/components/PickerWheel/TimeWheel.vue +23 -21
- package/src/components/PickerWheel/WheelColumn.vue +7 -5
- package/src/components/Popover/Popover.module.css +5 -3
- package/src/components/Popover/Popover.tsx +17 -8
- package/src/components/Popover/Popover.vue +26 -25
- package/src/components/ProgressBar/ProgressBar.module.css +4 -2
- package/src/components/ProgressBar/ProgressBar.tsx +6 -5
- package/src/components/ProgressBar/ProgressBar.vue +28 -25
- package/src/components/Prose/Prose.module.css +5 -3
- package/src/components/Prose/Prose.tsx +1 -1
- package/src/components/Prose/Prose.vue +5 -8
- package/src/components/Radio/Radio.module.css +10 -8
- package/src/components/Radio/Radio.tsx +10 -8
- package/src/components/Radio/Radio.vue +8 -8
- package/src/components/Radio/RadioGroup.vue +33 -35
- package/src/components/Radio/radioContext.ts +12 -0
- package/src/components/Retime/Retime.vue +25 -22
- package/src/components/RulerScrubber/RulerScrubber.module.css +11 -2
- package/src/components/RulerScrubber/RulerScrubber.tsx +19 -18
- package/src/components/RulerScrubber/RulerScrubber.vue +50 -54
- package/src/components/ScrollArea/ScrollArea.module.css +17 -15
- package/src/components/ScrollArea/ScrollArea.tsx +5 -4
- package/src/components/ScrollArea/ScrollArea.vue +15 -17
- package/src/components/SearchInput/SearchInput.module.css +6 -4
- package/src/components/SearchInput/SearchInput.tsx +22 -10
- package/src/components/SearchInput/SearchInput.vue +20 -17
- package/src/components/SearchInput/index.ts +1 -1
- package/src/components/SegmentedControl/SegmentedControl.module.css +7 -5
- package/src/components/SegmentedControl/SegmentedControl.tsx +9 -5
- package/src/components/SegmentedControl/SegmentedControl.vue +25 -29
- package/src/components/Select/Select.module.css +19 -17
- package/src/components/Select/Select.tsx +31 -18
- package/src/components/Select/Select.vue +63 -58
- package/src/components/Sheet/Sheet.module.css +6 -4
- package/src/components/Sheet/Sheet.tsx +39 -29
- package/src/components/Sheet/Sheet.vue +46 -40
- package/src/components/Skeleton/Skeleton.module.css +4 -2
- package/src/components/Skeleton/Skeleton.tsx +3 -2
- package/src/components/Skeleton/Skeleton.vue +16 -18
- package/src/components/Slider/Slider.module.css +14 -12
- package/src/components/Slider/Slider.tsx +27 -11
- package/src/components/Slider/Slider.vue +47 -37
- package/src/components/Spinner/Spinner.module.css +2 -0
- package/src/components/Spinner/Spinner.tsx +3 -3
- package/src/components/Spinner/Spinner.vue +9 -12
- package/src/components/Split/Split.module.css +2 -0
- package/src/components/Split/Split.tsx +3 -3
- package/src/components/Split/Split.vue +19 -17
- package/src/components/SplitFlap/SplitFlap.module.css +9 -7
- package/src/components/SplitFlap/SplitFlap.tsx +2 -2
- package/src/components/SplitFlap/SplitFlap.vue +24 -21
- package/src/components/Stack/Stack.module.css +2 -0
- package/src/components/Stack/Stack.tsx +1 -1
- package/src/components/Stack/Stack.vue +13 -12
- package/src/components/SwipeDeck/SwipeDeck.module.css +13 -11
- package/src/components/SwipeDeck/SwipeDeck.tsx +23 -28
- package/src/components/SwipeDeck/SwipeDeck.vue +32 -38
- package/src/components/Switch/Switch.module.css +10 -8
- package/src/components/Switch/Switch.tsx +6 -5
- package/src/components/Switch/Switch.vue +22 -24
- package/src/components/Table/Table.module.css +24 -22
- package/src/components/Table/Table.tsx +27 -30
- package/src/components/Table/Table.vue +93 -79
- package/src/components/TableOfContents/TableOfContents.module.css +9 -7
- package/src/components/TableOfContents/TableOfContents.tsx +8 -8
- package/src/components/TableOfContents/TableOfContents.vue +20 -23
- package/src/components/Tabs/Tab.vue +3 -0
- package/src/components/Tabs/TabList.vue +2 -2
- package/src/components/Tabs/TabPanel.vue +2 -0
- package/src/components/Tabs/Tabs.module.css +4 -2
- package/src/components/Tabs/Tabs.tsx +10 -5
- package/src/components/Tabs/Tabs.vue +1 -1
- package/src/components/Tag/Tag.module.css +12 -10
- package/src/components/Tag/Tag.tsx +13 -15
- package/src/components/Tag/Tag.vue +12 -14
- package/src/components/Textarea/Textarea.module.css +8 -6
- package/src/components/Textarea/Textarea.tsx +4 -3
- package/src/components/Textarea/Textarea.vue +32 -34
- package/src/components/ThemeToggle/ThemeToggle.module.css +2 -0
- package/src/components/ThemeToggle/ThemeToggle.tsx +7 -7
- package/src/components/ThemeToggle/ThemeToggle.vue +24 -22
- package/src/components/Toast/Toast.module.css +17 -15
- package/src/components/Toast/Toast.tsx +51 -34
- package/src/components/Toast/Toast.vue +35 -24
- package/src/components/Toast/ToastItem.vue +17 -16
- package/src/components/Toggle/Toggle.module.css +11 -9
- package/src/components/Toggle/Toggle.tsx +3 -2
- package/src/components/Toggle/Toggle.vue +13 -15
- package/src/components/Tooltip/Tooltip.module.css +5 -3
- package/src/components/Tooltip/Tooltip.tsx +1 -0
- package/src/components/Tooltip/Tooltip.vue +13 -18
- package/src/components/VisuallyHidden/VisuallyHidden.module.css +2 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +1 -1
- package/src/components/VisuallyHidden/VisuallyHidden.vue +5 -8
- package/src/{internal → icons}/icons.module.css +4 -2
- package/src/{internal → icons}/icons.tsx +15 -16
- package/src/internal/FieldMessage.module.css +5 -3
- package/src/internal/FieldMessage.tsx +2 -2
- package/src/internal/FieldMessage.vue +2 -2
- package/src/internal/Roll.module.css +5 -3
- package/src/internal/feel.ts +12 -10
- package/src/internal/fling.ts +3 -3
- package/src/internal/liquid.ts +12 -10
- package/src/internal/liquidMatter.ts +1 -1
- package/src/internal/liquidMore.ts +7 -7
- package/src/internal/motion/checkbox.ts +4 -4
- package/src/internal/motion/fling.ts +19 -9
- package/src/internal/motion/holdToConfirm.ts +3 -3
- package/src/internal/motion/index.ts +8 -6
- package/src/internal/motion/liquid.ts +16 -4
- package/src/internal/motion/liquidMatter.ts +8 -6
- package/src/internal/motion/liquidMore.ts +44 -25
- package/src/internal/motion/livePill.ts +1 -1
- package/src/internal/motion/numberInput.ts +2 -2
- package/src/internal/motion/pickerWheel.ts +7 -4
- package/src/internal/motion/ruler.ts +1 -1
- package/src/internal/motion/scrollArea.ts +3 -3
- package/src/internal/motion/scrollFrame.ts +9 -7
- package/src/internal/motion/scrubber.ts +39 -20
- package/src/internal/motion/slider.ts +38 -4
- package/src/internal/motion/softPress.ts +10 -9
- package/src/internal/motion/splitFlap.ts +4 -4
- package/src/internal/motion/swipeDeck.ts +38 -7
- package/src/internal/motion/table.ts +3 -6
- package/src/internal/motion/themeIcon.ts +1 -1
- package/src/internal/motion/themeReveal.ts +1 -1
- package/src/internal/motion/toast.ts +3 -3
- package/src/internal/motion.ts +7 -8
- package/src/internal/scrollFrame.ts +3 -3
- package/src/internal/useScrub.ts +1 -15
- package/src/internal/vue/useScrub.ts +2 -6
- package/src/tokens.css +81 -421
- package/src/{internal/vueIcons.ts → icons/vue.ts} +5 -5
|
@@ -23,7 +23,7 @@ import { useFloating, type Align } from '../../internal/useFloating'
|
|
|
23
23
|
import { usePresence } from '../../internal/usePresence'
|
|
24
24
|
import styles from './DropdownMenu.module.css'
|
|
25
25
|
|
|
26
|
-
export type
|
|
26
|
+
export type DropdownMenuEntry =
|
|
27
27
|
| {
|
|
28
28
|
type?: 'item'
|
|
29
29
|
label: string
|
|
@@ -50,7 +50,7 @@ export type DropdownMenuProps = {
|
|
|
50
50
|
/** One button that opens the menu. It gets the menu ARIA attributes, and an id if it has none. */
|
|
51
51
|
trigger: ReactElement<TriggerProps>
|
|
52
52
|
/** Items, separators and group labels, in menu order. */
|
|
53
|
-
items:
|
|
53
|
+
items: DropdownMenuEntry[]
|
|
54
54
|
/** Accessible name for the menu, if the trigger text is not enough. */
|
|
55
55
|
label?: string
|
|
56
56
|
/** Which edge of the trigger the menu lines up with. */
|
|
@@ -126,6 +126,7 @@ export function DropdownMenu({ trigger, items, label, align = 'start' }: Dropdow
|
|
|
126
126
|
role="menu"
|
|
127
127
|
aria-label={label}
|
|
128
128
|
aria-labelledby={label ? undefined : triggerId}
|
|
129
|
+
data-slot="dropdown-menu-content"
|
|
129
130
|
className={styles.menu}
|
|
130
131
|
data-state={state}
|
|
131
132
|
data-side={floating.side}
|
|
@@ -133,10 +134,10 @@ export function DropdownMenu({ trigger, items, label, align = 'start' }: Dropdow
|
|
|
133
134
|
onKeyDown={keys.current}
|
|
134
135
|
>
|
|
135
136
|
{items.map((item, i) => {
|
|
136
|
-
if (item.type === 'separator') return <div key={i} role="separator" className={styles.separator} />
|
|
137
|
+
if (item.type === 'separator') return <div key={i} role="separator" data-slot="dropdown-menu-separator" className={styles.separator} />
|
|
137
138
|
if (item.type === 'label')
|
|
138
139
|
return (
|
|
139
|
-
<div key={i} role="presentation" className={styles.groupLabel}>
|
|
140
|
+
<div key={i} role="presentation" data-slot="dropdown-menu-label" className={styles.groupLabel}>
|
|
140
141
|
{item.label}
|
|
141
142
|
</div>
|
|
142
143
|
)
|
|
@@ -148,9 +149,11 @@ export function DropdownMenu({ trigger, items, label, align = 'start' }: Dropdow
|
|
|
148
149
|
role="menuitem"
|
|
149
150
|
tabIndex={-1}
|
|
150
151
|
aria-disabled={item.disabled || undefined}
|
|
152
|
+
data-slot="dropdown-menu-item"
|
|
151
153
|
className={styles.item}
|
|
154
|
+
data-disabled={item.disabled || undefined}
|
|
152
155
|
data-destructive={item.destructive || undefined}
|
|
153
|
-
style={{ ['--i' as string]: n }}
|
|
156
|
+
style={{ ['--i' as string]: Math.min(n, 12) }}
|
|
154
157
|
onPointerMove={(e) => !item.disabled && e.currentTarget.focus()}
|
|
155
158
|
onClick={() => {
|
|
156
159
|
if (item.disabled) return
|
|
@@ -159,16 +162,16 @@ export function DropdownMenu({ trigger, items, label, align = 'start' }: Dropdow
|
|
|
159
162
|
}}
|
|
160
163
|
onKeyDown={itemKey}
|
|
161
164
|
>
|
|
162
|
-
{item.icon && <span className={styles.icon}>{item.icon}</span>}
|
|
163
|
-
<span className={styles.label}>
|
|
165
|
+
{item.icon && <span data-slot="dropdown-menu-item-icon" className={styles.icon}>{item.icon}</span>}
|
|
166
|
+
<span data-slot="dropdown-menu-item-label" className={styles.label}>
|
|
164
167
|
{item.label}
|
|
165
168
|
{reason && (
|
|
166
|
-
<span className={styles.reason}>
|
|
169
|
+
<span data-slot="dropdown-menu-item-reason" className={styles.reason}>
|
|
167
170
|
{reason}
|
|
168
171
|
</span>
|
|
169
172
|
)}
|
|
170
173
|
</span>
|
|
171
|
-
{item.shortcut && <kbd className={styles.shortcut}>{item.shortcut}</kbd>}
|
|
174
|
+
{item.shortcut && <kbd data-slot="dropdown-menu-shortcut" className={styles.shortcut}>{item.shortcut}</kbd>}
|
|
172
175
|
</div>
|
|
173
176
|
)
|
|
174
177
|
})}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Component } from 'vue'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type DropdownMenuEntry =
|
|
5
5
|
| {
|
|
6
6
|
type?: 'item'
|
|
7
7
|
label: string
|
|
@@ -23,8 +23,8 @@ export type MenuEntry =
|
|
|
23
23
|
import { computed, onBeforeUnmount, ref, shallowRef, useId, watch, type VNode } from 'vue'
|
|
24
24
|
import type { Align } from '../../internal/motion/floating'
|
|
25
25
|
import { dismissable } from '../../internal/motion/layers'
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
26
|
+
import { createMorph } from '../../internal/motion/liquid'
|
|
27
|
+
import { createBead } from '../../internal/motion/liquidMore'
|
|
28
28
|
import { createMenuKeys, itemKey, menuButtonKey, menuItems } from '../../internal/motion/menuKeys'
|
|
29
29
|
import { useFloating } from '../../internal/vue/useFloating'
|
|
30
30
|
import { usePresence } from '../../internal/vue/usePresence'
|
|
@@ -34,17 +34,14 @@ import styles from './DropdownMenu.module.css'
|
|
|
34
34
|
// The Vue DropdownMenu: the same look (DropdownMenu.module.css), keys, growth and bead as the React one.
|
|
35
35
|
// The trigger slot is one button that opens the menu. It gets the menu ARIA attributes, and an id if it has none.
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}>(),
|
|
46
|
-
{ align: 'start' },
|
|
47
|
-
)
|
|
37
|
+
const { items, align = 'start' } = defineProps<{
|
|
38
|
+
/** Items, separators and group labels, in menu order. */
|
|
39
|
+
items: DropdownMenuEntry[]
|
|
40
|
+
/** Accessible name for the menu, if the trigger text is not enough. */
|
|
41
|
+
label?: string
|
|
42
|
+
/** Which edge of the trigger the menu lines up with. */
|
|
43
|
+
align?: Align
|
|
44
|
+
}>()
|
|
48
45
|
const slots = defineSlots<{ trigger?: () => VNode[] }>()
|
|
49
46
|
|
|
50
47
|
const id = useId()
|
|
@@ -54,13 +51,10 @@ const anchor = shallowRef<HTMLElement | null>(null)
|
|
|
54
51
|
const setAnchor = elementRef(anchor)
|
|
55
52
|
const menu = ref<HTMLElement | null>(null)
|
|
56
53
|
const { mounted, state } = usePresence(open, 'morph-out')
|
|
57
|
-
const { style, side: placed, ready } = useFloating(anchor, menu, mounted, () => ({ side: 'bottom', align
|
|
54
|
+
const { style, side: placed, ready } = useFloating(anchor, menu, mounted, () => ({ side: 'bottom', align, offset: 6 }))
|
|
58
55
|
// Vue sets a bare number as no length at all, so the place gets its unit here.
|
|
59
56
|
// The menu grows out of its button and folds back into it.
|
|
60
|
-
const liquid =
|
|
61
|
-
() => menu.value,
|
|
62
|
-
() => anchor.value,
|
|
63
|
-
)
|
|
57
|
+
const liquid = createMorph(() => menu.value, { origin: () => anchor.value })
|
|
64
58
|
watch([state, () => mounted.value && ready.value], ([s, on]) => on && liquid.play(s), { flush: 'post' })
|
|
65
59
|
|
|
66
60
|
// The hover fill is a bead that follows the pointer from item to item.
|
|
@@ -69,7 +63,7 @@ watch(
|
|
|
69
63
|
mounted,
|
|
70
64
|
(on) => {
|
|
71
65
|
stopBead()
|
|
72
|
-
stopBead = on && menu.value ?
|
|
66
|
+
stopBead = on && menu.value ? createBead(menu.value, { className: styles.bead }).destroy : () => {}
|
|
73
67
|
},
|
|
74
68
|
{ flush: 'post' },
|
|
75
69
|
)
|
|
@@ -111,7 +105,7 @@ const onMenuKey = createMenuKeys(
|
|
|
111
105
|
() => close(),
|
|
112
106
|
)
|
|
113
107
|
|
|
114
|
-
const select = (item: Extract<
|
|
108
|
+
const select = (item: Extract<DropdownMenuEntry, { label: string; type?: 'item' }>) => {
|
|
115
109
|
if (item.disabled) return
|
|
116
110
|
close()
|
|
117
111
|
item.onSelect?.()
|
|
@@ -120,7 +114,7 @@ const select = (item: Extract<MenuEntry, { label: string; type?: 'item' }>) => {
|
|
|
120
114
|
// Each item's place in the stagger, counting items only.
|
|
121
115
|
const stagger = computed(() => {
|
|
122
116
|
let n = 0
|
|
123
|
-
return
|
|
117
|
+
return items.map((item) => (item.type === 'separator' || item.type === 'label' ? -1 : n++))
|
|
124
118
|
})
|
|
125
119
|
|
|
126
120
|
// A caller's id on the trigger wins, so their own labels and tests keep working. Read in the same render, after the trigger.
|
|
@@ -154,6 +148,7 @@ const labelledBy = () => triggerId
|
|
|
154
148
|
role="menu"
|
|
155
149
|
:aria-label="label"
|
|
156
150
|
:aria-labelledby="label ? undefined : labelledBy()"
|
|
151
|
+
data-slot="dropdown-menu-content"
|
|
157
152
|
:class="styles.menu"
|
|
158
153
|
:data-state="state"
|
|
159
154
|
:data-side="placed"
|
|
@@ -161,23 +156,25 @@ const labelledBy = () => triggerId
|
|
|
161
156
|
@keydown="onMenuKey"
|
|
162
157
|
>
|
|
163
158
|
<template v-for="(item, i) in items" :key="i">
|
|
164
|
-
<div v-if="item.type === 'separator'" role="separator" :class="styles.separator" />
|
|
165
|
-
<div v-else-if="item.type === 'label'" role="presentation" :class="styles.groupLabel">{{ item.label }}</div>
|
|
159
|
+
<div v-if="item.type === 'separator'" role="separator" data-slot="dropdown-menu-separator" :class="styles.separator" />
|
|
160
|
+
<div v-else-if="item.type === 'label'" role="presentation" data-slot="dropdown-menu-label" :class="styles.groupLabel">{{ item.label }}</div>
|
|
166
161
|
<div
|
|
167
162
|
v-else
|
|
168
163
|
role="menuitem"
|
|
169
164
|
tabindex="-1"
|
|
170
165
|
:aria-disabled="item.disabled || undefined"
|
|
166
|
+
data-slot="dropdown-menu-item"
|
|
171
167
|
:class="styles.item"
|
|
168
|
+
:data-disabled="item.disabled || undefined"
|
|
172
169
|
:data-destructive="item.destructive || undefined"
|
|
173
|
-
:style="{ '--i': stagger[i] }"
|
|
170
|
+
:style="{ '--i': Math.min(stagger[i], 12) }"
|
|
174
171
|
@pointermove="(e: PointerEvent) => !item.disabled && (e.currentTarget as HTMLElement).focus()"
|
|
175
172
|
@click="select(item)"
|
|
176
173
|
@keydown="itemKey"
|
|
177
174
|
>
|
|
178
|
-
<span v-if="item.icon" :class="styles.icon"><component :is="item.icon" /></span>
|
|
179
|
-
<span :class="styles.label">{{ item.label }}<span v-if="item.disabled && item.disabledReason" :class="styles.reason">{{ item.disabledReason }}</span></span>
|
|
180
|
-
<kbd v-if="item.shortcut" :class="styles.shortcut">{{ item.shortcut }}</kbd>
|
|
175
|
+
<span v-if="item.icon" data-slot="dropdown-menu-item-icon" :class="styles.icon"><component :is="item.icon" /></span>
|
|
176
|
+
<span data-slot="dropdown-menu-item-label" :class="styles.label">{{ item.label }}<span v-if="item.disabled && item.disabledReason" data-slot="dropdown-menu-item-reason" :class="styles.reason">{{ item.disabledReason }}</span></span>
|
|
177
|
+
<kbd v-if="item.shortcut" data-slot="dropdown-menu-shortcut" :class="styles.shortcut">{{ item.shortcut }}</kbd>
|
|
181
178
|
</div>
|
|
182
179
|
</template>
|
|
183
180
|
</div>
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
display: flex;
|
|
3
4
|
flex-direction: column;
|
|
4
5
|
align-items: center;
|
|
5
|
-
max-width: var(--gooee-empty-w);
|
|
6
|
+
max-width: var(--gooee-empty-state-w, 420px);
|
|
6
7
|
margin: 0 auto;
|
|
7
8
|
padding: var(--gooee-space-10) var(--gooee-space-5);
|
|
8
9
|
text-align: center;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
.root > * {
|
|
12
|
-
animation: rise var(--gooee-motion-slower) var(--gooee-ease-
|
|
13
|
+
animation: rise var(--gooee-motion-slower) var(--gooee-ease-morph) backwards;
|
|
13
14
|
animation-delay: calc(var(--i) * var(--gooee-motion-stagger) * 2);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
.icon {
|
|
17
18
|
display: grid;
|
|
18
19
|
place-items: center;
|
|
19
|
-
width: var(--gooee-empty-icon);
|
|
20
|
-
height: var(--gooee-empty-icon);
|
|
20
|
+
width: var(--gooee-empty-state-icon, 64px);
|
|
21
|
+
height: var(--gooee-empty-state-icon, 64px);
|
|
21
22
|
margin-bottom: var(--gooee-space-6);
|
|
22
23
|
border: var(--gooee-line) dashed var(--gooee-color-border-strong);
|
|
23
24
|
border-radius: var(--gooee-radius-panel);
|
|
@@ -64,3 +65,4 @@ h1.title { font-size: var(--gooee-text-2xl); }
|
|
|
64
65
|
@media (prefers-reduced-motion: reduce) {
|
|
65
66
|
.icon > svg { animation: none; }
|
|
66
67
|
}
|
|
68
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
2
|
import { cx } from '../../internal/cx'
|
|
3
|
-
import { InboxIcon } from '../../
|
|
3
|
+
import { InboxIcon } from '../../icons/icons'
|
|
4
4
|
import styles from './EmptyState.module.css'
|
|
5
5
|
|
|
6
6
|
export type EmptyStateProps = {
|
|
@@ -23,12 +23,12 @@ export type EmptyStateProps = {
|
|
|
23
23
|
export function EmptyState({ title, description, icon = <InboxIcon />, action, secondaryAction, headingLevel = 3, className }: EmptyStateProps) {
|
|
24
24
|
const H = `h${headingLevel}` as 'h3'
|
|
25
25
|
return (
|
|
26
|
-
<div className={cx(styles.root, className)}>
|
|
27
|
-
<div className={styles.icon} style={{ ['--i' as string]: 0 }} aria-hidden="true">{icon}</div>
|
|
28
|
-
<H className={styles.title} style={{ ['--i' as string]: 1 }}>{title}</H>
|
|
29
|
-
{description && <p className={styles.description} style={{ ['--i' as string]: 2 }}>{description}</p>}
|
|
26
|
+
<div data-slot="empty-state" className={cx(styles.root, className)}>
|
|
27
|
+
<div data-slot="empty-state-icon" className={styles.icon} style={{ ['--i' as string]: 0 }} aria-hidden="true">{icon}</div>
|
|
28
|
+
<H data-slot="empty-state-title" className={styles.title} style={{ ['--i' as string]: 1 }}>{title}</H>
|
|
29
|
+
{description && <p data-slot="empty-state-description" className={styles.description} style={{ ['--i' as string]: 2 }}>{description}</p>}
|
|
30
30
|
{(action || secondaryAction) && (
|
|
31
|
-
<div className={styles.actions} style={{ ['--i' as string]: 3 }}>
|
|
31
|
+
<div data-slot="empty-state-actions" className={styles.actions} style={{ ['--i' as string]: 3 }}>
|
|
32
32
|
{secondaryAction}
|
|
33
33
|
{action}
|
|
34
34
|
</div>
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { InboxIcon } from '../../
|
|
2
|
+
import { InboxIcon } from '../../icons/vue'
|
|
3
3
|
import styles from './EmptyState.module.css'
|
|
4
4
|
|
|
5
5
|
// The Vue EmptyState: the same look (EmptyState.module.css) as the React one.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}>(),
|
|
15
|
-
{ headingLevel: 3 },
|
|
16
|
-
)
|
|
6
|
+
const { headingLevel = 3 } = defineProps<{
|
|
7
|
+
/** Short heading that says what is empty. The title slot replaces it. */
|
|
8
|
+
title?: string
|
|
9
|
+
/** Text under the title, such as what to do next. The description slot replaces it. */
|
|
10
|
+
description?: string
|
|
11
|
+
/** Heading level for the title, to fit the page outline. Use 1 when the empty state is the whole page. */
|
|
12
|
+
headingLevel?: 1 | 2 | 3 | 4
|
|
13
|
+
}>()
|
|
17
14
|
/** icon: the picture above the title, hidden from screen readers. action: one primary action. secondaryAction: a less important one, shown before it. */
|
|
18
15
|
const slots = defineSlots<{ title?: () => unknown; description?: () => unknown; icon?: () => unknown; action?: () => unknown; secondaryAction?: () => unknown }>()
|
|
19
16
|
</script>
|
|
20
17
|
|
|
21
18
|
<template>
|
|
22
|
-
<div :class="styles.root">
|
|
23
|
-
<div :class="styles.icon" :style="{ '--i': 0 }" aria-hidden="true">
|
|
19
|
+
<div data-slot="empty-state" :class="styles.root">
|
|
20
|
+
<div data-slot="empty-state-icon" :class="styles.icon" :style="{ '--i': 0 }" aria-hidden="true">
|
|
24
21
|
<slot name="icon"><InboxIcon /></slot>
|
|
25
22
|
</div>
|
|
26
|
-
<component :is="`h${headingLevel}`" :class="styles.title" :style="{ '--i': 1 }"><slot name="title">{{ title }}</slot></component>
|
|
27
|
-
<p v-if="description || slots.description" :class="styles.description" :style="{ '--i': 2 }"><slot name="description">{{ description }}</slot></p>
|
|
28
|
-
<div v-if="slots.action || slots.secondaryAction" :class="styles.actions" :style="{ '--i': 3 }">
|
|
23
|
+
<component :is="`h${headingLevel}`" data-slot="empty-state-title" :class="styles.title" :style="{ '--i': 1 }"><slot name="title">{{ title }}</slot></component>
|
|
24
|
+
<p v-if="description || slots.description" data-slot="empty-state-description" :class="styles.description" :style="{ '--i': 2 }"><slot name="description">{{ description }}</slot></p>
|
|
25
|
+
<div v-if="slots.action || slots.secondaryAction" data-slot="empty-state-actions" :class="styles.actions" :style="{ '--i': 3 }">
|
|
29
26
|
<slot name="secondaryAction" />
|
|
30
27
|
<slot name="action" />
|
|
31
28
|
</div>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
/* In the thumb zone: the bottom corner of the screen, clear of the home indicator and a notch. */
|
|
2
3
|
.root {
|
|
3
4
|
position: fixed;
|
|
4
|
-
bottom: calc(env(safe-area-inset-bottom) + var(--gooee-fab-gap));
|
|
5
|
+
bottom: calc(env(safe-area-inset-bottom) + var(--gooee-fab-gap, 16px));
|
|
5
6
|
z-index: var(--gooee-z-sticky);
|
|
6
7
|
display: flex;
|
|
7
8
|
flex-direction: column;
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
pointer-events: none;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
.end { right: calc(env(safe-area-inset-right) + var(--gooee-fab-gap)); }
|
|
14
|
+
.end { right: calc(env(safe-area-inset-right) + var(--gooee-fab-gap, 16px)); }
|
|
14
15
|
|
|
15
16
|
.center {
|
|
16
17
|
left: 50%;
|
|
@@ -19,16 +20,16 @@
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
.contained { position: absolute; }
|
|
22
|
-
.contained.end { right: var(--gooee-fab-gap); }
|
|
23
|
-
.contained { bottom: var(--gooee-fab-gap); }
|
|
23
|
+
.contained.end { right: var(--gooee-fab-gap, 16px); }
|
|
24
|
+
.contained { bottom: var(--gooee-fab-gap, 16px); }
|
|
24
25
|
|
|
25
26
|
.fab {
|
|
26
27
|
position: relative;
|
|
27
28
|
display: inline-flex;
|
|
28
29
|
align-items: center;
|
|
29
|
-
min-width: var(--gooee-fab-size);
|
|
30
|
-
height: var(--gooee-fab-size);
|
|
31
|
-
padding: 0 calc((var(--gooee-fab-size) - var(--gooee-icon-md)) / 2);
|
|
30
|
+
min-width: var(--gooee-fab-size, 56px);
|
|
31
|
+
height: var(--gooee-fab-size, 56px);
|
|
32
|
+
padding: 0 calc((var(--gooee-fab-size, 56px) - var(--gooee-icon-md)) / 2);
|
|
32
33
|
border: 0;
|
|
33
34
|
border-radius: var(--gooee-radius-full);
|
|
34
35
|
background: var(--gooee-color-accent);
|
|
@@ -40,8 +41,8 @@
|
|
|
40
41
|
pointer-events: auto;
|
|
41
42
|
-webkit-tap-highlight-color: transparent;
|
|
42
43
|
transition:
|
|
43
|
-
background-color var(--gooee-motion-fast) var(--gooee-ease-
|
|
44
|
-
scale var(--gooee-motion-fast) var(--gooee-ease-
|
|
44
|
+
background-color var(--gooee-motion-fast) var(--gooee-ease-morph),
|
|
45
|
+
scale var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
@media (hover: hover) {
|
|
@@ -57,13 +58,13 @@
|
|
|
57
58
|
flex: none;
|
|
58
59
|
width: var(--gooee-icon-md);
|
|
59
60
|
height: var(--gooee-icon-md);
|
|
60
|
-
transition: rotate var(--gooee-motion-slow) var(--gooee-ease-
|
|
61
|
+
transition: rotate var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
.icon > svg { width: 100%; height: 100%; }
|
|
64
65
|
|
|
65
66
|
/* Open: the icon turns a quarter, the way a plus becomes a cross. */
|
|
66
|
-
.root[data-open] .icon { rotate: 45deg; }
|
|
67
|
+
.root[data-state='open'] .icon { rotate: 45deg; }
|
|
67
68
|
|
|
68
69
|
/* The label pours away into the icon: its column closes, so the pill shrinks to a circle around the icon. */
|
|
69
70
|
.labelWrap {
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
white-space: nowrap;
|
|
82
83
|
opacity: 0;
|
|
83
84
|
transition:
|
|
84
|
-
opacity var(--gooee-motion-base) var(--gooee-ease-
|
|
85
|
+
opacity var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
85
86
|
padding var(--gooee-motion-morph) var(--gooee-ease-morph);
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -110,14 +111,14 @@
|
|
|
110
111
|
scale: 0.6;
|
|
111
112
|
transform-origin: 100% 100%;
|
|
112
113
|
transition:
|
|
113
|
-
opacity var(--gooee-motion-base) var(--gooee-ease-
|
|
114
|
-
translate var(--gooee-motion-slow) var(--gooee-ease-
|
|
115
|
-
scale var(--gooee-motion-slow) var(--gooee-ease-
|
|
114
|
+
opacity var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
115
|
+
translate var(--gooee-motion-slow) var(--gooee-ease-morph),
|
|
116
|
+
scale var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
.center .actions li { transform-origin: 50% 100%; }
|
|
119
120
|
|
|
120
|
-
.root[data-open] .actions li {
|
|
121
|
+
.root[data-state='open'] .actions li {
|
|
121
122
|
opacity: 1;
|
|
122
123
|
translate: none;
|
|
123
124
|
scale: 1;
|
|
@@ -157,7 +158,7 @@
|
|
|
157
158
|
place-items: center;
|
|
158
159
|
width: var(--gooee-hit-min);
|
|
159
160
|
height: var(--gooee-hit-min);
|
|
160
|
-
margin-inline-end: calc((var(--gooee-fab-size) - var(--gooee-hit-min)) / 2);
|
|
161
|
+
margin-inline-end: calc((var(--gooee-fab-size, 56px) - var(--gooee-hit-min)) / 2);
|
|
161
162
|
border-radius: var(--gooee-radius-full);
|
|
162
163
|
background: var(--gooee-glass-bg, var(--gooee-color-surface));
|
|
163
164
|
-webkit-backdrop-filter: var(--gooee-glass-filter, none);
|
|
@@ -174,3 +175,4 @@
|
|
|
174
175
|
|
|
175
176
|
.action:focus-visible { outline: none; }
|
|
176
177
|
.action:focus-visible .actionIcon { box-shadow: var(--gooee-shadow-2), var(--gooee-focus-ring); }
|
|
178
|
+
}
|
|
@@ -27,14 +27,14 @@ export type FabProps = {
|
|
|
27
27
|
actions?: FabAction[]
|
|
28
28
|
/** Where it sits along the bottom of the screen. */
|
|
29
29
|
position?: 'end' | 'center'
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/** Pins it to the screen. false sits it at the bottom of its nearest positioned parent instead, for a demo or a panel. */
|
|
31
|
+
fixed?: boolean
|
|
32
32
|
/** Extra class for the root element. */
|
|
33
33
|
className?: string
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// One main action, floating in the thumb zone at the bottom of the screen.
|
|
37
|
-
export function Fab({ label, icon, onClick, extended = false, actions, position = 'end',
|
|
37
|
+
export function Fab({ label, icon, onClick, extended = false, actions, position = 'end', fixed = true, className }: FabProps) {
|
|
38
38
|
const id = useId()
|
|
39
39
|
const rootRef = useRef<HTMLDivElement>(null)
|
|
40
40
|
const buttonRef = useRef<HTMLButtonElement>(null)
|
|
@@ -59,14 +59,15 @@ export function Fab({ label, icon, onClick, extended = false, actions, position
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
|
-
<div ref={rootRef} className={cx(styles.root, styles[position],
|
|
62
|
+
<div ref={rootRef} data-slot="fab" className={cx(styles.root, styles[position], !fixed && styles.contained, className)} data-state={open ? 'open' : 'closed'}>
|
|
63
63
|
{hasActions && (
|
|
64
|
-
<ul id={`${id}-actions`} className={styles.actions} inert={!open}>
|
|
64
|
+
<ul id={`${id}-actions`} data-slot="fab-actions" className={styles.actions} inert={!open}>
|
|
65
65
|
{actions!.map((a, i) => (
|
|
66
66
|
<li key={a.label} style={{ ['--i' as string]: actions!.length - 1 - i }}>
|
|
67
67
|
<button
|
|
68
68
|
ref={i === 0 ? firstRef : undefined}
|
|
69
69
|
type="button"
|
|
70
|
+
data-slot="fab-action"
|
|
70
71
|
className={styles.action}
|
|
71
72
|
onClick={() => {
|
|
72
73
|
setOpen(false)
|
|
@@ -74,8 +75,8 @@ export function Fab({ label, icon, onClick, extended = false, actions, position
|
|
|
74
75
|
a.onSelect()
|
|
75
76
|
}}
|
|
76
77
|
>
|
|
77
|
-
<span className={styles.actionLabel}>{a.label}</span>
|
|
78
|
-
<span className={styles.actionIcon} aria-hidden="true">
|
|
78
|
+
<span data-slot="fab-action-label" className={styles.actionLabel}>{a.label}</span>
|
|
79
|
+
<span data-slot="fab-action-icon" className={styles.actionIcon} aria-hidden="true">
|
|
79
80
|
{a.icon}
|
|
80
81
|
</span>
|
|
81
82
|
</button>
|
|
@@ -86,6 +87,7 @@ export function Fab({ label, icon, onClick, extended = false, actions, position
|
|
|
86
87
|
<button
|
|
87
88
|
ref={buttonRef}
|
|
88
89
|
type="button"
|
|
90
|
+
data-slot="fab-trigger"
|
|
89
91
|
className={styles.fab}
|
|
90
92
|
aria-label={extended ? undefined : label}
|
|
91
93
|
aria-expanded={hasActions ? open : undefined}
|
|
@@ -93,12 +95,12 @@ export function Fab({ label, icon, onClick, extended = false, actions, position
|
|
|
93
95
|
data-extended={(extended && !compact) || undefined}
|
|
94
96
|
onClick={toggle}
|
|
95
97
|
>
|
|
96
|
-
<span className={styles.icon} aria-hidden="true">
|
|
98
|
+
<span data-slot="fab-icon" className={styles.icon} aria-hidden="true">
|
|
97
99
|
{icon}
|
|
98
100
|
</span>
|
|
99
101
|
{extended && (
|
|
100
102
|
<span className={styles.labelWrap}>
|
|
101
|
-
<span className={styles.label}>{label}</span>
|
|
103
|
+
<span data-slot="fab-label" className={styles.label}>{label}</span>
|
|
102
104
|
</span>
|
|
103
105
|
)}
|
|
104
106
|
</button>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { onBeforeUnmount, onMounted, ref, useId, watch, type Component } from 'vue'
|
|
3
3
|
import { foldOnScroll } from '../../internal/motion/fab'
|
|
4
4
|
import { dismissable } from '../../internal/motion/layers'
|
|
5
|
-
import {
|
|
5
|
+
import { createScrollFrame } from '../../internal/motion/scrollFrame'
|
|
6
6
|
import styles from './Fab.module.css'
|
|
7
7
|
|
|
8
8
|
export type FabAction = {
|
|
@@ -14,21 +14,23 @@ export type FabAction = {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// The Vue Fab: the same look (Fab.module.css), fold and actions as the React one. The main icon goes in the icon slot.
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
const {
|
|
18
|
+
extended = false,
|
|
19
|
+
actions,
|
|
20
|
+
position = 'end',
|
|
21
|
+
fixed = true,
|
|
22
|
+
} = defineProps<{
|
|
23
|
+
/** The button's name. Shown as text when extended, and always read by screen readers. */
|
|
24
|
+
label: string
|
|
25
|
+
/** Shows the label beside the icon. It pours away into the icon as the page scrolls down, and back on the way up. */
|
|
26
|
+
extended?: boolean
|
|
27
|
+
/** A short stack of actions that pours up out of the button when it is tapped. */
|
|
28
|
+
actions?: FabAction[]
|
|
29
|
+
/** Where it sits along the bottom of the screen. */
|
|
30
|
+
position?: 'end' | 'center'
|
|
31
|
+
/** Pins it to the screen. false sits it at the bottom of its nearest positioned parent instead, for a demo or a panel. */
|
|
32
|
+
fixed?: boolean
|
|
33
|
+
}>()
|
|
32
34
|
/** click: on tap. With actions, a tap opens them instead. */
|
|
33
35
|
const emit = defineEmits<{ click: [] }>()
|
|
34
36
|
defineSlots<{ icon?: () => unknown }>()
|
|
@@ -45,10 +47,10 @@ const fold = foldOnScroll((c) => (compact.value = c))
|
|
|
45
47
|
let stopFold: (() => void) | undefined
|
|
46
48
|
onMounted(() =>
|
|
47
49
|
watch(
|
|
48
|
-
() =>
|
|
50
|
+
() => extended,
|
|
49
51
|
(on) => {
|
|
50
52
|
stopFold?.()
|
|
51
|
-
stopFold = on ?
|
|
53
|
+
stopFold = on ? createScrollFrame(fold).destroy : undefined
|
|
52
54
|
},
|
|
53
55
|
{ immediate: true },
|
|
54
56
|
),
|
|
@@ -73,7 +75,7 @@ onBeforeUnmount(() => {
|
|
|
73
75
|
})
|
|
74
76
|
|
|
75
77
|
const setFirst = (el: unknown) => (firstEl.value = el as HTMLButtonElement | null)
|
|
76
|
-
const hasActions = () => Boolean(
|
|
78
|
+
const hasActions = () => Boolean(actions?.length)
|
|
77
79
|
const toggle = () => {
|
|
78
80
|
if (!hasActions()) return emit('click')
|
|
79
81
|
open.value = !open.value
|
|
@@ -87,18 +89,19 @@ const select = (a: FabAction) => {
|
|
|
87
89
|
</script>
|
|
88
90
|
|
|
89
91
|
<template>
|
|
90
|
-
<div ref="rootEl" :class="[styles.root, styles[position],
|
|
91
|
-
<ul v-if="actions?.length" :id="`${id}-actions`" :class="styles.actions" :inert="!open">
|
|
92
|
+
<div ref="rootEl" data-slot="fab" :class="[styles.root, styles[position], !fixed && styles.contained]" :data-state="open ? 'open' : 'closed'">
|
|
93
|
+
<ul v-if="actions?.length" :id="`${id}-actions`" data-slot="fab-actions" :class="styles.actions" :inert="!open">
|
|
92
94
|
<li v-for="(a, i) in actions" :key="a.label" :style="{ '--i': actions.length - 1 - i }">
|
|
93
|
-
<button :ref="i === 0 ? setFirst : undefined" type="button" :class="styles.action" @click="select(a)">
|
|
94
|
-
<span :class="styles.actionLabel">{{ a.label }}</span>
|
|
95
|
-
<span :class="styles.actionIcon" aria-hidden="true"><component :is="a.icon" /></span>
|
|
95
|
+
<button :ref="i === 0 ? setFirst : undefined" type="button" data-slot="fab-action" :class="styles.action" @click="select(a)">
|
|
96
|
+
<span data-slot="fab-action-label" :class="styles.actionLabel">{{ a.label }}</span>
|
|
97
|
+
<span data-slot="fab-action-icon" :class="styles.actionIcon" aria-hidden="true"><component :is="a.icon" /></span>
|
|
96
98
|
</button>
|
|
97
99
|
</li>
|
|
98
100
|
</ul>
|
|
99
101
|
<button
|
|
100
102
|
ref="buttonEl"
|
|
101
103
|
type="button"
|
|
104
|
+
data-slot="fab-trigger"
|
|
102
105
|
:class="styles.fab"
|
|
103
106
|
:aria-label="extended ? undefined : label"
|
|
104
107
|
:aria-expanded="actions?.length ? open : undefined"
|
|
@@ -106,9 +109,9 @@ const select = (a: FabAction) => {
|
|
|
106
109
|
:data-extended="(extended && !compact) || undefined"
|
|
107
110
|
@click="toggle"
|
|
108
111
|
>
|
|
109
|
-
<span :class="styles.icon" aria-hidden="true"><slot name="icon" /></span>
|
|
112
|
+
<span data-slot="fab-icon" :class="styles.icon" aria-hidden="true"><slot name="icon" /></span>
|
|
110
113
|
<span v-if="extended" :class="styles.labelWrap">
|
|
111
|
-
<span :class="styles.label">{{ label }}</span>
|
|
114
|
+
<span data-slot="fab-label" :class="styles.label">{{ label }}</span>
|
|
112
115
|
</span>
|
|
113
116
|
</button>
|
|
114
117
|
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
min-width: 0;
|
|
3
4
|
margin: 0;
|
|
@@ -32,3 +33,4 @@
|
|
|
32
33
|
dims here, so no control fades twice. */
|
|
33
34
|
.root:disabled > :is(.legend, .description) { opacity: var(--gooee-disabled-opacity); }
|
|
34
35
|
.root:disabled .fields { cursor: not-allowed; }
|
|
36
|
+
}
|
|
@@ -28,13 +28,14 @@ export function Fieldset({ legend, description, error, disabled, className, chil
|
|
|
28
28
|
<fieldset
|
|
29
29
|
{...rest}
|
|
30
30
|
id={id}
|
|
31
|
+
data-slot="fieldset"
|
|
31
32
|
className={cx(styles.root, className)}
|
|
32
33
|
disabled={disabled}
|
|
33
34
|
aria-describedby={describedBy || undefined}
|
|
34
35
|
>
|
|
35
|
-
<legend className={styles.legend}>{legend}</legend>
|
|
36
|
-
{description && <p id={descId} className={styles.description}>{description}</p>}
|
|
37
|
-
<div className={styles.fields}>{children}</div>
|
|
36
|
+
<legend data-slot="fieldset-legend" className={styles.legend}>{legend}</legend>
|
|
37
|
+
{description && <p id={descId} data-slot="fieldset-description" className={styles.description}>{description}</p>}
|
|
38
|
+
<div data-slot="fieldset-fields" className={styles.fields}>{children}</div>
|
|
38
39
|
<FieldMessage helpId={`${base}-help`} errorId={errorId} error={error} />
|
|
39
40
|
</fieldset>
|
|
40
41
|
)
|
|
@@ -33,10 +33,10 @@ const describedBy = computed(() => [hasDescription.value ? descId.value : null,
|
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
35
|
<template>
|
|
36
|
-
<fieldset v-bind="rest" :id="id" :class="styles.root" :disabled="disabled" :aria-describedby="describedBy">
|
|
37
|
-
<legend :class="styles.legend"><slot name="legend">{{ legend }}</slot></legend>
|
|
38
|
-
<p v-if="hasDescription" :id="descId" :class="styles.description"><slot name="description">{{ description }}</slot></p>
|
|
39
|
-
<div :class="styles.fields"><slot /></div>
|
|
36
|
+
<fieldset v-bind="rest" :id="id" data-slot="fieldset" :class="styles.root" :disabled="disabled" :aria-describedby="describedBy">
|
|
37
|
+
<legend data-slot="fieldset-legend" :class="styles.legend"><slot name="legend">{{ legend }}</slot></legend>
|
|
38
|
+
<p v-if="hasDescription" :id="descId" data-slot="fieldset-description" :class="styles.description"><slot name="description">{{ description }}</slot></p>
|
|
39
|
+
<div data-slot="fieldset-fields" :class="styles.fields"><slot /></div>
|
|
40
40
|
<FieldMessage :help-id="`${base}-help`" :error-id="errorId" :error="error" />
|
|
41
41
|
</fieldset>
|
|
42
42
|
</template>
|