ab-nextjs-components 0.1.8 โ†’ 0.1.10

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/ab-brand/index.tsx +30 -1
  3. package/ab-brand/styles.module.css +40 -1
  4. package/ab-button/helpers.ts +90 -0
  5. package/ab-button/index.tsx +164 -87
  6. package/ab-button/styles.module.css +79 -1
  7. package/ab-carousel/helpers.ts +146 -0
  8. package/ab-carousel/index.tsx +643 -0
  9. package/ab-carousel/styles.module.css +206 -0
  10. package/ab-chip/index.tsx +75 -0
  11. package/ab-chip/styles.module.css +87 -0
  12. package/ab-collapsible/index.tsx +30 -1
  13. package/ab-collapsible/styles.module.css +40 -1
  14. package/ab-flow-diagram/helpers.ts +77 -0
  15. package/ab-flow-diagram/index.tsx +141 -0
  16. package/ab-flow-diagram/styles.module.css +141 -0
  17. package/ab-icon/builtin.ts +61 -0
  18. package/ab-icon/helpers.ts +102 -0
  19. package/ab-icon/index.tsx +77 -16
  20. package/ab-icon/styles.module.css +53 -9
  21. package/ab-icon-button/index.tsx +110 -46
  22. package/ab-icon-button/styles.module.css +28 -10
  23. package/ab-install-snippet/helpers.ts +62 -0
  24. package/ab-install-snippet/index.tsx +170 -0
  25. package/ab-install-snippet/styles.module.css +104 -0
  26. package/ab-like-button/index.tsx +33 -1
  27. package/ab-like-button/styles.module.css +41 -6
  28. package/ab-linear-progress/index.tsx +129 -0
  29. package/ab-linear-progress/styles.module.css +105 -0
  30. package/ab-locale-switcher/index.tsx +213 -0
  31. package/ab-locale-switcher/styles.module.css +127 -0
  32. package/ab-logo/index.tsx +88 -30
  33. package/ab-logo/styles.module.css +79 -11
  34. package/ab-pill/index.tsx +74 -0
  35. package/ab-progress-chips/index.tsx +30 -1
  36. package/ab-progress-chips/styles.module.css +40 -1
  37. package/ab-searchbar/index.tsx +33 -2
  38. package/ab-searchbar/styles.module.css +41 -5
  39. package/ab-splash/csp.d.ts +54 -0
  40. package/ab-splash/csp.mjs +82 -0
  41. package/ab-splash/csp.ts +60 -0
  42. package/ab-splash/gate.ts +216 -0
  43. package/ab-splash/index.tsx +140 -0
  44. package/ab-splash/styles.module.css +103 -0
  45. package/ab-theme-toggle/index.tsx +188 -0
  46. package/ab-theme-toggle/styles.module.css +89 -0
  47. package/css/dialog.css +38 -3
  48. package/index.ts +47 -0
  49. package/package.json +46 -18
  50. package/server/ab-brand/index.tsx +29 -1
  51. package/server/ab-brand/styles.module.css +40 -1
  52. package/server/ab-button/index.tsx +96 -79
  53. package/server/ab-button/styles.module.css +79 -1
  54. package/server/ab-icon/index.tsx +68 -16
  55. package/server/ab-icon/styles.module.css +53 -9
  56. package/server/ab-logo/index.tsx +88 -29
  57. package/server/ab-logo/styles.module.css +79 -11
  58. package/types/css.d.ts +43 -0
  59. package/types/index.d.ts +2 -0
