ab-nextjs-components 0.4.2 โ 0.6.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/CHANGELOG.md +81 -17
- package/README.md +16 -2
- package/ab-app-bar/index.tsx +5 -5
- package/ab-app-bar/styles.module.css +5 -5
- package/ab-bottom-drawer/index.tsx +3 -3
- package/ab-bottom-drawer/styles.module.css +2 -2
- package/ab-bottom-drawer/use-ab-swipe-down.ts +1 -1
- package/ab-breadcrumbs/index.tsx +1 -1
- package/ab-breadcrumbs/styles.module.css +5 -5
- package/ab-button/index.tsx +1 -1
- package/ab-button/styles.module.css +5 -5
- package/ab-callout/index.tsx +1 -1
- package/ab-callout/styles.module.css +1 -1
- package/ab-carousel/helpers.ts +1 -1
- package/ab-carousel/index.tsx +4 -4
- package/ab-carousel/styles.module.css +2 -2
- package/ab-chip/styles.module.css +1 -1
- package/ab-code-block/focus.tsx +63 -0
- package/ab-code-block/index.tsx +55 -28
- package/ab-code-block/styles.module.css +4 -3
- package/ab-content-tabs/index.tsx +25 -3
- package/ab-demo-box/index.tsx +45 -7
- package/ab-demo-box/styles.module.css +19 -7
- package/ab-demo-code/index.tsx +38 -34
- package/ab-demo-code/styles.module.css +3 -41
- package/ab-doc-pager/index.tsx +1 -1
- package/ab-drawer/gestures.ts +1 -1
- package/ab-drawer/index.tsx +12 -4
- package/ab-drawer/kit.module.css +13 -13
- package/ab-drawer/styles.module.css +2 -2
- package/ab-drawer/use-ab-edge-swipe.ts +2 -2
- package/ab-flow-diagram/helpers.ts +2 -2
- package/ab-flow-diagram/index.tsx +2 -2
- package/ab-flow-diagram/styles.module.css +3 -3
- package/ab-icon/builtin.ts +4 -0
- package/ab-icon/helpers.ts +1 -1
- package/ab-icon/index.tsx +3 -3
- package/ab-icon/registrar.tsx +1 -1
- package/ab-icon-button/index.tsx +1 -1
- package/ab-install-snippet/styles.module.css +1 -1
- package/ab-link/index.tsx +2 -2
- package/ab-link/locale.ts +1 -1
- package/ab-list/styles.module.css +1 -1
- package/ab-locale-switcher/index.tsx +6 -6
- package/ab-locale-switcher/styles.module.css +5 -5
- package/ab-mobile-header/index.tsx +6 -6
- package/ab-nav-drawer/index.tsx +11 -6
- package/ab-navbar/index.tsx +1 -1
- package/ab-navbar/styles.module.css +1 -1
- package/ab-navbar/view.tsx +1 -1
- package/ab-package-card/index.tsx +3 -3
- package/ab-package-card/previews.tsx +1 -1
- package/ab-package-card/styles.module.css +2 -2
- package/ab-playground-scene/i18n.module.css +1 -1
- package/ab-playground-scene/icons.tsx +1 -1
- package/ab-playground-scene/index.tsx +4 -4
- package/ab-playground-scene/labels.ts +3 -3
- package/ab-playground-scene/scenes.tsx +4 -4
- package/ab-playground-scene/styles.module.css +6 -6
- package/ab-playground-scene/upgraded.tsx +3 -3
- package/ab-playground-scene/welcome.tsx +1 -1
- package/ab-preview-code/index.tsx +115 -0
- package/ab-preview-code/stage.tsx +153 -0
- package/ab-preview-code/styles.module.css +43 -0
- package/ab-progress-chips/index.tsx +1 -1
- package/ab-search-drawer/index.tsx +4 -4
- package/ab-search-trigger/index.tsx +5 -5
- package/ab-search-trigger/styles.module.css +3 -3
- package/ab-settings-drawer/index.tsx +2 -2
- package/ab-sidebar/active.ts +105 -0
- package/ab-sidebar/index.tsx +10 -6
- package/ab-sidebar/profile-button.tsx +2 -2
- package/ab-sidebar/styles.module.css +4 -4
- package/ab-sidebar/view.tsx +16 -8
- package/ab-theme-mode/index.tsx +3 -3
- package/ab-theme-toggle/index.tsx +6 -6
- package/ab-theme-toggle/styles.module.css +2 -2
- package/ab-toc/index.tsx +3 -3
- package/ab-toc/promo.tsx +2 -2
- package/ab-toc/styles.module.css +1 -1
- package/ab-toc-drawer/index.tsx +1 -1
- package/ab-version-switcher/index.tsx +2 -2
- package/css/dialog.css +1 -1
- package/index.ts +29 -18
- package/package.json +3 -1
- package/server/ab-button/index.tsx +1 -1
- package/server/ab-icon/index.tsx +2 -2
- package/server/ab-sidebar/index.tsx +3 -2
- package/types/index.d.ts +8 -7
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
// โ๏ธ types
|
|
40
40
|
import type { ReactElement } from 'react';
|
|
41
41
|
|
|
42
|
-
// ๐ผ๏ธ
|
|
42
|
+
// ๐ผ๏ธ the tiny line icons (welcome-v6 scenes.py `MS` + v5 common.py package icons), decorative only
|
|
43
43
|
const MS: Record<string, ReactElement> = {
|
|
44
44
|
home: <path d="M4 11 12 4l8 7v9h-5v-6H9v6H4z" />,
|
|
45
45
|
search: <><circle cx="11" cy="11" r="6" /><path d="m20 20-4.5-4.5" /></>,
|
|
@@ -42,7 +42,7 @@ import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
|
42
42
|
import clsx from 'clsx';
|
|
43
43
|
// ใฐ๏ธ the engine: AbFlowDiagram's v6 frame mode
|
|
44
44
|
import AbFlowDiagram from '../ab-flow-diagram';
|
|
45
|
-
// ๐งฑ
|
|
45
|
+
// ๐งฑ the scene data
|
|
46
46
|
import { AB_PLAYGROUND_SCENE_PACKAGES, buildAbPlaygroundCompactScene, buildAbPlaygroundFullScene } from './scenes';
|
|
47
47
|
// ๐ labels
|
|
48
48
|
import { AB_PLAYGROUND_LOCALES, resolveAbPlaygroundSceneLabels, type AbPlaygroundSceneLabelsInput, type AbPlaygroundSceneName } from './labels';
|
|
@@ -65,10 +65,10 @@ export const AB_PLAYGROUND_FRAMES = {
|
|
|
65
65
|
|
|
66
66
|
// โ๏ธ props
|
|
67
67
|
export interface AbPlaygroundSceneProps {
|
|
68
|
-
/** ๐๏ธ which package scene (
|
|
68
|
+
/** ๐๏ธ which package scene (the v6 1โ7, and illustration 8 `i18n`). */
|
|
69
69
|
name: AbPlaygroundSceneName;
|
|
70
70
|
/** ๐ `'full'` = 760ร600 laptop scene, `'compact'` = 350ร276 mobile scene. Default `'full'`.
|
|
71
|
-
* ๐ 0.2.3
|
|
71
|
+
* ๐ 0.2.3 `'auto'` = SSR-safe: BOTH are rendered and a CSS media query shows compact below 768px
|
|
72
72
|
* and full from 768px, so phones never flash the full scene and there is no hydration mismatch (no JS decides). */
|
|
73
73
|
variant?: 'full' | 'compact' | 'auto';
|
|
74
74
|
/** โถ๏ธ animate only while its slide is active (default true); reduced motion is always respected. */
|
|
@@ -91,7 +91,7 @@ export interface AbPlaygroundSceneProps {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
* ๐จ AbPlaygroundScene โ the Welcome "Live Playground" scenes from
|
|
94
|
+
* ๐จ AbPlaygroundScene โ the Welcome "Live Playground" scenes from the welcome-v6 mock, faithfully: same rects,
|
|
95
95
|
* same auto-routed wires (route() + rounded()), dotted surface, anchors, travelling pulses, card + header.
|
|
96
96
|
* Server-compatible (AbFlowDiagram's tiny scale island is the only client code). One accessible image (translated alt).
|
|
97
97
|
*/
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
// ๐ every visible WORD in the scenes (code, package names and file names stay as they are, like the mock).
|
|
40
40
|
// Pass `labels={{ ... }}` (e.g. from next-intl / the Welcome messages) to translate; missing keys fall back to English.
|
|
41
41
|
|
|
42
|
-
/** ๐๏ธ the 8 scene names (
|
|
43
|
-
/** ๐๏ธ 0.2.3
|
|
42
|
+
/** ๐๏ธ the 8 scene names (the v6 1โ7 + illustration 8 `i18n`) */
|
|
43
|
+
/** ๐๏ธ 0.2.3: + `welcome` (v6 s01, every package around the Ab mark) and `all` (v6 s09, the final slide) */
|
|
44
44
|
export type AbPlaygroundSceneName = 'core' | 'components' | 'theme' | 'icons' | 'fonts' | 'animations' | 'hooks' | 'i18n' | 'welcome' | 'all';
|
|
45
45
|
|
|
46
46
|
/** ๐ the 4 demo locales of the i18n scene, in cycle order (EN โ FR โ ES โ RU, 0.6s each) */
|
|
@@ -83,7 +83,7 @@ export const AB_PLAYGROUND_SCENE_LABELS = {
|
|
|
83
83
|
reduceAnimations: 'reduce animations', list: 'list', stagger: 'stagger', transition: 'transition', fadeSlide: 'fade ยท slide',
|
|
84
84
|
// ๐ช hooks
|
|
85
85
|
keyboard: 'keyboard', storage: 'storage', copy: 'copy', hooks: 'Hooks', scrollSpy: 'scroll spy',
|
|
86
|
-
// ๐ i18n (
|
|
86
|
+
// ๐ i18n (the illustration 8)
|
|
87
87
|
messages: 'messages', switcher: 'switcher', translations: 'translations', provider: 'provider', prefix: 'prefix',
|
|
88
88
|
intlFormat: 'Intl format',
|
|
89
89
|
// ๐ welcome + all (v6 s01 / s09)
|
|
@@ -46,7 +46,7 @@ import type { AbPlaygroundSceneLabels, AbPlaygroundSceneName } from './labels';
|
|
|
46
46
|
import { buildI18nCompact, buildI18nFull } from './i18n';
|
|
47
47
|
// ๐ 0.2.3: v6 s01 (welcome) + s09 (all)
|
|
48
48
|
import { buildAllCompact, buildAllFull, buildWelcomeCompact, buildWelcomeFull } from './welcome';
|
|
49
|
-
// ๐จ 0.2.3
|
|
49
|
+
// ๐จ 0.2.3: the upgraded package scenes
|
|
50
50
|
import { buildAnimationsUp, buildComponentsUp, buildCoreUp, buildFontsUp, buildHooksUp, buildIconsUp, buildThemeUp } from './upgraded';
|
|
51
51
|
|
|
52
52
|
// ๐ฆ v6 PKG
|
|
@@ -68,7 +68,7 @@ const N = (x: number, y: number, w: number, h: number, content: ReactNode, capti
|
|
|
68
68
|
export function buildAbPlaygroundFullScene(name: AbPlaygroundSceneName, L: AbPlaygroundSceneLabels, logo: ReactNode, still = 0): AbPlaygroundSceneData {
|
|
69
69
|
seq = 0;
|
|
70
70
|
switch (name) {
|
|
71
|
-
// ๐จ 0.2.3
|
|
71
|
+
// ๐จ 0.2.3: the Welcome v6 UPGRADED scenes (playground-spec.md rev 2): real export captions,
|
|
72
72
|
// 4 states ร 0.6s, reduced-motion still = state 0. Motion = ab-nextjs-animations' state cycle (upgraded.tsx)
|
|
73
73
|
case 'core': return { nodes: buildCoreUp(N, false) };
|
|
74
74
|
case 'components': return { nodes: buildComponentsUp(N, false, logo) };
|
|
@@ -79,7 +79,7 @@ export function buildAbPlaygroundFullScene(name: AbPlaygroundSceneName, L: AbPla
|
|
|
79
79
|
case 'hooks': return { nodes: buildHooksUp(N, false, logo) };
|
|
80
80
|
case 'welcome': return buildWelcomeFull(N, L, logo); // ๐ v6 s01
|
|
81
81
|
case 'all': return buildAllFull(N, L, logo); // ๐ v6 s09
|
|
82
|
-
default: return { nodes: buildI18nFull(N, L, still) }; // ๐
|
|
82
|
+
default: return { nodes: buildI18nFull(N, L, still) }; // ๐ the illustration 8 (`still` = the reduced-motion locale)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -88,7 +88,7 @@ export function buildAbPlaygroundCompactScene(name: AbPlaygroundSceneName, L: Ab
|
|
|
88
88
|
seq = 0;
|
|
89
89
|
const sc = (...n: AbFlowNode[]): AbPlaygroundSceneData => ({ nodes: n });
|
|
90
90
|
switch (name) {
|
|
91
|
-
// ๐จ 0.2.3
|
|
91
|
+
// ๐จ 0.2.3: upgraded mobile scenes (3 nodes + hub at y 122 / h 58; bottom caption right of the wire)
|
|
92
92
|
case 'core': return sc(...buildCoreUp(N, true));
|
|
93
93
|
case 'components': return sc(...buildComponentsUp(N, true, logo));
|
|
94
94
|
case 'theme': return sc(...buildThemeUp(N, true));
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
/* ===== AB PLAYGROUND SCENE STYLES ===== */
|
|
40
|
-
/* ๐จ
|
|
40
|
+
/* ๐จ the welcome-v6 scene content classes (scenes.py css()), scoped to this module. No motion here:
|
|
41
41
|
wires, pulses and the ease dot all ride ab-nextjs-animations' wire classes (reduced motion included). */
|
|
42
|
-
/* ๐ 0.2.3
|
|
42
|
+
/* ๐ 0.2.3: the card is v6's ORIGINAL --card via theme โฅ 0.3.7 `--ab-color-welcome-card`, so the white /
|
|
43
43
|
warmer gapped-desktop card tokens never leak in (fallbacks = the v6 values) */
|
|
44
44
|
.scene { --ab-flow-card: var(--ab-color-welcome-card, #fff); }
|
|
45
45
|
:global(:is(.dark, [data-theme="dark"])) .scene { --ab-flow-card: var(--ab-color-welcome-card, #241a12); }
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
.pnode { display: flex; flex-direction: column; gap: 9px; align-items: flex-start; width: 100%; padding: 0 14px; box-sizing: border-box; } /* ๐ฆ v6 pnode */
|
|
98
98
|
.swSm { display: block; width: 18px; height: 24px; border-radius: 5px; border: 1px solid var(--ab-flow-line, rgb(107 79 53 / 0.16)); box-sizing: border-box; } /* ๐จ */
|
|
99
99
|
.mchip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; white-space: nowrap; } /* ๐ v6 .mchip */
|
|
100
|
-
/* ๐จ 0.2.3
|
|
100
|
+
/* ๐จ 0.2.3 the Welcome v6 UPGRADED scenes (upgraded.tsx). Layout + colour only: every bit of motion is
|
|
101
101
|
ab-nextjs-animations' .ab-state-cycle-* (4 states ร 600ms = 2.4s), which also owns the still frame + reduced motion. */
|
|
102
102
|
.scene { --ab-state-cycle-duration: var(--ab-wire-pulse-duration, 2400ms); --ab-state-cycle-on-fg: #fff8f5; --ab-state-cycle-off-fg: var(--ab-flow-muted, rgb(33 26 22 / 0.62)); --ab-state-cycle-switch-off: var(--pg-chip); --ab-state-cycle-knob-travel: 22px; }
|
|
103
103
|
.ic { display: inline-flex; flex: none; } /* ๐ฃ real ab-nextjs-icons SVG */
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
.cyCentre { right: 0; display: flex; justify-content: center; } /* โ๏ธ centred without transform (the cycle owns transform) */
|
|
108
108
|
.segCycle > span { white-space: nowrap; } /* ๐๏ธ chips: colours come from .ab-state-cycle-chip */
|
|
109
109
|
.wts { display: flex; gap: 2px; } /* โญ weight picker */
|
|
110
|
-
.wt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 4px; border-radius: 7px; border: 1px solid transparent; --ab-state-cycle-hl-border: transparent; } /* โญ
|
|
110
|
+
.wt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 4px; border-radius: 7px; border: 1px solid transparent; --ab-state-cycle-hl-border: transparent; } /* โญ tint only */
|
|
111
111
|
.tog2 { width: 50px; height: 28px; border-radius: 999px; position: relative; flex: none; display: block; } /* ๐ track (colour = the cycle) */
|
|
112
112
|
.knob { position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff8f5; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); } /* โช */
|
|
113
113
|
.lpTrack { display: block; height: 4px; border-radius: 2px; background: var(--pg-chip); overflow: hidden; } /* โ */
|
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
.radiusTile { display: block; width: 30px; height: 28px; border: 2px solid var(--pg-bronze); box-sizing: border-box; } /* ๐ฒ */
|
|
138
138
|
/* ๐ฃ icons */
|
|
139
139
|
.icGrid { display: grid; grid-template-columns: repeat(6, 38px); gap: 8px 10px; } /* ๐ฃ */
|
|
140
|
-
.icCell { display: flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid transparent; box-sizing: border-box; --ab-state-cycle-hl-border: transparent; } /* ๐ฃ
|
|
141
|
-
/* ๐ 0.2.3
|
|
140
|
+
.icCell { display: flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid transparent; box-sizing: border-box; --ab-state-cycle-hl-border: transparent; } /* ๐ฃ tint only (his cells have no border) */
|
|
141
|
+
/* ๐ 0.2.3 variant="auto": both scenes ship, CSS picks one (SSR-safe, no flash, no hydration mismatch) */
|
|
142
142
|
.auto { display: contents; } /* ๐ซฅ no extra box */
|
|
143
143
|
.autoCompact.autoCompact { display: none; } /* ๐ฅ๏ธ โฅ 768px: full */
|
|
144
144
|
@media (width < 768px) {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
// ๐จ 0.2.3 (
|
|
39
|
+
// ๐จ 0.2.3 (the Welcome v6 "upgraded" designs): the 7 package scenes, 1:1 with
|
|
40
40
|
// ai-mocks/welcome-v6/upgraded/_src/build_upgraded.py + playground-spec.md rev 2 (real export names as captions,
|
|
41
41
|
// 4 states ร 0.6s = one 2.4s loop, reduced-motion still = state 0). ALL motion = ab-nextjs-animations' state cycle.
|
|
42
42
|
|
|
@@ -65,7 +65,7 @@ import article from 'ab-nextjs-icons/ab-icons/icons/article';
|
|
|
65
65
|
// ๐จ mock content classes
|
|
66
66
|
import s from './styles.module.css';
|
|
67
67
|
|
|
68
|
-
// ๐ฅ
|
|
68
|
+
// ๐ฅ the bronze
|
|
69
69
|
const BRONZE = '#A67C52';
|
|
70
70
|
// ๐ the 4 locale chips
|
|
71
71
|
const LOC = ['EN', 'FR', 'ES', 'RU'];
|
|
@@ -236,7 +236,7 @@ export function buildIconsUp(N: AbPgMk, compact: boolean): AbFlowNode[] {
|
|
|
236
236
|
const wts: Array<[number, number]> = [[100, 0.7], [200, 1.25], [400, 1.9], [700, 2.8]];
|
|
237
237
|
return [
|
|
238
238
|
N(220, 262, 320, 124, <span className={s.icGrid}>{names.map((n, i) => cell(n, i, 22, 38))}</span>, 'abIconNames', true),
|
|
239
|
-
// โญ
|
|
239
|
+
// โญ the weight picker steps with a soft highlight (his `[data-on]` has no chip fill here), same as the grid
|
|
240
240
|
N(40, 100, 210, 96, <span className={s.wts}>{wts.map(([w, sw], i) => <span key={w} {...hl(i, s.wt, 'transparent')}><Ic n="star" sz={22} sw={sw} /><span className={s.m} style={{ fontSize: 9.5 }}>{w}</span></span>)}</span>, 'abIconWeights'),
|
|
241
241
|
N(290, 112, 180, 64, <M><Br>200</Br></M>, 'abIconDefaultWeight'),
|
|
242
242
|
N(510, 104, 210, 84, <M><Br>getAbIconSvg</Br>(<Sg>"anchor"</Sg>)</M>, 'getAbIconSvg()'),
|
|
@@ -47,7 +47,7 @@ import type { AbPlaygroundSceneLabels } from './labels';
|
|
|
47
47
|
// ๐จ shared mock classes (.m, .br, .b1, .tog, .t13โฆ)
|
|
48
48
|
import s from './styles.module.css';
|
|
49
49
|
|
|
50
|
-
// ๐ฅ
|
|
50
|
+
// ๐ฅ the bronze
|
|
51
51
|
const BRONZE = '#A67C52';
|
|
52
52
|
// ๐จ v6 palette (theme swatches)
|
|
53
53
|
const PALETTE = ['#6B4F35', '#A67C52', '#D9BE9C', '#FFF8F5', '#19120C'];
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-components
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-components
|
|
27
|
+
* @name: AbPreviewCode (G16, 0.6.0)
|
|
28
|
+
* @file: ab-preview-code/index.tsx
|
|
29
|
+
* @type: Server component (AbContentTabs + the copy button are the only client islands)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage (MDX):
|
|
33
|
+
* 1+|> <AbPreviewCode label="Button" code={`<AbButton label="Save" />`}>
|
|
34
|
+
* -|> <AbButton label="Save" />
|
|
35
|
+
* -|> </AbPreviewCode>
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
* MOTTO: We'll always do more ๐!!!
|
|
41
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
// โ๏ธ React
|
|
45
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
46
|
+
// ๐งต classes
|
|
47
|
+
import clsx from 'clsx';
|
|
48
|
+
// ๐๏ธ WAI-ARIA tabs (client island)
|
|
49
|
+
import AbContentTabs, { AbContentTab } from '../ab-content-tabs';
|
|
50
|
+
// ๐งช the preview scope's scheme type
|
|
51
|
+
import type { AbDemoBoxScheme } from '../ab-demo-box';
|
|
52
|
+
// ๐งฐ 0.6.0: the toolbar + preview (a small client island; this file stays server-safe)
|
|
53
|
+
import AbPreviewStage from './stage';
|
|
54
|
+
// ๐ป the source half
|
|
55
|
+
import AbDemoCode from '../ab-demo-code';
|
|
56
|
+
// ๐จ styles
|
|
57
|
+
import styles from './styles.module.css';
|
|
58
|
+
|
|
59
|
+
/** ๐ translatable strings */
|
|
60
|
+
export interface AbPreviewCodeLabels {
|
|
61
|
+
preview?: string; // ๐งช the Preview tab (default "Preview")
|
|
62
|
+
code?: string; // ๐ป the Code tab (default "Code")
|
|
63
|
+
copy?: string; // ๐ the copy button (default "Copy code")
|
|
64
|
+
copied?: string; // โ
announced after a copy (default "Copied")
|
|
65
|
+
toolbar?: string; // ๐งฐ 0.6.0: names the preview toolbar (default "Preview tools")
|
|
66
|
+
dark?: string; // ๐ 0.6.0: the scheme toggle (default "Dark preview", aria-pressed = dark)
|
|
67
|
+
reload?: string; // ๐ 0.6.0: the remount button (default "Reload preview")
|
|
68
|
+
open?: string; // โ๏ธ 0.6.0: the open-in-new-tab link (default "Open preview in a new tab")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** โ๏ธ props */
|
|
72
|
+
export interface AbPreviewCodeProps {
|
|
73
|
+
children: ReactNode; // ๐งช the live preview: real JSX with package components (D-c: no eval, no live editor)
|
|
74
|
+
code: string; // ๐ the matching source: shown plain when there is no `trustedHtml` / `highlighted`, always what Copy copies
|
|
75
|
+
trustedHtml?: string; // ๐งพ Shiki `codeToHtml(code)` output, โ ๏ธ NOT sanitized: trusted HTML only, never user input (prefer `highlighted`)
|
|
76
|
+
highlighted?: ReactNode; // ๐๏ธ OR an already highlighted <pre> (e.g. an MDX fenced block)
|
|
77
|
+
language?: string; // ๐ค default 'tsx'
|
|
78
|
+
filename?: string; // ๐ shown in the code header
|
|
79
|
+
label?: string; // โฟ names the tablist, e.g. "Button example" (default "Example")
|
|
80
|
+
labels?: AbPreviewCodeLabels; // ๐
|
|
81
|
+
defaultTab?: 'preview' | 'code'; // ๐ฏ default 'preview'
|
|
82
|
+
scheme?: AbDemoBoxScheme; // ๐ force the preview's scheme (default: follow the page)
|
|
83
|
+
align?: 'center' | 'start' | 'stretch'; // ๐ the preview's alignment (default 'center')
|
|
84
|
+
toolbar?: boolean; // ๐งฐ 0.6.0: the preview toolbar (light/dark toggle + reload [+ open]); default true
|
|
85
|
+
href?: string; // โ๏ธ 0.6.0: a standalone page for this example โ an open-in-new-tab link in the toolbar
|
|
86
|
+
className?: string; // ๐ท๏ธ
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ๐งช๐ป AbPreviewCode โ the docs Preview / Code pair (G16): AbContentTabs over an AbDemoBox preview scope and an
|
|
91
|
+
* AbDemoCode source block. Both panels are in the server HTML (the inactive one `hidden`), so the preview's
|
|
92
|
+
* markup and the code are crawlable and work before hydration. The preview is the children you pass, rendered
|
|
93
|
+
* as-is: nothing is parsed or evaluated from `code`, so keep the two in sync (a test can compare them).
|
|
94
|
+
*/
|
|
95
|
+
const AbPreviewCode = ({ children, code, trustedHtml, highlighted, language = 'tsx', filename, label = 'Example', labels = {}, defaultTab = 'preview', scheme, align, toolbar = true, href, className }: AbPreviewCodeProps): ReactElement => {
|
|
96
|
+
const L = { preview: 'Preview', code: 'Code', copy: 'Copy code', copied: 'Copied', ...labels }; // ๐
|
|
97
|
+
const stageLabels = { toolbar: L.toolbar, dark: L.dark, reload: L.reload, open: L.open }; // ๐งฐ undefined โ the island's defaults
|
|
98
|
+
return (
|
|
99
|
+
<div className={clsx('AbPreviewCode', styles.abPreviewCode, className)} data-ab-part="preview-code">
|
|
100
|
+
<AbContentTabs label={label} defaultValue={defaultTab}>
|
|
101
|
+
<AbContentTab label={L.preview} value="preview">
|
|
102
|
+
{/* ๐งช the tabpanel already names it (aria-labelledby the tab), so the box needs no region role */}
|
|
103
|
+
<AbPreviewStage scheme={scheme} align={align} href={href} toolbar={toolbar} labels={stageLabels} className={styles.abPreviewCodeBox}>{children}</AbPreviewStage>
|
|
104
|
+
</AbContentTab>
|
|
105
|
+
<AbContentTab label={L.code} value="code">
|
|
106
|
+
<AbDemoCode code={code} trustedHtml={trustedHtml} language={language} filename={filename} copyLabel={L.copy} copiedLabel={L.copied}>{highlighted}</AbDemoCode>
|
|
107
|
+
</AbContentTab>
|
|
108
|
+
</AbContentTabs>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// ๐ฆ exports
|
|
114
|
+
export default AbPreviewCode;
|
|
115
|
+
export { AbPreviewCode };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-components
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-components
|
|
27
|
+
* @name: AbPreviewStage (0.6.0)
|
|
28
|
+
* @file: ab-preview-code/stage.tsx
|
|
29
|
+
* @type: Client component (island)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more ๐!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
'use client';
|
|
40
|
+
|
|
41
|
+
'use client';
|
|
42
|
+
|
|
43
|
+
// โ๏ธ React
|
|
44
|
+
import { useRef, useState, type KeyboardEvent, type ReactElement, type ReactNode } from 'react';
|
|
45
|
+
// ๐งต classes
|
|
46
|
+
import clsx from 'clsx';
|
|
47
|
+
// ๐ฃ icons (ab-nextjs-icons built-ins: dark_mode, light_mode, refresh, open_in_new)
|
|
48
|
+
import AbIcon from '../ab-icon';
|
|
49
|
+
// ๐งช the preview scope (server-safe, fine inside a client island)
|
|
50
|
+
import AbDemoBox, { type AbDemoBoxScheme } from '../ab-demo-box';
|
|
51
|
+
// ๐จ styles
|
|
52
|
+
import styles from './styles.module.css';
|
|
53
|
+
|
|
54
|
+
/** ๐ the toolbar's translatable names */
|
|
55
|
+
export interface AbPreviewStageLabels {
|
|
56
|
+
toolbar?: string; // โฟ names the toolbar (default "Preview tools")
|
|
57
|
+
dark?: string; // ๐ the scheme toggle, a pressed-state button (default "Dark preview")
|
|
58
|
+
reload?: string; // ๐ the remount button (default "Reload preview")
|
|
59
|
+
open?: string; // โ๏ธ the open-in-new-tab link (default "Open preview in a new tab")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** โ๏ธ props */
|
|
63
|
+
export interface AbPreviewStageProps {
|
|
64
|
+
children?: ReactNode; // ๐งช the live preview (server-rendered JSX passes straight through)
|
|
65
|
+
scheme?: AbDemoBoxScheme; // ๐ the starting scheme (default 'inherit'); the toggle then forces light / dark
|
|
66
|
+
align?: 'center' | 'start' | 'stretch'; // ๐ forwarded to AbDemoBox
|
|
67
|
+
href?: string; // โ๏ธ shows an "open in a new tab" link (target _blank, rel noopener noreferrer)
|
|
68
|
+
toolbar?: boolean; // ๐งฐ show the toolbar (default true); false = just the box
|
|
69
|
+
labels?: AbPreviewStageLabels; // ๐
|
|
70
|
+
className?: string; // ๐ท๏ธ on the AbDemoBox
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* ๐งฐ AbPreviewStage โ the small client island behind AbPreviewCode's preview: a WAI-ARIA toolbar (one tab stop,
|
|
75
|
+
* โ/โ/Home/End move between tools) over an AbDemoBox.
|
|
76
|
+
* - ๐ a light/dark toggle (`aria-pressed` = dark) that changes ONLY this preview's scheme (AbDemoBox `data-theme`)
|
|
77
|
+
* - ๐ reload: remounts the preview with a key bump (state, timers and animations start fresh)
|
|
78
|
+
* - โ๏ธ with `href`: an open-in-new-tab link
|
|
79
|
+
* Every tool is a โฅ44px target with an overridable aria-label. No motion here (motion lives in ab-nextjs-animations).
|
|
80
|
+
*/
|
|
81
|
+
const AbPreviewStage = ({ children, scheme = 'inherit', align, href, toolbar = true, labels = {}, className }: AbPreviewStageProps): ReactElement => {
|
|
82
|
+
const L = { toolbar: 'Preview tools', dark: 'Dark preview', reload: 'Reload preview', open: 'Open preview in a new tab', ...Object.fromEntries(Object.entries(labels).filter(([, v]) => v != null)) }; // ๐ undefined keeps the default
|
|
83
|
+
const [current, setCurrent] = useState<AbDemoBoxScheme>(scheme); // ๐ this preview only
|
|
84
|
+
const [key, setKey] = useState(0); // ๐ bumped โ AbDemoBox remounts
|
|
85
|
+
const [active, setActive] = useState(0); // ๐ฏ roving tab stop (index of the focusable tool)
|
|
86
|
+
const bar = useRef<HTMLDivElement>(null); // ๐งฐ
|
|
87
|
+
const dark = current === 'dark'; // ๐ pressed?
|
|
88
|
+
|
|
89
|
+
/** โจ๏ธ APG toolbar keys: โ/โ wrap, Home/End jump; only the active tool is in the tab order */
|
|
90
|
+
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
91
|
+
const tools = Array.from(bar.current?.querySelectorAll<HTMLElement>('[data-ab-tool]') ?? []); // ๐ the tools
|
|
92
|
+
const i = tools.indexOf(document.activeElement as HTMLElement); // ๐
|
|
93
|
+
if (i < 0) return; // ๐
focus is elsewhere
|
|
94
|
+
const n = tools.length; // ๐ข
|
|
95
|
+
const next = e.key === 'ArrowRight' ? (i + 1) % n : e.key === 'ArrowLeft' ? (i - 1 + n) % n : e.key === 'Home' ? 0 : e.key === 'End' ? n - 1 : -1; // ๐งญ
|
|
96
|
+
if (next < 0) return; // โญ๏ธ other keys pass through
|
|
97
|
+
e.preventDefault(); // ๐ no page scroll
|
|
98
|
+
setActive(next); // ๐ฏ
|
|
99
|
+
tools[next]?.focus(); // โจ๏ธ
|
|
100
|
+
};
|
|
101
|
+
const tab = (i: number) => (i === active ? 0 : -1); // ๐ฏ roving tabindex
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div className={styles.abPreviewStage} data-ab-part="preview-stage">
|
|
105
|
+
{toolbar && (
|
|
106
|
+
<div ref={bar} role="toolbar" aria-label={L.toolbar} className={styles.abPreviewToolbar} data-ab-part="preview-toolbar" onKeyDown={onKeyDown}>
|
|
107
|
+
<button
|
|
108
|
+
type="button"
|
|
109
|
+
data-ab-tool="scheme" // ๐
|
|
110
|
+
className={styles.abPreviewTool}
|
|
111
|
+
aria-label={L.dark} // โฟ the name stays; the state is aria-pressed
|
|
112
|
+
aria-pressed={dark} // ๐ true = dark preview
|
|
113
|
+
tabIndex={tab(0)}
|
|
114
|
+
onFocus={() => setActive(0)}
|
|
115
|
+
onClick={() => setCurrent(dark ? 'light' : 'dark')} // ๐ light โ dark (from 'inherit' โ dark first)
|
|
116
|
+
>
|
|
117
|
+
<AbIcon name={dark ? 'dark_mode' : 'light_mode'} size={20} /> {/* ๐/๐ decorative */}
|
|
118
|
+
</button>
|
|
119
|
+
<button
|
|
120
|
+
type="button"
|
|
121
|
+
data-ab-tool="reload" // ๐
|
|
122
|
+
className={styles.abPreviewTool}
|
|
123
|
+
aria-label={L.reload}
|
|
124
|
+
tabIndex={tab(1)}
|
|
125
|
+
onFocus={() => setActive(1)}
|
|
126
|
+
onClick={() => setKey((k) => k + 1)} // ๐ key bump โ remount
|
|
127
|
+
>
|
|
128
|
+
<AbIcon name="refresh" size={20} />
|
|
129
|
+
</button>
|
|
130
|
+
{href && (
|
|
131
|
+
<a
|
|
132
|
+
href={href}
|
|
133
|
+
target="_blank" // โ๏ธ new tab
|
|
134
|
+
rel="noopener noreferrer" // ๐ no window.opener, no referrer
|
|
135
|
+
data-ab-tool="open"
|
|
136
|
+
className={styles.abPreviewTool}
|
|
137
|
+
aria-label={L.open}
|
|
138
|
+
tabIndex={tab(2)}
|
|
139
|
+
onFocus={() => setActive(2)}
|
|
140
|
+
>
|
|
141
|
+
<AbIcon name="open_in_new" size={20} />
|
|
142
|
+
</a>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
)}
|
|
146
|
+
<AbDemoBox key={key} scheme={current} align={align} className={className}>{children}</AbDemoBox>
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// ๐ฆ exports
|
|
152
|
+
export default AbPreviewStage;
|
|
153
|
+
export { AbPreviewStage };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-components
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-components
|
|
27
|
+
* @name: styles.module.css
|
|
28
|
+
* @file: ab-preview-code/styles.module.css
|
|
29
|
+
* @type: CSS Stylesheet
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
|
|
32
|
+
/* ๐งช๐ป the pair: one block in the prose rhythm; the tabs' own bottom margin is dropped inside it */
|
|
33
|
+
.abPreviewCode { margin: 0 0 1.25em; min-inline-size: 0; } /* โ๏ธ + โ๏ธ never widens the page */
|
|
34
|
+
.abPreviewCode > :global(.AbContentTabs) { margin: 0; } /* โ๏ธ */
|
|
35
|
+
.abPreviewCodeBox { min-block-size: 180px; } /* ๐ room for a menu / drawer demo */
|
|
36
|
+
|
|
37
|
+
/* ๐งฐ 0.6.0: the preview toolbar (AbPreviewStage) โ tools end-aligned above the box */
|
|
38
|
+
.abPreviewStage { display: grid; min-inline-size: 0; } /* ๐ */
|
|
39
|
+
.abPreviewToolbar { display: flex; justify-content: flex-end; gap: 4px; padding: 2px; } /* ๐งฐ */
|
|
40
|
+
.abPreviewTool { display: inline-flex; align-items: center; justify-content: center; min-inline-size: 44px; min-block-size: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; } /* ๐ โฅ44px targets */
|
|
41
|
+
.abPreviewTool:hover { background: var(--ab-color-hover, rgb(92 64 48 / 0.08)); } /* ๐ฑ๏ธ */
|
|
42
|
+
.abPreviewTool:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* โฟ */
|
|
43
|
+
.abPreviewTool[aria-pressed='true'] { background: var(--ab-color-selected, rgb(92 64 48 / 0.14)); } /* ๐ pressed */
|
|
@@ -68,7 +68,7 @@ export interface AbProgressChipsProps {
|
|
|
68
68
|
|
|
69
69
|
const DEFAULT_CHIPS: AbProgressChip[] = [
|
|
70
70
|
{ id: 1, code: 'A', name: 'Prep', duration: 20 },
|
|
71
|
-
{ id: 2, code: 'B', name: '
|
|
71
|
+
{ id: 2, code: 'B', name: 'Simmer', duration: 40 },
|
|
72
72
|
{ id: 3, code: 'C', name: 'Plate', duration: 15 },
|
|
73
73
|
];
|
|
74
74
|
|
|
@@ -94,7 +94,7 @@ export interface AbSearchDrawerProps {
|
|
|
94
94
|
defaultQuery?: string; // ๐ฑ the query on open (default '')
|
|
95
95
|
recentKey?: string | null; // ๐ localStorage key (default `ab:search:recent`; null = no recents)
|
|
96
96
|
recentLimit?: number; // ๐ default 4
|
|
97
|
-
recentWhen?: 'always' | 'empty'; // ๐ 'always' = above the results (
|
|
97
|
+
recentWhen?: 'always' | 'empty'; // ๐ 'always' = above the results (the frames, default); 'empty' = only with no query
|
|
98
98
|
labels?: AbSearchDrawerLabels; // ๐
|
|
99
99
|
returnFocus?: string; // โฉ๏ธ
|
|
100
100
|
id?: string; // ๐
|
|
@@ -128,7 +128,7 @@ export function highlightAbSearch(text: string, q: string): ReactNode {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
* ๐ AbSearchDrawer โ
|
|
131
|
+
* ๐ AbSearchDrawer โ the search drawer (drawers v2 ยง4), a bottom-drawer variant.
|
|
132
132
|
*
|
|
133
133
|
* - ๐ฑ below 768px: straight to full height (no 70% stop: the keyboard is up); a hard swipe down closes
|
|
134
134
|
* - ๐ป 768px and up: centred in the main pane, min(640px, main width), 70% tall; results scroll inside with a 48px fade
|
|
@@ -149,7 +149,7 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
|
|
|
149
149
|
}; // ๐
|
|
150
150
|
const auto = useId().replace(/[^A-Za-z0-9_-]/g, ''); // ๐
|
|
151
151
|
const base = id ?? `ab-search-${auto}`;
|
|
152
|
-
// ๐
|
|
152
|
+
// ๐ review P2: group ids come from app data ("@scope/pkg", "a b"); keep only id-safe characters, and the index keeps them unique
|
|
153
153
|
const groupId = (g: AbSearchDrawerGroup, i: number) => `${base}-g-${i}-${String(g.id).replace(/[^A-Za-z0-9_-]/g, '_')}`;
|
|
154
154
|
const input = useRef<HTMLInputElement>(null); // ๐ค
|
|
155
155
|
const list = useRef<HTMLDivElement>(null); // ๐
|
|
@@ -172,7 +172,7 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
|
|
|
172
172
|
const t = setTimeout(() => {
|
|
173
173
|
Promise.resolve().then(() => latest.current(q)) // ๐งฏ a sync throw becomes a rejection too
|
|
174
174
|
.then((g) => { if (live) { setGroups(g); setActive(g.some((x) => x.items.length) ? 0 : -1); } })
|
|
175
|
-
.catch(() => { if (live) { setGroups([]); setActive(-1); } }); // ๐งฏ
|
|
175
|
+
.catch(() => { if (live) { setGroups([]); setActive(-1); } }); // ๐งฏ review P2: a failed search shows "no results", never the previous query's results
|
|
176
176
|
}, 150);
|
|
177
177
|
return () => { live = false; clearTimeout(t); };
|
|
178
178
|
}, [query, open]);
|
|
@@ -59,12 +59,12 @@ export interface AbSearchTriggerProps {
|
|
|
59
59
|
onOpen?: () => void; // ๐ opens your search dialog (button mode)
|
|
60
60
|
href?: string; // ๐ no onOpen โ a link to a search page (also the JS-off path)
|
|
61
61
|
hotkey?: boolean; // โจ๏ธ listen for โK / Ctrl+K (default true when onOpen is set)
|
|
62
|
-
shortcut?: boolean; // โจ๏ธ alias of `hotkey` (
|
|
62
|
+
shortcut?: boolean; // โจ๏ธ alias of `hotkey` (the spec name); `hotkey` wins when both are set
|
|
63
63
|
compact?: boolean; // ๐ฑ icon-only pill (the label stays for screen readers), e.g. the mobile app bar
|
|
64
64
|
comingSoon?: boolean; // ๐ง visible but inert: aria-disabled, no hotkey
|
|
65
65
|
comingSoonLabel?: string; // ๐ท๏ธ default "Coming soon"
|
|
66
66
|
variant?: 'pill' | 'field'; // ๐ 0.1.14 (P6): 'field' = the Home 300ร36 bordered field (default 'pill', the legacy look)
|
|
67
|
-
/** ๐ฑ 0.1.15
|
|
67
|
+
/** ๐ฑ 0.1.15: a shorter label (e.g. "Search") that a compact AbAppBar shows below 768px instead of `label`
|
|
68
68
|
* (CSS picks; only one is ever displayed, so the accessible name stays single). Home field only. */
|
|
69
69
|
compactLabel?: string;
|
|
70
70
|
size?: 'md' | 'sm' | 'lg'; // ๐ฑ 0.1.14 (P6): 'sm' = the mobile 34px "Search โK" pill (label + key cap stay visible)
|
|
@@ -124,7 +124,7 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
124
124
|
<>
|
|
125
125
|
<AbIcon name="search" size={20} className={styles.abSearchTriggerIcon} />
|
|
126
126
|
<span className={clsx(styles.abSearchTriggerLabel, compact && styles.abSearchTriggerSrOnly)}>{label}</span>
|
|
127
|
-
{/* ๐ง coming soon tag, or โจ๏ธ the key hint ONLY while a hotkey is really listening (
|
|
127
|
+
{/* ๐ง coming soon tag, or โจ๏ธ the key hint ONLY while a hotkey is really listening (#3, D24a) */}
|
|
128
128
|
{comingSoon
|
|
129
129
|
? !compact && <span className={styles.abSearchTriggerSoon}>{comingSoonLabel}</span>
|
|
130
130
|
: listen && !compact && <AbKbd keys={[apple ? 'โ' : 'Ctrl', 'K']} className={styles.abSearchTriggerKbd} />}
|
|
@@ -133,7 +133,7 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
133
133
|
const common = {
|
|
134
134
|
className: clsx('AbSearchTrigger', styles.abSearchTrigger, !comingSoon && 'ab-motion-interactive', className), // ๐ท๏ธ
|
|
135
135
|
'data-ab-part': 'search-trigger', // ๐งฉ
|
|
136
|
-
'aria-keyshortcuts': listen ? 'Meta+K Control+K' : undefined, // โฟ only announced when bound (
|
|
136
|
+
'aria-keyshortcuts': listen ? 'Meta+K Control+K' : undefined, // โฟ only announced when bound (#3)
|
|
137
137
|
'data-compact': compact ? 'true' : undefined, // ๐ฑ
|
|
138
138
|
'data-variant': variant === 'field' ? 'field' : undefined, // ๐ P6
|
|
139
139
|
'data-size': size === 'sm' || size === 'lg' ? size : undefined, // ๐ฑ P6 ยท ๐ 404 gaps: lg
|
|
@@ -143,7 +143,7 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
143
143
|
// ๐ง coming soon: focusable, announced, inert
|
|
144
144
|
if (comingSoon) return <button type="button" {...common} aria-disabled="true" data-coming-soon="true">{inner}</button>;
|
|
145
145
|
// ๐ href โ ALWAYS a real link, so it works with JS off (D24a: /docs). With onOpen too, JS intercepts
|
|
146
|
-
// the click and opens the dialog instead (
|
|
146
|
+
// the click and opens the dialog instead (#4); modified clicks (new tab, โฆ) keep the link.
|
|
147
147
|
if (href) {
|
|
148
148
|
const onClick = onOpen
|
|
149
149
|
? (e: MouseEvent<HTMLAnchorElement>) => {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
.abSearchTriggerIcon { flex: none; } /* ๐ฃ */
|
|
65
65
|
.abSearchTriggerSoon { font-size: 12px; opacity: 0.8; } /* ๐ง */
|
|
66
66
|
|
|
67
|
-
/* ๐ฑ compact (
|
|
67
|
+
/* ๐ฑ compact (#3/#16): icon-only round pill for small app bars, no overflow at 390px */
|
|
68
68
|
.abSearchTrigger[data-compact='true'] { flex: none; width: 40px; min-width: 40px; padding: 0; justify-content: center; } /* ๐ */
|
|
69
69
|
/* ๐ถ๏ธ visually hidden, still read by screen readers */
|
|
70
70
|
.abSearchTriggerSrOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; flex: none; }
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-button, 10px); /* ๐ฒ */
|
|
77
77
|
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); /* ๐จ */
|
|
78
78
|
font-size: 13.5px; line-height: 1; box-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* ๐ค ๐ */
|
|
79
|
-
flex: 0 8 auto; min-width: var(--ab-search-trigger-min-width, 160px); /* ๐ 0.4.1 (
|
|
79
|
+
flex: 0 8 auto; min-width: var(--ab-search-trigger-min-width, 160px); /* ๐ 0.4.1 (0.2.24, gap 4): its own space in a flex row; v2: shrinks first (flex-shrink 8) down to 160px, never under */
|
|
80
80
|
}
|
|
81
81
|
.abSearchTrigger[data-size='sm'] {
|
|
82
82
|
flex: none; width: auto; max-width: none; height: 34px; /* ๐ the pill still LOOKS 34px (mock) */
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-pill, 999px); /* ๐ */
|
|
86
86
|
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); font-size: 13px; line-height: 1; /* ๐จ ๐ค */
|
|
87
87
|
}
|
|
88
|
-
/* ๐ 0.3.2 (
|
|
88
|
+
/* ๐ 0.3.2 (0.2.23 gaps): an invisible 44px-tall hit area around the 34px pill (0.3.3: 6px above + below), so the
|
|
89
89
|
tap target is โฅ 44px (WCAG 2.5.5) without changing the look */
|
|
90
90
|
.abSearchTrigger[data-size='sm']::after { content: ''; position: absolute; inset: -6px 0; } /* ๐ซฅ hit area: 0.3.3 6px above + below โ 46px, safely โฅ 44 */
|
|
91
91
|
.abSearchTrigger[data-variant='field']:hover, .abSearchTrigger[data-size='sm']:hover { border-color: color-mix(in srgb, var(--ab-color-accent, #a67c52) 40%, transparent); } /* ๐ฑ๏ธ */
|
|
@@ -86,7 +86,7 @@ export interface AbSettingsDrawerProps {
|
|
|
86
86
|
onLocaleChange: (code: string) => void; // ๐ฃ
|
|
87
87
|
labels?: AbSettingsDrawerLabels; // ๐ท๏ธ
|
|
88
88
|
themes?: readonly AbSettingsTheme[]; // ๐๏ธ default light, dark, system
|
|
89
|
-
// ๐ค 0.2.1
|
|
89
|
+
// ๐ค 0.2.1: the account section is back, on top. `account` = signed in (avatar, name, email);
|
|
90
90
|
// signed out, pass `onSignIn` for a "Sign in" row. Neither = no section.
|
|
91
91
|
account?: AbProfileUser | null;
|
|
92
92
|
onAccount?: () => void; // ๐ค tap the signed-in row (e.g. open the profile page)
|
|
@@ -117,7 +117,7 @@ function radioKeys<T>(e: KeyboardEvent, items: readonly T[], current: T, pick: (
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* โ๏ธ AbSettingsDrawer โ
|
|
120
|
+
* โ๏ธ AbSettingsDrawer โ the Settings bottom drawer (drawers v2, spec ยง1): the default bottom sheet, holding
|
|
121
121
|
* ACCOUNT (0.2.1, optional), THEME (a Light / Dark / System segmented radiogroup, 48px) and LANGUAGE (48px radio rows, each label in its
|
|
122
122
|
* own `lang`, the checked one tinted with a check), then optional Help / About rows (0.2.1).
|
|
123
123
|
*
|