gooee 0.50.0 → 0.51.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 +17 -4
- package/package.json +5 -3
- package/scripts/add.js +28 -6
- package/src/components/Accordion/Accordion.vue +62 -0
- package/src/components/Accordion/AccordionItem.vue +45 -0
- package/src/components/Accordion/accordionContext.ts +6 -0
- package/src/components/Alert/Alert.tsx +7 -27
- package/src/components/Alert/Alert.vue +59 -0
- package/src/components/AlertDialog/AlertDialog.vue +126 -0
- package/src/components/AnimatedNumber/AnimatedNumber.vue +36 -0
- package/src/components/AspectRatio/AspectRatio.vue +17 -0
- package/src/components/Avatar/Avatar.vue +56 -0
- package/src/components/AvatarGroup/AvatarGroup.vue +42 -0
- package/src/components/Badge/Badge.vue +32 -0
- package/src/components/Breadcrumb/Breadcrumb.vue +58 -0
- package/src/components/Button/Button.vue +130 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +4 -21
- package/src/components/ButtonGroup/ButtonGroup.vue +33 -0
- package/src/components/Card/Card.vue +34 -0
- package/src/components/Center/Center.vue +32 -0
- package/src/components/Checkbox/Checkbox.tsx +8 -25
- package/src/components/Checkbox/Checkbox.vue +108 -0
- package/src/components/CheckboxGroup/CheckboxGroup.vue +76 -0
- package/src/components/Cluster/Cluster.vue +34 -0
- package/src/components/CodeBlock/CodeBlock.vue +45 -0
- package/src/components/Collapsible/Collapsible.vue +59 -0
- package/src/components/Container/Container.vue +22 -0
- package/src/components/CopyButton/CopyButton.tsx +3 -49
- package/src/components/CopyButton/CopyButton.vue +116 -0
- package/src/components/Dial/Dial.tsx +12 -120
- package/src/components/Dial/Dial.vue +228 -0
- package/src/components/Dialog/Dialog.vue +139 -0
- package/src/components/Divider/Divider.vue +27 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +11 -46
- package/src/components/DropdownMenu/DropdownMenu.vue +185 -0
- package/src/components/EmptyState/EmptyState.vue +33 -0
- package/src/components/Fab/Fab.tsx +4 -14
- package/src/components/Fab/Fab.vue +115 -0
- package/src/components/Fieldset/Fieldset.vue +42 -0
- package/src/components/FormField/FormField.tsx +2 -17
- package/src/components/FormField/FormField.vue +64 -0
- package/src/components/Grid/Grid.vue +43 -0
- package/src/components/HoldToConfirm/HoldToConfirm.tsx +13 -143
- package/src/components/HoldToConfirm/HoldToConfirm.vue +281 -0
- package/src/components/IconButton/IconButton.vue +25 -0
- package/src/components/Input/Input.vue +112 -0
- package/src/components/InputGroup/InputGroup.vue +102 -0
- package/src/components/Kbd/Kbd.tsx +2 -12
- package/src/components/Kbd/Kbd.vue +21 -0
- package/src/components/Link/Link.vue +38 -0
- package/src/components/LivePill/LivePill.tsx +11 -39
- package/src/components/LivePill/LivePill.vue +152 -0
- package/src/components/Meter/Meter.vue +88 -0
- package/src/components/MorphButton/MorphButton.tsx +11 -67
- package/src/components/MorphButton/MorphButton.vue +120 -0
- package/src/components/NumberInput/NumberInput.tsx +11 -48
- package/src/components/NumberInput/NumberInput.vue +184 -0
- package/src/components/Pagination/Pagination.tsx +2 -15
- package/src/components/Pagination/Pagination.vue +87 -0
- package/src/components/Pagination/range.ts +15 -0
- package/src/components/PasswordInput/PasswordInput.vue +53 -0
- package/src/components/PickerWheel/DateWheel.vue +48 -0
- package/src/components/PickerWheel/PickerWheel.tsx +15 -129
- package/src/components/PickerWheel/PickerWheel.vue +77 -0
- package/src/components/PickerWheel/TimeWheel.vue +50 -0
- package/src/components/PickerWheel/WheelColumn.vue +70 -0
- package/src/components/Popover/Popover.vue +108 -0
- package/src/components/ProgressBar/ProgressBar.vue +48 -0
- package/src/components/Prose/Prose.vue +18 -0
- package/src/components/Radio/Radio.vue +49 -0
- package/src/components/Radio/RadioGroup.vue +69 -0
- package/src/components/Retime/Retime.tsx +7 -40
- package/src/components/Retime/Retime.vue +64 -0
- package/src/components/RulerScrubber/RulerScrubber.tsx +9 -38
- package/src/components/RulerScrubber/RulerScrubber.vue +166 -0
- package/src/components/ScrollArea/ScrollArea.tsx +17 -129
- package/src/components/ScrollArea/ScrollArea.vue +58 -0
- package/src/components/SearchInput/SearchInput.tsx +2 -15
- package/src/components/SearchInput/SearchInput.vue +70 -0
- package/src/components/SegmentedControl/SegmentedControl.tsx +7 -51
- package/src/components/SegmentedControl/SegmentedControl.vue +111 -0
- package/src/components/Select/Select.tsx +16 -47
- package/src/components/Select/Select.vue +236 -0
- package/src/components/Sheet/Sheet.tsx +52 -231
- package/src/components/Sheet/Sheet.vue +249 -0
- package/src/components/Skeleton/Skeleton.vue +38 -0
- package/src/components/Slider/Slider.tsx +25 -84
- package/src/components/Slider/Slider.vue +113 -0
- package/src/components/Spinner/Spinner.vue +30 -0
- package/src/components/Split/Split.vue +34 -0
- package/src/components/SplitFlap/SplitFlap.tsx +11 -175
- package/src/components/SplitFlap/SplitFlap.vue +52 -0
- package/src/components/Stack/Stack.vue +22 -0
- package/src/components/SwipeDeck/SwipeDeck.tsx +30 -194
- package/src/components/SwipeDeck/SwipeDeck.vue +168 -0
- package/src/components/Switch/Switch.tsx +6 -75
- package/src/components/Switch/Switch.vue +66 -0
- package/src/components/Table/Table.module.css +12 -3
- package/src/components/Table/Table.tsx +8 -59
- package/src/components/Table/Table.vue +274 -0
- package/src/components/TableOfContents/TableOfContents.vue +90 -0
- package/src/components/Tabs/Tab.vue +37 -0
- package/src/components/Tabs/TabList.vue +47 -0
- package/src/components/Tabs/TabPanel.vue +26 -0
- package/src/components/Tabs/Tabs.module.css +2 -2
- package/src/components/Tabs/Tabs.tsx +11 -84
- package/src/components/Tabs/Tabs.vue +33 -0
- package/src/components/Tabs/tabsContext.ts +15 -0
- package/src/components/Tag/Tag.tsx +6 -26
- package/src/components/Tag/Tag.vue +63 -0
- package/src/components/Textarea/Textarea.tsx +2 -22
- package/src/components/Textarea/Textarea.vue +120 -0
- package/src/components/ThemeToggle/ThemeToggle.tsx +10 -84
- package/src/components/ThemeToggle/ThemeToggle.vue +90 -0
- package/src/components/Toast/Toast.tsx +34 -264
- package/src/components/Toast/Toast.vue +138 -0
- package/src/components/Toast/ToastItem.vue +108 -0
- package/src/components/Toggle/Toggle.vue +52 -0
- package/src/components/Tooltip/Tooltip.tsx +17 -48
- package/src/components/Tooltip/Tooltip.vue +95 -0
- package/src/components/VisuallyHidden/VisuallyHidden.vue +17 -0
- package/src/internal/FieldMessage.vue +41 -0
- package/src/internal/Roll.vue +20 -0
- package/src/internal/focus.ts +4 -47
- package/src/internal/icons.module.css +39 -27
- package/src/internal/layers.ts +7 -61
- package/src/internal/motion/alert.ts +17 -0
- package/src/internal/motion/buttonGroup.ts +21 -0
- package/src/internal/motion/checkbox.ts +39 -0
- package/src/internal/motion/collapseOut.ts +26 -0
- package/src/internal/motion/copyButton.ts +48 -0
- package/src/internal/motion/dial.ts +137 -0
- package/src/internal/motion/fab.ts +14 -0
- package/src/internal/motion/floating.ts +58 -0
- package/src/internal/motion/focus.ts +53 -0
- package/src/internal/motion/formField.ts +19 -0
- package/src/internal/motion/holdToConfirm.ts +147 -0
- package/src/internal/motion/keys.ts +42 -0
- package/src/internal/motion/layers.ts +78 -0
- package/src/internal/motion/listbox.ts +69 -0
- package/src/internal/motion/livePill.ts +71 -0
- package/src/internal/motion/menuKeys.ts +58 -0
- package/src/internal/motion/morphButton.ts +71 -0
- package/src/internal/motion/numberInput.ts +57 -0
- package/src/internal/motion/pickerWheel.ts +166 -0
- package/src/internal/motion/retime.ts +45 -0
- package/src/internal/motion/ruler.ts +57 -0
- package/src/internal/motion/scrollArea.ts +133 -0
- package/src/internal/motion/scrubLook.ts +15 -0
- package/src/internal/motion/segmented.ts +63 -0
- package/src/internal/motion/sheetDetents.ts +271 -0
- package/src/internal/motion/slider.ts +108 -0
- package/src/internal/motion/splitFlap.ts +205 -0
- package/src/internal/motion/swipeDeck.ts +236 -0
- package/src/internal/motion/switchThumb.ts +83 -0
- package/src/internal/motion/table.ts +77 -0
- package/src/internal/motion/tabs.ts +105 -0
- package/src/internal/motion/textarea.ts +22 -0
- package/src/internal/motion/themeIcon.ts +91 -0
- package/src/internal/motion/themeReveal.ts +71 -0
- package/src/internal/motion/toast.ts +291 -0
- package/src/internal/motion/tooltip.ts +58 -0
- package/src/internal/themeReveal.ts +3 -61
- package/src/internal/useFloating.ts +9 -49
- package/src/internal/useScrub.ts +1 -13
- package/src/internal/vue/trigger.ts +18 -0
- package/src/internal/vue/useFloating.ts +38 -0
- package/src/internal/vue/usePresence.ts +21 -0
- package/src/internal/vue/useScrub.ts +40 -0
- package/src/internal/vueIcons.ts +134 -0
- package/src/tokens.css +5 -0
- package/src/internal/relativeTime.ts +0 -26
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Gooee UI
|
|
2
2
|
|
|
3
|
-
React components where every part grows from the spot you touch. A button becomes its panel, a pill becomes a card, a card becomes its page: the edges move and the words stay still. Black, white and grey with one blue accent, and copied into your app so the code is yours.
|
|
3
|
+
React and Vue components where every part grows from the spot you touch. A button becomes its panel, a pill becomes a card, a card becomes its page: the edges move and the words stay still. Black, white and grey with one blue accent, and copied into your app so the code is yours.
|
|
4
4
|
|
|
5
5
|
<picture>
|
|
6
6
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/hilmanhaikal/gooee-ui/main/.github/assets/home-dark-0.37.png">
|
|
@@ -34,7 +34,19 @@ import { Button } from './ui/components/Button'
|
|
|
34
34
|
<Button onClick={save}>Save</Button>
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Using
|
|
37
|
+
Using Vue? Add `--vue` (`npx gooee@latest add button --vue`) and import the `.vue` file:
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import Button from './ui/components/Button/Button.vue'
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<Button @click="save">Save</Button>
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Using Next.js, React Router or Nuxt? The [installation guide](https://gooee.dev/installation) has the steps for each.
|
|
38
50
|
|
|
39
51
|
### With the shadcn CLI
|
|
40
52
|
|
|
@@ -56,6 +68,7 @@ It writes the same files as `npx gooee add button`, into `src/ui`, with `tokens.
|
|
|
56
68
|
|
|
57
69
|
| Option | What it does |
|
|
58
70
|
| --- | --- |
|
|
71
|
+
| `--vue` | `add`: copy the Vue 3.5 version of each part instead of React |
|
|
59
72
|
| `--to <folder>` | Where the files go. Default: the folder in `gooee.json`, else `src/ui` |
|
|
60
73
|
| `--dry-run` | Print what would happen, write nothing |
|
|
61
74
|
| `--overwrite` | `add`: replace files that are already there. Without it, they are skipped and listed |
|
|
@@ -84,8 +97,8 @@ Setup for other tools: [MCP server](https://gooee.dev/mcp).
|
|
|
84
97
|
- **One look, set by tokens.** Every colour, size and timing comes from one file, `tokens.css`. Colour appears only to mean something: good, caution or bad.
|
|
85
98
|
- **Light and dark.** Dark follows the system, or set `data-theme="dark"` on `<html>`.
|
|
86
99
|
- **Accessible.** Keyboard support per the WAI-ARIA patterns, visible focus, screen reader labels, and reduced motion. On touch screens every control gives at least a 44px target, even the small sizes; only the six PIN boxes and the seven calendar days get narrower when the row has no room, about 36px wide on a 320px phone. CalendarHeatmap's days are small by design, since a year must fit on screen; its month table gives the same numbers at full size.
|
|
87
|
-
- **Small.** React 19 and CSS Modules. No other runtime packages: no animation library, no icon package.
|
|
88
|
-
- **Works in** Vite, Next.js (App Router)
|
|
100
|
+
- **Small.** React 19 or Vue 3.5, and CSS Modules. No other runtime packages: no animation library, no icon package.
|
|
101
|
+
- **Works in** Vite, Next.js (App Router), React Router and Nuxt.
|
|
89
102
|
|
|
90
103
|
## Pro
|
|
91
104
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gooee",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React components in black, white and grey with one blue accent. Copy them into your app with npx gooee add <name>.",
|
|
3
|
+
"version": "0.51.1",
|
|
4
|
+
"description": "React and Vue components in black, white and grey with one blue accent. Copy them into your app with npx gooee add <name>.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://gooee.dev",
|
|
7
7
|
"repository": {
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^19.3.0",
|
|
33
33
|
"@types/react-dom": "^19.3.0",
|
|
34
|
+
"@vitejs/plugin-vue": "6.0.10",
|
|
34
35
|
"react": "^19.3.1",
|
|
35
36
|
"react-dom": "^19.3.1",
|
|
36
|
-
"typescript": "^7.0.2"
|
|
37
|
+
"typescript": "^7.0.2",
|
|
38
|
+
"vue": "3.5.44"
|
|
37
39
|
}
|
|
38
40
|
}
|
package/scripts/add.js
CHANGED
|
@@ -29,6 +29,7 @@ Options:
|
|
|
29
29
|
--overwrite add: replace files that are already there
|
|
30
30
|
--with-base add: also copy base.css (init always does)
|
|
31
31
|
--yes update: replace without asking
|
|
32
|
+
--vue add, diff, update: the Vue version of a part (.vue), not the React one
|
|
32
33
|
--dry-run Show what would happen, write nothing
|
|
33
34
|
|
|
34
35
|
In this repo, run: npm run add -- <command> ...`
|
|
@@ -47,7 +48,7 @@ function fromEntry(folder, both = true) {
|
|
|
47
48
|
const clean = folder.replace(/^\.\//, '').replace(/\/$/, '')
|
|
48
49
|
const inSrc = clean.startsWith('src/')
|
|
49
50
|
const rel = inSrc ? clean.slice(4) : clean
|
|
50
|
-
const where = inSrc ?
|
|
51
|
+
const where = inSrc ? `in your entry file inside src/ (for example src/main.${framework === 'vue' ? 'ts' : 'tsx'}):` : 'in a file at your project root:'
|
|
51
52
|
const lines = [`import './${rel}/tokens.css'`, ...(both ? [`import './${rel}/base.css'`] : [])]
|
|
52
53
|
return `${where}\n${lines.map((l) => ` ${l}`).join('\n')}`
|
|
53
54
|
}
|
|
@@ -78,6 +79,7 @@ function parseArgs(argv) {
|
|
|
78
79
|
else if (arg === '--overwrite') opts.overwrite = true
|
|
79
80
|
else if (arg === '--dry-run') opts.dryRun = true
|
|
80
81
|
else if (arg === '--with-base') opts.withBase = true
|
|
82
|
+
else if (arg === '--vue') framework = 'vue'
|
|
81
83
|
else if (arg === '--yes' || arg === '-y') opts.yes = true
|
|
82
84
|
else if (arg.startsWith('-')) fail(`Unknown option ${arg}.`)
|
|
83
85
|
else rest.push(arg)
|
|
@@ -190,13 +192,33 @@ function listFiles(dir) {
|
|
|
190
192
|
})
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
// React or Vue, from --vue. A part folder holds both: Switch.tsx and Switch.vue share Switch.module.css.
|
|
196
|
+
let framework = 'react'
|
|
197
|
+
const forFramework = (file) => (file.endsWith('.vue') ? framework === 'vue' : framework === 'react' || file.endsWith('.css'))
|
|
198
|
+
|
|
193
199
|
const filesOf = (item) => {
|
|
194
200
|
const k = kindOf(item.kind)
|
|
195
|
-
|
|
201
|
+
if (k.single) return [join(k.dir, `${item.name}.css`)]
|
|
202
|
+
const files = listFiles(join(k.dir, item.name))
|
|
203
|
+
if (framework === 'vue' && !files.some((f) => f.endsWith('.vue'))) {
|
|
204
|
+
const withVue = KINDS.filter((x) => !x.single)
|
|
205
|
+
.flatMap((x) => (existsSync(x.dir) ? readdirSync(x.dir).filter((d) => existsSync(join(x.dir, d, `${d}.vue`))) : []))
|
|
206
|
+
.map(kebab)
|
|
207
|
+
fail(`${item.name} has no Vue version yet. These do: ${withVue.join(', ') || 'none'}.`, false)
|
|
208
|
+
}
|
|
209
|
+
const kept = files.filter(forFramework)
|
|
210
|
+
// A Vue part also needs the plain .ts helpers in its own folder that it imports (Tabs reads tabsContext.ts).
|
|
211
|
+
if (framework === 'vue')
|
|
212
|
+
for (let i = 0; i < kept.length; i++)
|
|
213
|
+
for (const spec of importsOf(kept[i])) {
|
|
214
|
+
const target = files.find((f) => resolve(f) === resolveImport(kept[i], spec))
|
|
215
|
+
if (target && !kept.includes(target)) kept.push(target)
|
|
216
|
+
}
|
|
217
|
+
return kept
|
|
196
218
|
}
|
|
197
219
|
|
|
198
220
|
function importsOf(file) {
|
|
199
|
-
if (!/\.(ts|tsx)$/.test(file)) return []
|
|
221
|
+
if (!/\.(ts|tsx|vue)$/.test(file)) return []
|
|
200
222
|
const code = readFileSync(file, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '')
|
|
201
223
|
const found = []
|
|
202
224
|
const re = /(?:\bfrom\s*|\bimport\s*\(?\s*)['"]([^'"]+)['"]/g
|
|
@@ -271,10 +293,10 @@ function plan(items) {
|
|
|
271
293
|
// It is left out when comparing, so it never counts as a change.
|
|
272
294
|
function credit(file, pro) {
|
|
273
295
|
const text = pro ? `Gooee UI Pro, see LICENSE-PRO.md. ${SITE}` : `Gooee UI, MIT licence. ${SITE}`
|
|
274
|
-
return file.endsWith('.css') ? `/* ${text} */\n` : `// ${text}\n`
|
|
296
|
+
return file.endsWith('.css') ? `/* ${text} */\n` : file.endsWith('.vue') ? `<!-- ${text} -->\n` : `// ${text}\n`
|
|
275
297
|
}
|
|
276
298
|
// Copies made before the rename start with the old name, hlmnhkl/ui, so diff and update still see them as ours.
|
|
277
|
-
const withoutCredit = (text) => text.replace(/^(\/\/ (?:Gooee UI|hlmnhkl\/ui)[^\n]*|\/\* (?:Gooee UI|hlmnhkl\/ui)[^\n]
|
|
299
|
+
const withoutCredit = (text) => text.replace(/^(\/\/ (?:Gooee UI|hlmnhkl\/ui)[^\n]*|\/\* (?:Gooee UI|hlmnhkl\/ui)[^\n]*\*\/|<!-- Gooee UI[^\n]*-->)\n/, '')
|
|
278
300
|
|
|
279
301
|
// The project folder (npm runs scripts from the repo root; INIT_CWD is where the command was typed).
|
|
280
302
|
const CWD = process.env.INIT_CWD ?? process.cwd()
|
|
@@ -365,7 +387,7 @@ function runInit(opts) {
|
|
|
365
387
|
console.log(` ${CONFIG}: added, so later commands put files in ${folder}`)
|
|
366
388
|
}
|
|
367
389
|
console.log(`\nNext:\n 1. Import both once, tokens first, ${fromEntry(folder)}`)
|
|
368
|
-
console.log(` 2. Add your first component: npx gooee add button`)
|
|
390
|
+
console.log(` 2. Add your first component: npx gooee add button${framework === 'vue' ? ' --vue' : ''}`)
|
|
369
391
|
console.log(` See everything there is: npx gooee list, or ${SITE}`)
|
|
370
392
|
}
|
|
371
393
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, provide, ref } from 'vue'
|
|
3
|
+
import { accordionKey } from './accordionContext'
|
|
4
|
+
import styles from './Accordion.module.css'
|
|
5
|
+
|
|
6
|
+
// The Vue Accordion: the same look (Accordion.module.css) and keys as the React one. Put AccordionItem
|
|
7
|
+
// parts inside.
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(
|
|
10
|
+
defineProps<{
|
|
11
|
+
/** "single" keeps one item open at a time. */
|
|
12
|
+
type?: 'single' | 'multiple'
|
|
13
|
+
/** Starting open items when there is no v-model. */
|
|
14
|
+
defaultValue?: string[]
|
|
15
|
+
/** Heading level for item titles, to fit the page outline. */
|
|
16
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6
|
|
17
|
+
}>(),
|
|
18
|
+
{ type: 'single', defaultValue: () => [], headingLevel: 3 },
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
/** Values of the open items. Use v-model, or leave it out and the accordion keeps its own state. */
|
|
22
|
+
const model = defineModel<string[]>()
|
|
23
|
+
const local = ref(props.defaultValue)
|
|
24
|
+
const open = computed(() => model.value ?? local.value)
|
|
25
|
+
const set = (next: string[]) => {
|
|
26
|
+
local.value = next
|
|
27
|
+
model.value = next
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
provide(accordionKey, {
|
|
31
|
+
open,
|
|
32
|
+
level: computed(() => props.headingLevel),
|
|
33
|
+
toggle: (v) => {
|
|
34
|
+
const isOpen = open.value.includes(v)
|
|
35
|
+
if (props.type === 'single') set(isOpen ? [] : [v])
|
|
36
|
+
else set(isOpen ? open.value.filter((x) => x !== v) : [...open.value, v])
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const root = ref<HTMLElement | null>(null)
|
|
41
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
42
|
+
// Skips triggers of nested accordions, which handle their own keys.
|
|
43
|
+
const triggers = Array.from(root.value?.querySelectorAll<HTMLButtonElement>(`.${styles.trigger}:not(:disabled)`) ?? []).filter((t) => t.closest(`.${styles.root}`) === root.value)
|
|
44
|
+
const i = triggers.indexOf(document.activeElement as HTMLButtonElement)
|
|
45
|
+
if (i < 0) return
|
|
46
|
+
let next = -1
|
|
47
|
+
if (e.key === 'ArrowDown') next = (i + 1) % triggers.length
|
|
48
|
+
else if (e.key === 'ArrowUp') next = (i - 1 + triggers.length) % triggers.length
|
|
49
|
+
else if (e.key === 'Home') next = 0
|
|
50
|
+
else if (e.key === 'End') next = triggers.length - 1
|
|
51
|
+
if (next < 0) return
|
|
52
|
+
e.preventDefault()
|
|
53
|
+
e.stopPropagation()
|
|
54
|
+
triggers[next].focus()
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<div ref="root" :class="styles.root" @keydown="onKeyDown">
|
|
60
|
+
<slot />
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject, useId } from 'vue'
|
|
3
|
+
import { ChevronDownIcon } from '../../internal/vueIcons'
|
|
4
|
+
import { accordionKey } from './accordionContext'
|
|
5
|
+
import styles from './Accordion.module.css'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
/** Unique id for this item, used in the Accordion value list. */
|
|
9
|
+
value: string
|
|
10
|
+
/** Text on the button that opens and closes the item. The title slot replaces it. */
|
|
11
|
+
title?: string
|
|
12
|
+
/** Stops the item from opening or closing. */
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
}>()
|
|
15
|
+
defineSlots<{ default?: () => unknown; title?: () => unknown }>()
|
|
16
|
+
|
|
17
|
+
const ctx = inject(accordionKey, null)
|
|
18
|
+
if (!ctx) throw new Error('AccordionItem must be inside Accordion')
|
|
19
|
+
const id = useId()
|
|
20
|
+
const isOpen = computed(() => ctx.open.value.includes(props.value))
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div :class="styles.item" :data-open="isOpen || undefined">
|
|
25
|
+
<component :is="`h${ctx.level.value}`" :class="styles.heading">
|
|
26
|
+
<button
|
|
27
|
+
:id="`${id}-trigger`"
|
|
28
|
+
type="button"
|
|
29
|
+
:class="styles.trigger"
|
|
30
|
+
:aria-expanded="isOpen"
|
|
31
|
+
:aria-controls="`${id}-panel`"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
@click="ctx.toggle(value)"
|
|
34
|
+
>
|
|
35
|
+
<span :class="styles.title"><slot name="title">{{ title }}</slot></span>
|
|
36
|
+
<ChevronDownIcon :class="styles.chevron" />
|
|
37
|
+
</button>
|
|
38
|
+
</component>
|
|
39
|
+
<div :id="`${id}-panel`" role="region" :aria-labelledby="`${id}-trigger`" :class="styles.panel" :inert="!isOpen">
|
|
40
|
+
<div :class="styles.panelInner">
|
|
41
|
+
<div :class="styles.content"><slot /></div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey } from 'vue'
|
|
2
|
+
|
|
3
|
+
// What the Vue Accordion shares with each AccordionItem.
|
|
4
|
+
export type AccordionContext = { open: ComputedRef<string[]>; toggle: (v: string) => void; level: ComputedRef<number> }
|
|
5
|
+
|
|
6
|
+
export const accordionKey: InjectionKey<AccordionContext> = Symbol('gooee-accordion')
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { useRef, useState, type ReactNode } from 'react'
|
|
4
4
|
import { cx } from '../../internal/cx'
|
|
5
|
-
import { focusables } from '../../internal/focus'
|
|
6
5
|
import { CheckCircleIcon, ErrorIcon, InfoIcon, WarningIcon, XIcon } from '../../internal/icons'
|
|
7
|
-
import {
|
|
6
|
+
import { foldAway } from '../../internal/motion/alert'
|
|
7
|
+
import { focusPast } from '../../internal/motion/collapseOut'
|
|
8
8
|
import styles from './Alert.module.css'
|
|
9
9
|
|
|
10
10
|
export type AlertVariant = 'info' | 'success' | 'warning' | 'error'
|
|
@@ -36,35 +36,15 @@ export function Alert({ variant = 'info', title, children, onDismiss, dismissLab
|
|
|
36
36
|
const Icon = icons[variant]
|
|
37
37
|
const urgent = variant === 'error' || variant === 'warning'
|
|
38
38
|
|
|
39
|
-
// The close button is about to unmount, so focus moves
|
|
40
|
-
const finish = () => {
|
|
41
|
-
const el = ref.current
|
|
42
|
-
if (el?.contains(document.activeElement)) {
|
|
43
|
-
const others = focusables(document.body).filter((n) => !el.contains(n))
|
|
44
|
-
const next = others.find((n) => el.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_FOLLOWING)
|
|
45
|
-
const prev = [...others].reverse().find((n) => el.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_PRECEDING)
|
|
46
|
-
;(next ?? prev)?.focus({ preventScroll: true })
|
|
47
|
-
}
|
|
48
|
-
onDismiss?.()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Folds the height to zero, so content below slides up instead of jumping.
|
|
39
|
+
// Fades, then folds the height (motion/alert.ts). The close button is about to unmount, so focus moves on first.
|
|
52
40
|
const dismiss = () => {
|
|
53
41
|
const el = ref.current
|
|
54
42
|
if (!el || leaving) return
|
|
55
43
|
setLeaving(true)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
[
|
|
61
|
-
{ height: `${h}px`, opacity: 1, transform: 'scale(1)' },
|
|
62
|
-
{ height: `${h}px`, opacity: 0, transform: 'scale(0.98)', offset: 0.45 },
|
|
63
|
-
{ height: '0px', opacity: 0, transform: 'scale(0.98)', paddingTop: '0px', paddingBottom: '0px', marginTop: '0px', marginBottom: '0px', borderWidth: '0px' },
|
|
64
|
-
],
|
|
65
|
-
{ duration: ms, easing: easing('morph'), fill: 'forwards' },
|
|
66
|
-
)
|
|
67
|
-
anim.onfinish = finish
|
|
44
|
+
foldAway(el, () => {
|
|
45
|
+
focusPast(el)
|
|
46
|
+
onDismiss?.()
|
|
47
|
+
})
|
|
68
48
|
}
|
|
69
49
|
|
|
70
50
|
return (
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
import { foldAway } from '../../internal/motion/alert'
|
|
4
|
+
import { focusPast } from '../../internal/motion/collapseOut'
|
|
5
|
+
import { CheckCircleIcon, ErrorIcon, InfoIcon, WarningIcon, XIcon } from '../../internal/vueIcons'
|
|
6
|
+
import styles from './Alert.module.css'
|
|
7
|
+
|
|
8
|
+
// The Vue Alert: the same look (Alert.module.css) and fold-away dismiss as the React one.
|
|
9
|
+
export type AlertVariant = 'info' | 'success' | 'warning' | 'error'
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(
|
|
12
|
+
defineProps<{
|
|
13
|
+
/** Sets the colour and icon. Error and warning are announced at once. */
|
|
14
|
+
variant?: AlertVariant
|
|
15
|
+
/** Short bold line at the top. The title slot replaces it. */
|
|
16
|
+
title?: string
|
|
17
|
+
/** Shows a close button (listen with @dismiss). Called after the collapse animation. */
|
|
18
|
+
onDismiss?: () => void
|
|
19
|
+
/** Screen reader name for the close button. */
|
|
20
|
+
dismissLabel?: string
|
|
21
|
+
/** Full-width strip for the top of a page. */
|
|
22
|
+
banner?: boolean
|
|
23
|
+
}>(),
|
|
24
|
+
{ variant: 'info', dismissLabel: 'Dismiss' },
|
|
25
|
+
)
|
|
26
|
+
/** default: body text under the title. action: a button or link shown under the text. */
|
|
27
|
+
const slots = defineSlots<{ default?: () => unknown; title?: () => unknown; action?: () => unknown }>()
|
|
28
|
+
|
|
29
|
+
const icons = { info: InfoIcon, success: CheckCircleIcon, warning: WarningIcon, error: ErrorIcon }
|
|
30
|
+
const urgent = computed(() => props.variant === 'error' || props.variant === 'warning')
|
|
31
|
+
|
|
32
|
+
const root = ref<HTMLElement | null>(null)
|
|
33
|
+
const leaving = ref(false)
|
|
34
|
+
|
|
35
|
+
// Fades, then folds the height (motion/alert.ts). The close button is about to unmount, so focus moves on first.
|
|
36
|
+
const dismiss = () => {
|
|
37
|
+
const el = root.value
|
|
38
|
+
if (!el || leaving.value) return
|
|
39
|
+
leaving.value = true
|
|
40
|
+
foldAway(el, () => {
|
|
41
|
+
focusPast(el)
|
|
42
|
+
props.onDismiss?.()
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<div ref="root" :role="urgent ? 'alert' : 'status'" :class="[styles.root, styles[variant], banner && styles.banner]" :data-leaving="leaving || undefined">
|
|
49
|
+
<component :is="icons[variant]" :class="styles.icon" />
|
|
50
|
+
<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>
|
|
54
|
+
</div>
|
|
55
|
+
<button v-if="onDismiss" type="button" :class="styles.close" :aria-label="dismissLabel" @click="dismiss">
|
|
56
|
+
<XIcon />
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, onBeforeUnmount, ref, useId, watch } from 'vue'
|
|
3
|
+
import { trapFocus } from '../../internal/motion/focus'
|
|
4
|
+
import { dismissable, lockScroll } from '../../internal/motion/layers'
|
|
5
|
+
import { createDialogMorph } from '../../internal/motion/liquid'
|
|
6
|
+
import { motionMs } from '../../internal/motion'
|
|
7
|
+
import Button from '../Button/Button.vue'
|
|
8
|
+
import dialog from '../Dialog/Dialog.module.css'
|
|
9
|
+
import styles from './AlertDialog.module.css'
|
|
10
|
+
|
|
11
|
+
// The Vue AlertDialog: the same look, morph and focus as the React one.
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(
|
|
14
|
+
defineProps<{
|
|
15
|
+
/** The question, such as "Delete this project?". Also the accessible name. The title slot replaces it. */
|
|
16
|
+
title?: string
|
|
17
|
+
/** What happens if they confirm. Read out with the title when the dialog opens. The description slot replaces it. */
|
|
18
|
+
description?: string
|
|
19
|
+
/** Text of the confirm button. Name the action, such as "Delete project", not "OK". */
|
|
20
|
+
confirmLabel: string
|
|
21
|
+
/** Text of the cancel button. */
|
|
22
|
+
cancelLabel?: string
|
|
23
|
+
/** "danger" gives the confirm button the solid red look, for actions that destroy something. */
|
|
24
|
+
tone?: 'default' | 'danger'
|
|
25
|
+
}>(),
|
|
26
|
+
{ cancelLabel: 'Cancel', tone: 'default' },
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
/** Shows the dialog. Use v-model:open; Confirm, Cancel or Esc set it false. A tap outside never closes it. */
|
|
30
|
+
const open = defineModel<boolean>('open', { required: true })
|
|
31
|
+
const emit = defineEmits<{
|
|
32
|
+
/** They confirmed, before the dialog closes. */
|
|
33
|
+
confirm: []
|
|
34
|
+
/** They cancelled with the button or Esc, before the dialog closes. */
|
|
35
|
+
cancel: []
|
|
36
|
+
}>()
|
|
37
|
+
const slots = defineSlots<{ default?: () => unknown; title?: () => unknown; description?: () => unknown }>()
|
|
38
|
+
|
|
39
|
+
const id = useId()
|
|
40
|
+
const panel = ref<HTMLElement | null>(null)
|
|
41
|
+
const cancelButton = ref<InstanceType<typeof Button> | null>(null)
|
|
42
|
+
|
|
43
|
+
const cancel = () => {
|
|
44
|
+
emit('cancel')
|
|
45
|
+
open.value = false
|
|
46
|
+
}
|
|
47
|
+
const confirm = () => {
|
|
48
|
+
emit('confirm')
|
|
49
|
+
open.value = false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const mounted = ref(open.value)
|
|
53
|
+
const state = computed(() => (open.value ? 'open' : 'closed'))
|
|
54
|
+
let leaving = 0
|
|
55
|
+
const morph = createDialogMorph(() => panel.value)
|
|
56
|
+
|
|
57
|
+
let release: Array<() => void> = []
|
|
58
|
+
const stop = () => {
|
|
59
|
+
release.forEach((r) => r())
|
|
60
|
+
release = []
|
|
61
|
+
}
|
|
62
|
+
const server = typeof window === 'undefined'
|
|
63
|
+
|
|
64
|
+
// Before the new state renders, so the opener is read while it still has focus.
|
|
65
|
+
watch(
|
|
66
|
+
open,
|
|
67
|
+
(now, was) => {
|
|
68
|
+
if (server) return
|
|
69
|
+
clearTimeout(leaving)
|
|
70
|
+
if (now && !was) morph.opening()
|
|
71
|
+
if (now) mounted.value = true
|
|
72
|
+
else leaving = window.setTimeout(() => (mounted.value = false), motionMs('morph-out'))
|
|
73
|
+
},
|
|
74
|
+
{ immediate: true, flush: 'pre' },
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
watch(
|
|
78
|
+
[state, mounted],
|
|
79
|
+
async () => {
|
|
80
|
+
if (server || !mounted.value) return
|
|
81
|
+
await nextTick()
|
|
82
|
+
morph.play(state.value)
|
|
83
|
+
stop()
|
|
84
|
+
if (!open.value || !panel.value) return
|
|
85
|
+
const el = panel.value
|
|
86
|
+
// Focus starts on the least destructive choice, so a stray Enter never confirms.
|
|
87
|
+
release.push(
|
|
88
|
+
lockScroll(),
|
|
89
|
+
dismissable(() => [el], cancel, { outside: false }),
|
|
90
|
+
trapFocus(el, { initialFocus: cancelButton.value?.el ?? null }),
|
|
91
|
+
)
|
|
92
|
+
},
|
|
93
|
+
{ immediate: true, flush: 'post' },
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
onBeforeUnmount(() => {
|
|
97
|
+
clearTimeout(leaving)
|
|
98
|
+
stop()
|
|
99
|
+
morph.destroy()
|
|
100
|
+
})
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<template>
|
|
104
|
+
<Teleport v-if="mounted" to="body">
|
|
105
|
+
<div :class="dialog.overlay" :data-state="state" aria-hidden="true" />
|
|
106
|
+
<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">
|
|
108
|
+
<header :class="[dialog.header, styles.header]">
|
|
109
|
+
<div :class="dialog.titles">
|
|
110
|
+
<h2 :id="`${id}-title`" :class="dialog.title">
|
|
111
|
+
<slot name="title">{{ props.title }}</slot>
|
|
112
|
+
</h2>
|
|
113
|
+
<p :id="`${id}-desc`" :class="dialog.description">
|
|
114
|
+
<slot name="description">{{ props.description }}</slot>
|
|
115
|
+
</p>
|
|
116
|
+
</div>
|
|
117
|
+
</header>
|
|
118
|
+
<div v-if="slots.default" :class="dialog.body"><slot /></div>
|
|
119
|
+
<footer :class="dialog.footer">
|
|
120
|
+
<Button ref="cancelButton" variant="secondary" @click="cancel">{{ cancelLabel }}</Button>
|
|
121
|
+
<Button :variant="tone === 'danger' ? 'danger' : 'primary'" @click="confirm">{{ confirmLabel }}</Button>
|
|
122
|
+
</footer>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</Teleport>
|
|
126
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import styles from './AnimatedNumber.module.css'
|
|
4
|
+
|
|
5
|
+
// The Vue AnimatedNumber: the same look and roll (AnimatedNumber.module.css) as the React one.
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
/** Number to show. Digits roll to the new value when it changes. */
|
|
8
|
+
value: number
|
|
9
|
+
/** Passed to Intl.NumberFormat, for currency, percent, decimals and so on. */
|
|
10
|
+
format?: Intl.NumberFormatOptions
|
|
11
|
+
/** Locale for number formatting. Undefined uses the browser locale. */
|
|
12
|
+
locale?: string
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
16
|
+
const text = computed(() => new Intl.NumberFormat(props.locale, props.format).format(props.value))
|
|
17
|
+
const chars = computed(() => text.value.split(''))
|
|
18
|
+
const isDigit = (ch: string) => ch >= '0' && ch <= '9'
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<span :class="styles.root">
|
|
23
|
+
<span :class="styles.srOnly">{{ text }}</span>
|
|
24
|
+
<span :class="styles.visual" aria-hidden="true">
|
|
25
|
+
<!-- Keyed from the right, so the ones column stays the ones column when the number grows. -->
|
|
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">
|
|
28
|
+
<span :class="styles.strip" :style="{ transform: `translateY(${-Number(ch) * 10}%)` }">
|
|
29
|
+
<span v-for="n in DIGITS" :key="n" :class="styles.cell">{{ n }}</span>
|
|
30
|
+
</span>
|
|
31
|
+
</span>
|
|
32
|
+
<span v-else :class="styles.symbol">{{ ch }}</span>
|
|
33
|
+
</template>
|
|
34
|
+
</span>
|
|
35
|
+
</span>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import styles from './AspectRatio.module.css'
|
|
3
|
+
|
|
4
|
+
// The Vue AspectRatio: the same look (AspectRatio.module.css) as the React one. The child fills the box.
|
|
5
|
+
withDefaults(
|
|
6
|
+
defineProps<{
|
|
7
|
+
/** Width over height, such as 16 / 9 or 1 for a square. */
|
|
8
|
+
ratio?: number
|
|
9
|
+
}>(),
|
|
10
|
+
{ ratio: 16 / 9 },
|
|
11
|
+
)
|
|
12
|
+
defineSlots<{ default?: () => unknown }>()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div :class="styles.root" :style="{ '--ratio': ratio }"><slot /></div>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
import styles from './Avatar.module.css'
|
|
4
|
+
|
|
5
|
+
// The Vue Avatar: the same look (Avatar.module.css) as the React one.
|
|
6
|
+
const props = withDefaults(
|
|
7
|
+
defineProps<{
|
|
8
|
+
/** Used for the alt text and the initials fallback. */
|
|
9
|
+
name: string
|
|
10
|
+
/** Image URL. Initials show while it loads and if it fails. */
|
|
11
|
+
src?: string
|
|
12
|
+
/** Diameter of the avatar. */
|
|
13
|
+
size?: 'sm' | 'md' | 'lg' | 'xl'
|
|
14
|
+
/** Shows a status dot and adds the status to the spoken name. */
|
|
15
|
+
status?: 'online' | 'away' | 'offline'
|
|
16
|
+
}>(),
|
|
17
|
+
{ size: 'md' },
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const state = ref<'loading' | 'loaded' | 'error'>(props.src ? 'loading' : 'error')
|
|
21
|
+
watch(
|
|
22
|
+
() => props.src,
|
|
23
|
+
(src) => (state.value = src ? 'loading' : 'error'),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const initials = computed(() =>
|
|
27
|
+
props.name
|
|
28
|
+
.trim()
|
|
29
|
+
.split(/\s+/)
|
|
30
|
+
.slice(0, 2)
|
|
31
|
+
.map((p) => p[0]?.toUpperCase() ?? '')
|
|
32
|
+
.join(''),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
// A server-rendered image can finish before Vue hydrates, so its load event is gone by then.
|
|
36
|
+
const seen = (img: unknown) => {
|
|
37
|
+
if (img instanceof HTMLImageElement && img.complete && state.value === 'loading') state.value = img.naturalWidth ? 'loaded' : 'error'
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<span :class="[styles.root, styles[size]]" role="img" :aria-label="status ? `${name}, ${status}` : name">
|
|
43
|
+
<span :class="styles.fallback" aria-hidden="true">{{ initials }}</span>
|
|
44
|
+
<img
|
|
45
|
+
v-if="src && state !== 'error'"
|
|
46
|
+
:ref="seen"
|
|
47
|
+
:class="styles.img"
|
|
48
|
+
:src="src"
|
|
49
|
+
alt=""
|
|
50
|
+
:data-loaded="state === 'loaded' || undefined"
|
|
51
|
+
@load="state = 'loaded'"
|
|
52
|
+
@error="state = 'error'"
|
|
53
|
+
/>
|
|
54
|
+
<span v-if="status" :class="styles.status" :data-status="status" aria-hidden="true" />
|
|
55
|
+
</span>
|
|
56
|
+
</template>
|