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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, inject, useId } from 'vue'
|
|
3
|
-
import { ChevronDownIcon } from '../../
|
|
3
|
+
import { ChevronDownIcon } from '../../icons/vue'
|
|
4
4
|
import { accordionKey } from './accordionContext'
|
|
5
5
|
import styles from './Accordion.module.css'
|
|
6
6
|
|
|
@@ -21,24 +21,25 @@ const isOpen = computed(() => ctx.open.value.includes(props.value))
|
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<template>
|
|
24
|
-
<div :class="styles.item" :data-
|
|
25
|
-
<component :is="`h${ctx.level.value}`" :class="styles.heading">
|
|
24
|
+
<div data-slot="accordion-item" :class="styles.item" :data-state="isOpen ? 'open' : 'closed'" :data-disabled="disabled || undefined">
|
|
25
|
+
<component :is="`h${ctx.level.value}`" data-slot="accordion-heading" :class="styles.heading">
|
|
26
26
|
<button
|
|
27
27
|
:id="`${id}-trigger`"
|
|
28
28
|
type="button"
|
|
29
|
+
data-slot="accordion-trigger"
|
|
29
30
|
:class="styles.trigger"
|
|
30
31
|
:aria-expanded="isOpen"
|
|
31
32
|
:aria-controls="`${id}-panel`"
|
|
32
33
|
:disabled="disabled"
|
|
33
34
|
@click="ctx.toggle(value)"
|
|
34
35
|
>
|
|
35
|
-
<span :class="styles.title"><slot name="title">{{ title }}</slot></span>
|
|
36
|
-
<ChevronDownIcon :class="styles.chevron" />
|
|
36
|
+
<span data-slot="accordion-title" :class="styles.title"><slot name="title">{{ title }}</slot></span>
|
|
37
|
+
<ChevronDownIcon data-slot="accordion-icon" :class="styles.chevron" />
|
|
37
38
|
</button>
|
|
38
39
|
</component>
|
|
39
|
-
<div :id="`${id}-panel`" role="region" :aria-labelledby="`${id}-trigger`" :class="styles.panel" :inert="!isOpen">
|
|
40
|
+
<div :id="`${id}-panel`" role="region" :aria-labelledby="`${id}-trigger`" data-slot="accordion-panel" :class="styles.panel" :inert="!isOpen">
|
|
40
41
|
<div :class="styles.panelInner">
|
|
41
|
-
<div :class="styles.content"><slot /></div>
|
|
42
|
+
<div data-slot="accordion-content" :class="styles.content"><slot /></div>
|
|
42
43
|
</div>
|
|
43
44
|
</div>
|
|
44
45
|
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
display: flex;
|
|
3
4
|
align-items: flex-start;
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
border-radius: var(--gooee-radius-md);
|
|
8
9
|
background: var(--gooee-color-surface);
|
|
9
10
|
overflow: hidden;
|
|
10
|
-
animation: alertIn var(--gooee-motion-slow) var(--gooee-ease-
|
|
11
|
+
animation: alertIn var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/* The icon shape also tells statuses apart, so colour is never alone. */
|
|
@@ -19,14 +20,14 @@
|
|
|
19
20
|
background: var(--gooee-color-warning-soft);
|
|
20
21
|
border-color: color-mix(in srgb, var(--gooee-color-warning) 45%, var(--gooee-color-border));
|
|
21
22
|
}
|
|
22
|
-
.
|
|
23
|
+
.danger {
|
|
23
24
|
background: var(--gooee-color-danger-soft);
|
|
24
25
|
border-color: color-mix(in srgb, var(--gooee-color-danger) 45%, var(--gooee-color-border));
|
|
25
26
|
}
|
|
26
27
|
.success .icon { color: var(--gooee-color-success); }
|
|
27
28
|
.warning .icon { color: var(--gooee-color-warning); }
|
|
28
|
-
.
|
|
29
|
-
.
|
|
29
|
+
.danger .icon { color: var(--gooee-color-danger); }
|
|
30
|
+
.danger .title { font-weight: var(--gooee-weight-semibold); }
|
|
30
31
|
|
|
31
32
|
.banner {
|
|
32
33
|
--strip: var(--gooee-color-inverse);
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
--gooee-color-inverse-hover: color-mix(in srgb, var(--strip-fg) 82%, var(--strip));
|
|
55
56
|
--gooee-color-accent: var(--strip-fg);
|
|
56
57
|
--gooee-color-accent-fg: var(--strip);
|
|
57
|
-
--gooee-focus-ring: 0 0 0 var(--gooee-
|
|
58
|
+
--gooee-focus-ring: 0 0 0 var(--gooee-focus-width) var(--strip), 0 0 0 calc(var(--gooee-focus-width) * 2) var(--strip-fg);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
.icon {
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
width: var(--gooee-icon-lg);
|
|
63
64
|
height: var(--gooee-icon-lg);
|
|
64
65
|
margin-top: var(--gooee-space-1);
|
|
65
|
-
animation: iconIn var(--gooee-motion-slower) var(--gooee-ease-
|
|
66
|
+
animation: iconIn var(--gooee-motion-slower) var(--gooee-ease-morph);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/* On the inverse strip a status hue can drop under 3:1, so the banner icon keeps the strip's text colour. */
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
color: var(--gooee-color-fg-muted);
|
|
105
106
|
font-size: var(--gooee-icon-md);
|
|
106
107
|
cursor: pointer;
|
|
107
|
-
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-
|
|
108
|
+
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
@media (hover: hover) {
|
|
@@ -119,3 +120,4 @@
|
|
|
119
120
|
@keyframes iconIn {
|
|
120
121
|
from { opacity: 0; transform: scale(0.5) rotate(-20deg); }
|
|
121
122
|
}
|
|
123
|
+
}
|
|
@@ -2,39 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
import { useRef, useState, type ReactNode } from 'react'
|
|
4
4
|
import { cx } from '../../internal/cx'
|
|
5
|
-
import { CheckCircleIcon, ErrorIcon, InfoIcon, WarningIcon, XIcon } from '../../
|
|
5
|
+
import { CheckCircleIcon, ErrorIcon, InfoIcon, WarningIcon, XIcon } from '../../icons/icons'
|
|
6
6
|
import { foldAway } from '../../internal/motion/alert'
|
|
7
7
|
import { focusPast } from '../../internal/motion/collapseOut'
|
|
8
8
|
import styles from './Alert.module.css'
|
|
9
9
|
|
|
10
|
-
export type
|
|
10
|
+
export type AlertTone = 'info' | 'success' | 'warning' | 'danger'
|
|
11
|
+
|
|
12
|
+
export type AlertLabels = {
|
|
13
|
+
/** Name of the close button. */
|
|
14
|
+
dismiss: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const defaultLabels: AlertLabels = { dismiss: 'Dismiss' }
|
|
11
18
|
|
|
12
19
|
export type AlertProps = {
|
|
13
|
-
/** Sets the colour and icon.
|
|
14
|
-
|
|
20
|
+
/** Sets the colour and icon. Danger and warning are announced at once. */
|
|
21
|
+
tone?: AlertTone
|
|
15
22
|
/** Short bold line at the top. */
|
|
16
23
|
title?: ReactNode
|
|
17
24
|
/** Body text under the title. */
|
|
18
25
|
children?: ReactNode
|
|
19
26
|
/** Shows a close button. Called after the collapse animation. */
|
|
20
27
|
onDismiss?: () => void
|
|
21
|
-
/** Screen reader name for the close button. */
|
|
22
|
-
dismissLabel?: string
|
|
23
28
|
/** Full-width strip for the top of a page. */
|
|
24
29
|
banner?: boolean
|
|
25
30
|
/** Button or link shown under the text. */
|
|
26
31
|
action?: ReactNode
|
|
32
|
+
/** Screen reader text, so you can translate it. Missing keys use the English defaults. */
|
|
33
|
+
labels?: Partial<AlertLabels>
|
|
27
34
|
/** Extra class for the root element. */
|
|
28
35
|
className?: string
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
const icons = { info: InfoIcon, success: CheckCircleIcon, warning: WarningIcon,
|
|
38
|
+
const icons = { info: InfoIcon, success: CheckCircleIcon, warning: WarningIcon, danger: ErrorIcon }
|
|
32
39
|
|
|
33
|
-
export function Alert({
|
|
40
|
+
export function Alert({ tone = 'info', title, children, onDismiss, banner, action, labels: labelsProp, className }: AlertProps) {
|
|
41
|
+
const labels = { ...defaultLabels, ...labelsProp }
|
|
34
42
|
const ref = useRef<HTMLDivElement>(null)
|
|
35
43
|
const [leaving, setLeaving] = useState(false)
|
|
36
|
-
const Icon = icons[
|
|
37
|
-
const urgent =
|
|
44
|
+
const Icon = icons[tone]
|
|
45
|
+
const urgent = tone === 'danger' || tone === 'warning'
|
|
38
46
|
|
|
39
47
|
// Fades, then folds the height (motion/alert.ts). The close button is about to unmount, so focus moves on first.
|
|
40
48
|
const dismiss = () => {
|
|
@@ -51,17 +59,18 @@ export function Alert({ variant = 'info', title, children, onDismiss, dismissLab
|
|
|
51
59
|
<div
|
|
52
60
|
ref={ref}
|
|
53
61
|
role={urgent ? 'alert' : 'status'}
|
|
54
|
-
|
|
62
|
+
data-slot="alert"
|
|
63
|
+
className={cx(styles.root, styles[tone], banner && styles.banner, className)}
|
|
55
64
|
data-leaving={leaving || undefined}
|
|
56
65
|
>
|
|
57
|
-
<Icon className={styles.icon} />
|
|
66
|
+
<Icon data-slot="alert-icon" className={styles.icon} />
|
|
58
67
|
<div className={styles.text}>
|
|
59
|
-
{title && <p className={styles.title}>{title}</p>}
|
|
60
|
-
{children && <div className={styles.body}>{children}</div>}
|
|
61
|
-
{action && <div className={styles.action}>{action}</div>}
|
|
68
|
+
{title && <p data-slot="alert-title" className={styles.title}>{title}</p>}
|
|
69
|
+
{children && <div data-slot="alert-body" className={styles.body}>{children}</div>}
|
|
70
|
+
{action && <div data-slot="alert-action" className={styles.action}>{action}</div>}
|
|
62
71
|
</div>
|
|
63
72
|
{onDismiss && (
|
|
64
|
-
<button type="button" className={styles.close} aria-label={
|
|
73
|
+
<button type="button" data-slot="alert-close" className={styles.close} aria-label={labels.dismiss} onClick={dismiss}>
|
|
65
74
|
<XIcon />
|
|
66
75
|
</button>
|
|
67
76
|
)}
|
|
@@ -2,32 +2,36 @@
|
|
|
2
2
|
import { computed, ref } from 'vue'
|
|
3
3
|
import { foldAway } from '../../internal/motion/alert'
|
|
4
4
|
import { focusPast } from '../../internal/motion/collapseOut'
|
|
5
|
-
import { CheckCircleIcon, ErrorIcon, InfoIcon, WarningIcon, XIcon } from '../../
|
|
5
|
+
import { CheckCircleIcon, ErrorIcon, InfoIcon, WarningIcon, XIcon } from '../../icons/vue'
|
|
6
6
|
import styles from './Alert.module.css'
|
|
7
7
|
|
|
8
8
|
// The Vue Alert: the same look (Alert.module.css) and fold-away dismiss as the React one.
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
export type AlertTone = 'info' | 'success' | 'warning' | 'danger'
|
|
10
|
+
|
|
11
|
+
export type AlertLabels = {
|
|
12
|
+
/** Name of the close button. */
|
|
13
|
+
dismiss: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { tone = 'info', onDismiss, labels } = defineProps<{
|
|
17
|
+
/** Sets the colour and icon. Danger and warning are announced at once. */
|
|
18
|
+
tone?: AlertTone
|
|
19
|
+
/** Short bold line at the top. The title slot replaces it. */
|
|
20
|
+
title?: string
|
|
21
|
+
/** Shows a close button (listen with @dismiss). Called after the collapse animation. */
|
|
22
|
+
onDismiss?: () => void
|
|
23
|
+
/** Full-width strip for the top of a page. */
|
|
24
|
+
banner?: boolean
|
|
25
|
+
/** Screen reader text, so you can translate it. Missing keys use the English defaults. */
|
|
26
|
+
labels?: Partial<AlertLabels>
|
|
27
|
+
}>()
|
|
26
28
|
/** default: body text under the title. action: a button or link shown under the text. */
|
|
27
29
|
const slots = defineSlots<{ default?: () => unknown; title?: () => unknown; action?: () => unknown }>()
|
|
28
30
|
|
|
29
|
-
const icons = { info: InfoIcon, success: CheckCircleIcon, warning: WarningIcon,
|
|
30
|
-
const urgent = computed(() =>
|
|
31
|
+
const icons = { info: InfoIcon, success: CheckCircleIcon, warning: WarningIcon, danger: ErrorIcon }
|
|
32
|
+
const urgent = computed(() => tone === 'danger' || tone === 'warning')
|
|
33
|
+
|
|
34
|
+
const text = computed(() => ({ dismiss: 'Dismiss', ...labels }))
|
|
31
35
|
|
|
32
36
|
const root = ref<HTMLElement | null>(null)
|
|
33
37
|
const leaving = ref(false)
|
|
@@ -39,20 +43,20 @@ const dismiss = () => {
|
|
|
39
43
|
leaving.value = true
|
|
40
44
|
foldAway(el, () => {
|
|
41
45
|
focusPast(el)
|
|
42
|
-
|
|
46
|
+
onDismiss?.()
|
|
43
47
|
})
|
|
44
48
|
}
|
|
45
49
|
</script>
|
|
46
50
|
|
|
47
51
|
<template>
|
|
48
|
-
<div ref="root" :role="urgent ? 'alert' : 'status'" :class="[styles.root, styles[
|
|
49
|
-
<component :is="icons[
|
|
52
|
+
<div ref="root" :role="urgent ? 'alert' : 'status'" data-slot="alert" :class="[styles.root, styles[tone], banner && styles.banner]" :data-leaving="leaving || undefined">
|
|
53
|
+
<component :is="icons[tone]" data-slot="alert-icon" :class="styles.icon" />
|
|
50
54
|
<div :class="styles.text">
|
|
51
|
-
<p v-if="title || slots.title" :class="styles.title"><slot name="title">{{ title }}</slot></p>
|
|
52
|
-
<div v-if="slots.default" :class="styles.body"><slot /></div>
|
|
53
|
-
<div v-if="slots.action" :class="styles.action"><slot name="action" /></div>
|
|
55
|
+
<p v-if="title || slots.title" data-slot="alert-title" :class="styles.title"><slot name="title">{{ title }}</slot></p>
|
|
56
|
+
<div v-if="slots.default" data-slot="alert-body" :class="styles.body"><slot /></div>
|
|
57
|
+
<div v-if="slots.action" data-slot="alert-action" :class="styles.action"><slot name="action" /></div>
|
|
54
58
|
</div>
|
|
55
|
-
<button v-if="onDismiss" type="button" :class="styles.close" :aria-label="
|
|
59
|
+
<button v-if="onDismiss" type="button" data-slot="alert-close" :class="styles.close" :aria-label="text.dismiss" @click="dismiss">
|
|
56
60
|
<XIcon />
|
|
57
61
|
</button>
|
|
58
62
|
</div>
|
|
@@ -31,7 +31,7 @@ export type AlertDialogProps = {
|
|
|
31
31
|
/** Called when they cancel with the button or Esc, before the dialog closes. */
|
|
32
32
|
onCancel?: () => void
|
|
33
33
|
/** "danger" gives the confirm button the solid red look, for actions that destroy something. */
|
|
34
|
-
tone?: '
|
|
34
|
+
tone?: 'neutral' | 'danger'
|
|
35
35
|
/** Extra class for the dialog panel. */
|
|
36
36
|
className?: string
|
|
37
37
|
}
|
|
@@ -46,7 +46,7 @@ export function AlertDialog({
|
|
|
46
46
|
cancelLabel = 'Cancel',
|
|
47
47
|
onConfirm,
|
|
48
48
|
onCancel,
|
|
49
|
-
tone = '
|
|
49
|
+
tone = 'neutral',
|
|
50
50
|
className,
|
|
51
51
|
}: AlertDialogProps) {
|
|
52
52
|
const id = useId()
|
|
@@ -68,7 +68,7 @@ export function AlertDialog({
|
|
|
68
68
|
if (!mounted) return null
|
|
69
69
|
return (
|
|
70
70
|
<Portal>
|
|
71
|
-
<div className={dialog.overlay} data-state={state} aria-hidden="true" />
|
|
71
|
+
<div data-slot="alert-dialog-overlay" className={dialog.overlay} data-state={state} aria-hidden="true" />
|
|
72
72
|
<div className={dialog.positioner}>
|
|
73
73
|
<div
|
|
74
74
|
ref={panelRef}
|
|
@@ -77,17 +77,18 @@ export function AlertDialog({
|
|
|
77
77
|
aria-labelledby={`${id}-title`}
|
|
78
78
|
aria-describedby={`${id}-desc`}
|
|
79
79
|
tabIndex={-1}
|
|
80
|
+
data-slot="alert-dialog"
|
|
80
81
|
className={cx(dialog.panel, dialog.sm, className)}
|
|
81
82
|
data-state={state}
|
|
82
83
|
>
|
|
83
84
|
<header className={cx(dialog.header, styles.header)}>
|
|
84
85
|
<div className={dialog.titles}>
|
|
85
|
-
<h2 id={`${id}-title`} className={dialog.title}>{title}</h2>
|
|
86
|
-
<p id={`${id}-desc`} className={dialog.description}>{description}</p>
|
|
86
|
+
<h2 id={`${id}-title`} data-slot="alert-dialog-title" className={dialog.title}>{title}</h2>
|
|
87
|
+
<p id={`${id}-desc`} data-slot="alert-dialog-description" className={dialog.description}>{description}</p>
|
|
87
88
|
</div>
|
|
88
89
|
</header>
|
|
89
|
-
{children && <div className={dialog.body}>{children}</div>}
|
|
90
|
-
<footer className={dialog.footer}>
|
|
90
|
+
{children && <div data-slot="alert-dialog-body" className={dialog.body}>{children}</div>}
|
|
91
|
+
<footer data-slot="alert-dialog-footer" className={dialog.footer}>
|
|
91
92
|
<Button ref={cancelRef} variant="secondary" onClick={cancel}>
|
|
92
93
|
{cancelLabel}
|
|
93
94
|
</Button>
|
|
@@ -10,21 +10,23 @@ import styles from './AlertDialog.module.css'
|
|
|
10
10
|
|
|
11
11
|
// The Vue AlertDialog: the same look, morph and focus as the React one.
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
const {
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
cancelLabel = 'Cancel',
|
|
17
|
+
tone = 'neutral',
|
|
18
|
+
} = defineProps<{
|
|
19
|
+
/** The question, such as "Delete this project?". Also the accessible name. The title slot replaces it. */
|
|
20
|
+
title?: string
|
|
21
|
+
/** What happens if they confirm. Read out with the title when the dialog opens. The description slot replaces it. */
|
|
22
|
+
description?: string
|
|
23
|
+
/** Text of the confirm button. Name the action, such as "Delete project", not "OK". */
|
|
24
|
+
confirmLabel: string
|
|
25
|
+
/** Text of the cancel button. */
|
|
26
|
+
cancelLabel?: string
|
|
27
|
+
/** "danger" gives the confirm button the solid red look, for actions that destroy something. */
|
|
28
|
+
tone?: 'neutral' | 'danger'
|
|
29
|
+
}>()
|
|
28
30
|
|
|
29
31
|
/** Shows the dialog. Use v-model:open; Confirm, Cancel or Esc set it false. A tap outside never closes it. */
|
|
30
32
|
const open = defineModel<boolean>('open', { required: true })
|
|
@@ -102,21 +104,21 @@ onBeforeUnmount(() => {
|
|
|
102
104
|
|
|
103
105
|
<template>
|
|
104
106
|
<Teleport v-if="mounted" to="body">
|
|
105
|
-
<div :class="dialog.overlay" :data-state="state" aria-hidden="true" />
|
|
107
|
+
<div data-slot="alert-dialog-overlay" :class="dialog.overlay" :data-state="state" aria-hidden="true" />
|
|
106
108
|
<div :class="dialog.positioner">
|
|
107
|
-
<div ref="panel" role="alertdialog" aria-modal="true" :aria-labelledby="`${id}-title`" :aria-describedby="`${id}-desc`" tabindex="-1" :class="[dialog.panel, dialog.sm]" :data-state="state">
|
|
109
|
+
<div ref="panel" role="alertdialog" aria-modal="true" :aria-labelledby="`${id}-title`" :aria-describedby="`${id}-desc`" tabindex="-1" data-slot="alert-dialog" :class="[dialog.panel, dialog.sm]" :data-state="state">
|
|
108
110
|
<header :class="[dialog.header, styles.header]">
|
|
109
111
|
<div :class="dialog.titles">
|
|
110
|
-
<h2 :id="`${id}-title`" :class="dialog.title">
|
|
111
|
-
<slot name="title">{{
|
|
112
|
+
<h2 :id="`${id}-title`" data-slot="alert-dialog-title" :class="dialog.title">
|
|
113
|
+
<slot name="title">{{ title }}</slot>
|
|
112
114
|
</h2>
|
|
113
|
-
<p :id="`${id}-desc`" :class="dialog.description">
|
|
114
|
-
<slot name="description">{{
|
|
115
|
+
<p :id="`${id}-desc`" data-slot="alert-dialog-description" :class="dialog.description">
|
|
116
|
+
<slot name="description">{{ description }}</slot>
|
|
115
117
|
</p>
|
|
116
118
|
</div>
|
|
117
119
|
</header>
|
|
118
|
-
<div v-if="slots.default" :class="dialog.body"><slot /></div>
|
|
119
|
-
<footer :class="dialog.footer">
|
|
120
|
+
<div v-if="slots.default" data-slot="alert-dialog-body" :class="dialog.body"><slot /></div>
|
|
121
|
+
<footer data-slot="alert-dialog-footer" :class="dialog.footer">
|
|
120
122
|
<Button ref="cancelButton" variant="secondary" @click="cancel">{{ cancelLabel }}</Button>
|
|
121
123
|
<Button :variant="tone === 'danger' ? 'danger' : 'primary'" @click="confirm">{{ confirmLabel }}</Button>
|
|
122
124
|
</footer>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
display: inline-flex;
|
|
3
4
|
width: fit-content;
|
|
@@ -14,13 +15,13 @@
|
|
|
14
15
|
display: inline-block;
|
|
15
16
|
height: var(--gooee-leading-tight);
|
|
16
17
|
overflow: hidden;
|
|
17
|
-
animation: enter var(--gooee-motion-slow) var(--gooee-ease-
|
|
18
|
+
animation: enter var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
.strip {
|
|
21
22
|
display: flex;
|
|
22
23
|
flex-direction: column;
|
|
23
|
-
transition: transform var(--gooee-motion-slower) var(--gooee-ease-
|
|
24
|
+
transition: transform var(--gooee-motion-slower) var(--gooee-ease-morph);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
.cell {
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
|
|
32
33
|
.symbol {
|
|
33
34
|
display: inline-block;
|
|
34
|
-
animation: enter var(--gooee-motion-slow) var(--gooee-ease-
|
|
35
|
+
animation: enter var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
.srOnly {
|
|
@@ -46,3 +47,4 @@
|
|
|
46
47
|
@keyframes enter {
|
|
47
48
|
from { opacity: 0; transform: translateY(40%); }
|
|
48
49
|
}
|
|
50
|
+
}
|
|
@@ -8,7 +8,7 @@ export type AnimatedNumberProps = {
|
|
|
8
8
|
/** Number to show. Digits roll to the new value when it changes. */
|
|
9
9
|
value: number
|
|
10
10
|
/** Passed to Intl.NumberFormat, for currency, percent, decimals and so on. */
|
|
11
|
-
|
|
11
|
+
formatOptions?: Intl.NumberFormatOptions
|
|
12
12
|
/** Locale for number formatting. Undefined uses the browser locale. */
|
|
13
13
|
locale?: string
|
|
14
14
|
/** Extra class for the root element. */
|
|
@@ -17,12 +17,12 @@ export type AnimatedNumberProps = {
|
|
|
17
17
|
|
|
18
18
|
const DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
19
19
|
|
|
20
|
-
export function AnimatedNumber({ value,
|
|
21
|
-
const text = useMemo(() => new Intl.NumberFormat(locale,
|
|
20
|
+
export function AnimatedNumber({ value, formatOptions, locale, className }: AnimatedNumberProps) {
|
|
21
|
+
const text = useMemo(() => new Intl.NumberFormat(locale, formatOptions).format(value), [value, formatOptions, locale])
|
|
22
22
|
const chars = text.split('')
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
|
-
<span className={cx(styles.root, className)}>
|
|
25
|
+
<span data-slot="animated-number" className={cx(styles.root, className)}>
|
|
26
26
|
<span className={styles.srOnly}>{text}</span>
|
|
27
27
|
<span className={styles.visual} aria-hidden="true">
|
|
28
28
|
{chars.map((ch, i) => {
|
|
@@ -31,7 +31,7 @@ export function AnimatedNumber({ value, format, locale, className }: AnimatedNum
|
|
|
31
31
|
const d = Number(ch)
|
|
32
32
|
if (ch >= '0' && ch <= '9') {
|
|
33
33
|
return (
|
|
34
|
-
<span key={`d${key}`} className={styles.digit}>
|
|
34
|
+
<span key={`d${key}`} data-slot="animated-number-digit" className={styles.digit}>
|
|
35
35
|
<span className={styles.strip} style={{ transform: `translateY(${-d * 10}%)` }}>
|
|
36
36
|
{DIGITS.map((n) => (
|
|
37
37
|
<span key={n} className={styles.cell}>{n}</span>
|
|
@@ -41,7 +41,7 @@ export function AnimatedNumber({ value, format, locale, className }: AnimatedNum
|
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
return (
|
|
44
|
-
<span key={`s${key}${ch}`} className={styles.symbol}>
|
|
44
|
+
<span key={`s${key}${ch}`} data-slot="animated-number-symbol" className={styles.symbol}>
|
|
45
45
|
{ch}
|
|
46
46
|
</span>
|
|
47
47
|
)
|
|
@@ -7,29 +7,29 @@ const props = defineProps<{
|
|
|
7
7
|
/** Number to show. Digits roll to the new value when it changes. */
|
|
8
8
|
value: number
|
|
9
9
|
/** Passed to Intl.NumberFormat, for currency, percent, decimals and so on. */
|
|
10
|
-
|
|
10
|
+
formatOptions?: Intl.NumberFormatOptions
|
|
11
11
|
/** Locale for number formatting. Undefined uses the browser locale. */
|
|
12
12
|
locale?: string
|
|
13
13
|
}>()
|
|
14
14
|
|
|
15
15
|
const DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
16
|
-
const text = computed(() => new Intl.NumberFormat(props.locale, props.
|
|
16
|
+
const text = computed(() => new Intl.NumberFormat(props.locale, props.formatOptions).format(props.value))
|
|
17
17
|
const chars = computed(() => text.value.split(''))
|
|
18
18
|
const isDigit = (ch: string) => ch >= '0' && ch <= '9'
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<template>
|
|
22
|
-
<span :class="styles.root">
|
|
22
|
+
<span data-slot="animated-number" :class="styles.root">
|
|
23
23
|
<span :class="styles.srOnly">{{ text }}</span>
|
|
24
24
|
<span :class="styles.visual" aria-hidden="true">
|
|
25
25
|
<!-- Keyed from the right, so the ones column stays the ones column when the number grows. -->
|
|
26
26
|
<template v-for="(ch, i) in chars" :key="isDigit(ch) ? `d${chars.length - i}` : `s${chars.length - i}${ch}`">
|
|
27
|
-
<span v-if="isDigit(ch)" :class="styles.digit">
|
|
27
|
+
<span v-if="isDigit(ch)" data-slot="animated-number-digit" :class="styles.digit">
|
|
28
28
|
<span :class="styles.strip" :style="{ transform: `translateY(${-Number(ch) * 10}%)` }">
|
|
29
29
|
<span v-for="n in DIGITS" :key="n" :class="styles.cell">{{ n }}</span>
|
|
30
30
|
</span>
|
|
31
31
|
</span>
|
|
32
|
-
<span v-else :class="styles.symbol">{{ ch }}</span>
|
|
32
|
+
<span v-else data-slot="animated-number-symbol" :class="styles.symbol">{{ ch }}</span>
|
|
33
33
|
</template>
|
|
34
34
|
</span>
|
|
35
35
|
</span>
|
|
@@ -3,10 +3,10 @@ import { cx } from '../../internal/cx'
|
|
|
3
3
|
import styles from './AspectRatio.module.css'
|
|
4
4
|
|
|
5
5
|
export type AspectRatioProps = ComponentPropsWithRef<'div'> & {
|
|
6
|
-
/** Width over height, such as 16 / 9 or 1 for a square. */
|
|
7
|
-
ratio?: number
|
|
6
|
+
/** Width over height, such as 16 / 9, "16 / 9" or 1 for a square. */
|
|
7
|
+
ratio?: number | string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function AspectRatio({ ratio = 16 / 9, className, style, ...rest }: AspectRatioProps) {
|
|
11
|
-
return <div className={cx(styles.root, className)} style={{ '--ratio': ratio, ...style } as CSSProperties} {...rest} />
|
|
11
|
+
return <div data-slot="aspect-ratio" className={cx(styles.root, className)} style={{ '--ratio': ratio, ...style } as CSSProperties} {...rest} />
|
|
12
12
|
}
|
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
import styles from './AspectRatio.module.css'
|
|
3
3
|
|
|
4
4
|
// The Vue AspectRatio: the same look (AspectRatio.module.css) as the React one. The child fills the box.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}>(),
|
|
10
|
-
{ ratio: 16 / 9 },
|
|
11
|
-
)
|
|
5
|
+
const { ratio = 16 / 9 } = defineProps<{
|
|
6
|
+
/** Width over height, such as 16 / 9, "16 / 9" or 1 for a square. */
|
|
7
|
+
ratio?: number | string
|
|
8
|
+
}>()
|
|
12
9
|
defineSlots<{ default?: () => unknown }>()
|
|
13
10
|
</script>
|
|
14
11
|
|
|
15
12
|
<template>
|
|
16
|
-
<div :class="styles.root" :style="{ '--ratio': ratio }"><slot /></div>
|
|
13
|
+
<div data-slot="aspect-ratio" :class="styles.root" :style="{ '--ratio': ratio }"><slot /></div>
|
|
17
14
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
|
-
--size: var(--gooee-avatar-md);
|
|
3
|
+
--size: var(--gooee-avatar-md, 36px);
|
|
3
4
|
position: relative;
|
|
4
5
|
display: inline-grid;
|
|
5
6
|
place-items: center;
|
|
@@ -15,9 +16,9 @@
|
|
|
15
16
|
user-select: none;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
.sm { --size: var(--gooee-avatar-sm); }
|
|
19
|
-
.lg { --size: var(--gooee-avatar-lg); }
|
|
20
|
-
.xl { --size: var(--gooee-avatar-xl); }
|
|
19
|
+
.sm { --size: var(--gooee-avatar-sm, 28px); }
|
|
20
|
+
.lg { --size: var(--gooee-avatar-lg, 48px); }
|
|
21
|
+
.xl { --size: var(--gooee-avatar-xl, 72px); }
|
|
21
22
|
|
|
22
23
|
.fallback,
|
|
23
24
|
.img {
|
|
@@ -33,9 +34,9 @@
|
|
|
33
34
|
filter: blur(var(--gooee-blur-sm));
|
|
34
35
|
transform: scale(1.05);
|
|
35
36
|
transition:
|
|
36
|
-
opacity var(--gooee-motion-slow) var(--gooee-ease-
|
|
37
|
-
filter var(--gooee-motion-slow) var(--gooee-ease-
|
|
38
|
-
transform var(--gooee-motion-slow) var(--gooee-ease-
|
|
37
|
+
opacity var(--gooee-motion-slow) var(--gooee-ease-morph),
|
|
38
|
+
filter var(--gooee-motion-slow) var(--gooee-ease-morph),
|
|
39
|
+
transform var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
.img[data-loaded] {
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
height: 28%;
|
|
53
54
|
min-width: var(--gooee-space-3);
|
|
54
55
|
min-height: var(--gooee-space-3);
|
|
55
|
-
border: var(--gooee-
|
|
56
|
+
border: var(--gooee-focus-width) solid var(--gooee-color-bg);
|
|
56
57
|
border-radius: var(--gooee-radius-full);
|
|
57
58
|
background: var(--gooee-color-fg);
|
|
58
59
|
}
|
|
@@ -60,3 +61,4 @@
|
|
|
60
61
|
/* Without colour, status reads by fill: solid, half, hollow. */
|
|
61
62
|
.status[data-status="away"] { background: linear-gradient(90deg, var(--gooee-color-fg) 50%, var(--gooee-color-bg) 50%); box-shadow: inset 0 0 0 var(--gooee-line-thick) var(--gooee-color-fg); }
|
|
62
63
|
.status[data-status="offline"] { background: var(--gooee-color-bg); box-shadow: inset 0 0 0 var(--gooee-line-thick) var(--gooee-color-fg-muted); }
|
|
64
|
+
}
|
|
@@ -33,10 +33,11 @@ export function Avatar({ name, src, size = 'md', status, className }: AvatarProp
|
|
|
33
33
|
setState(src ? 'loading' : 'error')
|
|
34
34
|
}
|
|
35
35
|
return (
|
|
36
|
-
<span className={cx(styles.root, styles[size], className)} role="img" aria-label={status ? `${name}, ${status}` : name}>
|
|
37
|
-
<span className={styles.fallback} aria-hidden="true">{initials(name)}</span>
|
|
36
|
+
<span data-slot="avatar" className={cx(styles.root, styles[size], className)} role="img" aria-label={status ? `${name}, ${status}` : name}>
|
|
37
|
+
<span data-slot="avatar-fallback" className={styles.fallback} aria-hidden="true">{initials(name)}</span>
|
|
38
38
|
{src && state !== 'error' && (
|
|
39
39
|
<img
|
|
40
|
+
data-slot="avatar-image"
|
|
40
41
|
className={styles.img}
|
|
41
42
|
src={src}
|
|
42
43
|
alt=""
|
|
@@ -49,7 +50,7 @@ export function Avatar({ name, src, size = 'md', status, className }: AvatarProp
|
|
|
49
50
|
onError={() => setState('error')}
|
|
50
51
|
/>
|
|
51
52
|
)}
|
|
52
|
-
{status && <span className={styles.status} data-status={status} aria-hidden="true" />}
|
|
53
|
+
{status && <span data-slot="avatar-status" className={styles.status} data-status={status} aria-hidden="true" />}
|
|
53
54
|
</span>
|
|
54
55
|
)
|
|
55
56
|
}
|