@gecko-ui-kit/react 0.1.0 → 0.3.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/README.md +70 -34
- package/package.json +7 -7
- package/src/actions.d.ts +1 -1
- package/src/actions.js +28 -28
- package/src/basics.d.ts +1 -1
- package/src/basics.js +53 -53
- package/src/controls.d.ts +4 -4
- package/src/controls.js +30 -30
- package/src/core.d.ts +1 -1
- package/src/core.js +3 -3
- package/src/data.js +15 -15
- package/src/effects.d.ts +5 -5
- package/src/effects.js +33 -33
- package/src/forms.js +10 -10
- package/src/motion.d.ts +3 -3
- package/src/motion.js +10 -10
- package/src/overlays.d.ts +6 -2
- package/src/overlays.js +21 -18
- package/src/shell.js +76 -76
- package/src/text.js +10 -10
package/README.md
CHANGED
|
@@ -56,6 +56,40 @@ export function BookingFilters() {
|
|
|
56
56
|
|
|
57
57
|
Works the same in Vite, Remix or any React 18+ app: just import the CSS in your entry file.
|
|
58
58
|
|
|
59
|
+
## Fit it into an app that already has its own look
|
|
60
|
+
|
|
61
|
+
- **Nothing clashes.** Every class Gecko draws starts with `gk-` (`gk-btn`, `gk-card`, `gk-is-open`) and every CSS
|
|
62
|
+
variable with `--gk-` (`--gk-accent`), so your own `.btn`, `.card` or `--accent` keep working as before.
|
|
63
|
+
- **The reset stays inside Gecko.** `tokens/style.css` only resets Gecko's own elements; your `body`, links and buttons
|
|
64
|
+
are left alone. Want Gecko to set the page font, background and focus ring too? Add `@gecko-ui-kit/tokens/page.css`.
|
|
65
|
+
- **Match your theme** by setting variables after the imports (in your own CSS):
|
|
66
|
+
|
|
67
|
+
```css
|
|
68
|
+
:root {
|
|
69
|
+
--gk-font: 'Prompt', system-ui, sans-serif;
|
|
70
|
+
--gk-bg: #eef1f6; --gk-card: #ffffff; --gk-line: #e2e6ee; --gk-ink: #1a1a1a; --gk-muted: #595959;
|
|
71
|
+
--gk-accent: #006ce4; --gk-accent-2: #0057b8; --gk-accent-soft: #ebf3ff; /* main buttons, links, focus */
|
|
72
|
+
--gk-selected: #ffb700; --gk-selected-ink: #1a1a1a; /* the chosen segment, chip, tab line and page */
|
|
73
|
+
--gk-r-card: 14px; --gk-r-btn: 10px; --gk-r-field: 10px; --gk-r-tag: 6px; --gk-r-badge: 6px; --gk-r-pill: 10px;
|
|
74
|
+
--gk-w-strong: 500; --gk-w-semibold: 600; /* lighter buttons and labels */
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
Corners: `--gk-r-btn`, `--gk-r-iconbtn`, `--gk-r-field`, `--gk-r-chip`, `--gk-r-check`, `--gk-r-tag`, `--gk-r-badge`,
|
|
78
|
+
`--gk-r-pill` (segmented), `--gk-r-card`, `--gk-r-kpi`, `--gk-r-pop`, `--gk-r-toast`. Weights: `--gk-w-light` 300,
|
|
79
|
+
`--gk-w-medium` 500, `--gk-w-label` 550, `--gk-w-semibold` 600, `--gk-w-strong` 650, `--gk-w-bold` 700, `--gk-w-heavy` 750,
|
|
80
|
+
`--gk-w-black` 800. `--gk-selected` / `--gk-selected-ink` are unset by default (each piece keeps its own look).
|
|
81
|
+
|
|
82
|
+
## Phone apps (PWA, Capacitor)
|
|
83
|
+
|
|
84
|
+
The kit works in a phone app made from your Next.js site: a PWA, or the site wrapped by Capacitor. Let the page run
|
|
85
|
+
under the notch and home bar, and the app frame, phone sheets, toasts and tab bar keep clear of them on their own:
|
|
86
|
+
```js
|
|
87
|
+
// app/layout.js
|
|
88
|
+
export const viewport = { width: 'device-width', initialScale: 1, viewportFit: 'cover' }
|
|
89
|
+
```
|
|
90
|
+
The room comes from `--gk-safe-t`, `--gk-safe-r`, `--gk-safe-b`, `--gk-safe-l` (0 on desktop); set them yourself if
|
|
91
|
+
your native shell already pads for the notch. React Native does not draw with HTML and CSS, so the kit does not run there.
|
|
92
|
+
|
|
59
93
|
## How the components behave
|
|
60
94
|
|
|
61
95
|
- **Same look as the vanilla kit.** Each component draws the same HTML (same classes) as its vanilla piece, or runs the
|
|
@@ -168,7 +202,7 @@ A white panel with an optional head (title, small line, things on the right); `l
|
|
|
168
202
|
### Kpi
|
|
169
203
|
A number tile: a caption, a big value and a small line.
|
|
170
204
|
```tsx
|
|
171
|
-
<div className="kpis">
|
|
205
|
+
<div className="gk-kpis">
|
|
172
206
|
<Kpi label="Bikes out" value={12} sub="of 20" />
|
|
173
207
|
<Kpi label="Revenue" value="฿48,250" sub="This month" tone="good" />
|
|
174
208
|
</div>
|
|
@@ -184,7 +218,7 @@ What to show when a list has nothing in it.
|
|
|
184
218
|
- `icon`, `title`, `body`, `action`: nodes
|
|
185
219
|
|
|
186
220
|
### Table
|
|
187
|
-
A table styled by `.table`, inside `.table-wrap` so it scrolls sideways on phones. Give it columns and rows, or write the `<thead>`/`<tbody>` yourself.
|
|
221
|
+
A table styled by `.gk-table`, inside `.gk-table-wrap` so it scrolls sideways on phones. Give it columns and rows, or write the `<thead>`/`<tbody>` yourself.
|
|
188
222
|
```tsx
|
|
189
223
|
<Card title="Bookings" flush>
|
|
190
224
|
<Table rows={bookings} rowKey="id" slideRows columns={[
|
|
@@ -265,7 +299,8 @@ A row of options where exactly one is picked; the thumb stretches to the new cho
|
|
|
265
299
|
```tsx
|
|
266
300
|
<Segmented options={[['list', 'List', 'list'], ['board', 'Board', 'cards']]} value={view} onChange={setView} />
|
|
267
301
|
```
|
|
268
|
-
- `options`: `[value, label, icon?]`, `{ value, label, icon, disabled }` or strings · `value` / `defaultValue` · `onChange(value)` · `size: 'sm'`
|
|
302
|
+
- `options`: `[value, label, icon?, count?]`, `{ value, label, icon, count, disabled }` or strings · `value` / `defaultValue` · `onChange(value)` · `size: 'sm'`
|
|
303
|
+
- `count` — a number after the label, e.g. `['free', 'Free', null, 4]` shows **Free 4**
|
|
269
304
|
|
|
270
305
|
### Checkbox
|
|
271
306
|
A tick box that pops when ticked.
|
|
@@ -332,7 +367,7 @@ A code field with one box per character: typing moves on, Backspace goes back, p
|
|
|
332
367
|
```
|
|
333
368
|
- `length` (6), `split`, `mask` (PIN dots), `letters` (A–Z too), `label`, `name`
|
|
334
369
|
- `onComplete(code, el)`: return / resolve `true` (green wave, then a tick) or `false` (shake, then clear) · `gather`, `clear`
|
|
335
|
-
- `value` / `defaultValue`, `onChange(code)` · `disabled` · `ref` is the `.otp` element (`otpState` / `otpClear` work on it)
|
|
370
|
+
- `value` / `defaultValue`, `onChange(code)` · `disabled` · `ref` is the `.gk-otp` element (`otpState` / `otpClear` work on it)
|
|
336
371
|
|
|
337
372
|
## Forms
|
|
338
373
|
|
|
@@ -425,7 +460,7 @@ One email field and a button; the button grows into the thank-you message.
|
|
|
425
460
|
A password field with the strength meter after it: bars, a checklist that ticks off and a padlock.
|
|
426
461
|
```tsx
|
|
427
462
|
const [pw, setPw] = useState('');
|
|
428
|
-
<div className="field">
|
|
463
|
+
<div className="gk-field">
|
|
429
464
|
<label htmlFor="team-pw">Password for the team account</label>
|
|
430
465
|
<PasswordMeter id="team-pw" value={pw} onValueChange={setPw} reveal min={10} onChange={(s) => setCanSave(s.valid)} />
|
|
431
466
|
</div>
|
|
@@ -519,7 +554,7 @@ A long form split into steps that slide sideways; each step's content is your ow
|
|
|
519
554
|
```tsx
|
|
520
555
|
<Wizard words={{ finish: 'Book' }} onFinish={(values) => book(values)} steps={[
|
|
521
556
|
{ id: 'bike', title: 'Bike', content: <BikePicker /> },
|
|
522
|
-
{ id: 'rider', title: 'Rider', content: <><label className="field"><span>Phone</span><input className="input" name="phone" required /></label></> },
|
|
557
|
+
{ id: 'rider', title: 'Rider', content: <><label className="gk-field"><span>Phone</span><input className="gk-input" name="phone" required /></label></> },
|
|
523
558
|
{ id: 'pay', title: 'Payment', content: <PaymentStep />, validate: () => (paid ? true : 'Choose how to pay.') },
|
|
524
559
|
]} />
|
|
525
560
|
```
|
|
@@ -529,7 +564,7 @@ A long form split into steps that slide sideways; each step's content is your ow
|
|
|
529
564
|
- Without `validate`, the browser's own checks run on the step's fields (`required`, `type="email"`…)
|
|
530
565
|
|
|
531
566
|
### useValidation
|
|
532
|
-
The red-field pattern from the Validation page (`.field.is-bad`, the reason in `.field__hint`, a small shake) as a hook.
|
|
567
|
+
The red-field pattern from the Validation page (`.gk-field.gk-is-bad`, the reason in `.gk-field__hint`, a small shake) as a hook.
|
|
533
568
|
It is a pattern, not a piece: you draw the fields, the hook keeps the messages.
|
|
534
569
|
```tsx
|
|
535
570
|
const v = useValidation({
|
|
@@ -538,8 +573,8 @@ const v = useValidation({
|
|
|
538
573
|
});
|
|
539
574
|
<label className={cx('field', v.errors.email && 'is-bad')}>
|
|
540
575
|
<span>Email</span>
|
|
541
|
-
<input className="input" type="email" {...v.field('email')} />
|
|
542
|
-
<small className="field__hint">{v.errors.email || 'We send one email when we launch.'}</small>
|
|
576
|
+
<input className="gk-input" type="email" {...v.field('email')} />
|
|
577
|
+
<small className="gk-field__hint">{v.errors.email || 'We send one email when we launch.'}</small>
|
|
543
578
|
</label>
|
|
544
579
|
<Button variant="primary" onClick={() => v.validate() && join(v.values())}>Join the waitlist</Button>
|
|
545
580
|
```
|
|
@@ -680,7 +715,7 @@ A month calendar with events as small chips. It slides from month to month, and
|
|
|
680
715
|
List rows you slide sideways to show buttons behind them (archive, delete…). A long swipe runs the edge button.
|
|
681
716
|
|
|
682
717
|
```tsx
|
|
683
|
-
<SwipeActions className="card card--flush" onAction={(action, ctx) => {
|
|
718
|
+
<SwipeActions className="gk-card gk-card--flush" onAction={(action, ctx) => {
|
|
684
719
|
if (action === 'cancel') toast('Booking cancelled', { undo: () => ctx.undo() });
|
|
685
720
|
}}>
|
|
686
721
|
{bookings.map((b) => (
|
|
@@ -1051,7 +1086,7 @@ A slanted band of light sweeps across the letters, like light on a shiny sign. T
|
|
|
1051
1086
|
|
|
1052
1087
|
- `look` (`'gradient'` | `'ink'` | `'color'`), `trigger` (`'loop'` | `'view'` | `'hover'`).
|
|
1053
1088
|
- `duration` (1.4), `repeatDelay` (1.8), `delay`, `ease`, `angle` (110°), `width` (12), `color`.
|
|
1054
|
-
- CSS only, no React needed: `<span className="shine shine--ink shine--loop">…</span>`.
|
|
1089
|
+
- CSS only, no React needed: `<span className="gk-shine gk-shine--ink gk-shine--loop">…</span>`.
|
|
1055
1090
|
|
|
1056
1091
|
### Highlighter
|
|
1057
1092
|
|
|
@@ -1107,7 +1142,7 @@ A thin line that fills as the page (or a scrolling box) is read.
|
|
|
1107
1142
|
```
|
|
1108
1143
|
|
|
1109
1144
|
- `root` — the scrolling box (default the page). `onChange(progress)` with 0…1.
|
|
1110
|
-
- Colour and height: `--scroll-progress-c`, `--scroll-progress-h`.
|
|
1145
|
+
- Colour and height: `--gk-scroll-progress-c`, `--gk-scroll-progress-h`.
|
|
1111
1146
|
|
|
1112
1147
|
### Odometer
|
|
1113
1148
|
|
|
@@ -1126,7 +1161,7 @@ A number that rolls digit by digit like a car's meter; only the digits that chan
|
|
|
1126
1161
|
A number that counts up on mount, and from the number on screen to the new one when it changes.
|
|
1127
1162
|
|
|
1128
1163
|
```tsx
|
|
1129
|
-
<div className="kpi"><small>Revenue today</small><b><CountUp value={stats.revenue} prefix="฿" tick /></b></div>
|
|
1164
|
+
<div className="gk-kpi"><small>Revenue today</small><b><CountUp value={stats.revenue} prefix="฿" tick /></b></div>
|
|
1130
1165
|
<CountUp value={4.8} decimals={1} suffix=" / 5" />
|
|
1131
1166
|
```
|
|
1132
1167
|
|
|
@@ -1164,7 +1199,7 @@ The element leans toward the pointer while it hovers and springs back when it le
|
|
|
1164
1199
|
|
|
1165
1200
|
```tsx
|
|
1166
1201
|
<Magnetic strength={0.3}><Button variant="primary" iconRight="arrowR">Book a bike</Button></Magnetic>
|
|
1167
|
-
<Magnetic as="a" href="/bikes" className="btn" magnet={1.5}>See all bikes</Magnetic>
|
|
1202
|
+
<Magnetic as="a" href="/bikes" className="gk-btn" magnet={1.5}>See all bikes</Magnetic>
|
|
1168
1203
|
```
|
|
1169
1204
|
|
|
1170
1205
|
- `strength` (0.2), `strengthY` (0.28), `magnet` — a multiplier for this element.
|
|
@@ -1175,17 +1210,17 @@ The element leans toward the pointer while it hovers and springs back when it le
|
|
|
1175
1210
|
The element rises a few pixels while the pointer is over it: “you can click this”.
|
|
1176
1211
|
|
|
1177
1212
|
```tsx
|
|
1178
|
-
<Lift as="article" y={-6} className="card project-card">…</Lift>
|
|
1213
|
+
<Lift as="article" y={-6} className="gk-card project-card">…</Lift>
|
|
1179
1214
|
```
|
|
1180
1215
|
|
|
1181
|
-
- `y` — px it moves (-4). Pair it with a deeper shadow in your CSS (`:hover { box-shadow: var(--shadow-2) }`).
|
|
1216
|
+
- `y` — px it moves (-4). Pair it with a deeper shadow in your CSS (`:hover { box-shadow: var(--gk-shadow-2) }`).
|
|
1182
1217
|
|
|
1183
1218
|
### Tilt
|
|
1184
1219
|
|
|
1185
1220
|
The card leans toward the pointer in 3D with a soft glare; layers marked `data-depth` float above it.
|
|
1186
1221
|
|
|
1187
1222
|
```tsx
|
|
1188
|
-
<Tilt as="article" className="card" max={12} glare>
|
|
1223
|
+
<Tilt as="article" className="gk-card" max={12} glare>
|
|
1189
1224
|
<img data-depth="30" src="/bikes/e-bike.png" alt="" />
|
|
1190
1225
|
<h3 data-depth="14">City e-bike</h3>
|
|
1191
1226
|
</Tilt>
|
|
@@ -1200,12 +1235,12 @@ A soft light follows the pointer across a group of cards and lights up their edg
|
|
|
1200
1235
|
|
|
1201
1236
|
```tsx
|
|
1202
1237
|
<Spotlight className="plans" size={300}>
|
|
1203
|
-
{plans.map((p) => <div key={p.id} className="card">{p.name} · {p.price}</div>)}
|
|
1238
|
+
{plans.map((p) => <div key={p.id} className="gk-card">{p.name} · {p.price}</div>)}
|
|
1204
1239
|
</Spotlight>
|
|
1205
1240
|
```
|
|
1206
1241
|
|
|
1207
1242
|
- `size` (240 px), `follow` (0.2 s), `border` (true), `fill` (true), `focus` (true), `items` (default: the children).
|
|
1208
|
-
- Colour: `--spot-c`; edge: `--spot-ring`.
|
|
1243
|
+
- Colour: `--gk-spot-c`; edge: `--gk-spot-ring`.
|
|
1209
1244
|
|
|
1210
1245
|
### Marquee
|
|
1211
1246
|
|
|
@@ -1217,7 +1252,7 @@ const pause = useRef<HTMLButtonElement>(null);
|
|
|
1217
1252
|
<Marquee aria-label="Shops that ride with us" speed={50} gap={48} button={pause}>
|
|
1218
1253
|
{partners.map((p) => <img key={p.id} src={p.logo} alt={p.name} height={28} />)}
|
|
1219
1254
|
</Marquee>
|
|
1220
|
-
<button ref={pause} className="btn btn--sm">⏸</button>
|
|
1255
|
+
<button ref={pause} className="gk-btn gk-btn--sm">⏸</button>
|
|
1221
1256
|
```
|
|
1222
1257
|
|
|
1223
1258
|
- Each child becomes one item (`<li>` in a `<ul>`; `listAs` to change).
|
|
@@ -1236,8 +1271,8 @@ import { useMotion } from '@gecko-ui-kit/react';
|
|
|
1236
1271
|
import { rise, shake, tilt } from '@gecko-ui-kit/motion';
|
|
1237
1272
|
|
|
1238
1273
|
// a function of the element; the deps array plays it again
|
|
1239
|
-
const list = useMotion((el) => rise(el.querySelectorAll('.row'), { stagger: 0.04 }), [rows.length]);
|
|
1240
|
-
<div ref={list}>{rows.map((r) => <div key={r.id} className="row">{r.name}</div>)}</div>
|
|
1274
|
+
const list = useMotion((el) => rise(el.querySelectorAll('.gk-row'), { stagger: 0.04 }), [rows.length]);
|
|
1275
|
+
<div ref={list}>{rows.map((r) => <div key={r.id} className="gk-row">{r.name}</div>)}</div>
|
|
1241
1276
|
|
|
1242
1277
|
// play it when something happens
|
|
1243
1278
|
const err = useMotion((el) => (error ? shake(el) : undefined), [error]);
|
|
@@ -1245,7 +1280,7 @@ const err = useMotion((el) => (error ? shake(el) : undefined), [error]);
|
|
|
1245
1280
|
|
|
1246
1281
|
// a helper that takes (el, options): options are compared by content
|
|
1247
1282
|
const card = useMotion(tilt, { max: 8, glare: false });
|
|
1248
|
-
<article ref={card} className="card">…</article>
|
|
1283
|
+
<article ref={card} className="gk-card">…</article>
|
|
1249
1284
|
```
|
|
1250
1285
|
|
|
1251
1286
|
## Interactive effects
|
|
@@ -1257,16 +1292,16 @@ A highlight that stretches toward the newly active item, then snaps into place (
|
|
|
1257
1292
|
import { Indicator } from '@gecko-ui-kit/react';
|
|
1258
1293
|
|
|
1259
1294
|
const [page, setPage] = useState('bikes');
|
|
1260
|
-
<Indicator as="nav" active={page} radius={99} className="menu">
|
|
1295
|
+
<Indicator as="nav" active={page} radius={99} className="gk-menu">
|
|
1261
1296
|
{['bikes', 'bookings', 'returns'].map((p) => (
|
|
1262
1297
|
<button key={p} aria-current={page === p ? 'page' : undefined} onClick={() => setPage(p)}>{p}</button>
|
|
1263
1298
|
))}
|
|
1264
1299
|
</Indicator>
|
|
1265
1300
|
```
|
|
1266
|
-
- `active`: anything that changes when the active item changes; the pill goes to the child with `aria-current`, `aria-selected="true"`, `aria-pressed="true"` or `.is-active` (`selector` to change it).
|
|
1301
|
+
- `active`: anything that changes when the active item changes; the pill goes to the child with `aria-current`, `aria-selected="true"`, `aria-pressed="true"` or `.gk-is-active` (`selector` to change it).
|
|
1267
1302
|
- `radius` (13; 99 = round ends), `line` (an underline), `lead` / `trail` / `cross` (seconds per edge).
|
|
1268
1303
|
- `pillClassName` / `pillStyle` style the pill (default: the accent colour). `as` picks the element.
|
|
1269
|
-
- Hook form for your own markup: `const pill = useIndicator(page, { radius: 99 })`, then `<span ref={pill} className="menu__pill" />` as a child of the menu.
|
|
1304
|
+
- Hook form for your own markup: `const pill = useIndicator(page, { radius: 99 })`, then `<span ref={pill} className="gk-menu__pill" />` as a child of the menu.
|
|
1270
1305
|
|
|
1271
1306
|
### PageSwap
|
|
1272
1307
|
A page transition: when `swapKey` changes, the old page steps back and fades, then the new one slides in from the side you are heading to.
|
|
@@ -1282,7 +1317,7 @@ export default function Template({ children }: { children: React.ReactNode }) {
|
|
|
1282
1317
|
}
|
|
1283
1318
|
```
|
|
1284
1319
|
- `swapKey`: the page's identity (route, tab id). `dir`: `1` forward, `-1` back.
|
|
1285
|
-
- `leave` (blocks that drop out: `.card, .kpi, .lane, [data-swap]`), `head` (header parts that lift away).
|
|
1320
|
+
- `leave` (blocks that drop out: `.gk-card, .gk-kpi, .lane, [data-swap]`), `head` (header parts that lift away).
|
|
1286
1321
|
- `timing`: `{ out, in, shift, enter }` for this swap only. `onSwap(view)` runs when the new page is in.
|
|
1287
1322
|
|
|
1288
1323
|
### useFeedback · useFlash · useTick
|
|
@@ -1455,7 +1490,7 @@ const [open, setOpen] = useState(false);
|
|
|
1455
1490
|
<nav id="main-menu" hidden={!open}>…</nav>
|
|
1456
1491
|
```
|
|
1457
1492
|
- `open` / `defaultOpen` + `onToggle(open, button)` (a click, or Escape when `escape` is on).
|
|
1458
|
-
- `words` (`{ open: 'Open menu', close: 'Close menu' }`), `duration` (0.45 s), `controls` (the menu's id), `size`, `iconClassName` (size the lines with `--burger-w`, `--burger-h`, `--burger-t`).
|
|
1493
|
+
- `words` (`{ open: 'Open menu', close: 'Close menu' }`), `duration` (0.45 s), `controls` (the menu's id), `size`, `iconClassName` (size the lines with `--gk-burger-w`, `--gk-burger-h`, `--gk-burger-t`).
|
|
1459
1494
|
|
|
1460
1495
|
## Overlays
|
|
1461
1496
|
|
|
@@ -1480,6 +1515,7 @@ const editBtn = useRef<HTMLButtonElement>(null);
|
|
|
1480
1515
|
- `open` / `onClose()` — closing from inside (✕, scrim, Esc) calls `onClose`; set `open` to false there.
|
|
1481
1516
|
- `title`, `sub` — text or React nodes; they may change while it is open.
|
|
1482
1517
|
- `size` — `''`, `'sm'` or `'lg'`. `anchor` — element or ref it zooms out of. `footer` — buttons at the bottom.
|
|
1518
|
+
- `words` — `{ close }`, the ✕ button's label for screen readers (default `'Close'`), e.g. `words={{ close: 'ปิด' }}`.
|
|
1483
1519
|
|
|
1484
1520
|
### Drawer
|
|
1485
1521
|
|
|
@@ -1487,12 +1523,12 @@ A panel that slides in from the side (a bottom sheet on phones); its content dri
|
|
|
1487
1523
|
|
|
1488
1524
|
```tsx
|
|
1489
1525
|
<Drawer open={!!rider} onClose={() => setRider(null)} title={rider?.name} sub={`Rider since ${rider?.since}`}
|
|
1490
|
-
head={<span className="av av--teal">{rider?.initials}</span>} footer={<Button variant="primary">Message</Button>}>
|
|
1526
|
+
head={<span className="gk-av gk-av--teal">{rider?.initials}</span>} footer={<Button variant="primary">Message</Button>}>
|
|
1491
1527
|
<RiderBookings id={rider?.id} />
|
|
1492
1528
|
</Drawer>
|
|
1493
1529
|
```
|
|
1494
1530
|
|
|
1495
|
-
- `open` / `onClose()`, `title`, `sub`, `footer` — as in Modal.
|
|
1531
|
+
- `open` / `onClose()`, `title`, `sub`, `footer`, `words` — as in Modal.
|
|
1496
1532
|
- `head` — something before the title (an avatar). `side` — `'right'` (default) or `'left'`.
|
|
1497
1533
|
- Opening a drawer closes any other drawer (its `onClose` runs).
|
|
1498
1534
|
|
|
@@ -1518,7 +1554,7 @@ async function cancelBooking(b: Booking) {
|
|
|
1518
1554
|
A small panel that pops out of its trigger (the one child), with its origin pointing back at it.
|
|
1519
1555
|
|
|
1520
1556
|
```tsx
|
|
1521
|
-
<Popover align="end" label="Share" className="pop--wide"
|
|
1557
|
+
<Popover align="end" label="Share" className="gk-pop--wide"
|
|
1522
1558
|
content={(close) => <ShareBooking id={booking.id} onCopied={() => { close(); toast('Link copied', { icon: 'copy' }); }} />}>
|
|
1523
1559
|
<Button icon="send">Share</Button>
|
|
1524
1560
|
</Popover>
|
|
@@ -1578,7 +1614,7 @@ A small label that fades in under (or beside) an element on hover or keyboard fo
|
|
|
1578
1614
|
|
|
1579
1615
|
```tsx
|
|
1580
1616
|
<Tooltip text="Edit booking"><Button icon="edit" aria-label="Edit booking" /></Tooltip>
|
|
1581
|
-
<Tooltip text={<>Somchai K.<br />Mechanic</>} side="right"><span className="av av--teal" tabIndex={0}>SK</span></Tooltip>
|
|
1617
|
+
<Tooltip text={<>Somchai K.<br />Mechanic</>} side="right"><span className="gk-av gk-av--teal" tabIndex={0}>SK</span></Tooltip>
|
|
1582
1618
|
```
|
|
1583
1619
|
|
|
1584
1620
|
- `text` — a string (a `\n` makes a second line) or React nodes. `side` — `'below'` (default) or `'right'`.
|
|
@@ -1624,7 +1660,7 @@ const [isPending, startTransition] = useTransition();
|
|
|
1624
1660
|
<LoadingBar active={isPending} />
|
|
1625
1661
|
|
|
1626
1662
|
// or by hand
|
|
1627
|
-
const bar = useLoadingBar({ color: 'var(--good)' });
|
|
1663
|
+
const bar = useLoadingBar({ color: 'var(--gk-good)' });
|
|
1628
1664
|
async function save() { bar.start(); try { await api.save(booking); bar.done(); } catch { bar.fail(); } }
|
|
1629
1665
|
```
|
|
1630
1666
|
|
|
@@ -1704,7 +1740,7 @@ markup as `createShell()` (so they render on the server), but the router is Next
|
|
|
1704
1740
|
|
|
1705
1741
|
### AppShell
|
|
1706
1742
|
|
|
1707
|
-
The whole frame around your pages: Sidebar, Topbar, the page in `<main class="view">`, the phone tab bar, the ⌘K
|
|
1743
|
+
The whole frame around your pages: Sidebar, Topbar, the page in `<main class="gk-view">`, the phone tab bar, the ⌘K
|
|
1708
1744
|
palette, keyboard shortcuts and the opening animation. When the path changes, the new page slides in from the
|
|
1709
1745
|
direction of travel.
|
|
1710
1746
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gecko-ui-kit/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Every Gecko UI Kit piece as a React component (Next.js ready): buttons, forms, pickers, data display, charts, motion, overlays and the app shell.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@gecko-ui-kit/tokens": "^0.
|
|
37
|
-
"@gecko-ui-kit/icons": "^0.
|
|
38
|
-
"@gecko-ui-kit/motion": "^0.
|
|
39
|
-
"@gecko-ui-kit/components": "^0.
|
|
40
|
-
"@gecko-ui-kit/overlays": "^0.
|
|
41
|
-
"@gecko-ui-kit/shell": "^0.
|
|
36
|
+
"@gecko-ui-kit/tokens": "^0.3.0",
|
|
37
|
+
"@gecko-ui-kit/icons": "^0.4.0",
|
|
38
|
+
"@gecko-ui-kit/motion": "^0.10.0",
|
|
39
|
+
"@gecko-ui-kit/components": "^0.23.0",
|
|
40
|
+
"@gecko-ui-kit/overlays": "^0.8.0",
|
|
41
|
+
"@gecko-ui-kit/shell": "^0.4.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"gsap": "^3.12.0",
|
package/src/actions.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export interface SpeedDialProps extends HostProps {
|
|
|
143
143
|
side?: 'right' | 'left';
|
|
144
144
|
/** false = icons only (default true). */
|
|
145
145
|
labels?: boolean;
|
|
146
|
-
/** Pinned to the corner of the screen (--sd-x / --sd-y set the gap). */
|
|
146
|
+
/** Pinned to the corner of the screen (--gk-sd-x / --gk-sd-y set the gap). */
|
|
147
147
|
fixed?: boolean;
|
|
148
148
|
/** The main button's icon (default 'plus'; it turns into an ×). */
|
|
149
149
|
icon?: string;
|
package/src/actions.js
CHANGED
|
@@ -24,9 +24,9 @@ function useHandleRef(ref, cur) {
|
|
|
24
24
|
return proxy.current;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const TONES = { accent: 'var(--accent)', good: 'var(--good)', warn: 'var(--warn)', bad: 'var(--bad)' };
|
|
27
|
+
const TONES = { accent: 'var(--gk-accent)', good: 'var(--gk-good)', warn: 'var(--gk-warn)', bad: 'var(--gk-bad)' };
|
|
28
28
|
const HUES = ['indigo', 'teal', 'rose', 'amber', 'violet', 'green', 'slate', 'sky'];
|
|
29
|
-
const toColor = (t) => (!t ? '' : TONES[t] || (HUES.includes(t) ? `var(--hue-${t})` : String(t)));
|
|
29
|
+
const toColor = (t) => (!t ? '' : TONES[t] || (HUES.includes(t) ? `var(--gk-hue-${t})` : String(t)));
|
|
30
30
|
const withVar = (name, c, style) => (c ? { [name]: c, ...style } : style);
|
|
31
31
|
const wordsKey = (w) => JSON.stringify(w || {}); // the text words (functions are read live or ignored)
|
|
32
32
|
|
|
@@ -88,19 +88,19 @@ export const LikeButton = forwardRef(function LikeButton({ kind, pressed, defaul
|
|
|
88
88
|
|
|
89
89
|
return h('button', {
|
|
90
90
|
key: shape, ref: btn, type: 'button', ...rest,
|
|
91
|
-
className: cx('lk', 'lk--' + k, iconOnly && 'lk--icon', size && 'lk--' + size, className),
|
|
91
|
+
className: cx('gk-lk', 'gk-lk--' + k, iconOnly && 'gk-lk--icon', size && 'gk-lk--' + size, className),
|
|
92
92
|
'aria-pressed': s.on, 'data-kind': k, 'data-label': L, 'data-on-label': OL || undefined, 'data-count': hasCount ? s.n : undefined,
|
|
93
|
-
style: withVar('--lk-c', toColor(tone), style),
|
|
93
|
+
style: withVar('--gk-lk-c', toColor(tone), style),
|
|
94
94
|
...(iconOnly ? { 'aria-label': s.aria } : {}),
|
|
95
95
|
},
|
|
96
|
-
h('span', { className: 'lk__icon', 'aria-hidden': true },
|
|
97
|
-
k === 'bookmark' ? null : h('span', { className: 'lk__ring' }),
|
|
98
|
-
h('span', { className: 'lk__bits' }, Array.from({ length: k === 'bookmark' ? 4 : 8 }, (_, i) => h('i', { key: i }))),
|
|
99
|
-
h('span', { className: 'lk__glyph' }, h('span', { className: 'lk__line' }, lkSvg(k)), h('span', { className: 'lk__solid' }, lkSvg(k)))),
|
|
96
|
+
h('span', { className: 'gk-lk__icon', 'aria-hidden': true },
|
|
97
|
+
k === 'bookmark' ? null : h('span', { className: 'gk-lk__ring' }),
|
|
98
|
+
h('span', { className: 'gk-lk__bits' }, Array.from({ length: k === 'bookmark' ? 4 : 8 }, (_, i) => h('i', { key: i }))),
|
|
99
|
+
h('span', { className: 'gk-lk__glyph' }, h('span', { className: 'gk-lk__line' }, lkSvg(k)), h('span', { className: 'gk-lk__solid' }, lkSvg(k)))),
|
|
100
100
|
iconOnly ? null : [
|
|
101
|
-
swap ? h('span', { key: 'sr', className: 'lk__sr' }, L) : null,
|
|
102
|
-
h('span', { key: 'l', className: 'lk__label', 'aria-hidden': swap ? true : undefined }, s.on && swap ? OL : L),
|
|
103
|
-
hasCount ? h('span', { key: 'c', className: 'lk__count' }, h('span', { className: 'lk__num' }, s.num)) : null,
|
|
101
|
+
swap ? h('span', { key: 'sr', className: 'gk-lk__sr' }, L) : null,
|
|
102
|
+
h('span', { key: 'l', className: 'gk-lk__label', 'aria-hidden': swap ? true : undefined }, s.on && swap ? OL : L),
|
|
103
|
+
hasCount ? h('span', { key: 'c', className: 'gk-lk__count' }, h('span', { className: 'gk-lk__num' }, s.num)) : null,
|
|
104
104
|
]);
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -148,23 +148,23 @@ export const BellSwitch = forwardRef(function BellSwitch({ on, defaultOn = false
|
|
|
148
148
|
const name = label ?? W.label;
|
|
149
149
|
return h('button', {
|
|
150
150
|
key: shape, ref: btn, type: 'button', role: 'switch', ...rest,
|
|
151
|
-
className: cx('nbell', iconOnly && 'nbell--icon', className),
|
|
151
|
+
className: cx('gk-nbell', iconOnly && 'gk-nbell--icon', className),
|
|
152
152
|
'aria-checked': s.on,
|
|
153
153
|
...(iconOnly ? { 'aria-label': typeof name === 'string' ? name : W.label } : { 'aria-labelledby': id }),
|
|
154
154
|
'data-on-text': W.on, 'data-off-text': W.off,
|
|
155
|
-
style: withVar('--nb-c', toColor(tone), style),
|
|
155
|
+
style: withVar('--gk-nb-c', toColor(tone), style),
|
|
156
156
|
},
|
|
157
|
-
h('span', { className: 'nbell__icon', dangerouslySetInnerHTML: { __html: bellSvg(s.on) } }),
|
|
158
|
-
iconOnly ? null : h('span', { className: 'nbell__text' },
|
|
159
|
-
h('b', { className: 'nbell__label', id }, name),
|
|
160
|
-
h('small', { className: 'nbell__state', 'aria-hidden': true }, h('span', null, s.on ? W.on : W.off))));
|
|
157
|
+
h('span', { className: 'gk-nbell__icon', dangerouslySetInnerHTML: { __html: bellSvg(s.on) } }),
|
|
158
|
+
iconOnly ? null : h('span', { className: 'gk-nbell__text' },
|
|
159
|
+
h('b', { className: 'gk-nbell__label', id }, name),
|
|
160
|
+
h('small', { className: 'gk-nbell__state', 'aria-hidden': true }, h('span', null, s.on ? W.on : W.off))));
|
|
161
161
|
});
|
|
162
162
|
/** The same component as BellSwitch, under the name of the vanilla builder bellBtn(). */
|
|
163
163
|
export const BellButton = BellSwitch;
|
|
164
164
|
|
|
165
165
|
/* ------------------------------------------------------------------ PayButton */
|
|
166
166
|
const PAY_WORDS = { label: 'Pay now', busy: 'Processing', done: 'Paid', retry: 'Try again' };
|
|
167
|
-
const PAY_STATES = ['is-busy', 'is-done', 'is-failed'];
|
|
167
|
+
const PAY_STATES = ['gk-is-busy', 'gk-is-done', 'gk-is-failed'];
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
* <PayButton label="Pay ฿700" block onPay={() => checkout(cart)} onDone={(receipt) => show(receipt)} onFail={(e) => …} />
|
|
@@ -178,7 +178,7 @@ export const PayButton = forwardRef(function PayButton({ label, variant = 'dark'
|
|
|
178
178
|
const btn = useRef(null), cur = useRef(null);
|
|
179
179
|
const latest = useLatest({ onPay, onDone, onFail });
|
|
180
180
|
const proxy = useHandleRef(ref, cur);
|
|
181
|
-
const cls = cx('btn', variant && 'btn--' + variant, size && 'btn--' + size, block && 'btn--block', 'pay', className);
|
|
181
|
+
const cls = cx('gk-btn', variant && 'gk-btn--' + variant, size && 'gk-btn--' + size, block && 'gk-btn--block', 'gk-pay', className);
|
|
182
182
|
|
|
183
183
|
useIsoLayoutEffect(() => {
|
|
184
184
|
const x = C.payButton(btn.current, {
|
|
@@ -193,20 +193,20 @@ export const PayButton = forwardRef(function PayButton({ label, variant = 'dark'
|
|
|
193
193
|
useIsoLayoutEffect(() => { const x = cur.current; if (x) Object.assign(x.opts, { card, minBusy, back }); });
|
|
194
194
|
useIsoLayoutEffect(() => { // React wrote a new class list: put the state classes back
|
|
195
195
|
const x = cur.current, b = btn.current; if (!x || !b) return;
|
|
196
|
-
PAY_STATES.forEach((c) => b.classList.toggle(c, c === 'is-' + (x.state === 'failed' ? 'failed' : x.state)));
|
|
197
|
-
b.classList.toggle('is-still', x.state === 'busy' && M.RM());
|
|
196
|
+
PAY_STATES.forEach((c) => b.classList.toggle(c, c === 'gk-is-' + (x.state === 'failed' ? 'failed' : x.state)));
|
|
197
|
+
b.classList.toggle('gk-is-still', x.state === 'busy' && M.RM());
|
|
198
198
|
}, [cls]);
|
|
199
199
|
|
|
200
200
|
return h('button', { ref: btn, type: 'button', ...rest, className: cls },
|
|
201
|
-
h('span', { className: 'pay__face pay__idle' }, iconNode(icon || null), h('span', { className: 'pay__label' }, label ?? W.label)),
|
|
202
|
-
h('span', { className: 'pay__face pay__busy', 'aria-hidden': true }, h('span', null, W.busy), h('span', { className: 'pay__dots' }, h('i'), h('i'), h('i'))),
|
|
203
|
-
h('span', { className: 'pay__face pay__done', 'aria-hidden': true },
|
|
204
|
-
h('svg', { className: 'pay__tick', viewBox: '0 0 24 24', 'aria-hidden': true, focusable: 'false' },
|
|
201
|
+
h('span', { className: 'gk-pay__face gk-pay__idle' }, iconNode(icon || null), h('span', { className: 'gk-pay__label' }, label ?? W.label)),
|
|
202
|
+
h('span', { className: 'gk-pay__face gk-pay__busy', 'aria-hidden': true }, h('span', null, W.busy), h('span', { className: 'gk-pay__dots' }, h('i'), h('i'), h('i'))),
|
|
203
|
+
h('span', { className: 'gk-pay__face gk-pay__done', 'aria-hidden': true },
|
|
204
|
+
h('svg', { className: 'gk-pay__tick', viewBox: '0 0 24 24', 'aria-hidden': true, focusable: 'false' },
|
|
205
205
|
h('path', { d: 'm5 12.5 4.5 4.5L19 7.5', pathLength: 1, strokeDasharray: '1 2', strokeDashoffset: 1 })),
|
|
206
206
|
h('span', null, W.done)),
|
|
207
|
-
h('span', { className: 'pay__face pay__fail', 'aria-hidden': true }, h(Icon, { name: 'alert' }), h('span', null, W.retry)),
|
|
208
|
-
h('span', { className: 'pay__slot', 'aria-hidden': true }, h('i')),
|
|
209
|
-
h('span', { className: 'pay__card', 'aria-hidden': true }));
|
|
207
|
+
h('span', { className: 'gk-pay__face gk-pay__fail', 'aria-hidden': true }, h(Icon, { name: 'alert' }), h('span', null, W.retry)),
|
|
208
|
+
h('span', { className: 'gk-pay__slot', 'aria-hidden': true }, h('i')),
|
|
209
|
+
h('span', { className: 'gk-pay__card', 'aria-hidden': true }));
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
/* ------------------------------------------------------------------ SpeedDial */
|
package/src/basics.d.ts
CHANGED
|
@@ -180,7 +180,7 @@ export interface TableProps<R = any> extends React.TableHTMLAttributes<HTMLTable
|
|
|
180
180
|
rowKey?: string | ((row: R, index: number) => React.Key);
|
|
181
181
|
/** Rows for a <tfoot> (e.g. a total row). */
|
|
182
182
|
foot?: React.ReactNode;
|
|
183
|
-
/** Wrap in .table-wrap so it scrolls sideways on small screens (default true). */
|
|
183
|
+
/** Wrap in .gk-table-wrap so it scrolls sideways on small screens (default true). */
|
|
184
184
|
wrap?: boolean;
|
|
185
185
|
/** Rows slide in when they first appear (also rows added later). */
|
|
186
186
|
slideRows?: boolean;
|