@gecko-ui-kit/vue 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2016 -2
- package/index.d.ts +13 -0
- package/index.js +16 -0
- package/package.json +48 -4
- package/src/actions.d.ts +186 -0
- package/src/actions.js +329 -0
- package/src/basics.d.ts +315 -0
- package/src/basics.js +475 -0
- package/src/charts.d.ts +219 -0
- package/src/charts.js +93 -0
- package/src/controls.d.ts +149 -0
- package/src/controls.js +354 -0
- package/src/core.d.ts +109 -0
- package/src/core.js +414 -0
- package/src/data.d.ts +754 -0
- package/src/data.js +718 -0
- package/src/effects.d.ts +407 -0
- package/src/effects.js +699 -0
- package/src/forms.d.ts +757 -0
- package/src/forms.js +481 -0
- package/src/motion.d.ts +127 -0
- package/src/motion.js +216 -0
- package/src/overlays.d.ts +463 -0
- package/src/overlays.js +707 -0
- package/src/plugin.d.ts +6 -0
- package/src/plugin.js +27 -0
- package/src/shell.d.ts +210 -0
- package/src/shell.js +716 -0
- package/src/text.d.ts +309 -0
- package/src/text.js +383 -0
package/README.md
CHANGED
|
@@ -1,3 +1,2017 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gecko-ui-kit/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Every [Gecko UI Kit](https://woraphondev.github.io/UI-Package/playground/) piece as a Vue 3 component: buttons, forms,
|
|
4
|
+
pickers, data display, charts, text and scroll motion, overlays and the app shell. Made for Nuxt: every component
|
|
5
|
+
renders on the server and wakes up in the browser, and comes with TypeScript types.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install gsap @gecko-ui-kit/vue
|
|
9
|
+
```
|
|
10
|
+
It brings the other Gecko packages with it. `vue` 3.5 or newer comes from your app.
|
|
11
|
+
|
|
12
|
+
## Set up (Nuxt)
|
|
13
|
+
|
|
14
|
+
Load the CSS once, in this order, and register the components with a small plugin:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// nuxt.config.ts
|
|
18
|
+
export default defineNuxtConfig({
|
|
19
|
+
css: [
|
|
20
|
+
'@gecko-ui-kit/tokens/style.css', // variables + small reset (first)
|
|
21
|
+
'@gecko-ui-kit/motion/motion.css',
|
|
22
|
+
'@gecko-ui-kit/components/style.css',
|
|
23
|
+
'@gecko-ui-kit/overlays/style.css',
|
|
24
|
+
'@gecko-ui-kit/shell/style.css', // only if you use the app shell
|
|
25
|
+
'~/assets/main.css', // your own styles last
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// plugins/gecko.ts
|
|
32
|
+
import { GeckoUI } from '@gecko-ui-kit/vue'
|
|
33
|
+
export default defineNuxtPlugin((nuxt) => {
|
|
34
|
+
nuxt.vueApp.use(GeckoUI) // <Button>, <Rating>, <Modal>… in every template
|
|
35
|
+
// nuxt.vueApp.use(GeckoUI, { prefix: 'G' }) // → <GButton>, <GRating>…
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then use them in any page or component:
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<!-- pages/bikes.vue -->
|
|
43
|
+
<template>
|
|
44
|
+
<Card title="Honda Click 125" sub="Plate 1กข 1234">
|
|
45
|
+
<template #right><Tag tone="good">Available</Tag></template>
|
|
46
|
+
<Segmented v-model="view" :options="[['list', 'List', 'list'], ['calendar', 'Calendar', 'calendar']]" />
|
|
47
|
+
<Button variant="primary" icon="calendar" @click="open = true">Book</Button>
|
|
48
|
+
</Card>
|
|
49
|
+
<Modal v-model:open="open" title="Confirm booking">
|
|
50
|
+
<DateRange v-model="range" />
|
|
51
|
+
<template #footer><Button variant="primary" @click="book">Book</Button></template>
|
|
52
|
+
</Modal>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { ref } from 'vue'
|
|
57
|
+
import { toast } from '@gecko-ui-kit/vue'
|
|
58
|
+
const view = ref('list'), open = ref(false), range = ref(null)
|
|
59
|
+
function book() { open.value = false; toast('Booked!') }
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Plain Vue (Vite):** import the same CSS files in `main.ts` and call `app.use(GeckoUI)`, or import each component
|
|
64
|
+
where you use it: `import { Button, Modal } from '@gecko-ui-kit/vue'`.
|
|
65
|
+
|
|
66
|
+
## How the components behave
|
|
67
|
+
|
|
68
|
+
- **Same look as the vanilla kit.** Each component draws the same HTML (same classes) as its vanilla piece, or runs the
|
|
69
|
+
vanilla piece inside an element Vue leaves alone, so the CSS, motion and accessibility are identical.
|
|
70
|
+
- **v-model.** A piece with a value takes `v-model` (or `default-value` to let it keep its own). A new value updates the
|
|
71
|
+
piece in place (it animates to it); it does not rebuild it. Changes inside arrays and objects you pass
|
|
72
|
+
(`rows.value.push(…)`) are noticed too. Overlays use `v-model:open`.
|
|
73
|
+
- **Events** are the vanilla callbacks with the same arguments: `@change`, `@select`, `@close`… (declared as `onX`
|
|
74
|
+
props, so a handler may also return a value, e.g. a promise).
|
|
75
|
+
- **Your content is Vue.** Titles, card bodies, modal and drawer bodies, popover and tooltip content, slides, steps,
|
|
76
|
+
kanban cards… are slots (`#title`, `#footer`, scoped slots like `#cell="{ row }"`). Nothing asks you for HTML
|
|
77
|
+
strings, except a few `render(value) → string` callbacks for many small cells (data grid), which say so in their types.
|
|
78
|
+
- **Template refs.** Pieces that the vanilla code builds (DataGrid, Calendar, Rating…) give their handle
|
|
79
|
+
(`rating.value.set(4)`, `rating.value.el`), the same methods as the vanilla API. Markup pieces give the component
|
|
80
|
+
(`.$el` is the element).
|
|
81
|
+
- **Booleans** work as attributes: `<Rating half read-only />`. A boolean you leave out keeps the piece's own default.
|
|
82
|
+
- **Server rendering.** Markup pieces render fully on the server. Pieces the vanilla code builds render an empty slot on
|
|
83
|
+
the server and appear when the page wakes up. Nothing reads `window` or `localStorage` during setup or render.
|
|
84
|
+
- **Reduced motion** is honoured everywhere, as in the vanilla kit.
|
|
85
|
+
- **Texts** shown by a piece come from a `words` prop (English by default), e.g. `:words="{ loading: 'กำลังโหลด…' }"`.
|
|
86
|
+
- **Any motion helper** without its own component runs on your own element with `useMotion`:
|
|
87
|
+
`const list = useMotion(rise)` then `<ul ref="list">…</ul>`.
|
|
88
|
+
|
|
89
|
+
## Components
|
|
90
|
+
|
|
91
|
+
- [Basics](#basics): `Spinner`, `Button`, `IconButton`, `Tag`, `Badge`, `Avatar`, `AvatarGroup`, `Cell`, `CardHead`, `Card`, `Kpi`, `Empty`, `Table`, `Meter`, `Ring`, `Steps`, `Bars`, `Field`, `Input`, `Textarea`
|
|
92
|
+
- [Controls](#controls): `Switch`, `Segmented`, `normOption`, `Checkbox`, `Tabs`, `Chips`, `Range`, `Swatch`, `SearchBox`, `Select`, `Otp`
|
|
93
|
+
- [Forms](#forms): `MultiSelect`, `Combobox`, `TagsInput`, `RangeSlider`, `Stepper`, `Rating`, `RadioCards`, `SubscribeForm`, `PasswordMeter`, `PasswordToggle`, `AuthForm`, `SignaturePad`, `PhotoUpload`, `FileDrop`, `PricingToggle`, `DateRange`, `TimePicker`, `Wizard`, `useValidation`
|
|
94
|
+
- [Data display](#data-display): `Accordion`, `Carousel`, `BeforeAfter`, `Tree`, `DataGrid`, `VirtualList`, `Timeline`, `Calendar`, `SwipeItem`, `SwipeActions`, `Kanban`, `Notifications`, `Activity`, `Pagination`, `Breadcrumbs`, `Skeleton`, `Alert`
|
|
95
|
+
- [Action buttons](#action-buttons): `LikeButton`, `BellSwitch`, `PayButton`, `SpeedDial`, `Typing`
|
|
96
|
+
- [Charts](#charts): `LineChart`, `Donut`, `Gauge`, `Leaderboard`, `Heatmap`
|
|
97
|
+
- [Text & scroll motion](#text--scroll-motion): `TextReveal`, `Typewriter`, `Rotator`, `Shine`, `Highlighter`, `ScrollReveal`, `BlurIn`, `ScrollProgress`, `Odometer`, `CountUp`
|
|
98
|
+
- [Motion wrappers](#motion-wrappers): `Rise`, `Magnetic`, `Lift`, `Tilt`, `Spotlight`, `Marquee`, `useMotion`
|
|
99
|
+
- [Interactive effects](#interactive-effects): `Indicator`, `useIndicator`, `PageSwap`, `useFeedback`, `useFlash`, `useTick`, `ConfettiButton`, `useConfetti`, `confetti`, `Sortable`, `ThemeToggle`, `useTheme`, `SendButton`, `DeleteButton`, `DownloadButton`, `HoldButton`, `ExpandSearch`, `LiquidTabs`, `Burger`
|
|
100
|
+
- [Overlays](#overlays): `Modal`, `Drawer`, `confirm`, `useConfirm`, `Popover`, `Menu`, `ContextMenu`, `Tooltip`, `toast`, `CookieBanner`, `LoadingBar`, `useLoadingBar`, `CommandPalette`, `Tour`, `Lightbox`, `LightboxGallery`
|
|
101
|
+
- [App shell](#app-shell): `AppShell`, `useShell`, `shellBootScript`, `Sidebar`, `Topbar`, `PageHeader`, `MobileTabbar`
|
|
102
|
+
|
|
103
|
+
## Basics
|
|
104
|
+
|
|
105
|
+
### Spinner
|
|
106
|
+
The orbit loader: a small spinning comet on a faint ring.
|
|
107
|
+
```vue
|
|
108
|
+
<Spinner :size="36" label="Loading bookings…" stack />
|
|
109
|
+
```
|
|
110
|
+
- `size` (px or any CSS length), `tone` (`accent` `ink` `muted` `good` `warn` `bad` `current`), `speed` (seconds per lap)
|
|
111
|
+
- `label`, `stack` (label under the ring), `track` (default true), `decorative` (hidden from screen readers), `words`
|
|
112
|
+
|
|
113
|
+
### Button
|
|
114
|
+
A button with a look (variant), a size and an optional icon; `busy` locks it and shows a spinner while it works.
|
|
115
|
+
```vue
|
|
116
|
+
<Button variant="primary" icon="check" :busy="saving" busy-text="Saving…" @click="saveBooking">Save booking</Button>
|
|
117
|
+
```
|
|
118
|
+
- `variant`: `primary` `dark` `ghost` `danger` · `size`: `sm` `lg`
|
|
119
|
+
- `icon`, `icon-right`: an icon name, a component or a VNode · `block`: full width · `magnetic`: leans toward the mouse
|
|
120
|
+
- `busy`, `busy-text`: working state (disabled, `aria-busy`, spinner) · every other attribute and listener goes on the `<button>`
|
|
121
|
+
|
|
122
|
+
### IconButton
|
|
123
|
+
A square button that shows only an icon; the label is read by screen readers.
|
|
124
|
+
```vue
|
|
125
|
+
<IconButton icon="bell" label="Notifications" @click="openInbox" />
|
|
126
|
+
<IconButton icon="heart" label="Favourite bike" v-model:pressed="fav" size="sm" />
|
|
127
|
+
```
|
|
128
|
+
- `icon`, `label` (aria-label), `size: 'sm'` · default slot: anything after the icon
|
|
129
|
+
- `v-model:pressed` (or `default-pressed`): an on/off button (`aria-pressed`, pops when pressed) · `@change(pressed, event)`
|
|
130
|
+
|
|
131
|
+
### Tag
|
|
132
|
+
A small coloured status label.
|
|
133
|
+
```vue
|
|
134
|
+
<Tag :tone="booking.paid ? 'good' : 'warn'">{{ booking.paid ? 'Paid' : 'Unpaid' }}</Tag>
|
|
135
|
+
```
|
|
136
|
+
- `tone`: `good` `warn` `bad` `accent` `plain` · `dot` (default true; `:dot="false"` hides it) · `icon` instead of the dot
|
|
137
|
+
|
|
138
|
+
### Badge
|
|
139
|
+
A small round count.
|
|
140
|
+
```vue
|
|
141
|
+
<Button variant="ghost">Inbox <Badge tone="accent">{{ unread }}</Badge></Button>
|
|
142
|
+
```
|
|
143
|
+
- `tone: 'accent'` · default slot: the number
|
|
144
|
+
|
|
145
|
+
### Avatar
|
|
146
|
+
A round avatar with initials in one of eight colours; without a name it is an empty "open slot".
|
|
147
|
+
```vue
|
|
148
|
+
<Avatar name="Pim Wong" tone="teal" size="lg" online />
|
|
149
|
+
<Avatar /> <!-- nobody assigned yet -->
|
|
150
|
+
```
|
|
151
|
+
- `name` (tooltip, initials), `ini`, `tone` (`indigo` `teal` `rose` `amber` `violet` `green` `slate` `sky`)
|
|
152
|
+
- `size`: `sm` `lg` · `online`: green dot
|
|
153
|
+
|
|
154
|
+
### AvatarGroup
|
|
155
|
+
Small overlapping avatars, then "+N".
|
|
156
|
+
```vue
|
|
157
|
+
<AvatarGroup :people="task.assignees" :max="4" />
|
|
158
|
+
```
|
|
159
|
+
- `people`: `{ id?, name, ini?, tone? }[]` · `max` (default 4)
|
|
160
|
+
|
|
161
|
+
### Cell
|
|
162
|
+
An avatar with a name and a small line under it, for lists and table cells.
|
|
163
|
+
```vue
|
|
164
|
+
<Cell :name="rider.name" tone="rose" :sub="rider.phone" />
|
|
165
|
+
<Cell :name="rider.name"><template #sub><a :href="`tel:${rider.phone}`">{{ rider.phone }}</a></template></Cell>
|
|
166
|
+
```
|
|
167
|
+
- `name`, `ini`, `tone`, `online` · `sub`: text, or the `#sub` slot
|
|
168
|
+
|
|
169
|
+
### CardHead
|
|
170
|
+
Just the head row of a card: a title, a small line and things on the right.
|
|
171
|
+
```vue
|
|
172
|
+
<CardHead title="Today" :sub="`${bookings.length} bookings`">
|
|
173
|
+
<template #right><Button size="sm" variant="ghost">See all</Button></template>
|
|
174
|
+
</CardHead>
|
|
175
|
+
```
|
|
176
|
+
- `title`, `sub`, `right`: text props, or `#title` / `#sub` / `#right` slots
|
|
177
|
+
|
|
178
|
+
### Card
|
|
179
|
+
A white panel with an optional head (title, small line, things on the right); `lift` rises on hover.
|
|
180
|
+
```vue
|
|
181
|
+
<Card title="Today" :sub="`${bookings.length} bookings`" lift>
|
|
182
|
+
<template #right><Button size="sm" variant="ghost" @click="openAll">See all</Button></template>
|
|
183
|
+
<BookingList :items="bookings" />
|
|
184
|
+
</Card>
|
|
185
|
+
```
|
|
186
|
+
- `title`, `sub`, `right`: text props or `#title` / `#sub` / `#right` slots (the head shows when there is a title)
|
|
187
|
+
- `flush`: no padding (tables, lists) · `lift` · default slot: the body
|
|
188
|
+
|
|
189
|
+
### Kpi
|
|
190
|
+
A number tile: a caption, a big value and a small line.
|
|
191
|
+
```vue
|
|
192
|
+
<div class="kpis">
|
|
193
|
+
<Kpi label="Bikes out" :value="12" sub="of 20" />
|
|
194
|
+
<Kpi label="Revenue" value="฿48,250" sub="This month" tone="good" />
|
|
195
|
+
</div>
|
|
196
|
+
```
|
|
197
|
+
- `label`, `value`, `sub`: text props or `#label` / `#value` / `#sub` slots · `tone`: `accent` `good` `bad`
|
|
198
|
+
|
|
199
|
+
### Empty
|
|
200
|
+
What to show when a list has nothing in it.
|
|
201
|
+
```vue
|
|
202
|
+
<Empty icon="search" :title="`No bikes match “${q}”`" body="Check the spelling or try a shorter word.">
|
|
203
|
+
<template #action><Button size="sm" icon="close" @click="q = ''">Clear search</Button></template>
|
|
204
|
+
</Empty>
|
|
205
|
+
```
|
|
206
|
+
- `icon` (default `inbox`), `title`, `body`: props or `#title` / `#body` slots · `#action`: a button under the text
|
|
207
|
+
|
|
208
|
+
### Table
|
|
209
|
+
A table styled by `.table`, inside `.table-wrap` so it scrolls sideways on phones. Give it columns and rows (and draw cells with slots), or write the `<thead>`/`<tbody>` yourself.
|
|
210
|
+
```vue
|
|
211
|
+
<script setup>
|
|
212
|
+
const columns = [{ key: 'rider', title: 'Rider' }, { key: 'status', title: 'Status' }, { key: 'days', title: 'Days', align: 'right' }];
|
|
213
|
+
</script>
|
|
214
|
+
<template>
|
|
215
|
+
<Card title="Bookings" flush>
|
|
216
|
+
<Table :rows="bookings" :columns="columns" row-key="id" slide-rows>
|
|
217
|
+
<template #cell-rider="{ row }"><Cell :name="row.rider" :sub="row.phone" /></template>
|
|
218
|
+
<template #cell-status="{ row }"><Tag :tone="row.paid ? 'good' : 'warn'">{{ row.paid ? 'Paid' : 'Unpaid' }}</Tag></template>
|
|
219
|
+
<template #foot><tr><td>Total</td><td></td><td class="r">{{ totalDays }}</td></tr></template>
|
|
220
|
+
</Table>
|
|
221
|
+
</Card>
|
|
222
|
+
</template>
|
|
223
|
+
```
|
|
224
|
+
- `columns`: `{ key, title, align: 'right', class, render(row, i) }[]` · `rows` · `row-key` (field or function)
|
|
225
|
+
- slots: `#cell-<key>="{ row, column, value, index }"` for one column, `#cell="{ … }"` for any column (when it renders nothing the plain value shows), `#head-<key>` / `#head="{ column }"`, `#foot` (`<tr>`s for a `<tfoot>`)
|
|
226
|
+
- without `columns`: the default slot is the table's content · `slide-rows`: rows slide in when they first appear · `:wrap="false"` · attributes go on the `<table>`
|
|
227
|
+
|
|
228
|
+
### Meter
|
|
229
|
+
A thin bar that fills from zero, and glides when the value changes.
|
|
230
|
+
```vue
|
|
231
|
+
<Meter :value="task.done / task.total" :tone="late ? 'warn' : undefined" />
|
|
232
|
+
```
|
|
233
|
+
- `value`: 0 to 1 · `tone`: `good` `warn` `bad` · `delay`
|
|
234
|
+
|
|
235
|
+
### Ring
|
|
236
|
+
A round progress ring with a label in the middle; it sweeps on from the last value.
|
|
237
|
+
```vue
|
|
238
|
+
<Ring :value="0.72" :size="80" :stroke="8" label="72%" />
|
|
239
|
+
```
|
|
240
|
+
- `value`: 0 to 1 · `size` (56), `stroke` (6) · `label` or the `#label` slot
|
|
241
|
+
|
|
242
|
+
### Steps
|
|
243
|
+
A row of numbered steps: done ones get a tick, the bar fills up to the current one, the new dot pops.
|
|
244
|
+
```vue
|
|
245
|
+
<Steps :labels="['Bike', 'Dates', 'Extras', 'Pay']" :now="step" />
|
|
246
|
+
```
|
|
247
|
+
- `labels` · `now`: the current step from 0 · `#label="{ label, index }"` to draw a label yourself
|
|
248
|
+
|
|
249
|
+
### Bars
|
|
250
|
+
A small column chart: bars grow up from the baseline, then morph when the values change.
|
|
251
|
+
```vue
|
|
252
|
+
<Bars :values="perDay" :labels="['Mon', 'Tue', 'Wed', 'Thu', 'Fri']" show-values :height="160" :format="(v) => v + ' h'" />
|
|
253
|
+
```
|
|
254
|
+
- `values`, `max` (default: the biggest), `labels`, `show-values`, `format(value, index)`
|
|
255
|
+
- `highlight-top` (default true), `height` (210 px, or any CSS length), `label` for screen readers
|
|
256
|
+
|
|
257
|
+
### Field
|
|
258
|
+
A label above a control and a small hint under it.
|
|
259
|
+
```vue
|
|
260
|
+
<Field label="Phone" hint="We text the pick-up code here." :invalid="!!error">
|
|
261
|
+
<Input v-model="phone" type="tel" />
|
|
262
|
+
</Field>
|
|
263
|
+
```
|
|
264
|
+
- `label`, `hint`: text props or `#label` / `#hint` slots · `invalid`: red border and hint · default slot: the control
|
|
265
|
+
|
|
266
|
+
### Input
|
|
267
|
+
A text box with the kit's look: an `<input class="input">`.
|
|
268
|
+
```vue
|
|
269
|
+
<Input v-model.trim="email" type="email" placeholder="you@shop.com" size="sm" @blur="checkEmail" />
|
|
270
|
+
```
|
|
271
|
+
- `v-model` works like on a native input (`.lazy`, `.trim`, `.number`, waits for Thai/IME typing to finish) · or `default-value`
|
|
272
|
+
- `size: 'sm'` · `type` (default `text`) · every other attribute and listener (`placeholder`, `name`, `@input`, `@change`…) goes on the `<input>`
|
|
273
|
+
|
|
274
|
+
### Textarea
|
|
275
|
+
A text area with the same look; `auto-grow` makes it taller with each line, up to a limit.
|
|
276
|
+
```vue
|
|
277
|
+
<Field label="Note for the mechanic"><Textarea v-model="note" :rows="1" :auto-grow="6" /></Field>
|
|
278
|
+
```
|
|
279
|
+
- `v-model` like a native `<textarea>` · `auto-grow`: `true` (6 lines) or a number of lines · `size: 'sm'` · all `<textarea>` attributes
|
|
280
|
+
|
|
281
|
+
## Controls
|
|
282
|
+
|
|
283
|
+
### Switch
|
|
284
|
+
An on/off switch; the knob springs across.
|
|
285
|
+
```vue
|
|
286
|
+
<Switch v-model="settings.sms" label="SMS reminders" @change="(on) => save({ sms: on })" />
|
|
287
|
+
```
|
|
288
|
+
- `v-model` (boolean) or `default-value` · `@change(checked, event)` · `label` (aria-label)
|
|
289
|
+
|
|
290
|
+
### Segmented
|
|
291
|
+
A row of options where exactly one is picked; the thumb stretches to the new choice.
|
|
292
|
+
```vue
|
|
293
|
+
<Segmented v-model="view" :options="[['list', 'List', 'list'], ['board', 'Board', 'cards']]" />
|
|
294
|
+
```
|
|
295
|
+
- `options`: `[value, label, icon?]`, `{ value, label, icon, disabled }` or strings · `v-model` / `default-value` · `@change(value, event)` · `size: 'sm'`
|
|
296
|
+
|
|
297
|
+
### normOption
|
|
298
|
+
Turns any option form (`['id', 'Label', 'icon']`, `{ value, label }`, `'id'`) into `{ value, label, icon, disabled }`, for your own option lists.
|
|
299
|
+
```js
|
|
300
|
+
const list = bikes.map(normOption);
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Checkbox
|
|
304
|
+
A tick box that pops when ticked.
|
|
305
|
+
```vue
|
|
306
|
+
<Checkbox v-model="task.done" :label="task.title" @change="(done) => updateTask(task.id, { done })" />
|
|
307
|
+
```
|
|
308
|
+
- `v-model` (boolean) or `default-value` · `@change(checked, event)` · `label` (aria-label)
|
|
309
|
+
|
|
310
|
+
### Tabs
|
|
311
|
+
Tab buttons with a line that stretches to the selected one; a count shows as a badge.
|
|
312
|
+
```vue
|
|
313
|
+
<Tabs v-model="tab" :items="[['all', 'All tasks'], ['mine', 'Mine', myCount], ['done', 'Done']]" />
|
|
314
|
+
```
|
|
315
|
+
- `items`: `[value, label, count?]`, `{ value, label, count, disabled }` or strings · `v-model` / `default-value` · `@change(value, event)` · `name`
|
|
316
|
+
|
|
317
|
+
### Chips
|
|
318
|
+
Pill buttons for filters: one picked, or several with `multi`.
|
|
319
|
+
```vue
|
|
320
|
+
<Chips v-model="kind" :options="[['all', 'All'], ['scooter', 'Scooters', 'moto'], ['ebike', 'E-bikes', 'bike']]" />
|
|
321
|
+
<Chips v-model="shifts" multi :options="['morning', 'day', 'late']" />
|
|
322
|
+
```
|
|
323
|
+
- `options` (like Segmented) · `multi` · `v-model` / `default-value` (an array with `multi`) · `@change(value | values, event)` · `name`
|
|
324
|
+
|
|
325
|
+
### Range
|
|
326
|
+
A slider with a filled track (it fills up from zero when first shown) and a springy thumb.
|
|
327
|
+
```vue
|
|
328
|
+
<Field label="Days" :hint="`${days} days`"><Range v-model="days" :min="1" :max="14" /></Field>
|
|
329
|
+
```
|
|
330
|
+
- `min`, `max`, `step` · `v-model` (a number) or `default-value` (default: halfway) · `@change(value, event)` while it moves
|
|
331
|
+
|
|
332
|
+
### Swatch
|
|
333
|
+
A colour picker drawn as a round swatch; it pops when a colour is picked.
|
|
334
|
+
```vue
|
|
335
|
+
<Swatch v-model="label.colour" aria-label="Label colour" />
|
|
336
|
+
```
|
|
337
|
+
- `v-model` / `default-value` (`'#rrggbb'`, default `#5b4cf0`) · `@change(value, event)` while the colour changes
|
|
338
|
+
|
|
339
|
+
### SearchBox
|
|
340
|
+
A text field with a magnifying glass; Enter searches, an empty box shakes.
|
|
341
|
+
```vue
|
|
342
|
+
<SearchBox v-model="q" placeholder="Search bikes…" @search="(text) => router.push({ path: '/bikes', query: { q: text } })" />
|
|
343
|
+
```
|
|
344
|
+
- `placeholder` (also the aria-label) · `v-model` / `default-value` · `@change(value, event)` as it is typed · `@search(text, event)` · `size: 'sm'`
|
|
345
|
+
- `class` / `style` go on the box; every other attribute and listener (`name`, `@keydown`…) goes on the `<input>`
|
|
346
|
+
|
|
347
|
+
### Select
|
|
348
|
+
The animated dropdown: a real `<select>` (forms and `FormData` keep working) shown as a button whose list pops out, with a highlight that follows the mouse and the arrow keys.
|
|
349
|
+
```vue
|
|
350
|
+
<Field label="Assign to">
|
|
351
|
+
<Select v-model="owner" name="owner" :options="[
|
|
352
|
+
{ group: 'Design', options: [['pim', 'Pim Wong'], ['ann', 'Ann Ko']] },
|
|
353
|
+
{ group: 'Engineering', options: [['tom', 'Tom Lee'], ['max', 'Max Ru']] },
|
|
354
|
+
]" />
|
|
355
|
+
</Field>
|
|
356
|
+
```
|
|
357
|
+
- `options`: `[value, label, icon?]`, `{ value, label, icon, disabled }`, strings, or `{ group, options }` (labels are text, icons are icon names)
|
|
358
|
+
- `v-model` / `default-value` (default: the first option) · `@change(value, event)` · `size: 'sm'` · `disabled`, `name`, `aria-label`… go on the `<select>`
|
|
359
|
+
- the template ref's `$el.querySelector('select')` is the `<select>`; `dropdown(select)` from `@gecko-ui-kit/overlays` gives `{ open, close, sync }`
|
|
360
|
+
|
|
361
|
+
### Otp
|
|
362
|
+
A code field with one box per character: typing moves on, Backspace goes back, paste or the phone's code autofill fills every box. Return the answer from `@complete` to play it.
|
|
363
|
+
```vue
|
|
364
|
+
<Otp v-model="code" :length="6" split autofocus @complete="async (c) => (await api.verifyPhone(c)).ok" />
|
|
365
|
+
```
|
|
366
|
+
- `length` (6), `split`, `mask` (PIN dots), `letters` (A–Z too), `label`, `name`
|
|
367
|
+
- `@complete(code, el)`: return / resolve `true` (green wave, then a tick) or `false` (shake, then clear) · `gather`, `clear`
|
|
368
|
+
- `v-model` / `default-value`, `@change(code)` as it is typed · `disabled` · `autofocus` · the template ref's `$el` is the `.otp` element (`otpState` / `otpClear` work on it)
|
|
369
|
+
|
|
370
|
+
## Forms
|
|
371
|
+
|
|
372
|
+
### MultiSelect
|
|
373
|
+
Pick several people, labels or options; each pick flies up into the field as a chip.
|
|
374
|
+
```vue
|
|
375
|
+
<script setup>
|
|
376
|
+
const who = ref(['ploy'])
|
|
377
|
+
const team = [{ value: 'ploy', label: 'Ploy', person: true }, { value: 'tom', label: 'Tom', person: true }]
|
|
378
|
+
</script>
|
|
379
|
+
<template>
|
|
380
|
+
<MultiSelect v-model="who" :options="team" :max="3" placeholder="Assign to…" />
|
|
381
|
+
</template>
|
|
382
|
+
```
|
|
383
|
+
- `v-model` (or `default-value`): the picked values; a new value or new `options` are applied in place
|
|
384
|
+
- `options` (strings or `{ value, label, sub, group, person, color, icon, disabled }`), `max`, `creatable`, `close-on-select`, `name`, `disabled`, `words`
|
|
385
|
+
- `@change(values, options, ms)`, `@create(option, ms)`; ref: `set`, `add`, `remove`, `clear`, `open`, `setOptions`
|
|
386
|
+
|
|
387
|
+
### Combobox
|
|
388
|
+
A text field you type into to find one option; it can ask your server instead of a fixed list.
|
|
389
|
+
```vue
|
|
390
|
+
<Combobox v-model="branch" label="Pick-up branch" :options="branches" />
|
|
391
|
+
<Combobox v-model="customer" label="Customer" :source="(q, { signal }) => $fetch('/api/customers', { query: { q }, signal })" />
|
|
392
|
+
```
|
|
393
|
+
- `v-model` (or `default-value`): the picked value (or `{ value, label }` with a source); gets the value or `null`
|
|
394
|
+
- `options` or `source(query, { signal })`, `clearable`, `allow-custom`, `min-chars`, `debounce`, `max-results`, `name`, `label`, `disabled`, `words`
|
|
395
|
+
- `@change(value, option, cb)`, `@input(text, cb)`
|
|
396
|
+
|
|
397
|
+
### TagsInput
|
|
398
|
+
Type words and each one becomes a tag; a comma or Enter makes a tag, pasting a list makes many.
|
|
399
|
+
```vue
|
|
400
|
+
<TagsInput v-model="labels" :suggestions="['bug', 'design', 'mobile']" :max="5" />
|
|
401
|
+
```
|
|
402
|
+
- `v-model` (or `default-value`): the tags, applied in place
|
|
403
|
+
- `suggestions`, `max`, `unique`, `separators`, `validate(text) → true | 'message'`, `transform(text)`, `name`, `disabled`, `words`
|
|
404
|
+
- `@change(tags, ti)`; ref: `add`, `remove`, `clear`, `set`
|
|
405
|
+
|
|
406
|
+
### RangeSlider
|
|
407
|
+
Two thumbs for a low and a high value, with an optional histogram behind the track.
|
|
408
|
+
```vue
|
|
409
|
+
<RangeSlider v-model="price" label="Price per day" :min="0" :max="2000" :step="50"
|
|
410
|
+
:format="(v) => `฿${v.toLocaleString()}`" :histogram="[2, 5, 9, 4, 1]" />
|
|
411
|
+
```
|
|
412
|
+
- `v-model` (or `default-value`): `[low, high]`; the thumbs glide to a new value
|
|
413
|
+
- `min`, `max`, `step`, `min-gap`, `format`, `parse`, `marks`, `histogram`, `inputs`, `name`, `label`, `disabled`, `words`
|
|
414
|
+
- `@input(value, rs)` while dragging, `@change(value, rs)` when it settles (v-model follows `@change`)
|
|
415
|
+
|
|
416
|
+
### Stepper
|
|
417
|
+
− and + around a number whose digits roll like an odometer.
|
|
418
|
+
```vue
|
|
419
|
+
<Stepper v-model="days" :min="1" :max="30" :unit="(n) => (n === 1 ? 'day' : 'days')" />
|
|
420
|
+
```
|
|
421
|
+
- `v-model` (or `default-value`), `min`, `max` (applied in place; a value outside is pulled in), `step`
|
|
422
|
+
- `unit`, `prefix`, `format`, `locale`, `size`, `name`, `disabled`, `words`
|
|
423
|
+
- `@change(value, st)`; ref: `set`, `stepBy`, `setRange`
|
|
424
|
+
|
|
425
|
+
### Rating
|
|
426
|
+
Stars (or hearts) to give a score, or to show one read-only.
|
|
427
|
+
```vue
|
|
428
|
+
<Rating v-model="score" :labels="['Bad', 'Poor', 'Okay', 'Good', 'Great']" />
|
|
429
|
+
<Rating :default-value="4.6" read-only size="sm" />
|
|
430
|
+
```
|
|
431
|
+
- `v-model` (or `default-value`), `max`, `half`, `read-only` (applied in place), `clearable`
|
|
432
|
+
- `icon`, `size`, `labels`, `show-value`, `name`, `disabled`, `words`
|
|
433
|
+
- `@change(value, r)`; ref: `set`, `setReadOnly`
|
|
434
|
+
|
|
435
|
+
### RadioCards
|
|
436
|
+
Choices drawn as cards (real radio buttons underneath), exactly one picked.
|
|
437
|
+
```vue
|
|
438
|
+
<RadioCards v-model="bike" label="Choose a bike" :options="[
|
|
439
|
+
{ value: 'scoot', title: 'Scooter 125', desc: 'Easy in town', price: '฿350 / day', icon: 'moto' },
|
|
440
|
+
{ value: 'big', title: 'Scooter 160', desc: 'For two', price: '฿550 / day', badge: 'Popular' },
|
|
441
|
+
]" />
|
|
442
|
+
```
|
|
443
|
+
- `v-model` (or `default-value`), `options` (`{ value, title, desc, price, icon, badge, disabled }`)
|
|
444
|
+
- `label`, `hide-label`, `layout` (`list` | `grid`), `min`, `name`, `required`, `disabled`, `words`
|
|
445
|
+
- `@change(value, option, plan)`
|
|
446
|
+
|
|
447
|
+
### SubscribeForm
|
|
448
|
+
One email field and a button; the button grows into the thank-you message.
|
|
449
|
+
```vue
|
|
450
|
+
<script setup>
|
|
451
|
+
async function join(email) {
|
|
452
|
+
await $fetch('/api/waitlist', { method: 'POST', body: { email } }) // throw to show the error
|
|
453
|
+
}
|
|
454
|
+
</script>
|
|
455
|
+
<template>
|
|
456
|
+
<SubscribeForm icon="mail" :words="{ button: 'Join the waitlist' }" @submit="join" />
|
|
457
|
+
</template>
|
|
458
|
+
```
|
|
459
|
+
- `default-value`, `name`, `icon`, `layout` (`row` | `stack`), `validate(email)`, `reset-after`, `words`
|
|
460
|
+
- `@submit(email, sub)`: resolve (a string replaces the thanks text) or reject to show the error; ref: `setError`, `reset`, `state`
|
|
461
|
+
|
|
462
|
+
### PasswordMeter
|
|
463
|
+
A password field with the strength meter after it: bars, a checklist that ticks off and a padlock.
|
|
464
|
+
```vue
|
|
465
|
+
<div class="field">
|
|
466
|
+
<label for="team-pw">Password for the team account</label>
|
|
467
|
+
<PasswordMeter id="team-pw" v-model="pw" reveal :min="10" @change="(s) => (canSave = s.valid)" />
|
|
468
|
+
</div>
|
|
469
|
+
```
|
|
470
|
+
- The meter: `rules` (`{ id, test, label }`), `min`, `min-score`, `score`, `reveal`, `list`, `lock`, `words`, `@change({ score, level, valid, rules }, pw)`
|
|
471
|
+
- The text: `v-model` (or `default-value`) and `@value-change(text, event)`; every other attribute (`id`, `name`, `placeholder`…) goes on the `<input>`
|
|
472
|
+
- ref: `score`, `level`, `valid`, `rules`, `check()`, `reveal(on)`
|
|
473
|
+
|
|
474
|
+
### PasswordToggle
|
|
475
|
+
A password field with a show / hide eye inside it (drawn by Vue, so it renders fully on the server).
|
|
476
|
+
```vue
|
|
477
|
+
<PasswordToggle v-model="password" name="password" autocomplete="current-password" @toggle="(shown) => track(shown)" />
|
|
478
|
+
```
|
|
479
|
+
- `v-model` (or `default-value`): the text; `v-model:shown` (or `default-shown`) and `@toggle(shown)`: the eye; `words: { show, hide }`
|
|
480
|
+
- Every other attribute goes on the `<input>`; ref: `input`, `focus()`
|
|
481
|
+
|
|
482
|
+
### AuthForm
|
|
483
|
+
One card for signing in and creating an account, with checks, a strength meter and a busy button.
|
|
484
|
+
```vue
|
|
485
|
+
<script setup>
|
|
486
|
+
const mode = ref('in')
|
|
487
|
+
async function submit(values, mode) {
|
|
488
|
+
const r = await fetch(`/api/${mode === 'up' ? 'sign-up' : 'sign-in'}`, { method: 'POST', body: JSON.stringify(values) })
|
|
489
|
+
if (r.status === 401) throw Object.assign(new Error('That password isn’t right.'), { field: 'password' })
|
|
490
|
+
}
|
|
491
|
+
</script>
|
|
492
|
+
<template>
|
|
493
|
+
<AuthForm v-model:mode="mode" :fields="{ confirm: true }" @forgot="(email) => sendResetLink(email)" @submit="submit" />
|
|
494
|
+
</template>
|
|
495
|
+
```
|
|
496
|
+
- `v-model:mode` (or `default-mode`): `in` | `up`, applied in place; `fields`, `meter`, `min`, `values` (filled in when it mounts), `validate`, `words`
|
|
497
|
+
- `@submit(values, mode, f)`, `@mode-change(mode, f)`, `@forgot(email, f)`; ref: `setMode`, `setError`, `reset`, `values`
|
|
498
|
+
|
|
499
|
+
### SignaturePad
|
|
500
|
+
Sign with a finger, pen or mouse; the ink is thinner when you move fast.
|
|
501
|
+
```vue
|
|
502
|
+
<script setup>
|
|
503
|
+
const sig = ref(null)
|
|
504
|
+
const send = () => saveAgreement(sig.value.toJSON(), sig.value.toImage({ background: '#fff' }))
|
|
505
|
+
</script>
|
|
506
|
+
<template>
|
|
507
|
+
<SignaturePad ref="sig" :words="{ hint: 'Sign here' }" @change="(empty) => (signed = !empty)" />
|
|
508
|
+
<Button variant="primary" @click="send">Sign and send</Button>
|
|
509
|
+
<SignaturePad read-only :tools="false" :default-value="agreement.strokes" />
|
|
510
|
+
</template>
|
|
511
|
+
```
|
|
512
|
+
- `color`, `width`, `pressure`, `guide`, `tools`, `read-only`, `default-value` (saved `toJSON()` data), `words`
|
|
513
|
+
- `@change(isEmpty, sig)`, `@end(sig)`; ref: `undo`, `clear`, `replay`, `toJSON`, `fromJSON`, `toImage`, `toSVG`
|
|
514
|
+
- Changing `read-only` or another option keeps what was signed
|
|
515
|
+
|
|
516
|
+
### PhotoUpload
|
|
517
|
+
Drop, pick or paste photos; each tile uploads with a ring and can be dragged to reorder (the first is the cover).
|
|
518
|
+
```vue
|
|
519
|
+
<PhotoUpload v-model="bike.photos" :max="8"
|
|
520
|
+
:upload="(file, { progress, signal }) => uploadPhoto(file, { onProgress: progress, signal })" />
|
|
521
|
+
```
|
|
522
|
+
- `v-model` (or `default-value`): photos already uploaded (`[{ url }]` or URLs); after every change it gets each photo's upload result, in order
|
|
523
|
+
- `accept`, `max`, `max-size` (MB), `upload`, `concurrent`, `resize`, `cover`, `sortable`, `read-only`, `capture`, `words`
|
|
524
|
+
- `@change(items, up)`, `@reject`, `@uploaded`, `@error`; ref: `value`, `settled()`, `add`, `remove`, `move`, `open`
|
|
525
|
+
|
|
526
|
+
### FileDrop
|
|
527
|
+
A drop zone that lists each file with its own progress bar, tick or error.
|
|
528
|
+
```vue
|
|
529
|
+
<FileDrop accept=".pdf,image/*" :max-size="10 * 1024 * 1024"
|
|
530
|
+
:upload="(file, { progress, signal }) => sendReceipt(file, progress, signal)" @change="(files) => (receipts = files)" />
|
|
531
|
+
```
|
|
532
|
+
- `accept`, `multiple`, `max-size` (bytes), `max-files`, `upload`, `auto`, `concurrent`, `compact`, `words`
|
|
533
|
+
- `@change(files, fd)`, `@error(problem, fd)`; ref: `files`, `value`, `add`, `retry`, `cancel`, `clear`, `browse`, `upload()`
|
|
534
|
+
|
|
535
|
+
### PricingToggle
|
|
536
|
+
Plan cards with a monthly / yearly switch; every price rolls to its new number.
|
|
537
|
+
```vue
|
|
538
|
+
<PricingToggle v-model="period" locale="th-TH" :format="{ style: 'currency', currency: 'THB', maximumFractionDigits: 0 }"
|
|
539
|
+
:plans="[{ id: 'shop', name: 'Shop', price: { month: 390, year: 290 }, features: ['20 bikes'], action: 'Choose Shop', featured: true }]"
|
|
540
|
+
@select="(plan, period) => navigateTo(`/checkout?plan=${plan.id}&period=${period}`)" />
|
|
541
|
+
```
|
|
542
|
+
- `v-model` (or `default-value`): the period id; `plans`, `periods`, `format`, `locale`, `motion` (`roll` | `count`), `strike`, `words`
|
|
543
|
+
- `@change(periodId, prices)`, `@select(plan, periodId, prices)`
|
|
544
|
+
- Plan texts are plain strings (the piece draws them)
|
|
545
|
+
|
|
546
|
+
### DateRange
|
|
547
|
+
A month calendar to pick a start and an end (or one date), counting the days or nights.
|
|
548
|
+
```vue
|
|
549
|
+
<script setup>
|
|
550
|
+
const dates = ref({ start: '2026-12-04', end: '2026-12-07' })
|
|
551
|
+
</script>
|
|
552
|
+
<template>
|
|
553
|
+
<DateRange v-model="dates" count="days" :min="today" :disabled="bookedDays" :months="2" />
|
|
554
|
+
</template>
|
|
555
|
+
```
|
|
556
|
+
- `v-model` (or `default-value`): `{ start, end }` or one date (`'YYYY-MM-DD'` or `Date`); it gets `{ start, end, count }` back (end is `null` until it is picked)
|
|
557
|
+
- `mode` (`range` | `single`), `months`, `min`, `max`, `disabled`, `count`, `min-days`, `max-days`, `block-span`, `presets`, `locale`, `week-start`, `words`
|
|
558
|
+
- `@change(value, dp)`, `@invalid(reason, dp)`
|
|
559
|
+
|
|
560
|
+
### TimePicker
|
|
561
|
+
A wheel or a grid of time slots.
|
|
562
|
+
```vue
|
|
563
|
+
<TimePicker v-model="pickUp" look="slots" min="09:00" max="18:00" :disabled="takenSlots" />
|
|
564
|
+
```
|
|
565
|
+
- `v-model` (or `default-value`): `'HH:MM'`; `look` (`wheel` | `slots`), `step`, `min`, `max`, `disabled` (applied in place), `hour12`, `words`
|
|
566
|
+
- `@change(value, tp)`; ref: `set`, `setDisabled`, `format`
|
|
567
|
+
|
|
568
|
+
### Wizard
|
|
569
|
+
A long form split into steps that slide sideways; each step's content is your own Vue, in a slot named after the step's id.
|
|
570
|
+
```vue
|
|
571
|
+
<script setup>
|
|
572
|
+
const steps = [
|
|
573
|
+
{ id: 'bike', title: 'Bike' },
|
|
574
|
+
{ id: 'rider', title: 'Rider' },
|
|
575
|
+
{ id: 'pay', title: 'Payment', validate: () => (paid.value ? true : 'Choose how to pay.') },
|
|
576
|
+
]
|
|
577
|
+
</script>
|
|
578
|
+
<template>
|
|
579
|
+
<Wizard :steps="steps" :words="{ finish: 'Book' }" @finish="(values) => book(values)">
|
|
580
|
+
<template #bike><BikePicker /></template>
|
|
581
|
+
<template #rider><label class="field"><span>Phone</span><input class="input" name="phone" required /></label></template>
|
|
582
|
+
<template #pay><PaymentStep /></template>
|
|
583
|
+
</Wizard>
|
|
584
|
+
</template>
|
|
585
|
+
```
|
|
586
|
+
- `steps` (`{ id, title, sub, optional, validate(panel, wz), content }`); slots: `#<id>` per step, or `#step="{ step, index }"` for every step (`content` is plain text when there is no slot)
|
|
587
|
+
- `v-model:index` (applied with `go()`, without checking) or `start`; `linear`, `header` (`steps` | `bar` | `none`), `level`, `label`, `words`
|
|
588
|
+
- `@step(index, wz)`, `@finish(values, wz)`; ref: `next()`, `back()`, `go(i)`, `reset()`, `values`
|
|
589
|
+
- Without `validate`, the browser's own checks run on the step's fields (`required`, `type="email"`…)
|
|
590
|
+
|
|
591
|
+
### useValidation
|
|
592
|
+
The red-field pattern from the Validation page (`.field.is-bad`, the reason in `.field__hint`, a small shake) as a composable.
|
|
593
|
+
It is a pattern, not a piece: you draw the fields, the composable keeps the messages.
|
|
594
|
+
```vue
|
|
595
|
+
<script setup>
|
|
596
|
+
import { useValidation } from '@gecko-ui-kit/vue'
|
|
597
|
+
const v = useValidation({
|
|
598
|
+
name: (x) => (x.trim() ? '' : 'Please type your name.'),
|
|
599
|
+
email: (x) => (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x) ? '' : 'That email looks incomplete.'),
|
|
600
|
+
})
|
|
601
|
+
</script>
|
|
602
|
+
<template>
|
|
603
|
+
<label :class="['field', { 'is-bad': v.errors.email }]">
|
|
604
|
+
<span>Email</span>
|
|
605
|
+
<input class="input" type="email" v-bind="v.field('email')" />
|
|
606
|
+
<small class="field__hint">{{ v.errors.email || 'We send one email when we launch.' }}</small>
|
|
607
|
+
</label>
|
|
608
|
+
<Button variant="primary" @click="v.validate() && join(v.values())">Join the waitlist</Button>
|
|
609
|
+
</template>
|
|
610
|
+
```
|
|
611
|
+
- A rule gets `(value, values)` and returns `''` (fine) or the message; call it in `setup()`
|
|
612
|
+
- `v-bind="v.field(name)"` puts `name`, a ref, `@input` and `aria-invalid` on the input; `v.validate()` marks and shakes the bad fields, true when all are fine
|
|
613
|
+
- `v.errors` (reactive), `v.check(name)`, `v.setError(name, message)` (e.g. a server answer), `v.reset()`, `v.values()`
|
|
614
|
+
- Options: `{ live: true }` re-checks a red field on every key, `{ shake: true }`
|
|
615
|
+
|
|
616
|
+
## Data display
|
|
617
|
+
|
|
618
|
+
### Accordion
|
|
619
|
+
A list of headings that open to show more. The panel grows open and the chevron turns.
|
|
620
|
+
|
|
621
|
+
```vue
|
|
622
|
+
<script setup>
|
|
623
|
+
const open = ref(['deposit'])
|
|
624
|
+
const faq = [
|
|
625
|
+
{ id: 'helmet', title: 'Is a helmet included?', content: 'Yes, two helmets come with every bike.' },
|
|
626
|
+
{ id: 'deposit', title: 'Deposit', sub: 'Returned at drop-off' },
|
|
627
|
+
]
|
|
628
|
+
</script>
|
|
629
|
+
|
|
630
|
+
<template>
|
|
631
|
+
<Accordion v-model="open" :items="faq">
|
|
632
|
+
<template #content="{ item }">
|
|
633
|
+
<DepositInfo v-if="item.id === 'deposit'" :bike="bike" />
|
|
634
|
+
<p v-else>{{ item.content }}</p>
|
|
635
|
+
</template>
|
|
636
|
+
</Accordion>
|
|
637
|
+
</template>
|
|
638
|
+
```
|
|
639
|
+
- `items`: `{ id, title, sub, icon, badge, content, open, disabled }`. `content` and `title` are text.
|
|
640
|
+
- Slots: `#content="{ item, index }"` draws each panel, `#title="{ item, index }"` draws every heading.
|
|
641
|
+
- `v-model` (or `default-value`): the open ids. `@change(openIds)` · `@toggle(id, open)`.
|
|
642
|
+
- `multiple`, `collapsible`, `look: 'lines' | 'cards'`, `marker: 'chevron' | 'plus'`, `level`. Template ref: `open`, `close`, `closeAll`, `filter`…
|
|
643
|
+
|
|
644
|
+
### Carousel
|
|
645
|
+
Slides you swipe, drag or step through. The current dot stretches into a pill.
|
|
646
|
+
|
|
647
|
+
```vue
|
|
648
|
+
<Carousel v-model="slide" :per-view="{ 0: 1, 640: 2, 960: 3 }" :peek="40" label="Bikes">
|
|
649
|
+
<BikeCard v-for="b in bikes" :key="b.id" :bike="b" />
|
|
650
|
+
</Carousel>
|
|
651
|
+
```
|
|
652
|
+
- Each child of the default slot is one slide (a `v-for` works). `v-model` (or `default-value`): the slide index. `@change(index)`.
|
|
653
|
+
- `per-view`, `gap`, `peek`, `focus`, `rewind`, `autoplay` (ms), `arrows`, `dots`, `label`, `words`. Template ref: `go(i)`, `next()`, `prev()`, `play()`, `pause()`.
|
|
654
|
+
|
|
655
|
+
### BeforeAfter
|
|
656
|
+
Two pictures on top of each other, with a divider you drag to wipe between them.
|
|
657
|
+
|
|
658
|
+
```vue
|
|
659
|
+
<BeforeAfter hint>
|
|
660
|
+
<template #before><img src="/repairs/42-before.jpg" alt="Scratched side panel" /></template>
|
|
661
|
+
<template #after><img src="/repairs/42-after.jpg" alt="Repaired side panel" /></template>
|
|
662
|
+
</BeforeAfter>
|
|
663
|
+
```
|
|
664
|
+
- Slots `#before` and `#after` (or the `before` / `after` text props).
|
|
665
|
+
- `v-model` (or `default-value`): 0–100 (default 50). `@change(value)` while it moves.
|
|
666
|
+
- `hover`, `hint`, `labels`, `ratio` ('4/3'), `step`, `words`.
|
|
667
|
+
|
|
668
|
+
### Tree
|
|
669
|
+
Nested items that open and close, like folders, with keyboard support and optional checkboxes.
|
|
670
|
+
|
|
671
|
+
```vue
|
|
672
|
+
<Tree
|
|
673
|
+
v-model="picked"
|
|
674
|
+
v-model:checked="ticked"
|
|
675
|
+
:items="[{ id: 'scooters', label: 'Scooters', children: [{ id: 'click', label: 'Honda Click' }, { id: 'nmax', label: 'Yamaha NMAX' }] }]"
|
|
676
|
+
checkable
|
|
677
|
+
label="Fleet"
|
|
678
|
+
@activate="(item) => openBike(item.id)"
|
|
679
|
+
/>
|
|
680
|
+
```
|
|
681
|
+
- `items`: `{ id, label, icon, badge, children, open, disabled }`; `children: true` loads them with `load(item)` when it first opens.
|
|
682
|
+
- `v-model` (or `default-value`): the selected ids. `v-model:checked`: the ticked ids. Both change in place.
|
|
683
|
+
- `select: 'single' | 'multiple' | 'none'`, `checkable`, `lines`, `icons`, `open-on-click`. `@select(ids, item)` · `@check(ids)` · `@toggle(id, open)` · `@activate(item)`.
|
|
684
|
+
|
|
685
|
+
### DataGrid
|
|
686
|
+
A table people can search, filter, sort, page through and edit in place. Rows glide when the order changes.
|
|
687
|
+
|
|
688
|
+
```vue
|
|
689
|
+
<DataGrid
|
|
690
|
+
:columns="[
|
|
691
|
+
{ key: 'plate', label: 'Plate' },
|
|
692
|
+
{ key: 'model', label: 'Model', type: 'select', options: ['Click', 'NMAX'], filter: true },
|
|
693
|
+
{ key: 'rate', label: 'Rate / day', type: 'number', align: 'right', edit: true },
|
|
694
|
+
]"
|
|
695
|
+
:rows="bikes"
|
|
696
|
+
@change="(row, key, value) => saveBike(row.id, { [key]: value })"
|
|
697
|
+
/>
|
|
698
|
+
```
|
|
699
|
+
- A new `rows` is applied in place with `setRows()`. Nothing happens when it already matches what is on screen.
|
|
700
|
+
- `search`, `page-size`, `select`, `add`, `remove`, `density`, `stripes`, `row-key` (the id field, default `'id'`). `@change(row, key, value, old)` · `@add(row)` · `@remove(rows)`.
|
|
701
|
+
- `columns[].render(value, row)` returns trusted HTML. Escape app text yourself, or use `format` for plain text.
|
|
702
|
+
|
|
703
|
+
### VirtualList
|
|
704
|
+
Thousands of rows, but only the ones you can see are in the page.
|
|
705
|
+
|
|
706
|
+
```vue
|
|
707
|
+
<VirtualList v-model="pickedId" :items="customers" :row-height="56" :height="480" selectable label="Customers">
|
|
708
|
+
<template #item="{ item }"><CustomerRow :customer="item" /></template>
|
|
709
|
+
</VirtualList>
|
|
710
|
+
```
|
|
711
|
+
- Slot `#item="{ item, index }"` draws each row on screen (or `render(item, index)` → trusted HTML).
|
|
712
|
+
- `items`: an array or a count. A new `items` is applied in place. `row-height`: px or `'auto'` (measured).
|
|
713
|
+
- `v-model` (or `default-value`): the key of the picked row (`selectable`). `item-key(item, index)`. `@select(item, index)` · `@range(range)`. Template ref: `scrollTo(i)`, `select(i)`, `refresh()`.
|
|
714
|
+
|
|
715
|
+
### Timeline
|
|
716
|
+
Bookings as bars on a row per bike, room or person. Drag a bar to move it, pull its end to make it longer.
|
|
717
|
+
|
|
718
|
+
```vue
|
|
719
|
+
<Timeline
|
|
720
|
+
title="Fleet"
|
|
721
|
+
:rows="bikes.map((b) => ({ id: b.id, label: b.name }))"
|
|
722
|
+
:items="bookings"
|
|
723
|
+
from="2026-12-01"
|
|
724
|
+
:days="14"
|
|
725
|
+
@change="(booking) => saveBooking(booking)"
|
|
726
|
+
@add="({ row, start }) => newBooking(row, start)"
|
|
727
|
+
/>
|
|
728
|
+
```
|
|
729
|
+
- `items`: `{ id, row, start, end, label, status, color, edit }`. Changes are applied in place (bars glide and grow).
|
|
730
|
+
- `from`, `days`, `locale`, `edit`, `overlap`, `now`, `late`, `sub(item, days)`. `@change(item, before)` · `@open(item, bar)` · `@add({ row, start })` · `@clash(item, other)`.
|
|
731
|
+
|
|
732
|
+
### Calendar
|
|
733
|
+
A month of days with your events on them. Drag an event to another day.
|
|
734
|
+
|
|
735
|
+
```vue
|
|
736
|
+
<Calendar v-model="day" v-model:month="month" :events="bookings" draggable locale="th"
|
|
737
|
+
@move="(ev, start, end) => moveBooking(ev.id, start, end)" />
|
|
738
|
+
```
|
|
739
|
+
- `events`: `{ id, title, start, end, tone, allDay, time }`. A new `events` is applied in place.
|
|
740
|
+
- `v-model` (or `default-value`): the picked day (a click gives a `Date`). `v-model:month`: the month on show.
|
|
741
|
+
- `week-start`, `max-per-day`, `selectable`, `draggable`, `size: 'sm'`. `@day(date, events)` · `@event(event)` · `@month(date)` · `@move(event, start, end)` (return false to put it back).
|
|
742
|
+
|
|
743
|
+
### SwipeItem and SwipeActions
|
|
744
|
+
Rows you swipe left or right to show actions behind them, like a phone's mail app.
|
|
745
|
+
|
|
746
|
+
```vue
|
|
747
|
+
<SwipeActions class="card card--flush" @action="(action, ctx) => action === 'cancel' && cancelBooking(ctx.id)">
|
|
748
|
+
<SwipeItem v-for="b in bookings" :key="b.id" :id="b.id"
|
|
749
|
+
:start="[{ id: 'call', label: 'Call', icon: 'phone', tone: 'accent' }]"
|
|
750
|
+
:end="[{ id: 'cancel', label: 'Cancel', icon: 'trash', tone: 'bad', remove: true }]">
|
|
751
|
+
<BookingRow :booking="b" />
|
|
752
|
+
</SwipeItem>
|
|
753
|
+
</SwipeActions>
|
|
754
|
+
```
|
|
755
|
+
- `SwipeItem`: the default slot is the row. `start` (pulled right) and `end` (pulled left) actions `{ id, label, icon, tone, remove }`, listed from the edge inward. `look: 'icons' | 'labels'`, `label`.
|
|
756
|
+
- `SwipeActions`: `@action(action, ctx)` (ctx: `{ row, id, undo() }`; return false to keep the row) · `@open(row, side)` · `@close(row)`. A row with `remove: true` slides off and is hidden: drop it from your list when you are done.
|
|
757
|
+
- `full`, `full-at`, `single`, `haptic`, `as`. Template ref: `open(row, side)`, `close()`, `peek()`.
|
|
758
|
+
|
|
759
|
+
### Kanban
|
|
760
|
+
Columns of cards you drag between columns or up and down. A picked-up card hangs from where you hold it.
|
|
761
|
+
|
|
762
|
+
```vue
|
|
763
|
+
<Kanban
|
|
764
|
+
:columns="[{ id: 'todo', title: 'To do' }, { id: 'doing', title: 'Doing', limit: 3 }, { id: 'done', title: 'Done' }]"
|
|
765
|
+
:cards="tasks"
|
|
766
|
+
@move="(card, { to, index }) => moveTask(card.id, to, index)"
|
|
767
|
+
>
|
|
768
|
+
<template #card="{ card }"><TaskCard :task="card" /></template>
|
|
769
|
+
</Kanban>
|
|
770
|
+
```
|
|
771
|
+
- Slot `#card="{ card }"` draws each card. Leave it out to get the built-in card (`tags`, `title`, `text`).
|
|
772
|
+
- A new `cards` is applied in place: new cards grow in, removed ones fold away, moved ones slide.
|
|
773
|
+
- `strict-limit`, `can-drop(card, column)`. `@move(card, { from, to, index })` (return false to put it back) · `@open(card)` · `@add(column)`.
|
|
774
|
+
|
|
775
|
+
### Notifications
|
|
776
|
+
A notification feed, newest first and grouped by day. New ones slide in at the top, and unread dots fade when read.
|
|
777
|
+
|
|
778
|
+
```vue
|
|
779
|
+
<Notifications
|
|
780
|
+
:items="notes"
|
|
781
|
+
:height="420"
|
|
782
|
+
@open="(n) => markRead(n.id)"
|
|
783
|
+
@action="async (n, action) => { await api.answer(n.id, action); return action === 'accept' ? 'Accepted' : 'Declined' }"
|
|
784
|
+
/>
|
|
785
|
+
```
|
|
786
|
+
- `items`: `{ id, time, title, body, person, icon, tone, read, actions, href }`. Changes are applied in place.
|
|
787
|
+
- `group`, `filter: 'all' | 'unread'`, `header`, `tabs`, `mark-all`, `dismissible`, `plain`. `@open(item)` · `@action(item, id)` · `@dismiss(item)` · `@change(unreadCount)`.
|
|
788
|
+
|
|
789
|
+
### Activity
|
|
790
|
+
A timeline of what happened, newest first, with a line that draws down through the marks.
|
|
791
|
+
|
|
792
|
+
```vue
|
|
793
|
+
<Activity :items="[{ id: 1, who: 'Pim', what: 'checked the Click in', icon: 'check', tone: 'good', time: returnedAt }]" marks="auto" locale="th" />
|
|
794
|
+
```
|
|
795
|
+
- `items`: `{ id, time, who, what, title, detail, icon, tone }`. New ones at the top push the list down; others are set in place.
|
|
796
|
+
- `marks: 'auto' | 'icon' | 'avatar' | 'dot'`, `latest`, `max`, `intro` (`'view'`, true or false), `refresh` (s).
|
|
797
|
+
|
|
798
|
+
### Pagination
|
|
799
|
+
Page numbers with previous / next, a page-size list and “21–30 of 240”.
|
|
800
|
+
|
|
801
|
+
```vue
|
|
802
|
+
<Pagination v-model="page" v-model:page-size="pageSize" :total="bookingsTotal" />
|
|
803
|
+
```
|
|
804
|
+
- `v-model` (or `default-value`): the page, from 1. `v-model:page-size` follows the size list. A smaller `total` moves to the last page and reports it.
|
|
805
|
+
- `siblings`, `boundaries`, `sizes`, `info`, `look: 'numbers' | 'simple'`, `compact`. `@change(page, pageSize)`.
|
|
806
|
+
|
|
807
|
+
### Breadcrumbs
|
|
808
|
+
The path to the current page. Steps slide in and out when the path changes.
|
|
809
|
+
|
|
810
|
+
```vue
|
|
811
|
+
<Breadcrumbs :items="[{ label: 'Fleet', href: '/fleet' }, { label: 'Scooters', href: '/fleet/scooters' }, { label: 'Honda Click' }]"
|
|
812
|
+
@navigate="(item, i, e) => { e.preventDefault(); router.push(item.href) }" />
|
|
813
|
+
```
|
|
814
|
+
- `items`: `{ label, href, icon }`; the last one is the current page. A new `items` is set in place.
|
|
815
|
+
- `max`, `separator: 'chevron' | 'slash' | 'dot'`, `size`. `@navigate(item, index, event)`.
|
|
816
|
+
|
|
817
|
+
### Skeleton
|
|
818
|
+
Grey placeholders in the shape of what is loading; the real content rises into place when it is ready.
|
|
819
|
+
|
|
820
|
+
```vue
|
|
821
|
+
<Skeleton look="list" :rows="4" :loading="!riders" label="Riders">
|
|
822
|
+
<RiderList v-if="riders" :riders="riders" />
|
|
823
|
+
</Skeleton>
|
|
824
|
+
```
|
|
825
|
+
- The default slot is the real content. `loading` (default true): false reveals it, true brings the placeholders back.
|
|
826
|
+
- `look: 'list' | 'card' | 'text' | 'table' | 'custom'`, `rows`, `avatar`, `media`, `lines`, `cols`, `shimmer`.
|
|
827
|
+
|
|
828
|
+
### Alert
|
|
829
|
+
A message box in the page: info, success, warning or error, with actions and a close button.
|
|
830
|
+
|
|
831
|
+
```vue
|
|
832
|
+
<Alert v-model:open="showError" tone="bad" title="Couldn't save the booking" dismissible
|
|
833
|
+
:actions="[{ label: 'Try again', primary: true, run: () => saveBooking() }]">
|
|
834
|
+
The bike is already booked on those days.
|
|
835
|
+
</Alert>
|
|
836
|
+
```
|
|
837
|
+
- The default slot is the message. `tone`, `title`, `icon` and `actions` change in place (colours cross-fade, the text slides).
|
|
838
|
+
- `v-model:open`: false folds it away, true grows it back. Closing from inside (✕ or Esc) sets it to false and calls `@close`.
|
|
839
|
+
- `look: 'soft' | 'outline' | 'solid' | 'banner'`, `dismissible`, `icon` (false for none).
|
|
840
|
+
|
|
841
|
+
## Action buttons
|
|
842
|
+
|
|
843
|
+
### LikeButton
|
|
844
|
+
|
|
845
|
+
A like, star or bookmark button that pops (or fills) when it turns on, with a count that rolls up and down.
|
|
846
|
+
|
|
847
|
+
```vue
|
|
848
|
+
<script setup>
|
|
849
|
+
import { ref } from 'vue';
|
|
850
|
+
const props = defineProps({ bike: Object });
|
|
851
|
+
const saved = ref(props.bike.saved);
|
|
852
|
+
const saves = ref(props.bike.saves);
|
|
853
|
+
// return the request: if it fails, the button (and saved / saves) goes back and shakes
|
|
854
|
+
const save = (on) => fetch(`/api/bikes/${props.bike.id}/save`, { method: on ? 'PUT' : 'DELETE' })
|
|
855
|
+
.then((r) => { if (!r.ok) throw new Error(String(r.status)); });
|
|
856
|
+
</script>
|
|
857
|
+
|
|
858
|
+
<template>
|
|
859
|
+
<LikeButton kind="bookmark" v-model="saved" v-model:count="saves" @change="save" />
|
|
860
|
+
</template>
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
- `kind`: `'heart'` (default), `'star'` or `'bookmark'`.
|
|
864
|
+
- `v-model`: on or off (or `default-value` without v-model). `v-model:count` keeps your number in step.
|
|
865
|
+
- `count`: a number shows a rolling count; a new value (for example from the server) rolls to it.
|
|
866
|
+
- `label` / `on-label`, `icon-only`, `size` (`'sm'` `''` `'lg'`), `tone`, `format(n)`, `words`.
|
|
867
|
+
- `@change(pressed, count, handle)`: return a promise; if it fails, the button goes back with a shake (v-model too).
|
|
868
|
+
- Template ref → `{ pressed, count, set(on), toggle(), setCount(n), el }`.
|
|
869
|
+
|
|
870
|
+
### BellSwitch
|
|
871
|
+
|
|
872
|
+
A notification switch: turning it on rings the bell, turning it off draws a slash across it. `BellButton` is the same component.
|
|
873
|
+
|
|
874
|
+
```vue
|
|
875
|
+
<script setup>
|
|
876
|
+
import { ref, onMounted } from 'vue';
|
|
877
|
+
const alerts = ref(true);
|
|
878
|
+
const bell = ref(null);
|
|
879
|
+
onMounted(() => onNewBooking(() => bell.value?.ring()));
|
|
880
|
+
</script>
|
|
881
|
+
|
|
882
|
+
<template>
|
|
883
|
+
<BellSwitch ref="bell" v-model="alerts" label="Booking alerts" @change="(on) => saveSetting('booking-alerts', on)" />
|
|
884
|
+
</template>
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
- `v-model`: on or off (or `default-value`).
|
|
888
|
+
- `label` (text, or the `#label` slot; text with `icon-only`), `icon-only`, `tone`, `words: { label, on, off }`.
|
|
889
|
+
- `@change(on, handle)`: return a promise; if it fails, it switches back with a shake (v-model too).
|
|
890
|
+
- Template ref → `{ on, set(on), toggle(), ring(), el }`: `ring()` when something new comes in.
|
|
891
|
+
|
|
892
|
+
### PayButton
|
|
893
|
+
|
|
894
|
+
A checkout button: a card swipes through, "Processing", then "Paid" with a tick, or red "Try again" when the payment fails.
|
|
895
|
+
|
|
896
|
+
```vue
|
|
897
|
+
<script setup>
|
|
898
|
+
const checkout = async () => {
|
|
899
|
+
const r = await fetch('/api/checkout', { method: 'POST', body: JSON.stringify(cart.value) });
|
|
900
|
+
if (!r.ok) throw new Error('Card declined');
|
|
901
|
+
return r.json(); // resolves = paid
|
|
902
|
+
};
|
|
903
|
+
</script>
|
|
904
|
+
|
|
905
|
+
<template>
|
|
906
|
+
<PayButton block @pay="checkout" @done="(receipt) => router.push(`/bookings/${receipt.id}`)" @fail="(e) => (cardError = String(e))">
|
|
907
|
+
Pay <b>฿{{ total }}</b>
|
|
908
|
+
</PayButton>
|
|
909
|
+
</template>
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
- `@pay(handle)`: resolve = paid; throw, reject or return `false` = failed.
|
|
913
|
+
- `@done(result, handle)`, `@fail(error, handle)`.
|
|
914
|
+
- The label: the default slot, the `#label` slot or the `label` text. `variant` (`'dark'` default, `'primary'`), `size` (`'lg'` default), `block`, `icon` (`'card'`, `''` for none).
|
|
915
|
+
- `card` (the swipe, default on), `min-busy` (1.4 s), `back` (3 s; `0` stays "Paid"), `words`.
|
|
916
|
+
- Template ref → `{ state, pay(), reset(), el }`.
|
|
917
|
+
|
|
918
|
+
### SpeedDial
|
|
919
|
+
|
|
920
|
+
A round + button that fans out a few labelled quick actions.
|
|
921
|
+
|
|
922
|
+
```vue
|
|
923
|
+
<template>
|
|
924
|
+
<SpeedDial
|
|
925
|
+
fixed
|
|
926
|
+
:actions="[
|
|
927
|
+
{ id: 'booking', label: 'New booking', icon: 'calendar' },
|
|
928
|
+
{ id: 'bike', label: 'Add a bike', icon: 'plus' },
|
|
929
|
+
{ id: 'note', label: 'Write a note', icon: 'edit' },
|
|
930
|
+
]"
|
|
931
|
+
@select="(a) => router.push(`/new/${a.id}`)"
|
|
932
|
+
/>
|
|
933
|
+
</template>
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
- `actions`: `{ id, label, icon }` (icon name or `<svg>` string); a new list is swapped in place.
|
|
937
|
+
- `direction` (`'up'` / `'down'`), `side` (`'right'` / `'left'`), `labels`, `fixed`, `icon`, `words: { label, actions }`.
|
|
938
|
+
- `@select(action, handle)`, `@toggle(open, handle)`.
|
|
939
|
+
- Template ref → `{ isOpen, open(), close(), toggle(), setActions(list), el }`.
|
|
940
|
+
|
|
941
|
+
### Typing
|
|
942
|
+
|
|
943
|
+
Three bouncing dots in a chat bubble, with "Pim is typing…".
|
|
944
|
+
|
|
945
|
+
```vue
|
|
946
|
+
<template>
|
|
947
|
+
<Typing :visible="typingNames.length > 0" :names="typingNames" />
|
|
948
|
+
</template>
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
- `visible`: shows or hides it in place (the row opens and closes, `collapse`).
|
|
952
|
+
- `names`: `'Pim'` or `['Pim', 'Mali']`; changes in place.
|
|
953
|
+
- `text`, `bubble`, `size` (`'sm'` `''` `'lg'`), `tone` (`'muted'` `'accent'` `'ink'`), `collapse`, `words: { anon, one, two, many }`.
|
|
954
|
+
- Template ref → `{ visible, text, show(), hide(), set(names), el }`.
|
|
955
|
+
|
|
956
|
+
## Charts
|
|
957
|
+
|
|
958
|
+
### LineChart
|
|
959
|
+
A line or area chart of one or more series over the same labels, with a crosshair, a tooltip and legend keys.
|
|
960
|
+
```vue
|
|
961
|
+
<LineChart
|
|
962
|
+
label="Rental income by month"
|
|
963
|
+
:labels="['Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']"
|
|
964
|
+
:series="[{ name: 'Walk-in', data: walkIn }, { name: 'Booked online', data: online, tone: 'teal' }]"
|
|
965
|
+
:height="240"
|
|
966
|
+
:format="(v) => `฿${v.toLocaleString()}`"
|
|
967
|
+
/>
|
|
968
|
+
```
|
|
969
|
+
- `labels`, `series: [{ name, data, tone, hidden }]` (`null` in data leaves a gap): new ones morph in place
|
|
970
|
+
- `area`, `smooth`, `stacked`, `height`, `y-min`, `y-max`, `ticks`, `grid`, `dots` (`'hover'` / `true` / `false`), `tooltip`, `legend`
|
|
971
|
+
- `format(v)`, `axis-format(v)`, `label`, `words`, `@point(index, info, chart)`
|
|
972
|
+
- ref: `labels`, `series`, `update()`, `highlight(i)`, `toggle(name, on?)`, `el`
|
|
973
|
+
|
|
974
|
+
### Donut
|
|
975
|
+
Parts of a whole as a ring of slices, with the total in the middle.
|
|
976
|
+
```vue
|
|
977
|
+
<Donut
|
|
978
|
+
label="Bikes out today"
|
|
979
|
+
:data="[{ label: 'Scooters', value: 48 }, { label: 'E-bikes', value: 20, tone: 'teal' }, { label: 'City bikes', value: 12 }]"
|
|
980
|
+
centre="Bikes"
|
|
981
|
+
@select="(i, item) => (filter = item ? item.label : null)"
|
|
982
|
+
/>
|
|
983
|
+
```
|
|
984
|
+
- `data: [{ label, value, tone }]`: new data morphs the slices (matched by label)
|
|
985
|
+
- `size`, `thickness`, `gap`, `legend` (`'right'` / `'bottom'` / `false`), `sort`, `format(v)`, `centre`, `label`, `words`
|
|
986
|
+
- `@select(index, item, donut)` (index -1 when cleared); ref: `data`, `total`, `selected`, `set(data)`, `select(index | label | -1)`, `el`
|
|
987
|
+
|
|
988
|
+
### Gauge
|
|
989
|
+
One number on a half-circle dial, like today's bookings against a daily goal.
|
|
990
|
+
```vue
|
|
991
|
+
<Gauge
|
|
992
|
+
:value="todaySales" :max="12000" :goal="10000" label="Today's rentals"
|
|
993
|
+
:format="(v) => `฿${v.toLocaleString()}`"
|
|
994
|
+
:zones="[{ to: 4000, tone: 'bad' }, { to: 8000, tone: 'warn' }, { to: 12000, tone: 'good' }]"
|
|
995
|
+
/>
|
|
996
|
+
```
|
|
997
|
+
- `value` (a plain prop, not v-model: the gauge only shows it): a new value swings the needle from where it is now
|
|
998
|
+
- `min`, `max`, `goal`, `zones: [{ to, tone, label }]`, `tone`, `format(v)`, `label`, `size`, `needle`, `ends`, `words`
|
|
999
|
+
- ref: `value`, `set(v)`, `el`
|
|
1000
|
+
|
|
1001
|
+
### Leaderboard
|
|
1002
|
+
A ranked list with a bar under each row; when the numbers change the rows glide to their new ranks.
|
|
1003
|
+
```vue
|
|
1004
|
+
<Leaderboard
|
|
1005
|
+
label="Tasks done this week" :max="5"
|
|
1006
|
+
:items="team.map((p) => ({ id: p.id, label: p.name, sub: p.role, value: p.done, avatar: { name: p.name } }))"
|
|
1007
|
+
/>
|
|
1008
|
+
```
|
|
1009
|
+
- `items: [{ id, label, value, sub, avatar }]`: new items glide, bars stretch and numbers count
|
|
1010
|
+
- `max` (rows shown, 0 = all), `format(v)`, `bars`, `medals`, `label`, `words`
|
|
1011
|
+
- ref: `items`, `set(items)`, `el`
|
|
1012
|
+
|
|
1013
|
+
### Heatmap
|
|
1014
|
+
A calendar of small squares, one per day, darker on busier days.
|
|
1015
|
+
```vue
|
|
1016
|
+
<script setup>
|
|
1017
|
+
const day = ref(null) // 'YYYY-MM-DD'
|
|
1018
|
+
</script>
|
|
1019
|
+
<template>
|
|
1020
|
+
<div style="padding: 4px">
|
|
1021
|
+
<Heatmap v-model="day" :data="bookings.map((b) => ({ date: b.day, value: b.count }))" :weeks="26"
|
|
1022
|
+
:format="(v) => `${v} bookings`" />
|
|
1023
|
+
</div>
|
|
1024
|
+
</template>
|
|
1025
|
+
```
|
|
1026
|
+
- `data: [{ date, value }]` (`'YYYY-MM-DD'` or `Date`): new data re-shades every square in a ripple. (A function `(date) => number` is read once at the start.)
|
|
1027
|
+
- `v-model`: the picked day; a new value picks it in place, a click sets it to `'YYYY-MM-DD'` (`default-value` only at the start)
|
|
1028
|
+
- `@select(day, hm)` with `day = { date, value, level }`; `end` (default today), `weeks`, `week-start`, `levels`, `tone`, `format(v)`, `locale`, `words`
|
|
1029
|
+
- The scroll area reaches 4px past its box (room for the focus ring): give its container a little padding
|
|
1030
|
+
- ref: `value`, `set(data)`, `select(date | null)`, `el`
|
|
1031
|
+
|
|
1032
|
+
## Text & scroll motion
|
|
1033
|
+
|
|
1034
|
+
### TextReveal
|
|
1035
|
+
|
|
1036
|
+
A headline whose letters roll up out of a mask, one after another (`title()`); a new text plays again in place.
|
|
1037
|
+
|
|
1038
|
+
```vue
|
|
1039
|
+
<template>
|
|
1040
|
+
<TextReveal as="h1" :stagger="0.022" :tilt="6">Bikes for every trip, {{ city }}</TextReveal>
|
|
1041
|
+
</template>
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
- The default slot is the text (or the `text` prop). A new text plays the reveal again (`retitle()`), on the same element.
|
|
1045
|
+
- `delay`, `stagger` (0.022), `tilt` (6°), `duration` (0.85).
|
|
1046
|
+
- `as` — the element (`'span'` by default: use `'h1'`, `'h2'`…).
|
|
1047
|
+
|
|
1048
|
+
### Typewriter
|
|
1049
|
+
|
|
1050
|
+
Text typed letter by letter behind a caret; several phrases are deleted and typed in turn. Screen readers hear the whole list once.
|
|
1051
|
+
|
|
1052
|
+
```vue
|
|
1053
|
+
<template>
|
|
1054
|
+
<h2>We rent <Typewriter :phrases="['scooters', 'city bikes', 'e-bikes']" caret="bar" /></h2>
|
|
1055
|
+
<Typewriter as="p" :loop="false" :speed="0.03">Your bike is booked for {{ day }} at 9 am.</Typewriter>
|
|
1056
|
+
</template>
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
- `phrases` — the list (or one phrase as the default slot). A new list (or slot text) deletes the current phrase and types the new one.
|
|
1060
|
+
- `speed` (0.06 s a letter), `jitter`, `erase-speed`, `erase` (`'backspace'` | `'select'`), `hold`, `gap`, `delay`, `loop`.
|
|
1061
|
+
- `caret` (`'bar'` | `'block'` | `'underscore'` | `false`), `locale`, `label`, `when-visible`, `paused`.
|
|
1062
|
+
- `@phrase(i, text)`. Template ref → `{ phrase, play(), pause(), restart(), set(list), el }`.
|
|
1063
|
+
|
|
1064
|
+
### Rotator
|
|
1065
|
+
|
|
1066
|
+
One word in a sentence keeps changing; its slot glides to the new width so the sentence moves over smoothly.
|
|
1067
|
+
|
|
1068
|
+
```vue
|
|
1069
|
+
<template>
|
|
1070
|
+
<h2>Rent a <Rotator :words="['scooter', 'city bike', 'e-bike']" effect="roll" pill /> by the hour</h2>
|
|
1071
|
+
</template>
|
|
1072
|
+
```
|
|
1073
|
+
|
|
1074
|
+
- `words` — the list. A new list starts again from the first word.
|
|
1075
|
+
- `effect` (`'roll'` | `'drop'` | `'slide'` | `'blur'` | `'letters'`), `every` (2.2 s), `duration`, `ease`, `stagger`.
|
|
1076
|
+
- `pill` — a soft highlight box behind the word. `index` — show this word; `:auto="false"` to drive it yourself; `paused`.
|
|
1077
|
+
- `@change(i, word)`. Template ref → `{ index, next(), go(i), play(), pause(), set(words), el }`.
|
|
1078
|
+
|
|
1079
|
+
### Shine
|
|
1080
|
+
|
|
1081
|
+
A slanted band of light sweeps across the letters, like light on a shiny sign. The text stays real text.
|
|
1082
|
+
|
|
1083
|
+
```vue
|
|
1084
|
+
<template>
|
|
1085
|
+
<Shine as="h2" look="gradient" trigger="loop">Summer rides, 20% off</Shine>
|
|
1086
|
+
<Shine look="ink" trigger="hover" tabindex="0">Loading your bookings…</Shine>
|
|
1087
|
+
</template>
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
- `look` (`'gradient'` | `'ink'` | `'color'`), `trigger` (`'loop'` | `'view'` | `'hover'`).
|
|
1091
|
+
- `duration` (1.4), `repeat-delay` (1.8), `delay`, `ease`, `angle` (110°), `width` (12), `color`, `as` (`'span'`).
|
|
1092
|
+
- CSS only, no Vue needed: `<span class="shine shine--ink shine--loop">…</span>`.
|
|
1093
|
+
|
|
1094
|
+
### Highlighter
|
|
1095
|
+
|
|
1096
|
+
A marker stroke draws behind the words in `<mark>`, one after another, when the paragraph scrolls into view.
|
|
1097
|
+
|
|
1098
|
+
```vue
|
|
1099
|
+
<template>
|
|
1100
|
+
<Highlighter tone="amber">
|
|
1101
|
+
Every rental comes with <mark>a free helmet</mark> and <mark>a lock</mark>.
|
|
1102
|
+
</Highlighter>
|
|
1103
|
+
</template>
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
- `look` (`'marker'` | `'underline'`), `tone` (`accent amber green rose sky violet`) or `color`.
|
|
1107
|
+
- `trigger` (`'view'` | `'now'` | `'manual'`), `threshold` (0.6), `once`, `duration`, `stagger`, `delay`, `ease`, `selector`, `as` (`'p'`).
|
|
1108
|
+
- `active` — with `trigger="manual"`: `true` draws the strokes, `false` clears them. A new slot text is marked again.
|
|
1109
|
+
|
|
1110
|
+
### ScrollReveal
|
|
1111
|
+
|
|
1112
|
+
Blocks (or their words) wait out of sight and arrive as they scroll into view: fade, rise, slide, zoom or blur.
|
|
1113
|
+
|
|
1114
|
+
```vue
|
|
1115
|
+
<template>
|
|
1116
|
+
<ScrollReveal effect="rise"><BookingSummary :booking="b" /></ScrollReveal>
|
|
1117
|
+
|
|
1118
|
+
<ScrollReveal items=":scope > article" effect="slide" :x="-40">
|
|
1119
|
+
<article v-for="s in steps" :key="s.id"><h4>{{ s.title }}</h4><p>{{ s.text }}</p></article>
|
|
1120
|
+
</ScrollReveal>
|
|
1121
|
+
|
|
1122
|
+
<ScrollReveal as="p" words effect="blur">Pick a bike, choose your days and ride.</ScrollReveal>
|
|
1123
|
+
</template>
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
- Without `items` the element itself is revealed (and hidden in the server HTML until then, no flash).
|
|
1127
|
+
`items` — a selector inside: each match is revealed, top to bottom; items added later are revealed too.
|
|
1128
|
+
- `effect`, `words`, `y`, `x`, `scale`, `blur`, `duration`, `stagger`, `word-stagger`, `delay`, `ease`.
|
|
1129
|
+
With `words`, a new slot text is joined back before Vue draws it, then split and revealed again (links inside keep their `@click`).
|
|
1130
|
+
- `once` (false = play every time), `threshold` (0.2), `root-margin`, `root` (the scrolling box: element, template ref or selector).
|
|
1131
|
+
- `@enter(el)`, `@leave(el)`.
|
|
1132
|
+
|
|
1133
|
+
### BlurIn
|
|
1134
|
+
|
|
1135
|
+
The words of a paragraph come into focus one after another, right away (for a hero already on screen).
|
|
1136
|
+
|
|
1137
|
+
```vue
|
|
1138
|
+
<template>
|
|
1139
|
+
<BlurIn as="p" :blur="12" :stagger="0.05">Slow mornings, fresh coffee and a bike waiting at the door.</BlurIn>
|
|
1140
|
+
</template>
|
|
1141
|
+
```
|
|
1142
|
+
|
|
1143
|
+
- `blur` (10 px), `y` (25), `duration` (0.7), `stagger` (0.04), `delay`, `ease`, `as` (`'p'`). A new text plays again.
|
|
1144
|
+
|
|
1145
|
+
### ScrollProgress
|
|
1146
|
+
|
|
1147
|
+
A thin line that fills as the page (or a scrolling box) is read.
|
|
1148
|
+
|
|
1149
|
+
```vue
|
|
1150
|
+
<script setup>
|
|
1151
|
+
import { ref } from 'vue';
|
|
1152
|
+
const panel = ref(null);
|
|
1153
|
+
const read = ref(0);
|
|
1154
|
+
</script>
|
|
1155
|
+
|
|
1156
|
+
<template>
|
|
1157
|
+
<ScrollProgress style="position: sticky; top: 0" />
|
|
1158
|
+
<div ref="panel" class="panel">…</div>
|
|
1159
|
+
<ScrollProgress :root="panel" @change="(p) => (read = Math.round(p * 100))" />
|
|
1160
|
+
</template>
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
- `root` — the scrolling box (element, template ref or selector; default the page). `@change(progress)` with 0…1.
|
|
1164
|
+
- Colour and height: `--scroll-progress-c`, `--scroll-progress-h`.
|
|
1165
|
+
|
|
1166
|
+
### Odometer
|
|
1167
|
+
|
|
1168
|
+
A number that rolls digit by digit like a car's meter; only the digits that change spin.
|
|
1169
|
+
|
|
1170
|
+
```vue
|
|
1171
|
+
<template>
|
|
1172
|
+
<Odometer :value="yearly ? 1990 : 2490" :format="{ style: 'currency', currency: 'THB', minimumFractionDigits: 0, maximumFractionDigits: 0 }" locale="th-TH" />
|
|
1173
|
+
</template>
|
|
1174
|
+
```
|
|
1175
|
+
|
|
1176
|
+
- `value` — a number (or a ready-made string). A new value rolls in place.
|
|
1177
|
+
- `format` (Intl options or `(v) => text`), `locale`, `duration` (0.9), `stagger` (0.06), `direction` (`'auto'` | `'up'` | `'down'`), `ease`.
|
|
1178
|
+
- `from` — roll in from this value on mount.
|
|
1179
|
+
|
|
1180
|
+
### CountUp
|
|
1181
|
+
|
|
1182
|
+
A number that counts up on mount, and from the number on screen to the new one when it changes.
|
|
1183
|
+
|
|
1184
|
+
```vue
|
|
1185
|
+
<template>
|
|
1186
|
+
<div class="kpi"><small>Revenue today</small><b><CountUp :value="stats.revenue" prefix="฿" tick /></b></div>
|
|
1187
|
+
<CountUp :value="4.8" :decimals="1" suffix=" / 5" />
|
|
1188
|
+
</template>
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
- `value`, `from` (0), `duration` (1.2), `delay`.
|
|
1192
|
+
- `prefix`, `suffix`, `decimals`, `locale` ('en-US'), or your own `format(v)`.
|
|
1193
|
+
- `tick` — tint the number green going up, red going down.
|
|
1194
|
+
|
|
1195
|
+
## Motion wrappers
|
|
1196
|
+
|
|
1197
|
+
### Rise
|
|
1198
|
+
|
|
1199
|
+
Children that arrive one after another: they fade in and float up (or slide, or drop in like dealt cards).
|
|
1200
|
+
|
|
1201
|
+
```vue
|
|
1202
|
+
<template>
|
|
1203
|
+
<Rise class="grid" :stagger="0.05">
|
|
1204
|
+
<BikeCard v-for="bike in bikes" :key="bike.id" :bike="bike" />
|
|
1205
|
+
</Rise>
|
|
1206
|
+
|
|
1207
|
+
<Rise kind="slide" :x="-24" as="ul" class="list">
|
|
1208
|
+
<li v-for="b in bookings" :key="b.id">{{ b.rider }} · {{ b.bike }}</li>
|
|
1209
|
+
</Rise>
|
|
1210
|
+
</template>
|
|
1211
|
+
```
|
|
1212
|
+
|
|
1213
|
+
- `kind`: `rise` (default) · `slide` · `deal` · `reveal` (a small fade-down of the element itself, e.g. an accordion body).
|
|
1214
|
+
- `y`, `x`, `stagger`, `delay`, `duration`, `tilt` (deal) — the same options as `rise()` / `slide()` / `deal()`.
|
|
1215
|
+
- Children added later (a new booking in the list) arrive the same way; `:animate-new="false"` turns that off.
|
|
1216
|
+
- `items` — a selector inside to animate instead of the direct children; `as` — the element (`div`).
|
|
1217
|
+
|
|
1218
|
+
### Magnetic
|
|
1219
|
+
|
|
1220
|
+
The element leans toward the pointer and springs back when it leaves (mouse and trackpad only).
|
|
1221
|
+
|
|
1222
|
+
```vue
|
|
1223
|
+
<template>
|
|
1224
|
+
<Magnetic :strength="0.3">
|
|
1225
|
+
<Button variant="primary" icon-right="arrowR">Book a bike</Button>
|
|
1226
|
+
</Magnetic>
|
|
1227
|
+
</template>
|
|
1228
|
+
```
|
|
1229
|
+
|
|
1230
|
+
- `strength` (0.2) and `strength-y` (0.28): how far it follows the pointer; `magnet` multiplies it for this element.
|
|
1231
|
+
- It renders an inline-block `<span class="magnetic">` around your content; `as="a"` makes the element itself magnetic.
|
|
1232
|
+
|
|
1233
|
+
### Lift
|
|
1234
|
+
|
|
1235
|
+
The element rises a few pixels while the pointer is over it (mouse and trackpad only).
|
|
1236
|
+
|
|
1237
|
+
```vue
|
|
1238
|
+
<template>
|
|
1239
|
+
<Lift as="article" :y="-6" class="card">
|
|
1240
|
+
<h3>Old town tour</h3>
|
|
1241
|
+
<p>2 hours · 3 stops</p>
|
|
1242
|
+
</Lift>
|
|
1243
|
+
</template>
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
- `y` — pixels it moves (-4); `as` — the element (`div`).
|
|
1247
|
+
|
|
1248
|
+
### Tilt
|
|
1249
|
+
|
|
1250
|
+
A card that leans toward the pointer in 3D, with a soft glare; children with `data-depth` float above it.
|
|
1251
|
+
|
|
1252
|
+
```vue
|
|
1253
|
+
<template>
|
|
1254
|
+
<Tilt :max="10" glare as="article" class="card">
|
|
1255
|
+
<img data-depth="40" :src="bike.photo" :alt="bike.name" />
|
|
1256
|
+
<h3 data-depth="20">{{ bike.name }}</h3>
|
|
1257
|
+
</Tilt>
|
|
1258
|
+
</template>
|
|
1259
|
+
```
|
|
1260
|
+
|
|
1261
|
+
- `max` (12°), `scale` (1.03), `perspective` (900), `glare` (true), `parallax` (0.25), `follow` (0.35 s), `spring` (1 s).
|
|
1262
|
+
- Mouse and trackpad only; with reduced motion it stays still.
|
|
1263
|
+
|
|
1264
|
+
### Spotlight
|
|
1265
|
+
|
|
1266
|
+
A soft light follows the pointer across a group of cards and lights up their edges.
|
|
1267
|
+
|
|
1268
|
+
```vue
|
|
1269
|
+
<template>
|
|
1270
|
+
<Spotlight class="plans" :size="300">
|
|
1271
|
+
<div v-for="plan in plans" :key="plan.id" class="card">
|
|
1272
|
+
<h3>{{ plan.name }}</h3>
|
|
1273
|
+
<p>{{ plan.price }} ฿ / day</p>
|
|
1274
|
+
</div>
|
|
1275
|
+
</Spotlight>
|
|
1276
|
+
</template>
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1279
|
+
- `size` (240 px), `follow` (0.2 s), `border` (true), `fill` (true), `focus` (true: a focused card pulls the light onto itself).
|
|
1280
|
+
- `items` — a selector (or elements) for the cards; by default the children.
|
|
1281
|
+
|
|
1282
|
+
### Marquee
|
|
1283
|
+
|
|
1284
|
+
An endless sideways strip of logos or items; hover or focus slows it to a stop.
|
|
1285
|
+
|
|
1286
|
+
```vue
|
|
1287
|
+
<script setup>
|
|
1288
|
+
import { ref } from 'vue';
|
|
1289
|
+
const pause = ref(null);
|
|
1290
|
+
const strip = ref(null); // strip.value.pause(), .play(), .toggle(), .paused, .refresh(), .el
|
|
1291
|
+
</script>
|
|
1292
|
+
|
|
1293
|
+
<template>
|
|
1294
|
+
<Marquee ref="strip" aria-label="Shops that ride with us" :speed="50" :gap="48" :button="pause">
|
|
1295
|
+
<img v-for="p in partners" :key="p.id" :src="p.logo" :alt="p.name" height="28" />
|
|
1296
|
+
</Marquee>
|
|
1297
|
+
<button ref="pause" class="btn btn--sm">⏸</button>
|
|
1298
|
+
</template>
|
|
1299
|
+
```
|
|
1300
|
+
|
|
1301
|
+
- Each child becomes one item (`<li>` in a `<ul>`; `list-as` to change). New items are measured again.
|
|
1302
|
+
- `speed` (50 px/s), `direction`, `gap`, `fade` change in place; `pause-on-hover` (true), `paused`.
|
|
1303
|
+
- `button` — a pause / play button (element, template ref or selector); `words` — its labels.
|
|
1304
|
+
- Template ref → `{ play(), pause(), toggle(), paused, refresh(), el }`.
|
|
1305
|
+
|
|
1306
|
+
## Interactive effects
|
|
1307
|
+
|
|
1308
|
+
### Indicator
|
|
1309
|
+
|
|
1310
|
+
A box with a stretchy pill (or an underline) that slides to the active item when `active` changes.
|
|
1311
|
+
|
|
1312
|
+
```vue
|
|
1313
|
+
<script setup>
|
|
1314
|
+
import { ref } from 'vue';
|
|
1315
|
+
const page = ref('bikes');
|
|
1316
|
+
</script>
|
|
1317
|
+
|
|
1318
|
+
<template>
|
|
1319
|
+
<Indicator as="nav" :active="page" :radius="99" class="menu" style="display: flex; gap: 4px">
|
|
1320
|
+
<button v-for="p in ['today', 'bikes', 'returns']" :key="p" type="button"
|
|
1321
|
+
:aria-current="page === p ? 'page' : undefined" @click="page = p">{{ p }}</button>
|
|
1322
|
+
</Indicator>
|
|
1323
|
+
</template>
|
|
1324
|
+
```
|
|
1325
|
+
|
|
1326
|
+
- The active item is the child with `aria-current`, `aria-selected="true"`, `aria-pressed="true"` or `.is-active` (`selector` to change).
|
|
1327
|
+
- `radius` (13; 99 = round ends), `line` (an underline), `lead` / `trail` / `cross` (seconds per edge).
|
|
1328
|
+
- `pill-class` / `pill-style` style the pill (with `pill-class` the accent background is left off).
|
|
1329
|
+
|
|
1330
|
+
### useIndicator
|
|
1331
|
+
|
|
1332
|
+
The same pill on a menu you draw yourself: put the returned template ref on a `<span>` inside it.
|
|
1333
|
+
|
|
1334
|
+
```vue
|
|
1335
|
+
<script setup>
|
|
1336
|
+
import { ref } from 'vue';
|
|
1337
|
+
import { useIndicator } from '@gecko-ui-kit/vue';
|
|
1338
|
+
const view = ref('week');
|
|
1339
|
+
const pill = useIndicator(view, { radius: 99 });
|
|
1340
|
+
</script>
|
|
1341
|
+
|
|
1342
|
+
<template>
|
|
1343
|
+
<nav class="menu">
|
|
1344
|
+
<span ref="pill" class="menu__pill" />
|
|
1345
|
+
<button v-for="v in ['day', 'week', 'month']" :key="v" :aria-pressed="String(view === v)" @click="view = v">{{ v }}</button>
|
|
1346
|
+
</nav>
|
|
1347
|
+
</template>
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
- `useIndicator(active, options)` — `active` is a ref or getter; options as for `Indicator` (an object, ref or getter).
|
|
1351
|
+
|
|
1352
|
+
### PageSwap
|
|
1353
|
+
|
|
1354
|
+
A page transition: when `swap-key` changes, the old page steps back and fades, then the new one slides in.
|
|
1355
|
+
|
|
1356
|
+
```vue
|
|
1357
|
+
<template>
|
|
1358
|
+
<PageSwap :swap-key="route.path" :dir="forward ? 1 : -1" @swap="(view) => rise(view.querySelectorAll('.card'))">
|
|
1359
|
+
<RouterView />
|
|
1360
|
+
</PageSwap>
|
|
1361
|
+
</template>
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
- `dir` — 1 forward (new page from the right), -1 back.
|
|
1365
|
+
- `leave` — blocks that fade and drop on the way out (`.card, .kpi, .lane, [data-swap]`); `head` — header parts that lift away.
|
|
1366
|
+
- `timing` — `{ out, in, shift, enter }` for this swap only. `@swap(view)` runs once the new page is in.
|
|
1367
|
+
|
|
1368
|
+
### useFeedback · useFlash · useTick
|
|
1369
|
+
|
|
1370
|
+
Small reactions: pop a pressed button, shake a form, bounce a total that changed, tint a number up or down.
|
|
1371
|
+
|
|
1372
|
+
```vue
|
|
1373
|
+
<script setup>
|
|
1374
|
+
import { ref, computed } from 'vue';
|
|
1375
|
+
import { useFeedback, useFlash, useTick } from '@gecko-ui-kit/vue';
|
|
1376
|
+
const days = ref(2);
|
|
1377
|
+
const total = computed(() => days.value * 320);
|
|
1378
|
+
const { ref: form, shake, pop } = useFeedback();
|
|
1379
|
+
const totalEl = useFlash(total);
|
|
1380
|
+
const daysEl = useTick(days);
|
|
1381
|
+
</script>
|
|
1382
|
+
|
|
1383
|
+
<template>
|
|
1384
|
+
<form ref="form" @submit.prevent="days > 14 && shake()">
|
|
1385
|
+
<button type="button" @click="(e) => { pop(e); days++ }">+1 day</button>
|
|
1386
|
+
<b ref="daysEl">{{ days }}</b> days · <b ref="totalEl">฿{{ total }}</b>
|
|
1387
|
+
</form>
|
|
1388
|
+
</template>
|
|
1389
|
+
```
|
|
1390
|
+
|
|
1391
|
+
- `useFeedback()` → `{ ref, pop, shake, wiggle, flash, tick(up) }`; each runs on `ref`, or on what you pass (an element, a template ref or an event).
|
|
1392
|
+
- `useFlash(value)` / `useTick(value)` — a ref or getter; they return the template ref to put on the element.
|
|
1393
|
+
|
|
1394
|
+
### ConfettiButton · useConfetti · confetti
|
|
1395
|
+
|
|
1396
|
+
A burst of paper confetti from a button (or from any element or point).
|
|
1397
|
+
|
|
1398
|
+
```vue
|
|
1399
|
+
<script setup>
|
|
1400
|
+
import { useConfetti } from '@gecko-ui-kit/vue';
|
|
1401
|
+
const fire = useConfetti({ count: 150 });
|
|
1402
|
+
</script>
|
|
1403
|
+
|
|
1404
|
+
<template>
|
|
1405
|
+
<ConfettiButton variant="primary" icon="sparkle" :count="150" @click="pay">Pay ฿640</ConfettiButton>
|
|
1406
|
+
<Button @click="(e) => fire(e)">Celebrate</Button>
|
|
1407
|
+
</template>
|
|
1408
|
+
```
|
|
1409
|
+
|
|
1410
|
+
- `ConfettiButton` is a `Button` (same props); call `event.preventDefault()` in `@click` to skip the burst; `@done` when it has landed.
|
|
1411
|
+
- Options: `count`, `spread`, `angle`, `velocity`, `colors`, `shapes`, `gravity`, `duration`, `z-index`, `reduced`.
|
|
1412
|
+
- `useConfetti(options)` → `fire(origin?, options?)`; bursts still flying stop on unmount. `confetti(origin, options)` is the plain function.
|
|
1413
|
+
|
|
1414
|
+
### Sortable
|
|
1415
|
+
|
|
1416
|
+
A list you reorder by dragging (mouse at once, touch after a long press); the card lifts, the others slide aside, it lands with a squash.
|
|
1417
|
+
|
|
1418
|
+
```vue
|
|
1419
|
+
<script setup>
|
|
1420
|
+
import { ref } from 'vue';
|
|
1421
|
+
const lanes = ref({ todo: [{ id: 't1', title: 'Check brakes' }], done: [] });
|
|
1422
|
+
</script>
|
|
1423
|
+
|
|
1424
|
+
<template>
|
|
1425
|
+
<Sortable v-for="(tasks, lane) in lanes" :key="lane" v-model="lanes[lane]" group="board" :get-key="(t) => t.id" class="lane">
|
|
1426
|
+
<h4>{{ lane }}</h4>
|
|
1427
|
+
<template #item="{ item }"><TaskCard :task="item" /></template>
|
|
1428
|
+
</Sortable>
|
|
1429
|
+
</template>
|
|
1430
|
+
```
|
|
1431
|
+
|
|
1432
|
+
- `v-model` is the list (or `default-value` to let it keep its own order); `@reorder(next, { item, from, to, fromList, toList })`.
|
|
1433
|
+
- `#item="{ item, index }"` draws one item; the default slot is drawn before the items, inside the drop zone (a lane title).
|
|
1434
|
+
- `group` — lists with the same group pass items to each other; `@item-click(item)` — a press without moving.
|
|
1435
|
+
- `get-key`, `as` / `item-as` / `item-class`, `lift`, `squash` (true), `rotate` (3), `handle` (a grip selector).
|
|
1436
|
+
|
|
1437
|
+
### ThemeToggle · useTheme
|
|
1438
|
+
|
|
1439
|
+
A round moon / sun button that switches light ↔ dark with a circular reveal from the button, and saves the choice.
|
|
1440
|
+
|
|
1441
|
+
```vue
|
|
1442
|
+
<script setup>
|
|
1443
|
+
import { useTheme } from '@gecko-ui-kit/vue';
|
|
1444
|
+
const [theme, setTheme] = useTheme();
|
|
1445
|
+
</script>
|
|
1446
|
+
|
|
1447
|
+
<template>
|
|
1448
|
+
<ThemeToggle @change="(t) => saveSetting('theme', t)" />
|
|
1449
|
+
<Button @click="(e) => setTheme('dark', e)">Night mode</Button>
|
|
1450
|
+
<span>{{ theme }}</span>
|
|
1451
|
+
</template>
|
|
1452
|
+
```
|
|
1453
|
+
|
|
1454
|
+
- `storage-key` (`gecko:theme`; `''` = don't save), `duration` (450 ms), `easing`, `label`, `size`.
|
|
1455
|
+
- `useTheme(options)` → `[theme, setTheme(next | (current) => next, fromElementOrEvent?)]`; `theme` is `'light'` on the server and the real theme once mounted.
|
|
1456
|
+
|
|
1457
|
+
### SendButton
|
|
1458
|
+
|
|
1459
|
+
The plane winds back and flies off, then "Sent" rolls in with a tick.
|
|
1460
|
+
|
|
1461
|
+
```vue
|
|
1462
|
+
<template>
|
|
1463
|
+
<SendButton variant="primary" @click="sendInvoice">Send invoice</SendButton>
|
|
1464
|
+
<SendButton :sent="status === 'sent'" type="submit" />
|
|
1465
|
+
</template>
|
|
1466
|
+
```
|
|
1467
|
+
|
|
1468
|
+
- A click plays it and it comes back after `back` seconds (2.4; 0 = stays). With `sent` it follows the prop instead.
|
|
1469
|
+
- `done` (Sent), `path` (`up` · `straight` · `loop`), `trail`, `duration`, `icon`; `@done(button)`.
|
|
1470
|
+
|
|
1471
|
+
### DeleteButton
|
|
1472
|
+
|
|
1473
|
+
The bin opens and eats its own label letter by letter, chews, and "Deleted" rises in.
|
|
1474
|
+
|
|
1475
|
+
```vue
|
|
1476
|
+
<template>
|
|
1477
|
+
<DeleteButton variant="danger" :back="0" @done="removeBooking(id)">Delete</DeleteButton>
|
|
1478
|
+
</template>
|
|
1479
|
+
```
|
|
1480
|
+
|
|
1481
|
+
- The slot is the label (text). `deleted` follows a prop instead of the click; `done`, `order` (`first` · `last`), `chew`, `back`.
|
|
1482
|
+
- `@done(button)` when "Deleted" is in: remove the row there.
|
|
1483
|
+
|
|
1484
|
+
### DownloadButton
|
|
1485
|
+
|
|
1486
|
+
The button's own outline is the progress bar; it glows and ticks when done, shakes red when it fails.
|
|
1487
|
+
|
|
1488
|
+
```vue
|
|
1489
|
+
<template>
|
|
1490
|
+
<DownloadButton variant="primary" :progress="progress" :state="failed ? 'failed' : progress === 1 ? 'done' : undefined"
|
|
1491
|
+
@click="downloadReport">Download report</DownloadButton>
|
|
1492
|
+
</template>
|
|
1493
|
+
```
|
|
1494
|
+
|
|
1495
|
+
- `progress` 0–1 (null = size unknown: a segment chases round); `state` `idle` · `loading` · `done` · `failed`.
|
|
1496
|
+
- `label(progress)`, `wait` (Preparing…), `done`, `fail`, `back`, `width`.
|
|
1497
|
+
|
|
1498
|
+
### HoldButton
|
|
1499
|
+
|
|
1500
|
+
Press and hold to confirm: colour floods the button and only a full hold runs the action.
|
|
1501
|
+
|
|
1502
|
+
```vue
|
|
1503
|
+
<template>
|
|
1504
|
+
<HoldButton tone="bad" hint="Hold to delete" done="Deleted" @confirm="deleteBike(bike.id)">Delete bike</HoldButton>
|
|
1505
|
+
<HoldButton look="ring" tone="accent" icon="trash">Remove</HoldButton>
|
|
1506
|
+
</template>
|
|
1507
|
+
```
|
|
1508
|
+
|
|
1509
|
+
- `look` (`fill` · `ring`: a circle round a round icon button), `tone` (`bad` · `accent` · `good` · `warn`), `duration` (1.2 s).
|
|
1510
|
+
- `hint`, `done`, `back`, `haptic`, `icon`; `confirmed` confirms or resets it from a prop.
|
|
1511
|
+
- `@confirm(button, handle)`; `@cancel(button, handle, progress)` when let go too early.
|
|
1512
|
+
|
|
1513
|
+
### ExpandSearch
|
|
1514
|
+
|
|
1515
|
+
A round magnifier that stretches into a search field, types its hint in and draws a ×.
|
|
1516
|
+
|
|
1517
|
+
```vue
|
|
1518
|
+
<template>
|
|
1519
|
+
<ExpandSearch v-model="query" placeholder="Search bikes…" :width="280" shortcut="/" @search="findBikes" />
|
|
1520
|
+
</template>
|
|
1521
|
+
```
|
|
1522
|
+
|
|
1523
|
+
- `v-model` (or `default-value`) is the text, `@change(text)` on every change; `@search(text)` on Enter.
|
|
1524
|
+
- `v-model:open` (or `default-open`), `@open`, `@close`. Escape clears, then closes.
|
|
1525
|
+
- `width`, `typing`, `auto-close`, `look` (`outline` · `quiet`), `size` (`md` · `sm`), `name`, `label`, `close-label`.
|
|
1526
|
+
|
|
1527
|
+
### LiquidTabs
|
|
1528
|
+
|
|
1529
|
+
A phone tab bar where a liquid bubble moves to the active tab.
|
|
1530
|
+
|
|
1531
|
+
```vue
|
|
1532
|
+
<template>
|
|
1533
|
+
<LiquidTabs v-model="tab" label="Main" :items="[
|
|
1534
|
+
{ label: 'Home', icon: 'home' }, { label: 'Bikes', icon: 'box' },
|
|
1535
|
+
{ label: 'Trips', icon: 'calendar' }, { label: 'Me', icon: 'user' },
|
|
1536
|
+
]" />
|
|
1537
|
+
</template>
|
|
1538
|
+
```
|
|
1539
|
+
|
|
1540
|
+
- `v-model` is the active index (or `default-value`); `@change(index, tabElement)`.
|
|
1541
|
+
- `mode` (`dip` · `glide`), `splash`, `labels` (false: icons only), `goo`.
|
|
1542
|
+
- Items with `href` are links; `:link-as="NuxtLink"` renders them with your router (it gets `to`). `#label="{ item, index }"` draws a label.
|
|
1543
|
+
|
|
1544
|
+
### Burger
|
|
1545
|
+
|
|
1546
|
+
Three lines that turn into an ✕ and back, for the button that opens a phone menu.
|
|
1547
|
+
|
|
1548
|
+
```vue
|
|
1549
|
+
<template>
|
|
1550
|
+
<Burger v-model:open="menuOpen" controls="main-menu" />
|
|
1551
|
+
<nav id="main-menu" :hidden="!menuOpen">…</nav>
|
|
1552
|
+
</template>
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
- `v-model:open` (or `default-open`); a click or Escape asks for the other state (`@toggle(open, button)`).
|
|
1556
|
+
- `words` (`{ open, close }` labels), `duration` (0.45), `escape` (true), `size`, `icon-class`.
|
|
1557
|
+
|
|
1558
|
+
## Overlays
|
|
1559
|
+
|
|
1560
|
+
Things that pop up over the page. The vanilla `@gecko-ui-kit/overlays` code still opens, places, animates and
|
|
1561
|
+
stacks them; your slot content is teleported inside. Open state is `v-model:open`: when an overlay closes itself
|
|
1562
|
+
(✕, scrim, Esc), `open` turns false first and then its event (`@close`, `@end`…) runs. Esc closes the newest one
|
|
1563
|
+
(installed once, the first time one opens). Nothing is drawn on the server; they wake up in the browser.
|
|
1564
|
+
|
|
1565
|
+
### Modal
|
|
1566
|
+
|
|
1567
|
+
A dialog in the middle of the screen that zooms out of the button that opened it (a bottom sheet on phones).
|
|
1568
|
+
|
|
1569
|
+
```vue
|
|
1570
|
+
<script setup>
|
|
1571
|
+
const open = ref(false);
|
|
1572
|
+
const editBtn = ref(null);
|
|
1573
|
+
</script>
|
|
1574
|
+
|
|
1575
|
+
<template>
|
|
1576
|
+
<Button ref="editBtn" icon="edit" @click="open = true">Edit bike</Button>
|
|
1577
|
+
<Modal v-model:open="open" :anchor="editBtn" title="Edit bike" sub="Honda Click · กข 1234">
|
|
1578
|
+
<BikeForm :bike="bike" />
|
|
1579
|
+
<template #footer>
|
|
1580
|
+
<Button @click="open = false">Cancel</Button>
|
|
1581
|
+
<Button variant="primary" @click="save">Save</Button>
|
|
1582
|
+
</template>
|
|
1583
|
+
</Modal>
|
|
1584
|
+
</template>
|
|
1585
|
+
```
|
|
1586
|
+
|
|
1587
|
+
- `v-model:open`, `@close` — closing from inside (✕, scrim, Esc) sets `open` to false, then calls `@close`.
|
|
1588
|
+
- `title`, `sub` — text props, or `#title` / `#sub` slots for richer content; they may change while it is open.
|
|
1589
|
+
- `size` — `''`, `'sm'` or `'lg'`. `anchor` — element, template ref or component it zooms out of.
|
|
1590
|
+
- Slots: default (the body), `#footer` (buttons at the bottom), `#title`, `#sub`.
|
|
1591
|
+
|
|
1592
|
+
### Drawer
|
|
1593
|
+
|
|
1594
|
+
A panel that slides in from the side (a bottom sheet on phones); its content drifts up as it lands.
|
|
1595
|
+
|
|
1596
|
+
```vue
|
|
1597
|
+
<Drawer v-model:open="riderOpen" :title="rider.name" :sub="'Rider since ' + rider.since" side="right">
|
|
1598
|
+
<template #head><span class="av av--teal">{{ rider.initials }}</span></template>
|
|
1599
|
+
<RiderBookings :id="rider.id" />
|
|
1600
|
+
<template #footer><Button variant="primary">Message</Button></template>
|
|
1601
|
+
</Drawer>
|
|
1602
|
+
```
|
|
1603
|
+
|
|
1604
|
+
- `v-model:open`, `@close`, `title`, `sub` — as in Modal.
|
|
1605
|
+
- `head` — something before the title (text prop, or the `#head` slot for an avatar). `side` — `'right'` (default) or `'left'`.
|
|
1606
|
+
- Opening a drawer closes any other drawer (its `open` turns false and its `@close` runs).
|
|
1607
|
+
- Slots: default (the body), `#head`, `#title`, `#sub`, `#footer`.
|
|
1608
|
+
|
|
1609
|
+
### confirm / useConfirm
|
|
1610
|
+
|
|
1611
|
+
An “are you sure?” dialog you `await`: `true` for OK, `false` for Cancel, ✕, scrim or Esc.
|
|
1612
|
+
|
|
1613
|
+
```vue
|
|
1614
|
+
<script setup>
|
|
1615
|
+
import { useConfirm, toast } from '@gecko-ui-kit/vue';
|
|
1616
|
+
const confirm = useConfirm();
|
|
1617
|
+
|
|
1618
|
+
async function cancelBooking(b) {
|
|
1619
|
+
if (!(await confirm({ title: `Cancel booking #${b.id}?`, body: 'The rider gets a full refund.', ok: 'Cancel booking', danger: true }))) return;
|
|
1620
|
+
await api.cancel(b.id);
|
|
1621
|
+
toast('Booking cancelled', { tone: 'good' });
|
|
1622
|
+
}
|
|
1623
|
+
</script>
|
|
1624
|
+
```
|
|
1625
|
+
|
|
1626
|
+
- `title`, `body`, `ok`, `cancel` — plain text (safe for your data). `danger` — red OK button. `anchor` — zooms out of it.
|
|
1627
|
+
- `confirm()` works anywhere in the browser; `useConfirm()` (call it in `setup`) also closes a dialog that is still
|
|
1628
|
+
open when the component unmounts.
|
|
1629
|
+
|
|
1630
|
+
### Popover
|
|
1631
|
+
|
|
1632
|
+
A small panel that pops out of its trigger (the default slot: one element), with its origin pointing back at it.
|
|
1633
|
+
|
|
1634
|
+
```vue
|
|
1635
|
+
<Popover align="end" label="Share" class-name="pop--wide">
|
|
1636
|
+
<Button icon="send">Share</Button>
|
|
1637
|
+
<template #content="{ close }">
|
|
1638
|
+
<ShareBooking :id="booking.id" @copied="close" />
|
|
1639
|
+
</template>
|
|
1640
|
+
</Popover>
|
|
1641
|
+
```
|
|
1642
|
+
|
|
1643
|
+
- `#content` slot (gets `{ close }`), or a `content` text prop.
|
|
1644
|
+
- Clicking the trigger toggles it; a click outside, Esc or a resize closes it.
|
|
1645
|
+
- `v-model:open` to control it, or `default-open`. `@open-change(open)` after every change.
|
|
1646
|
+
- `align` — `'start' | 'center' | 'end'`. `class-name` (a class on the panel, e.g. `pop--wide`), `label`.
|
|
1647
|
+
- Template ref → `{ open(), close(), isOpen, el }`.
|
|
1648
|
+
|
|
1649
|
+
### Menu
|
|
1650
|
+
|
|
1651
|
+
A popover with a ready-made list of actions that slide in; ↑ ↓ move between them.
|
|
1652
|
+
|
|
1653
|
+
```vue
|
|
1654
|
+
<Menu align="end" :items="[
|
|
1655
|
+
{ section: 'Booking' },
|
|
1656
|
+
{ icon: 'edit', label: 'Edit', kbd: 'E', run: () => edit(b) },
|
|
1657
|
+
{ icon: 'copy', label: 'Duplicate', run: () => duplicate(b) },
|
|
1658
|
+
'-',
|
|
1659
|
+
{ icon: 'trash', label: 'Cancel booking', danger: true, run: () => cancelBooking(b) },
|
|
1660
|
+
]">
|
|
1661
|
+
<IconButton icon="more" label="More" />
|
|
1662
|
+
</Menu>
|
|
1663
|
+
```
|
|
1664
|
+
|
|
1665
|
+
- `items` — `{ label, icon, kbd, danger, run(trigger) }`, `{ section: 'Heading' }`, or `'-'` for a line. Labels are plain text.
|
|
1666
|
+
- `@select(item, index)` — after any action (after its `run`). `align`, `class-name`, `label`.
|
|
1667
|
+
- Template ref → `{ open(), close(), isOpen }`.
|
|
1668
|
+
|
|
1669
|
+
### ContextMenu
|
|
1670
|
+
|
|
1671
|
+
The menu you get with a right-click, a long-press on touch screens or Shift+F10. It grows from the pointer and has submenus and ticks.
|
|
1672
|
+
|
|
1673
|
+
```vue
|
|
1674
|
+
<script setup>
|
|
1675
|
+
const rowMenu = (event, row) => [
|
|
1676
|
+
{ section: `Booking #${row.dataset.id}` },
|
|
1677
|
+
{ icon: 'edit', label: 'Edit', kbd: 'E', run: () => edit(row.dataset.id) },
|
|
1678
|
+
{ label: 'Move to', items: bikes.value.map((bike) => ({ label: bike.name, run: () => move(row.dataset.id, bike.id) })) },
|
|
1679
|
+
{ label: 'Paid', checked: isPaid(row.dataset.id), run: (_el, item) => setPaid(row.dataset.id, item.checked) },
|
|
1680
|
+
'-',
|
|
1681
|
+
{ icon: 'trash', label: 'Cancel', danger: true, run: () => cancelBooking(row.dataset.id) },
|
|
1682
|
+
];
|
|
1683
|
+
</script>
|
|
1684
|
+
|
|
1685
|
+
<template>
|
|
1686
|
+
<table>
|
|
1687
|
+
<ContextMenu as="tbody" selector="tr[data-id]" :items="rowMenu">
|
|
1688
|
+
<tr v-for="b in bookings" :key="b.id" :data-id="b.id">…</tr>
|
|
1689
|
+
</ContextMenu>
|
|
1690
|
+
</table>
|
|
1691
|
+
</template>
|
|
1692
|
+
```
|
|
1693
|
+
|
|
1694
|
+
- `items` — a list, or `(event, el) => list` on every open (return `[]` to get the browser's own menu).
|
|
1695
|
+
Rows: `{ label, icon, kbd, hint, disabled, danger, checked, items, run(el, item) }`, `{ section }`, `'-'`.
|
|
1696
|
+
- `checked` rows flip on a copy (never your data): `run` / `@select` get the new value in `item.checked`.
|
|
1697
|
+
- `selector`, `long-press` (ms, 0 = off), `native-on-shift`, `icons`, `shortcuts`, `words: { label }`,
|
|
1698
|
+
`@select(item, el)`, `@open(el)`, `@close(el)`.
|
|
1699
|
+
- `as` — the wrapper element (default `div`). Template ref → `{ open(x, y, el?), close(), isOpen, menu, el }`.
|
|
1700
|
+
|
|
1701
|
+
### Tooltip
|
|
1702
|
+
|
|
1703
|
+
A small label that fades in under (or beside) an element on hover or keyboard focus. Hidden on phones.
|
|
1704
|
+
|
|
1705
|
+
```vue
|
|
1706
|
+
<Tooltip text="Edit booking"><IconButton icon="edit" label="Edit booking" /></Tooltip>
|
|
1707
|
+
<Tooltip side="right">
|
|
1708
|
+
<template #text>Somchai K.<br />Mechanic</template>
|
|
1709
|
+
<span class="av av--teal" tabindex="0">SK</span>
|
|
1710
|
+
</Tooltip>
|
|
1711
|
+
```
|
|
1712
|
+
|
|
1713
|
+
- `text` — a string (a `\n` makes a second line), or the `#text` slot. `side` — `'below'` (default) or `'right'`.
|
|
1714
|
+
- `disabled` — turn it off for now. Inside an element with `data-tips-right` it opens to the right.
|
|
1715
|
+
- The default slot is the element it explains (one element).
|
|
1716
|
+
|
|
1717
|
+
### toast
|
|
1718
|
+
|
|
1719
|
+
A short message that pops up at the bottom and goes away by itself. A plain function: call it from anywhere in the browser.
|
|
1720
|
+
|
|
1721
|
+
```js
|
|
1722
|
+
import { toast } from '@gecko-ui-kit/vue';
|
|
1723
|
+
|
|
1724
|
+
toast('Booking saved', { tone: 'good' });
|
|
1725
|
+
toast('Bike moved to the workshop', { icon: 'tool', undo: () => moveBack(bike) });
|
|
1726
|
+
const close = toast('Uploading photos…', { duration: 60000 }); // close() when done
|
|
1727
|
+
```
|
|
1728
|
+
|
|
1729
|
+
- `tone` — `''`, `'good'`, `'warn'` or `'bad'`. `icon` — an icon name. `duration` — ms (default 4200).
|
|
1730
|
+
- `undo` — adds an Undo button; `undoLabel`, `undoneText`. The text is shown as plain text (safe for your data).
|
|
1731
|
+
|
|
1732
|
+
### CookieBanner
|
|
1733
|
+
|
|
1734
|
+
Asks once which cookies a visitor allows, remembers the answer and stays away until you raise `version`.
|
|
1735
|
+
|
|
1736
|
+
```vue
|
|
1737
|
+
<script setup>
|
|
1738
|
+
const cookies = ref(null);
|
|
1739
|
+
</script>
|
|
1740
|
+
|
|
1741
|
+
<template>
|
|
1742
|
+
<CookieBanner ref="cookies" policy="/privacy" position="end"
|
|
1743
|
+
@change="(choices) => { if (choices.analytics) loadAnalytics(); }" />
|
|
1744
|
+
<footer><button @click="cookies.open({ settings: true })">Cookie settings</button></footer>
|
|
1745
|
+
</template>
|
|
1746
|
+
```
|
|
1747
|
+
|
|
1748
|
+
- `categories` — `{ id, label, text, required }[]` (default: necessary, analytics, marketing). Optional ones start off.
|
|
1749
|
+
- `storage-key` (default `'gecko:consent'`, `''` = never saved), `version`, `show` (`'auto'` or `false`),
|
|
1750
|
+
`position` (`'bottom' | 'start' | 'end'`), `mount`, `policy`, `words`.
|
|
1751
|
+
- `@change(choices, { action, at })`. Template ref → `{ choices, allowed(id), open({ settings }), close(), reset(), visible, el }`.
|
|
1752
|
+
- It draws nothing where you place it.
|
|
1753
|
+
|
|
1754
|
+
### LoadingBar / useLoadingBar
|
|
1755
|
+
|
|
1756
|
+
The thin line along the top of the page while something loads. Quick loads never show it.
|
|
1757
|
+
|
|
1758
|
+
```vue
|
|
1759
|
+
<script setup>
|
|
1760
|
+
import { useLoadingBar } from '@gecko-ui-kit/vue';
|
|
1761
|
+
const saving = ref(false);
|
|
1762
|
+
|
|
1763
|
+
// or by hand
|
|
1764
|
+
const bar = useLoadingBar({ color: 'var(--good)' });
|
|
1765
|
+
async function save() { bar.start(); try { await api.save(booking); bar.done(); } catch { bar.fail(); } }
|
|
1766
|
+
</script>
|
|
1767
|
+
|
|
1768
|
+
<template>
|
|
1769
|
+
<LoadingBar :active="saving" />
|
|
1770
|
+
</template>
|
|
1771
|
+
```
|
|
1772
|
+
|
|
1773
|
+
- `<LoadingBar :active>` starts when `active` turns true and finishes when it turns false. Template ref → the same handle as below.
|
|
1774
|
+
- `useLoadingBar(options)` (in `setup`) → `{ start(), done(all?), fail(), set(0..1), inc(n), value, loads, active, el }`,
|
|
1775
|
+
the same object for the component's life; removed on unmount. `options` may be an object, a ref or a getter.
|
|
1776
|
+
- Options: `mount` (element, template ref or selector; default the window), `height`, `color`, `trickle`, `delay`, `label`, `words`.
|
|
1777
|
+
|
|
1778
|
+
### CommandPalette
|
|
1779
|
+
|
|
1780
|
+
The ⌘K search window: type, move with the arrow keys, Enter picks, Esc closes.
|
|
1781
|
+
|
|
1782
|
+
```vue
|
|
1783
|
+
<script setup>
|
|
1784
|
+
const router = useRouter();
|
|
1785
|
+
const search = (q) => [
|
|
1786
|
+
{ label: 'Bikes', items: bikes.value.filter((b) => b.name.toLowerCase().includes(q)).map((b) => ({ title: b.name, sub: b.plate, icon: 'bike', run: () => router.push(`/bikes/${b.id}`) })) },
|
|
1787
|
+
{ label: 'Riders', items: riders.value.filter((r) => r.name.toLowerCase().includes(q)).map((r) => ({ title: r.name, sub: r.phone, icon: 'user', run: () => openRider(r) })) },
|
|
1788
|
+
];
|
|
1789
|
+
</script>
|
|
1790
|
+
|
|
1791
|
+
<template>
|
|
1792
|
+
<CommandPalette v-model:open="searching" placeholder="Search bikes and riders…" :search="search" />
|
|
1793
|
+
</template>
|
|
1794
|
+
```
|
|
1795
|
+
|
|
1796
|
+
- `search(q)` → groups `{ label, items: [{ title, sub, icon, run }] }`; `q` is trimmed and lowercased. Titles are plain text.
|
|
1797
|
+
- `v-model:open`, `@close`, `@select(item)` (after its `run`), `placeholder`, `empty-title`, `empty-body`.
|
|
1798
|
+
|
|
1799
|
+
### Tour
|
|
1800
|
+
|
|
1801
|
+
A walk-through: the page dims except a spotlight around each stop, and a bubble explains it. ← → move, Esc ends.
|
|
1802
|
+
|
|
1803
|
+
```vue
|
|
1804
|
+
<script setup>
|
|
1805
|
+
const touring = ref(false);
|
|
1806
|
+
const searchBtn = ref(null);
|
|
1807
|
+
const steps = [
|
|
1808
|
+
{ title: 'Welcome to MotoRent', text: 'A one-minute look around.' },
|
|
1809
|
+
{ target: searchBtn, title: 'Find a bike', text: 'Search by name or plate number.' },
|
|
1810
|
+
{ target: '#calendar', title: 'Bookings', slot: 'drag' },
|
|
1811
|
+
];
|
|
1812
|
+
</script>
|
|
1813
|
+
|
|
1814
|
+
<template>
|
|
1815
|
+
<button ref="searchBtn" class="btn">Search</button>
|
|
1816
|
+
<Tour v-model:open="touring" :steps="steps" @end="(finished) => finished && markTourSeen()">
|
|
1817
|
+
<template #drag><p>Drag a booking to <b>move</b> it to another bike.</p></template>
|
|
1818
|
+
</Tour>
|
|
1819
|
+
</template>
|
|
1820
|
+
```
|
|
1821
|
+
|
|
1822
|
+
- `steps` — `{ target, title, text, slot, placement, padding, radius }`. `target`: a template ref, element, component or
|
|
1823
|
+
selector (missing → skipped; none → bubble in the middle). `slot`: the name of a Tour slot shown instead of `text`
|
|
1824
|
+
(it gets `{ step, index }`).
|
|
1825
|
+
- `v-model:open` (setting it to false ends it quietly, without `@end`), `start`, `@step(index, step)`, `@end(finished)`.
|
|
1826
|
+
- `placement`, `padding`, `radius`, `backdrop`, `scroll`, `words`. Template ref → `{ start(i), next(), prev(), go(i), stop(), index, active }`.
|
|
1827
|
+
|
|
1828
|
+
### Lightbox
|
|
1829
|
+
|
|
1830
|
+
Full-screen photos that grow out of their thumbnail and shrink back into it. Swipe, zoom, drag down to close.
|
|
1831
|
+
|
|
1832
|
+
```vue
|
|
1833
|
+
<script setup>
|
|
1834
|
+
const thumbs = ref([]);
|
|
1835
|
+
const shown = ref(false), photo = ref(0);
|
|
1836
|
+
</script>
|
|
1837
|
+
|
|
1838
|
+
<template>
|
|
1839
|
+
<img v-for="(p, i) in bike.photos" :key="p.id" ref="thumbs" :src="p.thumb" :alt="p.alt" @click="photo = i; shown = true" />
|
|
1840
|
+
<Lightbox v-model:open="shown" v-model:index="photo"
|
|
1841
|
+
:items="bike.photos.map((p, i) => ({ src: p.big, alt: p.alt, caption: p.caption, from: thumbs[i] }))" />
|
|
1842
|
+
</template>
|
|
1843
|
+
```
|
|
1844
|
+
|
|
1845
|
+
- `items` — image addresses or `{ src, alt, caption, w, h, from }` (`from`: the thumbnail element, template ref or selector).
|
|
1846
|
+
- `v-model:open`, `v-model:index` (changing it while open moves there), `@change(index)`, `@close(index)`, `zoom`, `max-zoom`, `words`.
|
|
1847
|
+
|
|
1848
|
+
### LightboxGallery
|
|
1849
|
+
|
|
1850
|
+
The no-state version: wrap links to big images and clicking one opens its whole group.
|
|
1851
|
+
|
|
1852
|
+
```vue
|
|
1853
|
+
<LightboxGallery class="photos">
|
|
1854
|
+
<a v-for="p in bike.photos" :key="p.id" :href="p.big" data-lightbox="bike" :data-caption="p.caption">
|
|
1855
|
+
<img :src="p.thumb" :alt="p.alt" />
|
|
1856
|
+
</a>
|
|
1857
|
+
</LightboxGallery>
|
|
1858
|
+
```
|
|
1859
|
+
|
|
1860
|
+
- Elements with the same `data-lightbox` value form one gallery; image from `href`, `data-src` or the inner `<img>`.
|
|
1861
|
+
- `selector`, `zoom`, `max-zoom`, `words`, `@change(index)`, `@close(index)`, `as` (the wrapper element, default `div`).
|
|
1862
|
+
|
|
1863
|
+
## App shell
|
|
1864
|
+
|
|
1865
|
+
### AppShell
|
|
1866
|
+
|
|
1867
|
+
The whole frame around your pages: Sidebar, Topbar, the page in `<main class="view">`, the phone tab bar, the ⌘K
|
|
1868
|
+
palette, keyboard shortcuts and the opening animation. When the path changes, the new page slides in from the
|
|
1869
|
+
direction of travel. It works with Nuxt and vue-router: give it the current path and a way to navigate.
|
|
1870
|
+
|
|
1871
|
+
```vue
|
|
1872
|
+
<!-- layouts/default.vue (Nuxt) -->
|
|
1873
|
+
<script setup>
|
|
1874
|
+
import { AppShell } from '@gecko-ui-kit/vue';
|
|
1875
|
+
import { NuxtLink } from '#components';
|
|
1876
|
+
|
|
1877
|
+
const route = useRoute();
|
|
1878
|
+
const nav = [
|
|
1879
|
+
{ label: 'Shop', items: [
|
|
1880
|
+
{ id: 'today', label: 'Today', icon: 'today', href: '/' },
|
|
1881
|
+
{ id: 'bikes', label: 'Bikes', icon: 'layers', subs: [['fleet', 'Fleet'], ['repairs', 'Repairs']] }, // /bikes/fleet, /bikes/repairs
|
|
1882
|
+
{ id: 'bookings', label: 'Bookings', icon: 'rota', count: () => pending.value.length },
|
|
1883
|
+
] },
|
|
1884
|
+
{ label: 'People', items: [{ id: 'riders', label: 'Riders', icon: 'people' }] },
|
|
1885
|
+
];
|
|
1886
|
+
const me = { name: 'Pim Wong', role: 'Manager', menu: [{ icon: 'user', label: 'Profile', run: () => navigateTo('/profile') }] };
|
|
1887
|
+
</script>
|
|
1888
|
+
|
|
1889
|
+
<template>
|
|
1890
|
+
<AppShell :brand="{ name: 'MotoRent', sub: 'Chiang Mai' }" :nav="nav" :end="[{ id: 'settings', label: 'Settings', icon: 'settings' }]" :user="me"
|
|
1891
|
+
:path="route.path" @navigate="(href) => navigateTo(href)" :link="NuxtLink" storage-key="motorent"
|
|
1892
|
+
:top="{ search: { placeholder: 'Search bikes…' }, bell: { count: unread, onClick: openInbox }, primary: { label: 'New booking', run: newBooking } }"
|
|
1893
|
+
:search="(q) => [{ label: 'Bikes', items: findBikes(q).map((b) => ({ title: b.name, sub: b.plate, icon: 'layers', run: () => navigateTo(`/bikes/${b.id}`) })) }]">
|
|
1894
|
+
<slot />
|
|
1895
|
+
<template #extra><TimerButton /></template>
|
|
1896
|
+
</AppShell>
|
|
1897
|
+
</template>
|
|
1898
|
+
```
|
|
1899
|
+
|
|
1900
|
+
- `nav` (groups of `{ id, label, icon, href, count, subs, blurb, tabs }`), `end` (items pinned to the bottom), `brand`, `user`.
|
|
1901
|
+
An item's address is `href`, else `/${id}` (`base` adds a prefix); a sub-page's is `/${id}/${subId}`.
|
|
1902
|
+
- `path` — the current path (`useRoute().path`); `@navigate(href)` — called by every link, menu, the palette and keys
|
|
1903
|
+
(`navigateTo` / `router.push`); `link` — a link component such as `NuxtLink` or `RouterLink` (it gets `to`).
|
|
1904
|
+
- `top` — `{ search: { placeholder, onOpen } | false, theme, bell: { count, onClick }, primary: { label, icon, run } }`. `crumbs-root`.
|
|
1905
|
+
- `tabbar` (ids for the phone tab bar), `tabs`, `intro`, `shortcuts`, `keys: [{ key, label, run(shell) }]`, `search(q)`, `storage-key`, `rail-breakpoint`, `mobile`, `words`.
|
|
1906
|
+
- Slots: default (the page), `#extra` (buttons in the topbar before the theme switch).
|
|
1907
|
+
|
|
1908
|
+
### useShell
|
|
1909
|
+
|
|
1910
|
+
Inside `<AppShell>` (in any page or component under it), the shell's state and actions; `null` outside.
|
|
1911
|
+
|
|
1912
|
+
```vue
|
|
1913
|
+
<script setup>
|
|
1914
|
+
import { useShell } from '@gecko-ui-kit/vue';
|
|
1915
|
+
const shell = useShell();
|
|
1916
|
+
</script>
|
|
1917
|
+
|
|
1918
|
+
<template>
|
|
1919
|
+
<p v-if="shell?.route.page === 'bikes'">Section: {{ shell.route.sub }}</p>
|
|
1920
|
+
<Button icon="search" @click="shell?.palette()">Find a bike</Button>
|
|
1921
|
+
</template>
|
|
1922
|
+
```
|
|
1923
|
+
|
|
1924
|
+
- A reactive object: `route` (`{ page, sub }`) and `path` follow the current path.
|
|
1925
|
+
- `navigate(href)`, `palette()`, `shortcuts()`, `intro()`, `setRail(rail)`, `isRail()`.
|
|
1926
|
+
|
|
1927
|
+
### shellBootScript
|
|
1928
|
+
|
|
1929
|
+
A small script for the page `<head>` that puts the saved theme and rail on `<html>` before the first paint, so
|
|
1930
|
+
nothing jumps when the app wakes up.
|
|
1931
|
+
|
|
1932
|
+
```js
|
|
1933
|
+
// app.vue (Nuxt)
|
|
1934
|
+
import { shellBootScript } from '@gecko-ui-kit/vue';
|
|
1935
|
+
useHead({ script: [{ innerHTML: shellBootScript({ storageKey: 'motorent' }), tagPriority: 'critical' }] });
|
|
1936
|
+
```
|
|
1937
|
+
|
|
1938
|
+
- `storageKey` (same as on AppShell, default `'gecko'`), `railBreakpoint` (default 1280). Returns the script text.
|
|
1939
|
+
|
|
1940
|
+
### Sidebar
|
|
1941
|
+
|
|
1942
|
+
The main menu: a pill stretches to the current item, the open section unfolds its sub-pages, counts flash when
|
|
1943
|
+
they change, and it collapses to a rail of icons with a flyout on hover. On phones it is a drawer.
|
|
1944
|
+
|
|
1945
|
+
```vue
|
|
1946
|
+
<Sidebar :brand="{ name: 'Friday', sub: 'Projects', icon: 'logo' }" :nav="nav" :end="end" :user="me"
|
|
1947
|
+
:path="route.path" @navigate="(href) => router.push(href)" storage-key="friday" ref="sidebar" />
|
|
1948
|
+
```
|
|
1949
|
+
|
|
1950
|
+
- Same `nav`, `end`, `path`, `base`, `home`, `@navigate`, `link`, `words` as AppShell; `brand`, `user`, `storage-key`, `rail-breakpoint`, `mobile`.
|
|
1951
|
+
- Clicking the open item folds its sub-pages instead of navigating. The `[` key and the panel button switch the rail (inside AppShell).
|
|
1952
|
+
- Template ref → `{ setRail(rail), isRail(), el }` (`sidebar.value.setRail(true)`).
|
|
1953
|
+
|
|
1954
|
+
### Topbar
|
|
1955
|
+
|
|
1956
|
+
The bar above the page: breadcrumbs from the route, a search button, your own buttons, a theme switch that
|
|
1957
|
+
spreads from the button, a bell whose badge pops when the number goes up, and one main action.
|
|
1958
|
+
|
|
1959
|
+
```vue
|
|
1960
|
+
<Topbar :nav="nav" :path="route.path" @navigate="(href) => router.push(href)" crumbs-root="Friday"
|
|
1961
|
+
:search="{ placeholder: 'Search projects…', onOpen: () => (searching = true) }"
|
|
1962
|
+
:bell="{ count: unread, onClick: (button) => openInbox(button) }"
|
|
1963
|
+
:primary="{ label: 'New project', icon: 'plus', run: () => (creating = true) }">
|
|
1964
|
+
<TimerButton />
|
|
1965
|
+
</Topbar>
|
|
1966
|
+
```
|
|
1967
|
+
|
|
1968
|
+
- `crumbs-root`, `search` (`false` hides it), `theme` (`false` hides it), `bell: { count, onClick(button) }`, `primary: { label, icon, tip, run(button) }`, `@search`.
|
|
1969
|
+
- Default slot: buttons before the theme switch. The menu button (phones) opens the Sidebar drawer.
|
|
1970
|
+
|
|
1971
|
+
### PageHeader
|
|
1972
|
+
|
|
1973
|
+
The top of a page: an eyebrow, a big title whose letters roll up (again when it changes), a line of text,
|
|
1974
|
+
buttons on the right, and tabs with an underline that stretches to the chosen tab.
|
|
1975
|
+
|
|
1976
|
+
```vue
|
|
1977
|
+
<!-- pages/bikes/repairs.vue — inside AppShell the Bikes sub-pages become link tabs by themselves -->
|
|
1978
|
+
<PageHeader eyebrow="Workshop" title="Repairs" sub="Bikes in the workshop this week." :counts="{ repairs: waiting.length }">
|
|
1979
|
+
<template #actions><Button variant="primary" icon="plus">Book a repair</Button></template>
|
|
1980
|
+
</PageHeader>
|
|
1981
|
+
|
|
1982
|
+
<!-- your own tabs (buttons) -->
|
|
1983
|
+
<PageHeader title="Project Apollo" :tabs="[['board', 'Board'], ['list', 'List'], ['files', 'Files', 4]]" v-model="view" />
|
|
1984
|
+
```
|
|
1985
|
+
|
|
1986
|
+
- `title` (text), `eyebrow`, `sub` (text or `#eyebrow` / `#sub` slots), `#actions` slot.
|
|
1987
|
+
- `tabs` — `[{ id, label, count, href }]` or `[id, label, count?, href?]`; with `href` they are links, without they are buttons
|
|
1988
|
+
(`v-model` = the chosen id, or `default-value`; `@tab-change(id)`). Inside AppShell, leave it out to get the current item's
|
|
1989
|
+
sub-pages; `:tabs="false"` hides them. `counts: { tabId: n }` adds badges.
|
|
1990
|
+
- Letters are split by grapheme, so Thai vowels and tone marks stay on their letter. Template ref → `{ el }` (the `<header>`).
|
|
1991
|
+
|
|
1992
|
+
### MobileTabbar
|
|
1993
|
+
|
|
1994
|
+
On phones (760px and below) a tab bar at the bottom with your main sections; a soft highlight stretches to the
|
|
1995
|
+
current one and “More” lists the rest. Hidden on wider screens.
|
|
1996
|
+
|
|
1997
|
+
```vue
|
|
1998
|
+
<MobileTabbar :nav="nav" :end="end" :path="route.path" @navigate="(href) => router.push(href)" :tabbar="['today', 'bikes', 'bookings', 'riders']" />
|
|
1999
|
+
```
|
|
2000
|
+
|
|
2001
|
+
- `tabbar` — ids that get a tab (default: the first four items). The rest go under “More” (`words.more`).
|
|
2002
|
+
|
|
2003
|
+
## Helpers
|
|
2004
|
+
|
|
2005
|
+
- `useMotion(fn, options)`: run any `@gecko-ui-kit/motion` helper on an element you render; returns a template ref.
|
|
2006
|
+
`options` may be a value, a ref or a getter (it runs again when they change). Stopped on unmount.
|
|
2007
|
+
- `useModel(props)` + `modelProps()`: the v-model / default-value pattern the components use.
|
|
2008
|
+
- `mounted(name, mountFn, spec)` and `enhancer(name, motionFn, spec)`: turn your own vanilla-style piece into a
|
|
2009
|
+
component the same way this package does (see `src/core.js`).
|
|
2010
|
+
- `<Icon name="bike" />`: any icon from `@gecko-ui-kit/icons`.
|
|
2011
|
+
- `GeckoUI` (plugin) and `components` (every component by name).
|
|
2012
|
+
|
|
2013
|
+
## Tests
|
|
2014
|
+
|
|
2015
|
+
`npm run check:vue` in the repo type-checks every component, draws each one on the server, hydrates it in a browser on
|
|
2016
|
+
a desktop (light) and a phone (dark, reduced motion), clicks and types through it, unmounts it, mounts it again and
|
|
2017
|
+
unmounts it again, and checks nothing is left behind. It runs on every push.
|