@@ -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: AbFlowDiagram - Server (G38, Welcome illustrations)
28
+ * @file: ab-flow-diagram/index.tsx
29
+ * @type: Server component โ€” animated node/wire scene, zero JS
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> <AbFlowDiagram title="Live Playground" caption="ab-nextjs-core" alt={t('s02.illustrationAlt')} active={index === 1}
34
+ * -|> nodes={[{ id: 'hub', label: 'AbProvider', x: 50, y: 50, tone: 'hub' }, { id: 'cfg', label: 'config', x: 20, y: 25 }]} edges={[{ from: 'cfg', to: 'hub' }]} />
35
+ */
36
+
37
+ /*
38
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
39
+ * MOTTO: We'll always do more ๐Ÿ˜œ!!!
40
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
+ */
42
+
43
+ // โš›๏ธ types
44
+ import type { CSSProperties, ReactElement, ReactNode } from 'react';
45
+ // ๐Ÿงต classes
46
+ import clsx from 'clsx';
47
+ // ๐Ÿงฎ pure geometry
48
+ import { getAbFlowEdgePath, type AbFlowEdge, type AbFlowNode } from './helpers';
49
+ // ๐ŸŽจ styles (all motion is CSS: draw-on, pulses, reduced motion, pause)
50
+ import styles from './styles.module.css';
51
+ // ๐ŸŽฌ wire draw-on + pulse come from ab-nextjs-animations (>= 0.2.4); this component only sets its tokens
52
+ import { AB_WIRE_DRAW_CLASS, AB_WIRE_PULSE_CLASS } from 'ab-nextjs-animations/wire';
53
+ import 'ab-nextjs-animations/wire/styles.css'; // ใ€ฐ๏ธ .ab-wire-draw / .ab-wire-pulse
54
+
55
+ // ๐Ÿ“ฆ re-export helpers + types
56
+ export * from './helpers';
57
+
58
+ // โš™๏ธ props
59
+ export interface AbFlowDiagramProps {
60
+ nodes: readonly AbFlowNode[]; // ๐Ÿ”ต nodes in 0โ€“100 coordinates
61
+ edges: readonly AbFlowEdge[]; // ใ€ฐ๏ธ wires between node ids
62
+ alt: string; // โ™ฟ one-sentence description (Welcome.sNN.illustrationAlt)
63
+ title?: string; // ๐Ÿท๏ธ card title, e.g. "Live Playground" (visual)
64
+ caption?: string; // ๐Ÿท๏ธ PKG label, e.g. "ab-nextjs-core" (visual, mono)
65
+ live?: boolean | string; // ๐ŸŸข sage "live" dot; a string sets its visible text
66
+ active?: boolean; // โ–ถ๏ธ animate only while its slide is active (default true)
67
+ loops?: number | 'infinite'; // ๐Ÿ” pulse loops (default infinite; mobile CSS caps at 3)
68
+ variant?: 'full' | 'compact'; // ๐Ÿ“ compact = mobile 276px scene
69
+ posterAt?: number; // ๐Ÿ–ผ๏ธ 0โ€“1, frozen pulse position for reduced motion (mock MID = 0.45)
70
+ duration?: number; // โฑ๏ธ pulse loop ms (default 2400)
71
+ className?: string; // ๐Ÿท๏ธ
72
+ style?: CSSProperties; // ๐ŸŽจ
73
+ children?: ReactNode; // ๐Ÿงฉ optional extra overlay (decorative)
74
+ }
75
+
76
+ /** ๐ŸŽจ Live Playground scene: SVG wires + HTML nodes, CSS-only motion, one accessible image. */
77
+ export function AbFlowDiagram(props: AbFlowDiagramProps): ReactElement {
78
+ // ๐Ÿงฉ props
79
+ const { nodes, edges, alt, title, caption, live = false, active = true, loops = 'infinite', variant = 'full', posterAt = 0.45, duration = 2400, className, style, children } = props;
80
+ // ๐Ÿ—บ๏ธ id โ†’ node
81
+ const byId = new Map(nodes.map((n) => [n.id, n]));
82
+ // ๐ŸŽ›๏ธ ab-nextjs-animations wire tokens drive all timing
83
+ const vars = {
84
+ ...style, // ๐ŸŽจ
85
+ '--ab-wire-pulse-duration': `${duration}ms`, // โฑ๏ธ
86
+ // ๐Ÿ” explicit loops win; default = infinite on laptop, 3 on phones (set in styles.module.css)
87
+ ...(loops === 'infinite' ? {} : { '--ab-wire-pulse-iterations': String(loops) }),
88
+ '--ab-wire-poster': String(100 - Math.min(1, Math.max(0, posterAt)) * 100), // ๐Ÿ–ผ๏ธ dashoffset at the poster frame
89
+ } as CSSProperties;
90
+
91
+ return (
92
+ <figure
93
+ role="img" // โ™ฟ the whole scene is ONE image
94
+ aria-label={alt} // ๐Ÿ—ฃ๏ธ
95
+ className={clsx('AbFlowDiagram', styles.root, className)} // ๐Ÿท๏ธ
96
+ style={vars} // ๐ŸŽ›๏ธ
97
+ data-ab-part="flow-diagram" // ๐Ÿ—‚๏ธ
98
+ data-active={String(active)} // โ–ถ๏ธ / โธ๏ธ
99
+ data-ab-paused={String(!active)} // โธ๏ธ ab-nextjs-animations pauses wires on inactive slides
100
+ data-variant={variant} // ๐Ÿ“
101
+ >
102
+ {/* ๐Ÿท๏ธ card header (decorative: alt already describes it) */}
103
+ {title || live || caption ? (
104
+ <div className={styles.header} aria-hidden="true">
105
+ {title ? <span className={styles.title}>{title}</span> : null}
106
+ {live ? <span className={styles.live}><span className={styles.liveDot} />{typeof live === 'string' ? live : null}</span> : null}
107
+ {caption ? <span className={styles.caption}>{caption}</span> : null}
108
+ </div>
109
+ ) : null}
110
+ {/* ใ€ฐ๏ธ wires layer */}
111
+ <svg className={styles.wires} viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true" focusable="false">
112
+ {edges.map((e, i) => {
113
+ const a = byId.get(e.from); // ๐Ÿ”ต
114
+ const b = byId.get(e.to); // ๐Ÿ”ต
115
+ if (!a || !b) return null; // ๐Ÿงฏ unknown id: skip, don't crash the slide
116
+ const d = getAbFlowEdgePath(a, b, e.curve); // ใ€ฐ๏ธ
117
+ const delay = { '--ab-wire-index': String(i) } as CSSProperties; // โฑ๏ธ stagger (ab-nextjs-animations)
118
+ return (
119
+ <g key={`${e.from}-${e.to}-${i}`} style={delay}>
120
+ <path className={clsx(styles.wire, AB_WIRE_DRAW_CLASS)} d={d} pathLength={100} />{/* ๐Ÿ–Š๏ธ draws on */}
121
+ <path className={clsx(styles.pulse, AB_WIRE_PULSE_CLASS)} d={d} pathLength={100} />{/* โœจ travelling pulse */}
122
+ </g>
123
+ );
124
+ })}
125
+ </svg>
126
+ {/* ๐Ÿ”ต nodes layer (HTML: crisp text, real fonts) */}
127
+ <div className={styles.nodes} aria-hidden="true">
128
+ {nodes.map((n) => (
129
+ <span key={n.id} className={styles.node} data-tone={n.tone ?? 'node'} style={{ left: `${n.x}%`, top: `${n.y}%` }}>
130
+ {n.icon ? <span className={styles.nodeIcon}>{n.icon}</span> : null}
131
+ <span>{n.label}</span>
132
+ </span>
133
+ ))}
134
+ </div>
135
+ {children ? <div className={styles.overlay} aria-hidden="true">{children}</div> : null}
136
+ </figure>
137
+ );
138
+ }
139
+
140
+ // ๐Ÿ“ฆ default export
141
+ export default AbFlowDiagram;
@@ -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: AbFlowDiagram - Styles (G38)
28
+ * @file: ab-flow-diagram/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
+ /* ๐Ÿƒ scene card (laptop 760ร—600 ratio) */
40
+ .root {
41
+ position: relative; /* ๐Ÿ“Œ layers */
42
+ margin: 0; /* ๐Ÿงน figure default */
43
+ width: 100%; /* โ†”๏ธ */
44
+ aspect-ratio: 760 / 600; /* ๐Ÿ“ mock card */
45
+ border-radius: 1.25rem; /* ๐Ÿ”ฒ */
46
+ border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* ๐Ÿ–Š๏ธ */
47
+ background: var(--ab-color-surface-container, transparent); /* ๐ŸŽจ */
48
+ overflow: hidden; /* โœ‚๏ธ */
49
+ color: var(--ab-color-on-surface, currentColor); /* ๐ŸŽจ */
50
+ }
51
+ .root[data-variant='compact'] {
52
+ aspect-ratio: auto; /* ๐Ÿ“ */
53
+ height: 276px; /* ๐Ÿ“ mobile scene */
54
+ }
55
+
56
+ /* ๐Ÿท๏ธ header row */
57
+ .header {
58
+ position: absolute; /* ๐Ÿ“Œ */
59
+ inset: 0.875rem 1rem auto; /* ๐Ÿ“ top */
60
+ display: flex; /* ๐Ÿ“ */
61
+ align-items: center; /* โ†•๏ธ */
62
+ gap: 0.5rem; /* ๐Ÿงฑ */
63
+ font-size: 0.8125rem; /* ๐Ÿ”ก */
64
+ z-index: 2; /* ๐Ÿงฑ */
65
+ }
66
+ .title { font-weight: 600; } /* ๐Ÿ’ช */
67
+ .caption {
68
+ margin-inline-start: auto; /* โžก๏ธ end */
69
+ font-family: var(--ab-font-mono, ui-monospace, monospace); /* ๐Ÿ”ค PKG label */
70
+ color: var(--ab-color-bronze-text, #8A6440); /* โ™ฟ small text */
71
+ }
72
+ .live { display: inline-flex; align-items: center; gap: 0.25rem; } /* ๐ŸŸข */
73
+ .liveDot {
74
+ width: 0.5rem; height: 0.5rem; border-radius: 50%; /* โšช */
75
+ background: var(--ab-color-sage, #7C9A7E); /* ๐ŸŒฟ */
76
+ }
77
+
78
+ /* ใ€ฐ๏ธ wires layer */
79
+ .wires {
80
+ position: absolute; /* ๐Ÿ“Œ */
81
+ inset: 0; /* ๐Ÿ“ full card */
82
+ width: 100%; /* โ†”๏ธ */
83
+ height: 100%; /* โ†•๏ธ */
84
+ overflow: visible; /* ๐Ÿšซ clip */
85
+ }
86
+ .wire,
87
+ .pulse {
88
+ fill: none; /* ๐Ÿซฅ */
89
+ vector-effect: non-scaling-stroke; /* ๐Ÿ“ stroke stays crisp with preserveAspectRatio="none" */
90
+ stroke-linecap: round; /* โšช */
91
+ }
92
+ .wire {
93
+ stroke: color-mix(in srgb, currentColor 28%, transparent); /* ๐ŸŒซ๏ธ */
94
+ stroke-width: 1.5; /* ๐Ÿ“ px */
95
+ /* ๐Ÿ–Š๏ธ draw-on = .ab-wire-draw (ab-nextjs-animations) */
96
+ }
97
+ .pulse {
98
+ stroke: var(--ab-color-bronze, #A67C52); /* ๐Ÿฅ‰ */
99
+ stroke-width: 3; /* ๐Ÿ“ */
100
+ /* โœจ dash, reveal + travel = .ab-wire-pulse (ab-nextjs-animations) */
101
+ }
102
+
103
+ /* ๐Ÿ”ต nodes layer */
104
+ .nodes { position: absolute; inset: 0; } /* ๐Ÿ“ */
105
+ .node {
106
+ position: absolute; /* ๐Ÿ“Œ x/y */
107
+ transform: translate(-50%, -50%); /* ๐ŸŽฏ centre on the point */
108
+ display: inline-flex; /* ๐Ÿ“ */
109
+ align-items: center; /* โ†•๏ธ */
110
+ gap: 0.375rem; /* ๐Ÿงฑ */
111
+ padding: 0.375rem 0.625rem; /* ๐Ÿงฑ */
112
+ border-radius: 0.625rem; /* ๐Ÿ”ฒ */
113
+ border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* ๐Ÿ–Š๏ธ */
114
+ background: var(--ab-color-surface, #fff); /* ๐ŸŽจ */
115
+ font-size: 0.8125rem; /* ๐Ÿ”ก */
116
+ white-space: nowrap; /* ๐Ÿšซ wrap */
117
+ }
118
+ .node[data-tone='hub'] {
119
+ padding: 0.625rem 0.875rem; /* ๐Ÿงฑ bigger */
120
+ border-color: var(--ab-color-bronze, #A67C52); /* ๐Ÿฅ‰ */
121
+ font-weight: 700; /* ๐Ÿ’ช */
122
+ box-shadow: 0 0 0 6px color-mix(in srgb, var(--ab-color-bronze, #A67C52) 12%, transparent); /* โœจ glow */
123
+ }
124
+ .node[data-tone='accent'] { color: var(--ab-color-bronze-text, #8A6440); } /* โ™ฟ */
125
+ .nodeIcon { display: inline-flex; width: 1.125rem; height: 1.125rem; } /* ๐Ÿ–ผ๏ธ */
126
+ .root[data-variant='compact'] .node { font-size: 0.6875rem; padding: 0.25rem 0.5rem; } /* ๐Ÿ“ฑ */
127
+ .overlay { position: absolute; inset: 0; pointer-events: none; } /* ๐Ÿงฉ */
128
+
129
+ /* ๐Ÿ–ฑ๏ธ hover glow on laptop only */
130
+ @media (hover: hover) and (min-width: 1024px) {
131
+ .node:hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ab-color-bronze, #A67C52) 18%, transparent); }
132
+ }
133
+
134
+ /* โธ๏ธ inactive slide: paused by ab-nextjs-animations via data-ab-paused */
135
+
136
+ /* ๐Ÿ“ฑ battery: 3 pulse loops on small screens (token only; an explicit `loops` prop wins via inline style) */
137
+ @media (max-width: 639px) {
138
+ .root { --ab-wire-pulse-iterations: 3; } /* ๐Ÿ”‹ */
139
+ }
140
+
141
+ /* ๐Ÿง˜ reduced motion: handled by ab-nextjs-animations (wires drawn, pulses frozen at --ab-wire-poster) */
@@ -0,0 +1,61 @@
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: AbIcon - Built-in glyphs (G2)
28
+ * @file: ab-icon/builtin.ts
29
+ * @type: TypeScript โ€” the only icons components draw themselves
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
33
+ /*
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more ๐Ÿ˜œ!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
39
+ // ๐Ÿ”ฃ one module per icon (ab-nextjs-icons โ‰ฅ 0.2.3): bundlers keep only these 8
40
+ import arrowBack from 'ab-nextjs-icons/ab-icons/icons/arrow_back'; // โฎ๏ธ AbCarouselPrev
41
+ import arrowForward from 'ab-nextjs-icons/ab-icons/icons/arrow_forward'; // โญ๏ธ AbCarouselNext
42
+ import lightMode from 'ab-nextjs-icons/ab-icons/icons/light_mode'; // ๐ŸŒž AbThemeToggle
43
+ import darkMode from 'ab-nextjs-icons/ab-icons/icons/dark_mode'; // ๐ŸŒ™ AbThemeToggle
44
+ import computer from 'ab-nextjs-icons/ab-icons/icons/computer'; // ๐Ÿ–ฅ๏ธ AbThemeToggle (system)
45
+ import language from 'ab-nextjs-icons/ab-icons/icons/language'; // ๐ŸŒ AbLocaleSwitcher
46
+ import contentCopy from 'ab-nextjs-icons/ab-icons/icons/content_copy'; // ๐Ÿ“‹ AbInstallSnippet
47
+ import check from 'ab-nextjs-icons/ab-icons/icons/check'; // โœ… AbInstallSnippet (copied)
48
+ // ๐Ÿงพ shape
49
+ import type { AbIconSvgData } from './helpers';
50
+
51
+ /** ๐Ÿ—‚๏ธ Icons the component library renders internally (always registered by AbIcon). */
52
+ export const AB_ICON_BUILTINS: Record<string, AbIconSvgData> = {
53
+ arrow_back: arrowBack, // โฎ๏ธ
54
+ arrow_forward: arrowForward, // โญ๏ธ
55
+ light_mode: lightMode, // ๐ŸŒž
56
+ dark_mode: darkMode, // ๐ŸŒ™
57
+ computer, // ๐Ÿ–ฅ๏ธ
58
+ language, // ๐ŸŒ
59
+ content_copy: contentCopy, // ๐Ÿ“‹
60
+ check, // โœ…
61
+ };
@@ -0,0 +1,102 @@
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: AbIcon - Shared helpers + registry (G2)
28
+ * @file: ab-icon/helpers.ts
29
+ * @type: TypeScript (pure, server-safe)
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> import arrowBack from 'ab-nextjs-icons/ab-icons/icons/arrow_back' // ๐Ÿ“ฆ icons โ‰ฅ 0.2.3, one icon per module
34
+ * -|> registerAbIcons({ arrow_back: arrowBack }) // ๐Ÿ—‚๏ธ at module scope (same on server + client โ†’ no hydration mismatch)
35
+ */
36
+
37
+ /*
38
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
39
+ * MOTTO: We'll always do more ๐Ÿ˜œ!!!
40
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
+ */
42
+
43
+ // ๐Ÿงพ one icon's SVG markup (same shape as ab-nextjs-icons `AbIconSvgEntry`)
44
+ export interface AbIconSvgData {
45
+ outlined: string; // โœ๏ธ outlined markup (stroke = currentColor)
46
+ filled?: string; // โฌ› filled markup (optional)
47
+ }
48
+
49
+ // ๐ŸŽš๏ธ variants + weights (mirrors ab-nextjs-icons โ‰ฅ 0.2.0)
50
+ export type AbIconVariant = 'outlined' | 'filled';
51
+ export type AbIconWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700;
52
+
53
+ // ๐Ÿ“ weight โ†’ stroke width. Copied from ab-nextjs-icons `abIconWeightStroke`
54
+ // (importing it would pull the whole 378 KB icon map into client bundles).
55
+ export const AB_ICON_WEIGHT_STROKE: Record<AbIconWeight, number> = {
56
+ 100: 1.0, 200: 1.25, 300: 1.5, 400: 1.85, 500: 2.2, 600: 2.5, 700: 2.85, // โœ… test guards drift
57
+ };
58
+
59
+ // ๐Ÿงญ package default weight (icons 0.2.0+: 200)
60
+ export const AB_ICON_DEFAULT_WEIGHT: AbIconWeight = 200;
61
+
62
+ // ๐Ÿ—‚๏ธ module-level registry: name โ†’ markup (client bundles only carry what you register)
63
+ const registry = new Map<string, AbIconSvgData>();
64
+
65
+ /**
66
+ * @name registerAbIcons
67
+ * @description ๐Ÿ—‚๏ธ Make icons available to the client `<AbIcon name>`. Call at module
68
+ * scope so server render + hydration see the same set. Later calls overwrite names.
69
+ */
70
+ export function registerAbIcons(icons: Record<string, AbIconSvgData>): void {
71
+ for (const [name, data] of Object.entries(icons)) registry.set(name, data); // โž•
72
+ }
73
+
74
+ // ๐Ÿ” registry lookup (tests + server twin fallback)
75
+ export function getRegisteredAbIcon(name: string): AbIconSvgData | undefined {
76
+ return registry.get(name); // ๐ŸŽฏ
77
+ }
78
+
79
+ /**
80
+ * @name pickAbIconMarkup
81
+ * @description ๐ŸŽฏ Choose markup for a variant; filled falls back to outlined (like getAbIconSvg).
82
+ */
83
+ export function pickAbIconMarkup(data: AbIconSvgData | undefined, variant: AbIconVariant): string | undefined {
84
+ if (!data) return undefined; // ๐Ÿ™…
85
+ return variant === 'filled' ? (data.filled ?? data.outlined) : data.outlined; // โœ…
86
+ }
87
+
88
+ /**
89
+ * @name getAbIconStroke
90
+ * @description ๐Ÿ“ Stroke width for a weight (snaps to the nearest supported weight).
91
+ */
92
+ export function getAbIconStroke(weight: number = AB_ICON_DEFAULT_WEIGHT): number {
93
+ const keys = Object.keys(AB_ICON_WEIGHT_STROKE).map(Number) as AbIconWeight[]; // ๐Ÿ”ข
94
+ const nearest = keys.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a)); // ๐ŸŽฏ
95
+ return AB_ICON_WEIGHT_STROKE[nearest]; // ๐Ÿ“
96
+ }
97
+
98
+ // ๐Ÿ“ normalise size โ†’ CSS length
99
+ export function toAbIconSize(size: number | string | undefined): string {
100
+ if (size == null) return '24px'; // ๐Ÿงญ default 24
101
+ return typeof size === 'number' ? `${size}px` : size; // ๐Ÿ“
102
+ }
package/ab-icon/index.tsx CHANGED
@@ -22,42 +22,103 @@
22
22
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
23
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
24
  * SOFTWARE.
25
-
26
25
  *
27
26
  * @project: ab-nextjs-components
28
- * @name: AbIcon - Client
27
+ * @name: AbIcon - Client (G2)
29
28
  * @file: ab-icon/index.tsx
29
+ * @type: Component (client) โ€” AbIcons SVG, no icon font
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> <AbIcon name="arrow_back" /> // ๐Ÿ™ˆ decorative
34
+ * -|> <AbIcon name="github" label="GitHub" svg={github} /> // ๐Ÿ–ผ๏ธ named image
35
+ */
36
+
37
+ /*
38
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
39
+ * MOTTO: We'll always do more ๐Ÿ˜œ!!!
40
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
30
41
  */
31
42
 
32
43
  'use client';
33
44
 
34
- import type { ReactElement } from 'react';
45
+ // โš›๏ธ types
46
+ import type { CSSProperties, ReactElement } from 'react';
47
+ // ๐Ÿงต classes
35
48
  import clsx from 'clsx';
49
+ // ๐Ÿงฎ shared helpers (NO icon map import: client bundles stay small)
50
+ import { getAbIconStroke, getRegisteredAbIcon, pickAbIconMarkup, registerAbIcons, toAbIconSize, type AbIconSvgData, type AbIconVariant, type AbIconWeight } from './helpers';
51
+ // ๐Ÿ—‚๏ธ the 8 glyphs components draw themselves (per-icon modules, not the map)
52
+ import { AB_ICON_BUILTINS } from './builtin';
53
+ // ๐ŸŽจ styles
36
54
  import styles from './styles.module.css';
37
55
 
56
+ // ๐Ÿ“ฆ helpers for consumers (registerAbIcons, types)
57
+ export * from './helpers';
58
+ export { AB_ICON_BUILTINS } from './builtin';
59
+
60
+ // ๐Ÿ—‚๏ธ register built-ins at module scope (same on server render + hydration โ†’ no mismatch)
61
+ registerAbIcons(AB_ICON_BUILTINS);
62
+
63
+ // โš™๏ธ props
38
64
  export interface AbIconProps {
39
- name: string;
40
- className?: string;
41
- filled?: boolean;
42
- size?: number | string;
43
- title?: string;
65
+ name: string; // ๐Ÿ—‚๏ธ AbIcons name (snake_case); Material ligature fallback if unknown
66
+ variant?: AbIconVariant; // ๐ŸŽš๏ธ outlined (default) | filled
67
+ filled?: boolean; // ๐Ÿ•ฐ๏ธ legacy alias for variant="filled"
68
+ weight?: AbIconWeight | number; // ๐Ÿ“ 100โ€“700 (outlined), default 200
69
+ size?: number | string; // ๐Ÿ“ default 24px
70
+ label?: string; // โ™ฟ NEW: accessible name; omitted = decorative (aria-hidden)
71
+ title?: string; // ๐Ÿ’ฌ legacy tooltip + name
72
+ svg?: AbIconSvgData; // ๐Ÿงพ NEW: explicit markup (tree-shaken per-icon import)
73
+ className?: string; // ๐Ÿท๏ธ
74
+ style?: CSSProperties; // ๐ŸŽจ
44
75
  }
45
76
 
46
- /** Material Symbols ligature icon (client). */
47
- const AbIcon = ({ name, className, filled = false, size, title }: AbIconProps): ReactElement => {
77
+ /** ๐Ÿ”ฃ AbIcons SVG icon (client): `svg` prop โ†’ registry โ†’ Material ligature fallback. */
78
+ const AbIcon = ({ name, variant, filled = false, weight, size, label, title, svg, className, style }: AbIconProps): ReactElement => {
79
+ // ๐Ÿ” resolve markup without the full map
80
+ const markup = pickAbIconMarkup(svg ?? getRegisteredAbIcon(name), variant ?? (filled ? 'filled' : 'outlined'));
81
+ // ๐ŸŽš๏ธ legacy `filled` โ†’ variant
82
+ const v: AbIconVariant = variant ?? (filled ? 'filled' : 'outlined');
83
+ // ๐Ÿท๏ธ accessible name: `label` (new) or `title` (legacy)
84
+ const name_ = label ?? title;
85
+ // ๐ŸŽจ size + weight as CSS variables (weight overrides SVG stroke-width via CSS)
86
+ const vars = { ...style, '--ab-icon-size': toAbIconSize(size), '--ab-icon-stroke': String(getAbIconStroke(weight)) } as CSSProperties;
87
+ // โ™ฟ labelled = image, else decorative
88
+ const a11y = name_ ? { role: 'img' as const, 'aria-label': name_ } : { 'aria-hidden': true as const };
89
+
90
+ // โœ… AbIcons SVG
91
+ if (markup) {
92
+ return (
93
+ <span
94
+ className={clsx('AbIcon', styles.abIcon, className)} // ๐Ÿท๏ธ
95
+ style={vars} // ๐ŸŽจ
96
+ data-variant={v} // ๐ŸŽš๏ธ
97
+ data-icon={name} // ๐Ÿ—‚๏ธ
98
+ title={title} // ๐Ÿ’ฌ legacy tooltip only
99
+ {...a11y} // โ™ฟ
100
+ // ๐Ÿ”’ trusted, package-generated static markup (never user input)
101
+ dangerouslySetInnerHTML={{ __html: markup }}
102
+ />
103
+ );
104
+ }
105
+
106
+ // ๐Ÿ•ฐ๏ธ fallback: Material Symbols ligature (pre-G2 behaviour) for names not in AbIcons
48
107
  return (
49
108
  <span
50
- className={clsx('material-symbols-rounded', 'icon', styles.abIcon, className)}
51
- style={size != null ? { fontSize: typeof size === 'number' ? `${size}px` : size } : undefined}
52
- title={title}
53
- aria-hidden={title ? undefined : true}
54
- role={title ? 'img' : undefined}
55
- data-filled={filled ? 'true' : 'false'}
109
+ className={clsx('material-symbols-rounded', 'icon', styles.abIconFont, className)} // ๐Ÿท๏ธ
110
+ style={{ ...style, fontSize: toAbIconSize(size) }} // ๐Ÿ“
111
+ data-filled={v === 'filled' ? 'true' : 'false'} // ๐ŸŽš๏ธ
112
+ data-icon={name} // ๐Ÿ—‚๏ธ
113
+ data-ab-icon-fallback="font" // ๐Ÿ”Ž easy to audit
114
+ title={title} // ๐Ÿ’ฌ
115
+ {...a11y} // โ™ฟ
56
116
  >
57
117
  {name}
58
118
  </span>
59
119
  );
60
120
  };
61
121
 
122
+ // ๐Ÿ“ฆ exports
62
123
  export default AbIcon;
63
124
  export { AbIcon };
@@ -4,7 +4,30 @@
4
4
  * ab-nextjs-components
5
5
  * ~~~~~~~~~~~~
6
6
  * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
- * Plain CSS modules โ€” no Tailwind Tailwind apply (Turbopack-safe).
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: AbIcon - Styles (G2)
28
+ * @file: ab-icon/styles.module.css
29
+ * @type: CSS module
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
8
31
  */
9
32
 
10
33
  /*
@@ -13,15 +36,36 @@
13
36
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
37
  */
15
38
 
39
+ /* ๐Ÿ”ฃ SVG icon box */
16
40
  .abIcon {
17
- display: inline-flex;
18
- align-items: center;
19
- justify-content: center;
20
- font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
21
- line-height: 1;
22
- user-select: none;
41
+ display: inline-flex; /* ๐Ÿ“ */
42
+ flex: none; /* ๐Ÿšซ squash */
43
+ width: var(--ab-icon-size, 24px); /* ๐Ÿ“ */
44
+ height: var(--ab-icon-size, 24px); /* ๐Ÿ“ */
45
+ line-height: 0; /* ๐Ÿงน no baseline gap */
46
+ color: inherit; /* ๐ŸŽจ currentColor flows into the SVG */
23
47
  }
24
48
 
25
- .abIcon[data-filled='true'] {
26
- font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
49
+ /* ๐Ÿ“ the inline SVG fills the box */
50
+ .abIcon > svg {
51
+ width: 100%; /* โ†”๏ธ */
52
+ height: 100%; /* โ†•๏ธ */
53
+ }
54
+
55
+ /* ๐Ÿ“ weight: CSS beats SVG presentation attributes, outlined only (filled stay solid) */
56
+ .abIcon[data-variant='outlined'] > svg [stroke] {
57
+ stroke-width: var(--ab-icon-stroke, 1.25); /* โœ๏ธ */
58
+ }
59
+
60
+ /* ๐Ÿ•ฐ๏ธ Material Symbols fallback (unchanged from pre-G2) */
61
+ .abIconFont {
62
+ display: inline-flex; /* ๐Ÿ“ */
63
+ align-items: center; /* โ†•๏ธ */
64
+ justify-content: center; /* โ†”๏ธ */
65
+ font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; /* ๐Ÿ”ค */
66
+ line-height: 1; /* ๐Ÿ“ */
67
+ user-select: none; /* ๐Ÿšซ */
68
+ }
69
+ .abIconFont[data-filled='true'] {
70
+ font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; /* โฌ› */
27
71
  }