ab-nextjs-components 0.2.1 โ 0.2.3
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 +5 -1
- package/ab-bottom-drawer/index.tsx +35 -4
- package/ab-bottom-drawer/use-ab-swipe-down.ts +125 -0
- package/ab-button/helpers.ts +2 -2
- package/ab-button/index.tsx +1 -1
- package/ab-button/styles.module.css +86 -20
- package/ab-carousel/index.tsx +202 -31
- package/ab-carousel/styles.module.css +22 -1
- package/ab-drawer/kit.module.css +27 -0
- package/ab-flow-diagram/frame-scale.tsx +65 -0
- package/ab-flow-diagram/helpers.ts +89 -3
- package/ab-flow-diagram/index.tsx +116 -3
- package/ab-flow-diagram/styles.module.css +112 -1
- package/ab-mobile-header/index.tsx +151 -12
- package/ab-package-card/index.tsx +1 -1
- package/ab-package-card/previews.tsx +20 -4
- package/ab-playground-scene/i18n.module.css +54 -0
- package/ab-playground-scene/i18n.tsx +141 -0
- package/ab-playground-scene/icons.tsx +96 -0
- package/ab-playground-scene/index.tsx +138 -0
- package/ab-playground-scene/labels.ts +103 -0
- package/ab-playground-scene/scenes.tsx +103 -0
- package/ab-playground-scene/styles.module.css +148 -0
- package/ab-playground-scene/upgraded.tsx +315 -0
- package/ab-playground-scene/welcome.tsx +120 -0
- package/ab-theme-mode/index.tsx +82 -0
- package/ab-theme-toggle/index.tsx +22 -3
- package/index.ts +11 -1
- package/package.json +9 -5
- package/server/ab-button/index.tsx +3 -2
- package/server/ab-test-hello/styles.module.css +3 -0
- package/types/index.d.ts +8 -1
- package/server/ab-button/styles.module.css +0 -191
|
@@ -45,7 +45,9 @@ import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
|
45
45
|
// ๐งต classes
|
|
46
46
|
import clsx from 'clsx';
|
|
47
47
|
// ๐งฎ pure geometry
|
|
48
|
-
import { getAbFlowEdgePath, type AbFlowEdge, type AbFlowNode } from './helpers';
|
|
48
|
+
import { getAbFlowEdgePath, getAbFlowRoundedPath, routeAbFlowWires, type AbFlowEdge, type AbFlowFrame, type AbFlowNode, type AbFlowPoint } from './helpers';
|
|
49
|
+
// ๐ 0.2.3: the one client island (frame scaling)
|
|
50
|
+
import AbFlowFrameScale from './frame-scale';
|
|
49
51
|
// ๐จ styles (all motion is CSS: draw-on, pulses, reduced motion, pause)
|
|
50
52
|
import styles from './styles.module.css';
|
|
51
53
|
// ๐ฌ wire draw-on + pulse come from ab-nextjs-animations (>= 0.2.4); this component only sets its tokens
|
|
@@ -58,7 +60,21 @@ export * from './helpers';
|
|
|
58
60
|
// โ๏ธ props
|
|
59
61
|
export interface AbFlowDiagramProps {
|
|
60
62
|
nodes: readonly AbFlowNode[]; // ๐ต nodes in 0โ100 coordinates
|
|
61
|
-
edges
|
|
63
|
+
edges?: readonly AbFlowEdge[] | 'auto'; // ใฐ๏ธ wires between node ids; `'auto'` (default with `frame`) = v6 route() every node โ the hub
|
|
64
|
+
/** ๐ผ๏ธ 0.2.3 (Welcome v6): a fixed design frame, e.g. `{ w: 760, h: 600, header: 56 }`. Node x/y/w/h are then frame px
|
|
65
|
+
* (John's rects 1:1) and the whole stage scales with the card width. */
|
|
66
|
+
frame?: AbFlowFrame;
|
|
67
|
+
/** ใฐ๏ธ 0.2.3: extra wires as frame-px polylines (v6 `extras`), drawn with rounded corners. */
|
|
68
|
+
wires?: readonly (readonly AbFlowPoint[])[];
|
|
69
|
+
/** ๐ค 0.2.3: dotted surface below the header band (theme โฅ 0.3.7 `--ab-dot-*`, v6 fallbacks). Default true. */
|
|
70
|
+
dotted?: boolean;
|
|
71
|
+
/** ๐
ฐ๏ธ 0.2.3: a logo before the title (v6 header mark). */
|
|
72
|
+
logo?: ReactNode;
|
|
73
|
+
/** โ 0.2.3: anchor dots at both ends of every frame wire (v6 `.anc`). Default true. */
|
|
74
|
+
anchors?: boolean;
|
|
75
|
+
/** โฟ 0.2.3: `'always'` = the reduced-motion still frame regardless of the OS (sets data-ab-reduced-motion,
|
|
76
|
+
* which ab-nextjs-animations honours). Default `'auto'` (the OS setting). */
|
|
77
|
+
reducedMotion?: 'auto' | 'always';
|
|
62
78
|
alt: string; // โฟ one-sentence description (Welcome.sNN.illustrationAlt)
|
|
63
79
|
title?: string; // ๐ท๏ธ card title, e.g. "Live Playground" (visual)
|
|
64
80
|
caption?: string; // ๐ท๏ธ PKG label, e.g. "ab-nextjs-core" (visual, mono)
|
|
@@ -82,10 +98,14 @@ const nodeStyle = (n: AbFlowNode): CSSProperties =>
|
|
|
82
98
|
|
|
83
99
|
/** ๐จ Live Playground scene: SVG wires + HTML nodes, CSS-only motion, one accessible image. */
|
|
84
100
|
export function AbFlowDiagram(props: AbFlowDiagramProps): ReactElement {
|
|
101
|
+
// ๐ผ๏ธ 0.2.3: pixel frame mode (Welcome v6)
|
|
102
|
+
if (props.frame) return <AbFlowFrameDiagram {...props} frame={props.frame} />;
|
|
85
103
|
// ๐งฉ props
|
|
86
|
-
const { nodes, edges, alt, title, caption, live = false, active = true, loops = 'infinite', variant = 'full', posterAt = 0.45, duration = 2400, className, style, children } = props;
|
|
104
|
+
const { nodes, edges: edgesProp, alt, title, caption, live = false, active = true, loops = 'infinite', variant = 'full', posterAt = 0.45, duration = 2400, className, style, children } = props;
|
|
87
105
|
// ๐บ๏ธ id โ node
|
|
88
106
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
107
|
+
const edges = Array.isArray(edgesProp) ? edgesProp : []; // ใฐ๏ธ 'auto' needs a frame
|
|
108
|
+
const dotted = props.dotted ?? true; // ๐ค
|
|
89
109
|
// ๐๏ธ ab-nextjs-animations wire tokens drive all timing
|
|
90
110
|
const vars = {
|
|
91
111
|
...style, // ๐จ
|
|
@@ -109,10 +129,12 @@ export function AbFlowDiagram(props: AbFlowDiagramProps): ReactElement {
|
|
|
109
129
|
data-ab-paused={String(!active)} // โธ๏ธ ab-nextjs-animations pauses wires on inactive slides
|
|
110
130
|
data-variant={variant} // ๐
|
|
111
131
|
data-ab-header={String(hasHeader)} // ๐ท๏ธ header-safe stage: nodes + wires start below the header
|
|
132
|
+
data-ab-dotted={String(dotted)} // ๐ค 0.2.3
|
|
112
133
|
>
|
|
113
134
|
{/* ๐ท๏ธ card header (decorative: alt already describes it) */}
|
|
114
135
|
{hasHeader ? (
|
|
115
136
|
<div className={styles.header} aria-hidden="true">
|
|
137
|
+
{props.logo ? <span className={styles.logo}>{props.logo}</span> : null}
|
|
116
138
|
{title ? <span className={styles.title}>{title}</span> : null}
|
|
117
139
|
{live ? <span className={styles.live}><span className={styles.liveDot} />{typeof live === 'string' ? live : null}</span> : null}
|
|
118
140
|
{caption ? <span className={styles.caption}>{caption}</span> : null}
|
|
@@ -148,5 +170,96 @@ export function AbFlowDiagram(props: AbFlowDiagramProps): ReactElement {
|
|
|
148
170
|
);
|
|
149
171
|
}
|
|
150
172
|
|
|
173
|
+
// โ๏ธ frame props (frame required)
|
|
174
|
+
type FrameProps = AbFlowDiagramProps & { frame: AbFlowFrame };
|
|
175
|
+
|
|
176
|
+
/** ๐ผ๏ธ 0.2.3 (Welcome v6): the pixel-frame scene. A fixed wรh stage (v6 px), scaled to the card width by CSS
|
|
177
|
+
* (`100cqw / w`) and the AbFlowFrameScale island; wires auto-route node โ hub like John's route(). */
|
|
178
|
+
function AbFlowFrameDiagram(props: FrameProps): ReactElement {
|
|
179
|
+
// ๐งฉ props
|
|
180
|
+
const { nodes, edges = 'auto', frame, wires = [], alt, title, caption, live = false, active = true, loops = 'infinite', variant = 'full', posterAt = 0.45, duration = 2400, className, style, children, dotted = true, logo, anchors = true, reducedMotion = 'auto' } = props;
|
|
181
|
+
const header = frame.header ?? 0; // ๐ท๏ธ header band px
|
|
182
|
+
const hub = nodes.find((n) => n.tone === 'hub'); // ๐ฏ
|
|
183
|
+
const byId = new Map(nodes.map((n) => [n.id, n])); // ๐บ๏ธ
|
|
184
|
+
// ใฐ๏ธ auto: every non-hub node โ the hub (v6 route); explicit edges: route each pair; + extra polylines
|
|
185
|
+
const routed: AbFlowPoint[][] = edges === 'auto'
|
|
186
|
+
? (hub ? routeAbFlowWires(nodes.filter((n) => n !== hub), hub) : [])
|
|
187
|
+
: edges.flatMap((e) => { const a = byId.get(e.from); const b = byId.get(e.to); return a && b ? routeAbFlowWires([a], b) : []; }); // ๐งฏ unknown ids skipped
|
|
188
|
+
const all = [...routed, ...wires.map((w) => [...w])]; // โ extras
|
|
189
|
+
const radius = variant === 'compact' ? 9 : 12; // ๐ v6: 12 laptop, 9 mobile
|
|
190
|
+
const n = Math.max(1, all.length); // ๐ข
|
|
191
|
+
// ๐๏ธ tokens: frame geometry + ab-nextjs-animations wire timing (pulses spread evenly over one loop, like v6 t + i/n)
|
|
192
|
+
const vars = {
|
|
193
|
+
...style,
|
|
194
|
+
'--ab-flow-w': `${frame.w}px`, '--ab-flow-h': `${frame.h}px`, '--ab-flow-header': `${header}px`, // ๐
|
|
195
|
+
'--ab-flow-ratio': `${frame.w} / ${frame.h}`, // ๐
|
|
196
|
+
'--ab-wire-pulse-duration': `${duration}ms`, // โฑ๏ธ
|
|
197
|
+
'--ab-wire-pulse-stagger': `${Math.round(duration / n)}ms`, // โฑ๏ธ v6: phase i/n
|
|
198
|
+
...(loops === 'infinite' ? {} : { '--ab-wire-pulse-iterations': String(loops) }), // ๐
|
|
199
|
+
'--ab-wire-poster': String(100 - Math.min(1, Math.max(0, posterAt)) * 100), // ๐ผ๏ธ
|
|
200
|
+
} as CSSProperties;
|
|
201
|
+
const hasHeader = Boolean(title || live || caption || logo); // ๐ท๏ธ
|
|
202
|
+
return (
|
|
203
|
+
<figure
|
|
204
|
+
role="img" // โฟ ONE image
|
|
205
|
+
aria-label={alt} // ๐ฃ๏ธ
|
|
206
|
+
className={clsx('AbFlowDiagram', styles.root, styles.framed, className)}
|
|
207
|
+
style={vars}
|
|
208
|
+
data-ab-part="flow-diagram"
|
|
209
|
+
data-active={String(active)} // โถ๏ธ
|
|
210
|
+
data-ab-paused={String(!active)} // โธ๏ธ ab-nextjs-animations
|
|
211
|
+
data-variant={variant} // ๐
|
|
212
|
+
data-ab-frame="true" // ๐ผ๏ธ
|
|
213
|
+
data-ab-reduced-motion={reducedMotion === 'always' ? 'true' : undefined} // โฟ forced still
|
|
214
|
+
data-ab-header={String(hasHeader)} // ๐ท๏ธ
|
|
215
|
+
data-ab-dotted={String(dotted)} // ๐ค
|
|
216
|
+
>
|
|
217
|
+
<AbFlowFrameScale width={frame.w} />{/* ๐ the only client bit */}
|
|
218
|
+
<div className={styles.stage} aria-hidden="true">
|
|
219
|
+
{dotted ? <div className={styles.dots} data-ab-part="flow-dots" /> : null}{/* ๐ค below the header band */}
|
|
220
|
+
{hasHeader ? (
|
|
221
|
+
<div className={styles.frameHeader}>
|
|
222
|
+
{logo ? <span className={styles.logo}>{logo}</span> : null}
|
|
223
|
+
{title ? <span className={styles.title}>{title}</span> : null}
|
|
224
|
+
{caption ? <span className={styles.pkg}>{caption}</span> : null}
|
|
225
|
+
{live ? <span className={styles.frameLive}>{typeof live === 'string' ? live : null}</span> : null}
|
|
226
|
+
</div>
|
|
227
|
+
) : null}
|
|
228
|
+
<svg className={styles.frameWires} viewBox={`0 0 ${frame.w} ${frame.h}`} width={frame.w} height={frame.h} focusable="false">
|
|
229
|
+
{all.map((pts, i) => {
|
|
230
|
+
const d = getAbFlowRoundedPath(pts, radius); // ใฐ๏ธ v6 rounded()
|
|
231
|
+
// โฑ๏ธ stagger + โฟ the still frame of THIS wire: spec ยง4 shows t = posterAt with each wire offset by i/n
|
|
232
|
+
const still = ((Math.min(1, Math.max(0, posterAt)) + i / n) % 1) * 100; // ๐ 0โ100 along the wire
|
|
233
|
+
const idx = { '--ab-wire-index': String(i), '--ab-wire-poster': String(+(100 - still).toFixed(2)) } as CSSProperties;
|
|
234
|
+
return (
|
|
235
|
+
<g key={i} style={idx}>
|
|
236
|
+
<path className={clsx(styles.wireGlow, AB_WIRE_DRAW_CLASS)} d={d} pathLength={100} />{/* ๐ซ๏ธ 7px halo */}
|
|
237
|
+
<path className={clsx(styles.frameWire, AB_WIRE_DRAW_CLASS)} d={d} pathLength={100} />{/* ๐๏ธ 1.8px wire */}
|
|
238
|
+
<path className={clsx(styles.dotHalo, AB_WIRE_PULSE_CLASS)} d={d} pathLength={100} />{/* โจ pulse glow */}
|
|
239
|
+
<path className={clsx(styles.dotCore, AB_WIRE_PULSE_CLASS)} d={d} pathLength={100} />{/* โช pulse dot */}
|
|
240
|
+
</g>
|
|
241
|
+
);
|
|
242
|
+
})}
|
|
243
|
+
</svg>
|
|
244
|
+
{nodes.filter((nd) => nd !== hub).concat(hub ? [hub] : []).map((nd) => (
|
|
245
|
+
<div
|
|
246
|
+
key={nd.id}
|
|
247
|
+
className={styles.richNode}
|
|
248
|
+
data-tone={nd.tone ?? 'node'}
|
|
249
|
+
style={{ left: nd.x, top: nd.y, width: nd.w, height: nd.h }} // ๐ v6 rect, px
|
|
250
|
+
>
|
|
251
|
+
{nd.caption ? <span className={styles.nodeCaption} data-at={nd.captionAt ?? 'start'}>{nd.caption}</span> : null}{/* ๐ท๏ธ v6 .lb (spec rev 2: on a card chip) */}
|
|
252
|
+
{nd.content ?? (<>{nd.icon ? <span className={styles.nodeIcon}>{nd.icon}</span> : null}{nd.label ? <span>{nd.label}</span> : null}</>)}
|
|
253
|
+
</div>
|
|
254
|
+
))}
|
|
255
|
+
{anchors ? all.flatMap((pts, i) => [pts[0], pts[pts.length - 1]].map((p, j) => (
|
|
256
|
+
<i key={`${i}-${j}`} className={styles.anchor} style={{ left: p[0], top: p[1] }} />
|
|
257
|
+
))) : null}{/* โ v6 .anc */}
|
|
258
|
+
{children ? <div className={styles.overlay}>{children}</div> : null}
|
|
259
|
+
</div>
|
|
260
|
+
</figure>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
151
264
|
// ๐ฆ default export
|
|
152
265
|
export default AbFlowDiagram;
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
aspect-ratio: 760 / 600; /* ๐ mock card */
|
|
45
45
|
border-radius: 1.25rem; /* ๐ฒ */
|
|
46
46
|
border: 1px solid var(--ab-color-border, var(--ab-color-outline-variant, rgb(0 0 0 / 0.12))); /* ๐๏ธ */
|
|
47
|
-
background: var(--ab-color-surface-container, transparent); /*
|
|
47
|
+
background: var(--ab-flow-card, var(--ab-color-card, var(--ab-color-surface-container, transparent))); /* ๐ 0.2.3 (God, Welcome v5): the theme card (#fff ยท #fffcfa โฅ1920 ยท #241a12 dark); `--ab-flow-card` overrides it (e.g. the Welcome card) */
|
|
48
|
+
--ab-flow-dot: var(--ab-dot-color, rgb(107 79 53 / 0.16)); /* ๐ค v6 grid (theme โฅ 0.3.7, else the mock value) */
|
|
48
49
|
overflow: hidden; /* โ๏ธ */
|
|
49
50
|
color: var(--ab-color-on-surface, currentColor); /* ๐จ */
|
|
50
51
|
container-type: inline-size; /* ๐ฆ nodes scale with the card width (cqi units below) */
|
|
@@ -156,3 +157,113 @@
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
/* ๐ง reduced motion: handled by ab-nextjs-animations (wires drawn, pulses frozen at --ab-wire-poster) */
|
|
160
|
+
|
|
161
|
+
/* ===================================================================================================== */
|
|
162
|
+
/* ๐ค 0.2.3 dotted surface (Welcome v6 `.dots`): theme โฅ 0.3.7 --ab-dot-*, else John's values (light + dark) */
|
|
163
|
+
:global(:is(.dark, [data-theme="dark"])) .root { --ab-flow-dot: var(--ab-dot-color, rgb(245 235 225 / 0.1)); } /* ๐ */
|
|
164
|
+
.root[data-ab-dotted='true']:not([data-ab-frame='true'])::before {
|
|
165
|
+
content: "";
|
|
166
|
+
position: absolute;
|
|
167
|
+
inset: var(--ab-flow-diagram-stage-top) 0 0; /* โฌ๏ธ below the header band */
|
|
168
|
+
pointer-events: none; /* ๐ฑ๏ธ */
|
|
169
|
+
background-image: radial-gradient(var(--ab-flow-dot) var(--ab-dot-size, 1.3px), transparent calc(var(--ab-dot-size, 1.3px) + 0.1px));
|
|
170
|
+
background-size: var(--ab-dot-gap, 20px) var(--ab-dot-gap, 20px); /* ๐ */
|
|
171
|
+
background-position: calc(var(--ab-dot-gap, 20px) / 2) calc(var(--ab-dot-gap, 20px) / 2); /* ๐ฏ 10px 10px */
|
|
172
|
+
}
|
|
173
|
+
.logo { display: inline-flex; align-items: center; height: 1.25rem; } /* ๐
ฐ๏ธ */
|
|
174
|
+
.logo :is(img, svg) { height: 100%; width: auto; } /* ๐
ฐ๏ธ */
|
|
175
|
+
|
|
176
|
+
/* ===================================================================================================== */
|
|
177
|
+
/* ๐ผ๏ธ 0.2.3 frame mode (Welcome v6): a fixed wรh px stage (John's rects 1:1), scaled to the card width. */
|
|
178
|
+
.framed {
|
|
179
|
+
aspect-ratio: var(--ab-flow-ratio); /* ๐ e.g. 760 / 600 */
|
|
180
|
+
flex: none; min-width: 0; /* ๐ a flex column (e.g. the aside scroller) must not squash the ratio */
|
|
181
|
+
height: auto; /* ๐ the ratio wins (compact too: 350 / 276) */
|
|
182
|
+
border-radius: 22px; /* ๐ฒ v6 .pg */
|
|
183
|
+
border-color: var(--ab-flow-line, rgb(107 79 53 / 0.16)); /* โ v6 --line */
|
|
184
|
+
box-shadow: 0 30px 80px -30px var(--ab-flow-shadow, rgb(107 79 53 / 0.25)); /* ๐ซ๏ธ v6 */
|
|
185
|
+
--ab-flow-line: rgb(107 79 53 / 0.16); /* โ */
|
|
186
|
+
--ab-flow-node: var(--ab-color-welcome-node, var(--ab-flow-card, var(--ab-color-card, #fff))); /* ๐ต v6 --node (theme โฅ 0.3.7 token) */
|
|
187
|
+
--ab-flow-muted: var(--ab-color-muted, rgb(33 26 22 / 0.62)); /* ๐๏ธ v6 --mut */
|
|
188
|
+
--ab-flow-wire: #a67c52; /* ๐ฅ v6 wire */
|
|
189
|
+
--ab-flow-pulse-core: #ffe6c7; /* โช v6 .pt */
|
|
190
|
+
}
|
|
191
|
+
.framed[data-variant='compact'] { border-radius: 18px; } /* ๐ฑ v6 .mpg */
|
|
192
|
+
:global(:is(.dark, [data-theme="dark"])) .framed {
|
|
193
|
+
--ab-flow-line: rgb(255 232 210 / 0.1); /* โ */
|
|
194
|
+
--ab-flow-node: var(--ab-color-welcome-node, #2a1f17); /* ๐ต v6 dark node (theme โฅ 0.3.7 token) */
|
|
195
|
+
--ab-flow-muted: rgb(245 235 225 / 0.62); /* ๐๏ธ */
|
|
196
|
+
--ab-flow-shadow: rgb(0 0 0 / 0.6); /* ๐ซ๏ธ */
|
|
197
|
+
}
|
|
198
|
+
/* ๐ the stage: frame px, scaled from the top-left. Typed arithmetic (100cqw / px) where supported, then the island */
|
|
199
|
+
.stage {
|
|
200
|
+
--ab-flow-scale-css: calc(100cqw / var(--ab-flow-w)); /* ๐ browsers with typed arithmetic */
|
|
201
|
+
position: absolute; left: 0; top: 0; /* ๐ */
|
|
202
|
+
width: var(--ab-flow-w); height: var(--ab-flow-h); /* ๐ */
|
|
203
|
+
transform-origin: 0 0; /* โ๏ธ */
|
|
204
|
+
transform: scale(var(--ab-flow-scale, var(--ab-flow-scale-css, 1))); /* ๐ */
|
|
205
|
+
font-size: 13px; /* ๐ก v6 base */
|
|
206
|
+
}
|
|
207
|
+
.framed { container-type: inline-size; } /* ๐ฆ 100cqw = the card width */
|
|
208
|
+
.dots {
|
|
209
|
+
position: absolute; inset: var(--ab-flow-header) 0 0; /* โฌ๏ธ v6: inset 56px 0 0 */
|
|
210
|
+
background-image: radial-gradient(var(--ab-flow-dot) var(--ab-dot-size, 1.3px), transparent calc(var(--ab-dot-size, 1.3px) + 0.1px));
|
|
211
|
+
background-size: var(--ab-flow-dot-gap, var(--ab-dot-gap, 20px)) var(--ab-flow-dot-gap, var(--ab-dot-gap, 20px)); /* ๐ */
|
|
212
|
+
background-position: calc(var(--ab-flow-dot-gap, var(--ab-dot-gap, 20px)) / 2) calc(var(--ab-flow-dot-gap, var(--ab-dot-gap, 20px)) / 2); /* ๐ฏ */
|
|
213
|
+
}
|
|
214
|
+
.framed[data-variant='compact'] { --ab-flow-dot-gap: 16px; } /* ๐ฑ v6 mobile 16px */
|
|
215
|
+
.frameHeader {
|
|
216
|
+
position: absolute; inset: 0 0 auto; height: var(--ab-flow-header); /* ๐ v6 .hd */
|
|
217
|
+
display: flex; align-items: center; gap: 10px; padding: 0 22px; /* ๐ */
|
|
218
|
+
border-bottom: 1px solid var(--ab-flow-line); /* โ */
|
|
219
|
+
font-size: 15px; font-weight: 600; white-space: nowrap; /* ๐ก */
|
|
220
|
+
}
|
|
221
|
+
.frameHeader .logo { height: 20px; } /* ๐
ฐ๏ธ */
|
|
222
|
+
.pkg { font: 500 12px var(--ab-font-code, 'Roboto Mono', var(--ab-font-mono, ui-monospace, monospace)); color: var(--ab-flow-muted); } /* ๐ฆ v6 .pk */
|
|
223
|
+
.frameLive {
|
|
224
|
+
display: inline-flex; align-items: center; gap: 6px; margin-left: auto; /* โก๏ธ */
|
|
225
|
+
font-size: 12px; font-weight: 500; color: var(--ab-color-sage, #8a9a88); /* ๐ฟ */
|
|
226
|
+
}
|
|
227
|
+
.frameLive::before {
|
|
228
|
+
content: ""; width: 7px; height: 7px; border-radius: 50%; /* โช */
|
|
229
|
+
background: var(--ab-color-sage, #8a9a88); box-shadow: 0 0 0 3px rgb(138 154 136 / 0.25); /* ๐ฟ */
|
|
230
|
+
}
|
|
231
|
+
.framed[data-variant='compact'] .frameHeader { padding: 0 14px; font-size: 12.5px; gap: 8px; } /* ๐ฑ */
|
|
232
|
+
.framed[data-variant='compact'] .frameHeader .logo { height: 14px; } /* ๐ฑ */
|
|
233
|
+
.framed[data-variant='compact'] .pkg { font-size: 10.5px; margin-left: auto; } /* ๐ฑ */
|
|
234
|
+
.framed[data-variant='compact'] .frameLive { display: none; } /* ๐ฑ v6 hides "live" */
|
|
235
|
+
.frameWires { position: absolute; inset: 0; overflow: visible; } /* ใฐ๏ธ */
|
|
236
|
+
.wireGlow, .frameWire, .dotHalo, .dotCore { fill: none; stroke-linecap: round; } /* โช */
|
|
237
|
+
.wireGlow { stroke: var(--ab-flow-wire); stroke-width: 7; opacity: 0.14; } /* ๐ซ๏ธ */
|
|
238
|
+
.frameWire { stroke: var(--ab-flow-wire); stroke-width: 1.8; opacity: 0.8; } /* ๐๏ธ */
|
|
239
|
+
/* โจ the pulse is ab-nextjs-animations' .ab-wire-pulse dash, shrunk to a zero-length dash = a round dot */
|
|
240
|
+
.dotHalo.dotHalo { stroke: var(--ab-flow-wire); stroke-width: 12; stroke-dasharray: 0 100; filter: blur(2px); } /* ๐ */
|
|
241
|
+
.dotCore.dotCore { stroke: var(--ab-flow-pulse-core); stroke-width: 5.2; stroke-dasharray: 0 100; } /* โช */
|
|
242
|
+
.framed[data-variant='compact'] .wireGlow { stroke-width: 5; } /* ๐ฑ */
|
|
243
|
+
.framed[data-variant='compact'] .frameWire { stroke-width: 1.6; } /* ๐ฑ */
|
|
244
|
+
.framed[data-variant='compact'] .dotHalo { stroke-width: 10; } /* ๐ฑ */
|
|
245
|
+
.framed[data-variant='compact'] .dotCore { stroke-width: 4.4; } /* ๐ฑ */
|
|
246
|
+
.richNode {
|
|
247
|
+
position: absolute; box-sizing: border-box; /* ๐ v6 .n */
|
|
248
|
+
display: flex; align-items: center; justify-content: center; gap: 10px; /* ๐ */
|
|
249
|
+
background: var(--ab-flow-node); border: 1px solid var(--ab-flow-line); border-radius: 14px; /* ๐ต */
|
|
250
|
+
box-shadow: 0 0 0 1px rgb(166 124 82 / 0.12), 0 10px 30px -8px rgb(166 124 82 / 0.35); /* โจ bronze glow */
|
|
251
|
+
}
|
|
252
|
+
.richNode[data-tone='hub'] {
|
|
253
|
+
border-color: rgb(166 124 82 / 0.55); /* ๐ฅ */
|
|
254
|
+
box-shadow: 0 0 0 1px rgb(166 124 82 / 0.45), 0 0 40px 5px rgb(166 124 82 / 0.32); /* ๐ v6 hub glow (mid value) */
|
|
255
|
+
}
|
|
256
|
+
.framed[data-variant='compact'] .richNode { border-radius: 11px; font-size: 13px; font-weight: 600; gap: 7px; } /* ๐ฑ */
|
|
257
|
+
.nodeCaption {
|
|
258
|
+
position: absolute; top: -21px; left: 2px; /* ๐ท๏ธ v6 .lb */
|
|
259
|
+
font: 400 10.5px var(--ab-font-code, 'Roboto Mono', var(--ab-font-mono, ui-monospace, monospace)); color: var(--ab-flow-muted); white-space: nowrap;
|
|
260
|
+
/* ๐ท๏ธ spec rev 2: the label sits on a small card chip, so wires pass BEHIND it (v6 let wires cross labels) */
|
|
261
|
+
background: var(--ab-flow-card, var(--ab-color-card, #fff)); padding: 0 4px; margin-left: -4px; border-radius: 4px; z-index: 1;
|
|
262
|
+
}
|
|
263
|
+
.nodeCaption[data-at='beside-centre'] { left: calc(50% + 9px); margin-left: 0; } /* ๐ฑ spec rev 2: right of the centre wire */
|
|
264
|
+
.framed[data-variant='compact'] .nodeCaption { font-size: 10px; top: -16px; } /* ๐ฑ */
|
|
265
|
+
.anchor {
|
|
266
|
+
position: absolute; width: 9px; height: 9px; border-radius: 50%; /* โ v6 .anc */
|
|
267
|
+
background: var(--ab-flow-wire); box-shadow: 0 0 0 3px var(--ab-flow-card, var(--ab-color-card, #fff)); transform: translate(-50%, -50%);
|
|
268
|
+
}
|
|
269
|
+
.framed[data-variant='compact'] .anchor { width: 7px; height: 7px; } /* ๐ฑ */
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
* 1+|> <AbAppLayout variant="panes" mobileHeader="main" content={<AbMainLayout
|
|
34
34
|
* -|> mainHeader={<AbMobileHeader logo={<a href="/" id="home-logo">โฆ</a>} onLanguage={openLanguage}
|
|
35
35
|
* -|> theme={mode} onThemeChange={setMode} />} โฆ />} />
|
|
36
|
+
* 0.2.3 (Joseph, Welcome 0.2.21): a counter row under the bar + the 3-state theme cycle
|
|
37
|
+
* 2+|> <AbMobileHeader logo={logo} themeMode={mode} onThemeModeChange={setMode}
|
|
38
|
+
* -|> row={<AbCarouselCounter />} />
|
|
36
39
|
*
|
|
37
40
|
* ๐ Requires ab-nextjs-core โฅ 0.2.1 with `mobileHeader="main"` on AbAppLayout. That hides the app header below
|
|
38
41
|
* 768px and turns the main header slot into this 56px bar; older core shows it inside the normal main header.
|
|
@@ -48,13 +51,34 @@
|
|
|
48
51
|
'use client';
|
|
49
52
|
|
|
50
53
|
// โ๏ธ React
|
|
51
|
-
import type
|
|
54
|
+
import { useSyncExternalStore, type MouseEvent, type ReactElement, type ReactNode, type Ref } from 'react';
|
|
52
55
|
// ๐งต classes
|
|
53
56
|
import clsx from 'clsx';
|
|
54
57
|
// ๐ฃ icons
|
|
55
58
|
import AbIcon from '../ab-icon';
|
|
56
59
|
// ๐จ the drawers v2 kit
|
|
57
60
|
import kit from '../ab-drawer/kit.module.css';
|
|
61
|
+
// ๐ 0.2.3: the shared theme state (AbThemeModeProvider)
|
|
62
|
+
import { useAbThemeModeContext } from '../ab-theme-mode';
|
|
63
|
+
|
|
64
|
+
/** ๐ 0.2.3: the three theme modes (same names as ab-nextjs-hooks' AbThemeMode) */
|
|
65
|
+
export type AbMobileHeaderThemeMode = 'light' | 'dark' | 'system';
|
|
66
|
+
/** ๐ 0.2.3: the 3-state cycle order */
|
|
67
|
+
export const AB_MOBILE_HEADER_THEME_CYCLE: readonly AbMobileHeaderThemeMode[] = ['light', 'dark', 'system'];
|
|
68
|
+
// ๐ฃ the glyph of each mode
|
|
69
|
+
const THEME_ICON: Record<AbMobileHeaderThemeMode, string> = { light: 'light_mode', dark: 'dark_mode', system: 'computer' };
|
|
70
|
+
|
|
71
|
+
/** ๐ 0.2.3: one entry of the no-JS language list */
|
|
72
|
+
export interface AbMobileHeaderLanguage {
|
|
73
|
+
locale: string; // ๐ท๏ธ e.g. 'fr' (lang + hreflang on the link)
|
|
74
|
+
label: string; // ๐ฃ๏ธ e.g. 'Franรงais' (in its own language)
|
|
75
|
+
href: string; // ๐ that locale's URL of the current page
|
|
76
|
+
current?: boolean; // โ
aria-current="true" on the active one
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ๐ข hydrated? false on the server + the hydration pass, true after (no setState-in-effect)
|
|
80
|
+
const subscribeNothing = () => () => {};
|
|
81
|
+
const useHydrated = (): boolean => useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
58
82
|
|
|
59
83
|
/** โ๏ธ props */
|
|
60
84
|
export interface AbMobileHeaderProps {
|
|
@@ -63,8 +87,34 @@ export interface AbMobileHeaderProps {
|
|
|
63
87
|
theme?: 'light' | 'dark'; // ๐ the resolved theme now
|
|
64
88
|
onThemeChange?: (next: 'light' | 'dark') => void; // ๐ the toggle (it shows the mode it switches TO: a moon in light)
|
|
65
89
|
actions?: ReactNode; // โ more 44px buttons after the two (none in John's frame)
|
|
66
|
-
labels?: { language?: string; toDark?: string; toLight?: string; header?: string }; // ๐ "Change language", "Switch to dark theme", "Switch to light theme", "Main header"
|
|
90
|
+
labels?: { language?: string; toDark?: string; toLight?: string; toSystem?: string; header?: string }; // ๐ "Change language", "Switch to dark theme", "Switch to light theme", (0.2.3) "Use the system theme", "Main header"
|
|
67
91
|
languageExpanded?: boolean; // โฟ aria-expanded on the globe while its sheet is open
|
|
92
|
+
// ๐ 0.2.3: the 3-state theme (light โ dark โ system โ light). When `onThemeModeChange` is set it replaces the
|
|
93
|
+
// 2-state toggle; the button shows (and names) the mode a tap switches TO, like the 2-state one
|
|
94
|
+
themeMode?: AbMobileHeaderThemeMode;
|
|
95
|
+
onThemeModeChange?: (next: AbMobileHeaderThemeMode) => void;
|
|
96
|
+
// โ 0.2.3: extra content shared with the main header, as a second row under the bar (e.g. Welcome's counter
|
|
97
|
+
// row). Core โฅ 0.2.3 lets the 56px mobile bar grow to fit it
|
|
98
|
+
row?: ReactNode;
|
|
99
|
+
// ๐ 0.2.3: the globe's popup wiring. `languageControls` = the language sheet's id โ aria-controls, and
|
|
100
|
+
// aria-expanded is always present (false unless `languageExpanded`). `languageRef` = the globe element, e.g.
|
|
101
|
+
// for AbBottomDrawer's `trigger` focus return
|
|
102
|
+
languageControls?: string;
|
|
103
|
+
languageRef?: Ref<HTMLButtonElement & HTMLAnchorElement>;
|
|
104
|
+
// ๐งฉ 0.2.3 no-JS fallback: with `languageHref` the globe is a real link to a language list (works before
|
|
105
|
+
// hydration and without JS); once hydrated, `onLanguage` (if set) opens the sheet instead of navigating
|
|
106
|
+
languageHref?: string;
|
|
107
|
+
// ๐งฉ 0.2.3 no-JS fallback (preferred; the app has no language route): with `languages` the globe is a
|
|
108
|
+
// <details>/<summary> holding a list of links, which works with no JS at all. Once hydrated and `onLanguage`
|
|
109
|
+
// is set, the summary opens the sheet instead (aria-controls / aria-expanded kept). Wins over `languageHref`
|
|
110
|
+
languages?: readonly AbMobileHeaderLanguage[];
|
|
111
|
+
// ๐ 0.2.3: 'compact' = a 48px bar with 18px start inset (the Welcome v6 mock: 48 + the counter row = 96px).
|
|
112
|
+
// Default 'default' (56px, John's drawers v2 frame)
|
|
113
|
+
size?: 'default' | 'compact';
|
|
114
|
+
// ๐ฑ 0.2.3 (Joseph, Welcome 0.2.21): where the bar (logo ยท globe ยท theme) shows, from CSS only (no JS, SSR-safe):
|
|
115
|
+
// 'auto' (default) = hidden from 768px up ONLY inside a core mainHeaderAt="all" layout (there the app header
|
|
116
|
+
// already has the logo, so just the `row` stays), else everywhere; 'all' = always; 'mobile' = below 768px only
|
|
117
|
+
barAt?: 'auto' | 'all' | 'mobile';
|
|
68
118
|
className?: string; // ๐ท๏ธ
|
|
69
119
|
}
|
|
70
120
|
|
|
@@ -74,23 +124,112 @@ export interface AbMobileHeaderProps {
|
|
|
74
124
|
* no menu button (the left drawer opens with an edge swipe). Put it in AbMainLayout's `mainHeader` with core
|
|
75
125
|
* โฅ 0.2.1 `mobileHeader="main"`: the 56px row, its divider and the hidden app header come from core.
|
|
76
126
|
*/
|
|
77
|
-
const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, actions, labels = {}, languageExpanded, className }: AbMobileHeaderProps): ReactElement => {
|
|
78
|
-
const L = { language: 'Change language', toDark: 'Switch to dark theme', toLight: 'Switch to light theme', header: 'Main header', ...labels }; // ๐
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
127
|
+
const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, themeMode = 'system', onThemeModeChange, actions, row, labels = {}, languageExpanded, languageControls, languageRef, languageHref, languages, size = 'default', barAt = 'auto', className }: AbMobileHeaderProps): ReactElement => {
|
|
128
|
+
const L = { language: 'Change language', toDark: 'Switch to dark theme', toLight: 'Switch to light theme', toSystem: 'Use the system theme', header: 'Main header', ...labels }; // ๐
|
|
129
|
+
const name: Record<AbMobileHeaderThemeMode, string> = { light: L.toLight, dark: L.toDark, system: L.toSystem }; // โฟ "switch TO" names
|
|
130
|
+
// ๐ 0.2.3: under an AbThemeModeProvider with no theme props, the button is the 3-state cycle on the SHARED state
|
|
131
|
+
// (same mode as the laptop toggles, no drift across 768px). Explicit props still win
|
|
132
|
+
const shared = useAbThemeModeContext();
|
|
133
|
+
const hydrated = useHydrated(); // ๐ข 0.2.3: the <details> fallback hands over to the sheet only once JS runs
|
|
134
|
+
const sheet = hydrated && !!onLanguage; // ๐ฑ the globe opens the sheet
|
|
135
|
+
const fromShared = !!shared && !onThemeModeChange && !onThemeChange; // ๐ง
|
|
136
|
+
const mode3 = fromShared ? (shared.mode as AbMobileHeaderThemeMode) : themeMode; // ๐ the mode shown
|
|
137
|
+
const set3 = fromShared ? shared.setMode : onThemeModeChange; // ๐ the setter used
|
|
138
|
+
// ๐ 0.2.3: 3-state when onThemeModeChange is given (or shared), else the 2-state toggle (unchanged)
|
|
139
|
+
const three = !!set3;
|
|
140
|
+
const next: AbMobileHeaderThemeMode = three
|
|
141
|
+
? AB_MOBILE_HEADER_THEME_CYCLE[(Math.max(0, AB_MOBILE_HEADER_THEME_CYCLE.indexOf(mode3)) + 1) % AB_MOBILE_HEADER_THEME_CYCLE.length] // ๐
|
|
142
|
+
: theme === 'dark' ? 'light' : 'dark'; // ๐ the target
|
|
143
|
+
const showTheme = three || !!onThemeChange; // ๐
|
|
144
|
+
// ๐งฑ the 56px bar: logo ยท globe ยท theme ยท actions
|
|
145
|
+
const bar = (
|
|
146
|
+
<>
|
|
82
147
|
<span className={kit.logoRow}>{logo}</span>
|
|
83
|
-
{
|
|
84
|
-
<
|
|
148
|
+
{languages && languages.length > 0 ? (
|
|
149
|
+
// ๐งฉ 0.2.3: <details> = a native disclosure of plain links: no JS needed. With JS + onLanguage, the summary
|
|
150
|
+
// click is intercepted (no toggle) and opens the sheet; its popup ARIA only appears then
|
|
151
|
+
<details className={kit.langDetails} data-ab-part="mobile-header-languages">
|
|
152
|
+
<summary
|
|
153
|
+
ref={languageRef as Ref<HTMLElement>}
|
|
154
|
+
className={kit.ibtn}
|
|
155
|
+
aria-label={L.language}
|
|
156
|
+
aria-haspopup={sheet ? 'dialog' : undefined} // โฟ
|
|
157
|
+
aria-controls={sheet ? languageControls : undefined} // ๐
|
|
158
|
+
aria-expanded={sheet ? !!languageExpanded : undefined} // โฟ native <details> state otherwise
|
|
159
|
+
onClick={(e: MouseEvent<HTMLElement>) => { if (!sheet) return; e.preventDefault(); onLanguage!(); }} // ๐ฑ
|
|
160
|
+
data-ab-part="mobile-header-language"
|
|
161
|
+
>
|
|
162
|
+
<AbIcon name="language" size={24} />
|
|
163
|
+
</summary>
|
|
164
|
+
<ul className={kit.langList} aria-label={L.language}>
|
|
165
|
+
{languages.map((l) => (
|
|
166
|
+
<li key={l.locale}>
|
|
167
|
+
<a href={l.href} hrefLang={l.locale} lang={l.locale} aria-current={l.current ? 'true' : undefined}>{l.label}</a>
|
|
168
|
+
</li>
|
|
169
|
+
))}
|
|
170
|
+
</ul>
|
|
171
|
+
</details>
|
|
172
|
+
) : languageHref != null ? (
|
|
173
|
+
// ๐งฉ 0.2.3: a link first (no-JS / pre-hydration: navigates to the list), upgraded to the sheet by onLanguage
|
|
174
|
+
<a
|
|
175
|
+
ref={languageRef}
|
|
176
|
+
href={languageHref}
|
|
177
|
+
className={kit.ibtn}
|
|
178
|
+
aria-label={L.language}
|
|
179
|
+
aria-haspopup={onLanguage ? 'dialog' : undefined} // โฟ only when it opens a sheet
|
|
180
|
+
aria-controls={onLanguage ? languageControls : undefined} // ๐
|
|
181
|
+
aria-expanded={onLanguage && languageControls ? !!languageExpanded : languageExpanded} // โฟ
|
|
182
|
+
onClick={(e: MouseEvent<HTMLAnchorElement>) => { if (!onLanguage || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return; e.preventDefault(); onLanguage(); }} // ๐ฑ๏ธ new-tab clicks still navigate
|
|
183
|
+
data-ab-part="mobile-header-language"
|
|
184
|
+
>
|
|
185
|
+
<AbIcon name="language" size={24} />
|
|
186
|
+
</a>
|
|
187
|
+
) : onLanguage && (
|
|
188
|
+
<button
|
|
189
|
+
ref={languageRef}
|
|
190
|
+
type="button"
|
|
191
|
+
className={kit.ibtn}
|
|
192
|
+
aria-label={L.language}
|
|
193
|
+
aria-haspopup="dialog"
|
|
194
|
+
aria-controls={languageControls} // ๐ 0.2.3
|
|
195
|
+
aria-expanded={languageControls ? !!languageExpanded : languageExpanded} // โฟ 0.2.3: always set with a target
|
|
196
|
+
onClick={onLanguage}
|
|
197
|
+
data-ab-part="mobile-header-language"
|
|
198
|
+
>
|
|
85
199
|
<AbIcon name="language" size={24} />
|
|
86
200
|
</button>
|
|
87
201
|
)}
|
|
88
|
-
{
|
|
89
|
-
<button
|
|
90
|
-
|
|
202
|
+
{showTheme && (
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
className={kit.ibtn}
|
|
206
|
+
aria-label={name[next]} // โฟ the mode a tap switches TO
|
|
207
|
+
onClick={() => (three ? set3!(next) : onThemeChange?.(next as 'light' | 'dark'))} // ๐
|
|
208
|
+
data-ab-part="mobile-header-theme"
|
|
209
|
+
data-theme-mode={three ? mode3 : undefined} // ๐งช 0.2.3: the current mode (3-state only)
|
|
210
|
+
>
|
|
211
|
+
<AbIcon name={THEME_ICON[next]} size={24} />
|
|
91
212
|
</button>
|
|
92
213
|
)}
|
|
93
214
|
{actions}
|
|
215
|
+
</>
|
|
216
|
+
);
|
|
217
|
+
return (
|
|
218
|
+
<div
|
|
219
|
+
className={clsx('AbMobileHeader', kit.mh, row != null && kit.mhStack, size === 'compact' && kit.mhCompact, className)} // ๐งฑ 0.2.3: a column when there is a row
|
|
220
|
+
role="group"
|
|
221
|
+
aria-label={L.header}
|
|
222
|
+
data-ab-part="mobile-header"
|
|
223
|
+
data-ab-bar-at={barAt} // ๐ฑ 0.2.3: kit CSS hides the bar from 768px up for 'mobile' (and 'auto' in mainHeaderAt="all")
|
|
224
|
+
data-ab-header-size={size === 'compact' ? 'compact' : undefined} // ๐ 0.2.3: core โฅ 0.2.3 sizes the slot to 48px
|
|
225
|
+
data-ab-header-extra={row != null ? 'true' : undefined} // ๐ 0.2.3: core โฅ 0.2.3 lets the 56px slot grow for it
|
|
226
|
+
>
|
|
227
|
+
{row != null ? (
|
|
228
|
+
<>
|
|
229
|
+
<div className={kit.mhBar} data-ab-part="mobile-header-bar">{bar}</div>
|
|
230
|
+
<div className={kit.mhRow} data-ab-part="mobile-header-row">{row}</div>
|
|
231
|
+
</>
|
|
232
|
+
) : bar}
|
|
94
233
|
</div>
|
|
95
234
|
);
|
|
96
235
|
};
|
|
@@ -140,4 +140,4 @@ const AbPackageCardLegacy = ({ name, href, description, version, icon, media, id
|
|
|
140
140
|
export default AbPackageCard;
|
|
141
141
|
export { AbPackageCard };
|
|
142
142
|
// ๐ผ๏ธ 0.2.1 (God 02:44): the Home preview tiles (mock .pv-anim / .pv-code / .pv-comp)
|
|
143
|
-
export { AbPackagePreviewCurve, AbPackagePreviewCode, AbPackagePreviewComponents } from './previews';
|
|
143
|
+
export { AbPackagePreviewCurve, AbPackagePreviewCode, AbPackagePreviewComponents, type AbPackagePreviewComponentsLabels, type AbPackagePreviewComponentsProps } from './previews';
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
* <AbPackageCard preview={<AbPackagePreviewCode lines={['*use*Theme()', '*use*Media()']} />} โฆ /> // ๐ช Hooks
|
|
35
35
|
* <AbPackageCard preview={<AbPackagePreviewCode lines={['<*AbProvider*>', '~ {children}']} />} โฆ /> // ๐งฑ Core
|
|
36
36
|
* <AbPackageCard preview={<AbPackagePreviewComponents />} โฆ /> // ๐งฉ Components: button ยท switch ยท chip
|
|
37
|
+
* <AbPackagePreviewComponents labels={{ button: 'Bouton', chip: 'Puce', switch: 'Interrupteur' }} /> // ๐ 0.2.2
|
|
37
38
|
*/
|
|
38
39
|
|
|
39
40
|
/*
|
|
@@ -82,13 +83,28 @@ export function AbPackagePreviewCode({ lines }: { lines: readonly string[] }): R
|
|
|
82
83
|
);
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
/** ๐ 0.2.2: the Components tile's strings (English defaults) */
|
|
87
|
+
export interface AbPackagePreviewComponentsLabels {
|
|
88
|
+
button?: string; // ๐ default "Button"
|
|
89
|
+
chip?: string; // ๐ default "Chip"
|
|
90
|
+
switch?: string; // ๐๏ธ default "Switch" (the switch's name when the tile is used outside an aria-hidden card preview)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** โ๏ธ props: `labels` (0.2.2) wins over the 0.2.1 `button` / `chip` props (kept for back-compat) */
|
|
94
|
+
export interface AbPackagePreviewComponentsProps {
|
|
95
|
+
labels?: AbPackagePreviewComponentsLabels; // ๐
|
|
96
|
+
button?: string; // ๐ฐ๏ธ 0.2.1: prefer `labels.button`
|
|
97
|
+
chip?: string; // ๐ฐ๏ธ 0.2.1: prefer `labels.chip`
|
|
98
|
+
}
|
|
99
|
+
|
|
85
100
|
/** ๐งฉ Components tile: a mini button, an on switch and a pill chip, intrinsic size (no stretch), centred both ways. */
|
|
86
|
-
export function AbPackagePreviewComponents({
|
|
101
|
+
export function AbPackagePreviewComponents({ labels = {}, button, chip }: AbPackagePreviewComponentsProps): ReactElement {
|
|
102
|
+
const L = { button: button ?? 'Button', chip: chip ?? 'Chip', switch: 'Switch', ...labels }; // ๐ defaults < legacy props < labels
|
|
87
103
|
return (
|
|
88
104
|
<span className={styles.pvComp} data-ab-part="preview-components">
|
|
89
|
-
<span className={styles.pvBtn}>{button}</span> {/* ๐ 6px radius (kept) */}
|
|
90
|
-
<span className={styles.pvSw}><i /></span> {/* ๐๏ธ on */}
|
|
91
|
-
<span className={styles.pvChip}>{chip}</span> {/* ๐ pill */}
|
|
105
|
+
<span className={styles.pvBtn}>{L.button}</span> {/* ๐ 6px radius (kept) */}
|
|
106
|
+
<span className={styles.pvSw} role="img" aria-label={L.switch}><i /></span> {/* ๐๏ธ on */}
|
|
107
|
+
<span className={styles.pvChip}>{L.chip}</span> {/* ๐ pill */}
|
|
92
108
|
</span>
|
|
93
109
|
);
|
|
94
110
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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: AbPlaygroundScene - Styles (G38)
|
|
28
|
+
* @file: ab-playground-scene/styles.module.css
|
|
29
|
+
* @type: CSS module โ transform/opacity/dash only (CLS 0)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more ๐!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/* ===== AB PLAYGROUND SCENE ยท I18N (illustration 8) ===== */
|
|
40
|
+
/* ๐ฌ 0.2.3 (God 02:26): NO motion here any more. The EN โ FR โ ES โ RU cycle (keyframes, ease-out-cubic rise,
|
|
41
|
+
instant chip jumps, the [data-ab-still] frame, pause + reduced motion) ships from ab-nextjs-animations โฅ 0.2.5
|
|
42
|
+
(`ab-nextjs-animations/locale-cycle`). This module only lays the pieces out. */
|
|
43
|
+
|
|
44
|
+
.greet, .tv, .lseg { --ab-locale-cycle-duration: var(--ab-wire-pulse-duration, 2400ms); } /* โฑ๏ธ the loop follows the scene's `duration` prop */
|
|
45
|
+
.greet { position: relative; display: block; } /* ๐ฆ v6 .gr (size inline) */
|
|
46
|
+
.word {
|
|
47
|
+
position: absolute; left: 0; right: 0; top: 0; text-align: center; white-space: nowrap; /* ๐ stacked, centred */
|
|
48
|
+
font-family: var(--ab-font-title, 'Mulish', sans-serif); font-weight: 700; letter-spacing: -0.01em; /* ๐ค Mulish 700 */
|
|
49
|
+
}
|
|
50
|
+
.tv { position: relative; display: inline-block; width: 66px; height: 16px; } /* ๐ท๏ธ v6 .tv */
|
|
51
|
+
.valueWord.valueWord { right: auto; text-align: start; font-family: var(--ab-font-code, 'Roboto Mono', ui-monospace, monospace); font-weight: 400; letter-spacing: 0; } /* ๐ป Roboto Mono */
|
|
52
|
+
.lseg { --ab-locale-cycle-on-bg: #a67c52; --ab-locale-cycle-on-fg: #fff8f5; --ab-locale-cycle-off-fg: var(--ab-flow-muted, rgb(33 26 22 / 0.62)); } /* ๐ฅ v6 .on / idle */
|
|
53
|
+
.lseg .chip { padding: 6px 11px; border-radius: 7px; color: var(--ab-locale-cycle-off-fg); } /* ๐๏ธ v6 .seg span */
|
|
54
|
+
.ms .chip { padding: 5px 6px; } /* ๐ฑ v6 .ms span */
|