ab-nextjs-components 0.2.2 β 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/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-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
|
@@ -0,0 +1,141 @@
|
|
|
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 i18n (illustration 8)
|
|
28
|
+
* @file: ab-playground-scene/i18n.tsx
|
|
29
|
+
* @type: Module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more π!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
// βοΈ types
|
|
40
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
41
|
+
// π§΅ classes
|
|
42
|
+
import clsx from 'clsx';
|
|
43
|
+
// πΌοΈ the globe
|
|
44
|
+
import { Ms } from './icons';
|
|
45
|
+
// π labels + the 4 demo locales
|
|
46
|
+
import { AB_PLAYGROUND_LOCALES, type AbPlaygroundSceneLabels } from './labels';
|
|
47
|
+
// π¨ shared mock classes (.m, .br, .sg, .segβ¦)
|
|
48
|
+
import s from './styles.module.css';
|
|
49
|
+
// π¬ 0.2.3: the locale cycle now ships from ab-nextjs-animations β₯ 0.2.5 (keyframes, still frame, βΏ, pause)
|
|
50
|
+
import { AB_LOCALE_CYCLE_CHIP_CLASS, AB_LOCALE_CYCLE_WORD_CLASS } from 'ab-nextjs-animations/locale-cycle';
|
|
51
|
+
import 'ab-nextjs-animations/locale-cycle/styles.css'; // π .ab-locale-cycle-word / .ab-locale-cycle-chip
|
|
52
|
+
// π¨ layout only (stacking, fonts, chip padding): no motion lives here any more
|
|
53
|
+
import x from './i18n.module.css';
|
|
54
|
+
|
|
55
|
+
// π₯
|
|
56
|
+
const BRONZE = '#A67C52';
|
|
57
|
+
// β±οΈ each locale's slot in the 2.4s loop: index i is active during [iΒ·0.6s, (i+1)Β·0.6s)
|
|
58
|
+
const slot = (i: number): CSSProperties => ({ '--ab-locale-cycle-index': String(i) }) as CSSProperties;
|
|
59
|
+
|
|
60
|
+
/** π v6 `greet(sz)`: the 4 greetings stacked in one box; only the active one shows (cycle, or the still) */
|
|
61
|
+
export function AbPgGreeting({ L, sz, still }: { L: AbPlaygroundSceneLabels; sz: number; still: number }): ReactElement {
|
|
62
|
+
return (
|
|
63
|
+
<span className={x.greet} style={{ height: Math.trunc(sz * 1.25), width: Math.trunc(sz * 3.9) }}>
|
|
64
|
+
{AB_PLAYGROUND_LOCALES.map((loc, i) => (
|
|
65
|
+
<span key={loc} lang={loc} className={clsx(x.word, AB_LOCALE_CYCLE_WORD_CLASS)} data-ab-still={i === still ? '' : undefined} style={{ ...slot(i), fontSize: sz }}>{L.greetings[loc]}</span>
|
|
66
|
+
))}
|
|
67
|
+
</span>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** ποΈ v6 `seg()`: EN FR ES RU; the bronze chip jumps at every 0.6s boundary (instant, no slide) */
|
|
72
|
+
export function AbPgLocaleSeg({ fs, still, compact }: { fs: number; still: number; compact?: boolean }): ReactElement {
|
|
73
|
+
return (
|
|
74
|
+
<span className={clsx(s.seg, x.lseg, compact && x.ms)} style={{ fontSize: fs }}>
|
|
75
|
+
{AB_PLAYGROUND_LOCALES.map((loc, i) => (
|
|
76
|
+
<span key={loc} className={clsx(x.chip, AB_LOCALE_CYCLE_CHIP_CLASS)} data-ab-still={i === still ? '' : undefined} style={slot(i)}>{loc.toUpperCase()}</span>
|
|
77
|
+
))}
|
|
78
|
+
</span>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** π·οΈ v6 `val()`: the `t("hello")` value, cycling with the greeting */
|
|
83
|
+
export function AbPgValue({ L, still }: { L: AbPlaygroundSceneLabels; still: number }): ReactElement {
|
|
84
|
+
return (
|
|
85
|
+
<span className={x.tv}>
|
|
86
|
+
{AB_PLAYGROUND_LOCALES.map((loc, i) => (
|
|
87
|
+
<span key={loc} lang={loc} className={clsx(x.word, x.valueWord, s.sg, s.m, AB_LOCALE_CYCLE_WORD_CLASS)} data-ab-still={i === still ? '' : undefined} style={slot(i)}>"{L.greetings[loc]}"</span>
|
|
88
|
+
))}
|
|
89
|
+
</span>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// π΅ a node in frame px (same shape as scenes.tsx N())
|
|
94
|
+
type Mk = (x: number, y: number, w: number, h: number, content: ReactNode, caption?: string, hub?: boolean) => import('../ab-flow-diagram/helpers').AbFlowNode;
|
|
95
|
+
const M = ({ children, className, style }: { children: ReactNode; className?: string; style?: CSSProperties }): ReactElement => <span className={clsx(s.m, className)} style={style}>{children}</span>;
|
|
96
|
+
const Br = ({ children }: { children: ReactNode }): ReactElement => <span className={s.br}>{children}</span>;
|
|
97
|
+
const Sg = ({ children }: { children: ReactNode }): ReactElement => <span className={s.sg}>{children}</span>;
|
|
98
|
+
const Globe = ({ sz }: { sz: number }): ReactElement => <span style={{ display: 'flex', color: BRONZE }}><Ms n="globe" sz={sz} /></span>;
|
|
99
|
+
|
|
100
|
+
/** π a locale-following value (path, Intl outputβ¦): stacked, the cycle shows the active locale (still = `still`) */
|
|
101
|
+
function AbPgLocaleValue({ values, still, w }: { values: ReactNode[]; still: number; w: number }): ReactElement {
|
|
102
|
+
return (
|
|
103
|
+
<span className={x.tv} style={{ width: w, height: 16, display: 'inline-block', position: 'relative' }}>
|
|
104
|
+
{values.map((v, i) => (
|
|
105
|
+
<span key={i} lang={AB_PLAYGROUND_LOCALES[i]} className={clsx(x.word, AB_LOCALE_CYCLE_WORD_CLASS)} data-ab-still={i === still ? '' : undefined} style={{ ...slot(i), left: 0, right: 0, display: 'flex', justifyContent: 'center' }}>{v}</span>
|
|
106
|
+
))}
|
|
107
|
+
</span>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
// π£οΈ /en|fr|es|ru/docs and πΆ the REAL Intl.NumberFormat EUR output per locale (spec rev 2 Β§3.8; fixed strings, so
|
|
111
|
+
// the server and every browser ICU render the same text: no hydration mismatch)
|
|
112
|
+
const PATHS = AB_PLAYGROUND_LOCALES.map((l) => <M key={l}>/<Br>{l}</Br>/docs</M>);
|
|
113
|
+
const EUR = ['β¬1,234.50', '1 234,50 β¬', '1234,50 β¬', '1 234,50 β¬'].map((v, i) => <M key={i}>{v}</M>);
|
|
114
|
+
|
|
115
|
+
/** π₯οΈ illustration 8, rev 2 (build_upgraded.py `i18n`): 760Γ600, real ab-nextjs-i18n exports */
|
|
116
|
+
export function buildI18nFull(N: Mk, L: AbPlaygroundSceneLabels, still: number) {
|
|
117
|
+
return [
|
|
118
|
+
N(230, 270, 300, 104, (
|
|
119
|
+
<div className={s.col} style={{ gap: 6 }}>
|
|
120
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}><Globe sz={30} /><AbPgGreeting L={L} sz={34} still={still} /></div>
|
|
121
|
+
<M className={s.mut}><AbI18nProvider></M>
|
|
122
|
+
</div>
|
|
123
|
+
), 'AbI18nProvider', true),
|
|
124
|
+
N(40, 100, 210, 96, <div className={s.m} style={{ lineHeight: 1.7 }}><Br>defineAbI18n</Br>({'{'}<br /> locales: [<Sg>'en'</Sg>,<br /> <Sg>'fr','es','ru'</Sg>] {'}'})</div>, 'ab-nextjs-i18n/config'),
|
|
125
|
+
N(290, 116, 180, 60, <AbPgLocaleSeg fs={11} still={still} />, 'useAbLocaleSwitch()'),
|
|
126
|
+
N(510, 104, 210, 84, <><M><Br>t</Br>("hello") β</M><AbPgValue L={L} still={still} /></>, 'useAbTranslations()'),
|
|
127
|
+
N(40, 456, 210, 74, <AbPgLocaleValue values={PATHS} still={still} w={90} />, 'localizeAbPathname()'),
|
|
128
|
+
N(290, 456, 180, 74, <AbPgLocaleValue values={EUR} still={still} w={110} />, 'useAbFormatter()'),
|
|
129
|
+
N(510, 456, 210, 74, <M>hreflang <Br>Γ4</Br></M>, 'getAbAlternates()'),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** π± illustration 8, rev 2: 350Γ276 (hub y 122 / h 58, bottom caption right of the centre wire) */
|
|
134
|
+
export function buildI18nCompact(N: Mk, L: AbPlaygroundSceneLabels, still: number) {
|
|
135
|
+
return [
|
|
136
|
+
N(80, 122, 190, 58, <><Globe sz={20} /><AbPgGreeting L={L} sz={20} still={still} /></>, '', true),
|
|
137
|
+
N(14, 62, 150, 52, <AbPgLocaleSeg fs={10} still={still} compact />, 'useAbLocaleSwitch'),
|
|
138
|
+
N(186, 62, 150, 52, <AbPgLocaleValue values={PATHS} still={still} w={90} />, 'localizeAbPathname'),
|
|
139
|
+
{ ...N(100, 212, 150, 50, <M><Br>t</Br>("hello")</M>, 'useAbTranslations'), captionAt: 'beside-centre' as const },
|
|
140
|
+
];
|
|
141
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 icons
|
|
28
|
+
* @file: ab-playground-scene/icons.tsx
|
|
29
|
+
* @type: Server Component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more π!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
// βοΈ types
|
|
40
|
+
import type { ReactElement } from 'react';
|
|
41
|
+
|
|
42
|
+
// πΌοΈ John's tiny line icons (welcome-v6 scenes.py `MS` + v5 common.py package icons), decorative only
|
|
43
|
+
const MS: Record<string, ReactElement> = {
|
|
44
|
+
home: <path d="M4 11 12 4l8 7v9h-5v-6H9v6H4z" />,
|
|
45
|
+
search: <><circle cx="11" cy="11" r="6" /><path d="m20 20-4.5-4.5" /></>,
|
|
46
|
+
heart: <path d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.5A4 4 0 0 1 19 10c0 5.6-7 10-7 10z" />,
|
|
47
|
+
bolt: <path d="M13 3 5 13h6l-1 8 8-10h-6z" />,
|
|
48
|
+
user: <><circle cx="12" cy="8" r="4" /><path d="M4 20c1.5-4 4.5-6 8-6s6.5 2 8 6" /></>,
|
|
49
|
+
gear: <><circle cx="12" cy="12" r="3" /><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" /></>,
|
|
50
|
+
bell: <><path d="M6 17V11a6 6 0 0 1 12 0v6l2 2H4z" /><path d="M10 21h4" /></>,
|
|
51
|
+
star: <path d="m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z" />,
|
|
52
|
+
mail: <><rect x="3" y="5" width="18" height="14" rx="2" /><path d="m3 7 9 6 9-6" /></>,
|
|
53
|
+
cal: <><rect x="3" y="5" width="18" height="16" rx="2" /><path d="M3 10h18M8 3v4M16 3v4" /></>,
|
|
54
|
+
cart: <><path d="M3 4h2l2.5 11h11L21 7H6" /><circle cx="9" cy="19" r="1.5" /><circle cx="18" cy="19" r="1.5" /></>,
|
|
55
|
+
share: <><circle cx="6" cy="12" r="2.5" /><circle cx="18" cy="6" r="2.5" /><circle cx="18" cy="18" r="2.5" /><path d="m8.2 11 7.6-4M8.2 13l7.6 4" /></>,
|
|
56
|
+
globe: <><circle cx="12" cy="12" r="9" /><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18" /></>,
|
|
57
|
+
// π¦ 0.2.3 package marks for the Welcome + All scenes (v5 common.py ICON stand-ins, line style)
|
|
58
|
+
pkgCore: <><rect x="4" y="4" width="7" height="7" rx="1.5" /><rect x="13" y="4" width="7" height="7" rx="1.5" /><rect x="4" y="13" width="7" height="7" rx="1.5" /><path d="M16.5 13v7M13 16.5h7" /></>,
|
|
59
|
+
pkgComponents: <><path d="m12 3 4 4-4 4-4-4z" /><path d="m7 8 4 4-4 4-4-4z" /><path d="m17 8 4 4-4 4-4-4z" /><path d="m12 13 4 4-4 4-4-4z" /></>,
|
|
60
|
+
pkgTheme: <><path d="M12 3a9 9 0 1 0 0 18c1.2 0 1.8-.8 1.8-1.7 0-1.3-1-1.6-1-2.6 0-.9.7-1.5 1.6-1.5H17a4 4 0 0 0 4-4c0-4.5-4-8.2-9-8.2z" /><circle cx="7.5" cy="11" r="1" /><circle cx="10" cy="7" r="1" /><circle cx="15" cy="7.5" r="1" /></>,
|
|
61
|
+
pkgIcons: <><circle cx="8" cy="8" r="4" /><path d="m16 4 4.5 8h-9z" /><rect x="4" y="14" width="7" height="7" rx="1" /><path d="m17.5 14 1.2 2.4 2.6.4-1.9 1.8.5 2.6-2.4-1.3-2.4 1.3.5-2.6-1.9-1.8 2.6-.4z" /></>,
|
|
62
|
+
pkgFonts: <><path d="M3 19 8.5 5h1L15 19M5.3 14h7.4" /><path d="M21 19v-6.5a2.5 2.5 0 0 0-5 0M21 15.5c-3.5 0-5 .8-5 2s1 1.5 2 1.5c1.8 0 3-1.3 3-3.5" /></>,
|
|
63
|
+
pkgAnimations: <><path d="M3 17c3 0 4-10 9-10s6 10 9 10" /><circle cx="12" cy="7" r="2" /></>,
|
|
64
|
+
pkgHooks: <><path d="M15 4v8a5 5 0 0 1-10 0v-2" /><path d="m3 12 2-2 2 2" /><circle cx="15" cy="4" r="1.6" /></>,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** π£ the 12 grid icon names (Icons scene) */
|
|
68
|
+
export const AB_PLAYGROUND_ICON_NAMES = ['home', 'search', 'heart', 'bolt', 'user', 'gear', 'bell', 'star', 'mail', 'cal', 'cart', 'share'] as const;
|
|
69
|
+
|
|
70
|
+
/** πΌοΈ v6 `ms(name, size, colour)` */
|
|
71
|
+
export function Ms({ n, sz = 22, col = 'currentColor' }: { n: string; sz?: number; col?: string }): ReactElement {
|
|
72
|
+
return (
|
|
73
|
+
<svg width={sz} height={sz} viewBox="0 0 24 24" fill="none" stroke={col} strokeWidth={1.8} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
74
|
+
{MS[n]}
|
|
75
|
+
</svg>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** βοΈ / π v5 `ic('sun' | 'moon')` (1em) */
|
|
80
|
+
export function Sun(): ReactElement {
|
|
81
|
+
return <svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" aria-hidden="true"><circle cx="12" cy="12" r="4" /><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" /></svg>;
|
|
82
|
+
}
|
|
83
|
+
export function Moon(): ReactElement {
|
|
84
|
+
return <svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinejoin="round" aria-hidden="true"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" /></svg>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** π€ v5 AVATAR (gradient id made unique per scene by the caller) */
|
|
88
|
+
export function Avatar({ id = 'ab-pg-av' }: { id?: string }): ReactElement {
|
|
89
|
+
return (
|
|
90
|
+
<svg viewBox="0 0 64 64" width="100%" height="100%" aria-hidden="true">
|
|
91
|
+
<defs><linearGradient id={id} x1="0" y1="0" x2="0" y2="1"><stop offset="0" stopColor="#E9D3B8" /><stop offset="1" stopColor="#C9A57C" /></linearGradient></defs>
|
|
92
|
+
<circle cx="32" cy="32" r="32" fill={`url(#${id})`} /><circle cx="32" cy="26" r="11" fill="#FFF8F5" opacity=".92" />
|
|
93
|
+
<path d="M12 56c3-11 11-16 20-16s17 5 20 16a32 32 0 0 1-40 0z" fill="#FFF8F5" opacity=".92" />
|
|
94
|
+
</svg>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
|
28
|
+
* @file: ab-playground-scene/index.tsx
|
|
29
|
+
* @type: Server Component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more π!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
// βοΈ types
|
|
40
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
41
|
+
// π§΅ classes
|
|
42
|
+
import clsx from 'clsx';
|
|
43
|
+
// γ°οΈ the engine: AbFlowDiagram's v6 frame mode
|
|
44
|
+
import AbFlowDiagram from '../ab-flow-diagram';
|
|
45
|
+
// π§± John's scene data
|
|
46
|
+
import { AB_PLAYGROUND_SCENE_PACKAGES, buildAbPlaygroundCompactScene, buildAbPlaygroundFullScene } from './scenes';
|
|
47
|
+
// π labels
|
|
48
|
+
import { AB_PLAYGROUND_LOCALES, resolveAbPlaygroundSceneLabels, type AbPlaygroundSceneLabelsInput, type AbPlaygroundSceneName } from './labels';
|
|
49
|
+
// π¨ content classes
|
|
50
|
+
import styles from './styles.module.css';
|
|
51
|
+
|
|
52
|
+
// π¦ re-exports
|
|
53
|
+
export * from './labels';
|
|
54
|
+
export { AB_PLAYGROUND_SCENE_PACKAGES, buildAbPlaygroundFullScene, buildAbPlaygroundCompactScene } from './scenes';
|
|
55
|
+
|
|
56
|
+
/** π
°οΈ the Ab mark (same data URI as ab-logo's AB_LOGO_DEFAULT_SRC; copied, because ab-logo is a client module and
|
|
57
|
+
* a constant imported from one is a client reference in a Server Component) */
|
|
58
|
+
export const AB_PLAYGROUND_MARK_SRC = 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xml%3Aspace%3D%22preserve%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23A67C52%22%20d%3D%22m1.8%2020.5%209.3-17v17zM22.2%207.7l-9.3-4.2v17l9.3-4.2-4.7-4.3z%22/%3E%3Cpath%20d%3D%22m12.9%2020.5%209.3-4.2-9.3-8.6z%22%20opacity%3D%22.1%22/%3E%3C/svg%3E';
|
|
59
|
+
|
|
60
|
+
/** π v6 frames */
|
|
61
|
+
export const AB_PLAYGROUND_FRAMES = {
|
|
62
|
+
full: { w: 760, h: 600, header: 56 }, // π₯οΈ laptop / tablet aside
|
|
63
|
+
compact: { w: 350, h: 276, header: 36 }, // π± mobile
|
|
64
|
+
} as const;
|
|
65
|
+
|
|
66
|
+
// βοΈ props
|
|
67
|
+
export interface AbPlaygroundSceneProps {
|
|
68
|
+
/** ποΈ which package scene (John's v6 1β7, and illustration 8 `i18n`). */
|
|
69
|
+
name: AbPlaygroundSceneName;
|
|
70
|
+
/** π `'full'` = 760Γ600 laptop scene, `'compact'` = 350Γ276 mobile scene. Default `'full'`.
|
|
71
|
+
* π 0.2.3 (Joseph 02:55) `'auto'` = SSR-safe: BOTH are rendered and a CSS media query shows compact below 768px
|
|
72
|
+
* and full from 768px, so phones never flash the full scene and there is no hydration mismatch (no JS decides). */
|
|
73
|
+
variant?: 'full' | 'compact' | 'auto';
|
|
74
|
+
/** βΆοΈ animate only while its slide is active (default true); reduced motion is always respected. */
|
|
75
|
+
active?: boolean;
|
|
76
|
+
/** π translated words (merged over English). */
|
|
77
|
+
labels?: AbPlaygroundSceneLabelsInput;
|
|
78
|
+
/** π
°οΈ logo for the header and hubs (default: the shipped Ab mark). */
|
|
79
|
+
logo?: ReactNode;
|
|
80
|
+
/** βΏ `'always'` forces the still frame (like the OS reduced-motion setting); default `'auto'` follows the OS. */
|
|
81
|
+
reducedMotion?: 'auto' | 'always';
|
|
82
|
+
/** π i18n scene: the locale shown in the still frame (reduced motion / before CSS), e.g. the app's locale.
|
|
83
|
+
* One of en Β· fr Β· es Β· ru (anything else β en). */
|
|
84
|
+
locale?: string;
|
|
85
|
+
/** π pulse loops (default infinite; phones get 3 via the AbFlowDiagram token). */
|
|
86
|
+
loops?: number | 'infinite';
|
|
87
|
+
/** β±οΈ pulse loop ms (default 2400). */
|
|
88
|
+
duration?: number;
|
|
89
|
+
className?: string;
|
|
90
|
+
style?: CSSProperties;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* π¨ AbPlaygroundScene β the Welcome "Live Playground" scenes from John's welcome-v6 mock, faithfully: same rects,
|
|
95
|
+
* same auto-routed wires (route() + rounded()), dotted surface, anchors, travelling pulses, card + header.
|
|
96
|
+
* Server-compatible (AbFlowDiagram's tiny scale island is the only client code). One accessible image (translated alt).
|
|
97
|
+
*/
|
|
98
|
+
export function AbPlaygroundScene(props: AbPlaygroundSceneProps): ReactElement {
|
|
99
|
+
// π 0.2.3 'auto': render both variants; styles.module.css `.auto` picks one by media query (display: none hides the
|
|
100
|
+
// other from the a11y tree, and its animations never run)
|
|
101
|
+
if (props.variant === 'auto') {
|
|
102
|
+
return (
|
|
103
|
+
<div className={clsx('AbPlaygroundSceneAuto', styles.auto, props.className)} style={props.style} data-ab-part="playground-scene-auto">
|
|
104
|
+
<AbPlaygroundScene {...props} variant="full" className={styles.autoFull} style={undefined} />
|
|
105
|
+
<AbPlaygroundScene {...props} variant="compact" className={styles.autoCompact} style={undefined} />
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
const { name, variant = 'full', active = true, labels, logo, loops, duration, className, style, reducedMotion = 'auto', locale } = props;
|
|
110
|
+
const still = Math.max(0, AB_PLAYGROUND_LOCALES.indexOf((locale ?? 'en').slice(0, 2).toLowerCase() as never)); // πΌοΈ the still locale
|
|
111
|
+
const L = resolveAbPlaygroundSceneLabels(labels); // π
|
|
112
|
+
// eslint-disable-next-line @next/next/no-img-element -- πΌοΈ inline data-URI SVG mark, nothing for next/image to optimize
|
|
113
|
+
const mark = logo ?? <img src={AB_PLAYGROUND_MARK_SRC} alt="" />; // π
°οΈ
|
|
114
|
+
const data = (variant === 'compact' ? buildAbPlaygroundCompactScene : buildAbPlaygroundFullScene)(name, L, mark, still); // π§±
|
|
115
|
+
return (
|
|
116
|
+
<AbFlowDiagram
|
|
117
|
+
nodes={data.nodes}
|
|
118
|
+
wires={data.wires}
|
|
119
|
+
edges={data.edges} // π 0.2.3: welcome compact = spokes only
|
|
120
|
+
anchors={data.anchors} // β 0.2.3
|
|
121
|
+
frame={AB_PLAYGROUND_FRAMES[variant]} // π
|
|
122
|
+
variant={variant}
|
|
123
|
+
alt={L.alt[name]} // βΏ
|
|
124
|
+
title={L.title} // π·οΈ
|
|
125
|
+
caption={AB_PLAYGROUND_SCENE_PACKAGES[name]} // π¦ mono package name
|
|
126
|
+
live={L.live} // π’
|
|
127
|
+
logo={mark} // π
°οΈ
|
|
128
|
+
active={active} // βΆοΈ
|
|
129
|
+
reducedMotion={reducedMotion} // βΏ
|
|
130
|
+
loops={loops}
|
|
131
|
+
duration={duration}
|
|
132
|
+
className={clsx('AbPlaygroundScene', styles.scene, className)}
|
|
133
|
+
style={style}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export default AbPlaygroundScene;
|
|
@@ -0,0 +1,103 @@
|
|
|
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 labels
|
|
28
|
+
* @file: ab-playground-scene/labels.ts
|
|
29
|
+
* @type: Module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more π!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
// π every visible WORD in the scenes (code, package names and file names stay as they are, like the mock).
|
|
40
|
+
// Pass `labels={{ ... }}` (e.g. from next-intl / the Welcome messages) to translate; missing keys fall back to English.
|
|
41
|
+
|
|
42
|
+
/** ποΈ the 8 scene names (John's v6 1β7 + illustration 8 `i18n`) */
|
|
43
|
+
/** ποΈ 0.2.3 (Joseph 02:35): + `welcome` (v6 s01, every package around the Ab mark) and `all` (v6 s09, the final slide) */
|
|
44
|
+
export type AbPlaygroundSceneName = 'core' | 'components' | 'theme' | 'icons' | 'fonts' | 'animations' | 'hooks' | 'i18n' | 'welcome' | 'all';
|
|
45
|
+
|
|
46
|
+
/** π the 4 demo locales of the i18n scene, in cycle order (EN β FR β ES β RU, 0.6s each) */
|
|
47
|
+
export const AB_PLAYGROUND_LOCALES = ['en', 'fr', 'es', 'ru'] as const;
|
|
48
|
+
export type AbPlaygroundLocale = (typeof AB_PLAYGROUND_LOCALES)[number];
|
|
49
|
+
|
|
50
|
+
/** π¬π§ English defaults */
|
|
51
|
+
export const AB_PLAYGROUND_SCENE_LABELS = {
|
|
52
|
+
title: 'Live Playground', // π·οΈ header
|
|
53
|
+
live: 'live', // π’ header
|
|
54
|
+
alt: {
|
|
55
|
+
core: 'Live playground: the AbPageProvider hub wired to AbAppLayout, AbMainLayout, useAbAsideToggle, AbDottedSurface, AbAsideLayout and AbLinearProgress.',
|
|
56
|
+
components: 'Live playground: ab-nextjs-components wired to AbButton, AbThemeToggle, AbTabs, AbBottomDrawer, AbAvatar and AbNavbar previews.',
|
|
57
|
+
theme: 'Live playground: the AbThemeModeProvider palette wired to tokens, colour scheme, light and dark, radius, contrast and Tailwind nodes.',
|
|
58
|
+
icons: 'Live playground: an icon set wired to size, variant, AbIcon, bundle, fill axis and typed import nodes.',
|
|
59
|
+
fonts: 'Live playground: ab-nextjs-fonts wired to Zilla Slab, Inter weights, Inter, Mulish, Quicksand and Roboto samples.',
|
|
60
|
+
animations: 'Live playground: an ease-out curve with a moving dot, wired to spring, duration, preset, reduced motion, the wire pulse and stagger nodes.',
|
|
61
|
+
hooks: 'Live playground: ab-nextjs-hooks wired to useAbTheme, useAbMedia, useAbReducedMotion, useAbLocalStorage, useAbScrollSpy and useAbClipboard.',
|
|
62
|
+
i18n: 'Live playground: the AbI18nProvider hub greets in English, French, Spanish and Russian, wired to messages, the locale switcher, translations, the locale prefix, Intl formatting and hreflang alternates.',
|
|
63
|
+
welcome: 'Live playground: the Ab mark wired to Theme, Components, Icons, Fonts, Hooks, Animations and Core, each with a small preview.',
|
|
64
|
+
all: 'Live playground: AbElements wired to all seven packages: Core, Components, Theme, Icons, Fonts, Animations and Hooks.',
|
|
65
|
+
} as Record<AbPlaygroundSceneName, string>,
|
|
66
|
+
// π§± core
|
|
67
|
+
providerHub: 'provider hub', primitive: 'primitive', a11y: 'a11y', locale: 'locale', focusRing: 'Focus ring', focus: 'Focus',
|
|
68
|
+
client: 'client', server: 'server', ssrSafe: 'SSRβsafe', config: 'config',
|
|
69
|
+
open: 'open', closed: 'closed', drawerBelow: 'drawer β€ 1179px', aside: 'aside landmark', // π§± 0.2.3 real-export core scene
|
|
70
|
+
// π§© components
|
|
71
|
+
primary: 'Primary', outline: 'Outline', button: 'Button', dark: 'Dark', preview: 'Preview', code: 'Code', props: 'Props',
|
|
72
|
+
shareSheet: 'Share sheet', tabs: 'Tabs', components: 'Components',
|
|
73
|
+
// π¨ theme
|
|
74
|
+
lightDark: 'light / dark', contrast: 'contrast', scheme: 'scheme', light: 'Light', darkChip: 'Dark', tokens: 'tokens',
|
|
75
|
+
// π£ icons
|
|
76
|
+
iconSet: 'icon set', size: 'size', variant: 'variant', outlined: 'Outlined', rounded: 'Rounded', bundle: 'bundle',
|
|
77
|
+
treeShaken: 'treeβshaken', fillAxis: 'fill axis', typed: 'typed', import: 'import',
|
|
78
|
+
// π€ fonts
|
|
79
|
+
display: 'display', headingsBold: 'headings Β· bold', interWeights: 'Inter weights', sans: 'sans', uiBody: 'UI Β· body',
|
|
80
|
+
altSans: 'alt sans', roundedFont: 'rounded', neutral: 'neutral', headings: 'headings',
|
|
81
|
+
// π¬ animations
|
|
82
|
+
easeOut: 'easeβout', spring: 'spring', duration: 'duration', preset: 'preset', fade: 'fade', slide: 'slide', scale: 'scale',
|
|
83
|
+
reduceAnimations: 'reduce animations', list: 'list', stagger: 'stagger', transition: 'transition', fadeSlide: 'fade Β· slide',
|
|
84
|
+
// πͺ hooks
|
|
85
|
+
keyboard: 'keyboard', storage: 'storage', copy: 'copy', hooks: 'Hooks', scrollSpy: 'scroll spy',
|
|
86
|
+
// π i18n (John's illustration 8)
|
|
87
|
+
messages: 'messages', switcher: 'switcher', translations: 'translations', provider: 'provider', prefix: 'prefix',
|
|
88
|
+
intlFormat: 'Intl format',
|
|
89
|
+
// π welcome + all (v6 s01 / s09)
|
|
90
|
+
pkgCore: 'Core', pkgComponents: 'Components', pkgTheme: 'Theme', pkgIcons: 'Icons', pkgFonts: 'Fonts', pkgAnimations: 'Animations', pkgHooks: 'Hooks',
|
|
91
|
+
abElements: 'AbElements', sevenPackages: '7 packages', mitFree: 'MIT Β· free', liveDocs: 'Live docs', onePwa: 'One PWA',
|
|
92
|
+
/** π the cycling greeting, one per demo locale (each in its OWN language, so usually left as is) */
|
|
93
|
+
greetings: { en: 'Hello', fr: 'Bonjour', es: 'Hola', ru: 'ΠΡΠΈΠ²Π΅Ρ' } as Record<AbPlaygroundLocale, string>,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** π the label dictionary (nested `alt` may be partial too) */
|
|
97
|
+
export type AbPlaygroundSceneLabels = typeof AB_PLAYGROUND_SCENE_LABELS;
|
|
98
|
+
export type AbPlaygroundSceneLabelsInput = Partial<Omit<AbPlaygroundSceneLabels, 'alt' | 'greetings'>> & { alt?: Partial<AbPlaygroundSceneLabels['alt']>; greetings?: Partial<AbPlaygroundSceneLabels['greetings']> };
|
|
99
|
+
|
|
100
|
+
/** π merge app labels over the English defaults */
|
|
101
|
+
export function resolveAbPlaygroundSceneLabels(labels?: AbPlaygroundSceneLabelsInput): AbPlaygroundSceneLabels {
|
|
102
|
+
return { ...AB_PLAYGROUND_SCENE_LABELS, ...labels, alt: { ...AB_PLAYGROUND_SCENE_LABELS.alt, ...labels?.alt }, greetings: { ...AB_PLAYGROUND_SCENE_LABELS.greetings, ...labels?.greetings } };
|
|
103
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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 scenes
|
|
28
|
+
* @file: ab-playground-scene/scenes.tsx
|
|
29
|
+
* @type: Module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more π!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
// βοΈ types
|
|
40
|
+
import type { ReactNode } from 'react';
|
|
41
|
+
// γ°οΈ flow types
|
|
42
|
+
import type { AbFlowNode, AbFlowPoint } from '../ab-flow-diagram/helpers';
|
|
43
|
+
// π labels
|
|
44
|
+
import type { AbPlaygroundSceneLabels, AbPlaygroundSceneName } from './labels';
|
|
45
|
+
// π illustration 8
|
|
46
|
+
import { buildI18nCompact, buildI18nFull } from './i18n';
|
|
47
|
+
// π 0.2.3: v6 s01 (welcome) + s09 (all)
|
|
48
|
+
import { buildAllCompact, buildAllFull, buildWelcomeCompact, buildWelcomeFull } from './welcome';
|
|
49
|
+
// π¨ 0.2.3 (God 03:02): John's upgraded package scenes
|
|
50
|
+
import { buildAnimationsUp, buildComponentsUp, buildCoreUp, buildFontsUp, buildHooksUp, buildIconsUp, buildThemeUp } from './upgraded';
|
|
51
|
+
|
|
52
|
+
// π¦ v6 PKG
|
|
53
|
+
export const AB_PLAYGROUND_SCENE_PACKAGES: Record<AbPlaygroundSceneName, string> = {
|
|
54
|
+
core: 'ab-nextjs-core', components: 'ab-nextjs-components', theme: 'ab-nextjs-theme', icons: 'ab-nextjs-icons',
|
|
55
|
+
fonts: 'ab-nextjs-fonts', animations: 'ab-nextjs-animations', hooks: 'ab-nextjs-hooks', i18n: 'ab-nextjs-i18n',
|
|
56
|
+
welcome: 'ab-elements', all: 'ab-elements', // π 0.2.3 v6 PKG[0] / PKG[8]
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** π§± a built scene: nodes (hub included) + optional extra wires */
|
|
60
|
+
export interface AbPlaygroundSceneData { nodes: AbFlowNode[]; wires?: AbFlowPoint[][]; /** π 0.2.3: `[]` = no auto routing */ edges?: []; /** β 0.2.3: false = no anchor dots */ anchors?: boolean }
|
|
61
|
+
|
|
62
|
+
// π΅ v6 N(x, y, w, h, html, lb, cls)
|
|
63
|
+
let seq = 0;
|
|
64
|
+
const N = (x: number, y: number, w: number, h: number, content: ReactNode, caption = '', hub = false): AbFlowNode =>
|
|
65
|
+
({ id: hub ? 'hub' : `n${seq++}`, x, y, w, h, content, caption: caption || undefined, tone: hub ? 'hub' : 'node' });
|
|
66
|
+
|
|
67
|
+
/** π₯οΈ the 760Γ600 scenes (scenes.py `scene_nodes` k = 1β¦7) */
|
|
68
|
+
export function buildAbPlaygroundFullScene(name: AbPlaygroundSceneName, L: AbPlaygroundSceneLabels, logo: ReactNode, still = 0): AbPlaygroundSceneData {
|
|
69
|
+
seq = 0;
|
|
70
|
+
switch (name) {
|
|
71
|
+
// π¨ 0.2.3 (God 03:02): John's Welcome v6 UPGRADED scenes (playground-spec.md rev 2): real export captions,
|
|
72
|
+
// 4 states Γ 0.6s, reduced-motion still = state 0. Motion = ab-nextjs-animations' state cycle (upgraded.tsx)
|
|
73
|
+
case 'core': return { nodes: buildCoreUp(N, false) };
|
|
74
|
+
case 'components': return { nodes: buildComponentsUp(N, false, logo) };
|
|
75
|
+
case 'theme': return { nodes: buildThemeUp(N, false) };
|
|
76
|
+
case 'icons': return { nodes: buildIconsUp(N, false) };
|
|
77
|
+
case 'fonts': return { nodes: buildFontsUp(N, false) };
|
|
78
|
+
case 'animations': return { nodes: buildAnimationsUp(N, false) };
|
|
79
|
+
case 'hooks': return { nodes: buildHooksUp(N, false, logo) };
|
|
80
|
+
case 'welcome': return buildWelcomeFull(N, L, logo); // π v6 s01
|
|
81
|
+
case 'all': return buildAllFull(N, L, logo); // π v6 s09
|
|
82
|
+
default: return { nodes: buildI18nFull(N, L, still) }; // π John's illustration 8 (`still` = the reduced-motion locale)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** π± the 350Γ276 scenes (scenes.py `mscene_nodes` k = 1β¦7) */
|
|
87
|
+
export function buildAbPlaygroundCompactScene(name: AbPlaygroundSceneName, L: AbPlaygroundSceneLabels, logo: ReactNode, still = 0): AbPlaygroundSceneData {
|
|
88
|
+
seq = 0;
|
|
89
|
+
const sc = (...n: AbFlowNode[]): AbPlaygroundSceneData => ({ nodes: n });
|
|
90
|
+
switch (name) {
|
|
91
|
+
// π¨ 0.2.3 (God 03:02): upgraded mobile scenes (3 nodes + hub at y 122 / h 58; bottom caption right of the wire)
|
|
92
|
+
case 'core': return sc(...buildCoreUp(N, true));
|
|
93
|
+
case 'components': return sc(...buildComponentsUp(N, true, logo));
|
|
94
|
+
case 'theme': return sc(...buildThemeUp(N, true));
|
|
95
|
+
case 'icons': return sc(...buildIconsUp(N, true));
|
|
96
|
+
case 'fonts': return sc(...buildFontsUp(N, true));
|
|
97
|
+
case 'animations': return sc(...buildAnimationsUp(N, true));
|
|
98
|
+
case 'hooks': return sc(...buildHooksUp(N, true, logo));
|
|
99
|
+
case 'welcome': return buildWelcomeCompact(N, L, logo); // π v6 s01, mobile
|
|
100
|
+
case 'all': return buildAllCompact(N, L, logo); // π v6 s09, mobile
|
|
101
|
+
default: return sc(...buildI18nCompact(N, L, still)); // π illustration 8, mobile
|
|
102
|
+
}
|
|
103
|
+
}
|