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.
- package/CHANGELOG.md +42 -0
- package/ab-brand/index.tsx +30 -1
- package/ab-brand/styles.module.css +40 -1
- package/ab-button/helpers.ts +90 -0
- package/ab-button/index.tsx +164 -87
- package/ab-button/styles.module.css +79 -1
- package/ab-carousel/helpers.ts +146 -0
- package/ab-carousel/index.tsx +643 -0
- package/ab-carousel/styles.module.css +206 -0
- package/ab-chip/index.tsx +75 -0
- package/ab-chip/styles.module.css +87 -0
- package/ab-collapsible/index.tsx +30 -1
- package/ab-collapsible/styles.module.css +40 -1
- package/ab-flow-diagram/helpers.ts +77 -0
- package/ab-flow-diagram/index.tsx +141 -0
- package/ab-flow-diagram/styles.module.css +141 -0
- package/ab-icon/builtin.ts +61 -0
- package/ab-icon/helpers.ts +102 -0
- package/ab-icon/index.tsx +77 -16
- package/ab-icon/styles.module.css +53 -9
- package/ab-icon-button/index.tsx +110 -46
- package/ab-icon-button/styles.module.css +28 -10
- package/ab-install-snippet/helpers.ts +62 -0
- package/ab-install-snippet/index.tsx +170 -0
- package/ab-install-snippet/styles.module.css +104 -0
- package/ab-like-button/index.tsx +33 -1
- package/ab-like-button/styles.module.css +41 -6
- package/ab-linear-progress/index.tsx +129 -0
- package/ab-linear-progress/styles.module.css +105 -0
- package/ab-locale-switcher/index.tsx +213 -0
- package/ab-locale-switcher/styles.module.css +127 -0
- package/ab-logo/index.tsx +88 -30
- package/ab-logo/styles.module.css +79 -11
- package/ab-pill/index.tsx +74 -0
- package/ab-progress-chips/index.tsx +30 -1
- package/ab-progress-chips/styles.module.css +40 -1
- package/ab-searchbar/index.tsx +33 -2
- package/ab-searchbar/styles.module.css +41 -5
- package/ab-splash/csp.d.ts +54 -0
- package/ab-splash/csp.mjs +82 -0
- package/ab-splash/csp.ts +60 -0
- package/ab-splash/gate.ts +216 -0
- package/ab-splash/index.tsx +140 -0
- package/ab-splash/styles.module.css +103 -0
- package/ab-theme-toggle/index.tsx +188 -0
- package/ab-theme-toggle/styles.module.css +89 -0
- package/css/dialog.css +38 -3
- package/index.ts +47 -0
- package/package.json +46 -18
- package/server/ab-brand/index.tsx +29 -1
- package/server/ab-brand/styles.module.css +40 -1
- package/server/ab-button/index.tsx +96 -79
- package/server/ab-button/styles.module.css +79 -1
- package/server/ab-icon/index.tsx +68 -16
- package/server/ab-icon/styles.module.css +53 -9
- package/server/ab-logo/index.tsx +88 -29
- package/server/ab-logo/styles.module.css +79 -11
- package/types/css.d.ts +43 -0
- package/types/index.d.ts +2 -0
|
@@ -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
|
+
*
|
|
27
|
+
* @project: ab-nextjs-components
|
|
28
|
+
* @name: AbSplash - Component Stylesheet (plain CSS, Tailwind-independent)
|
|
29
|
+
* @file: ab-splash/styles.module.css
|
|
30
|
+
* @type: CSS Module
|
|
31
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
36
|
+
* MOTTO: We'll always do more 😜!!!
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/* 💦 overlay: hidden by default (JS off = no Splash 🙈) */
|
|
41
|
+
.abSplash {
|
|
42
|
+
display: none; /* 🙈 off unless the gate turned it on */
|
|
43
|
+
position: fixed; /* 📌 cover the viewport */
|
|
44
|
+
inset: 0; /* 📐 edge to edge */
|
|
45
|
+
z-index: 1000; /* 🔝 above everything */
|
|
46
|
+
flex-direction: column; /* ⬇️ brand above progress */
|
|
47
|
+
align-items: center; /* ↔️ centered */
|
|
48
|
+
justify-content: center; /* ↕️ centered */
|
|
49
|
+
gap: 2.25rem; /* ↕️ brand ↔ bar */
|
|
50
|
+
background-color: #FFF8F3; /* ☀️ light surface (matches the splash mocks) */
|
|
51
|
+
color: #A67C52; /* 🎨 bronze brand */
|
|
52
|
+
--ab-motion-duration: 200ms; /* 🌫️ fade-out = .ab-motion-colors (ab-nextjs-animations; off under reduced motion) */
|
|
53
|
+
animation: abSplashFailsafe 0s linear 1.2s forwards; /* ⏱️ never longer than 1.2 s, even without hydration */
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* 🌙 dark */
|
|
57
|
+
:global(html.dark) .abSplash {
|
|
58
|
+
background-color: #1A1310; /* 🌙 dark surface (matches the splash mocks) */
|
|
59
|
+
color: #FFF8F5; /* 🤍 light brand */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* 🚦 gate said "on" (or leaving) */
|
|
63
|
+
:global(html[data-ab-splash]) .abSplash {
|
|
64
|
+
display: flex;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* 🔒 no scrolling behind the overlay — with the same 1.2 s failsafe as the overlay itself */
|
|
68
|
+
:global(html[data-ab-splash='on']) {
|
|
69
|
+
overflow: hidden; /* 🔒 lock */
|
|
70
|
+
animation: abSplashUnlock 0s linear 1.2s forwards; /* ⏱️ unlock even if hydration never happens */
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* ⏱️ failsafe unlock keyframes (overflow animates discretely) */
|
|
74
|
+
@keyframes abSplashUnlock {
|
|
75
|
+
to { overflow: visible; }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* 👋 leaving: fade out */
|
|
79
|
+
:global(html[data-ab-splash='leaving']) .abSplash {
|
|
80
|
+
opacity: 0;
|
|
81
|
+
pointer-events: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* 🅰️ brand lockup size */
|
|
85
|
+
.abSplash__brand {
|
|
86
|
+
font-size: clamp(2.5rem, 6vw, 3.25rem); /* 📏 as in the mock */
|
|
87
|
+
color: inherit; /* 🎨 follow light/dark */
|
|
88
|
+
--ab-logo-color: currentColor; /* 🎨 mark + wordmark follow the overlay color */
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* 📶 progress track */
|
|
92
|
+
.abSplash__progress {
|
|
93
|
+
width: min(18rem, 28vw); /* ↔️ mobile + laptop, as in the mock */
|
|
94
|
+
--ab-linear-progress-height: 0.375rem; /* ↕️ 6 px */
|
|
95
|
+
--ab-linear-progress-color: #A67C52; /* 🎨 bronze bar in both themes */
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* ♿ reduced motion: no fade (handled by ab-nextjs-animations .ab-motion-colors) */
|
|
99
|
+
|
|
100
|
+
/* ⏱️ failsafe keyframes */
|
|
101
|
+
@keyframes abSplashFailsafe {
|
|
102
|
+
to { visibility: hidden; pointer-events: none; }
|
|
103
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
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: AbThemeToggle - Client (G9/G34)
|
|
28
|
+
* @file: ab-theme-toggle/index.tsx
|
|
29
|
+
* @type: Component (client) — light / dark / system
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbThemeToggle labels={{ group: t('theme.label'), light: t('theme.light'), dark: t('theme.dark'), system: t('theme.system') }} />
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
* MOTTO: We'll always do more 😜!!!
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
'use client';
|
|
43
|
+
|
|
44
|
+
// ⚛️ React
|
|
45
|
+
import type { CSSProperties, KeyboardEvent, ReactNode } from 'react';
|
|
46
|
+
import { useRef } from 'react';
|
|
47
|
+
// 🧵 classes
|
|
48
|
+
import clsx from 'clsx';
|
|
49
|
+
// 🌗 theme engine (hooks ≥ 0.1.6, deep import = tree-shaken)
|
|
50
|
+
import { useAbThemeMode, AB_THEME_MODES, type AbThemeMode } from 'ab-nextjs-hooks/useAbTheme';
|
|
51
|
+
// 🔣 icons (SVG once G2 lands)
|
|
52
|
+
import AbIcon from '../ab-icon';
|
|
53
|
+
// 🎨 styles
|
|
54
|
+
import styles from './styles.module.css';
|
|
55
|
+
import { AB_MOTION } from 'ab-nextjs-animations/motion'; // 🎬 transition class names (ab-nextjs-animations >= 0.2.4)
|
|
56
|
+
import 'ab-nextjs-animations/motion/styles.css'; // 🎨 .ab-motion-*
|
|
57
|
+
|
|
58
|
+
// 📦 re-export the mode type for consumers
|
|
59
|
+
export type { AbThemeMode } from 'ab-nextjs-hooks/useAbTheme';
|
|
60
|
+
|
|
61
|
+
// 🏷️ i18n labels (required: no English defaults baked into a11y names)
|
|
62
|
+
export interface AbThemeToggleLabels {
|
|
63
|
+
group: string; // 🗂️ "Theme"
|
|
64
|
+
light: string; // 🌞 "Light"
|
|
65
|
+
dark: string; // 🌙 "Dark"
|
|
66
|
+
system: string; // 🖥️ "System"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ⚙️ props
|
|
70
|
+
export interface AbThemeToggleProps {
|
|
71
|
+
labels: AbThemeToggleLabels; // 🏷️
|
|
72
|
+
variant?: 'segmented' | 'icon'; // 🎨 pill of radios, or one cycling icon button
|
|
73
|
+
modes?: readonly AbThemeMode[]; // 🎚️ default light, dark, system
|
|
74
|
+
value?: AbThemeMode; // 🎛️ controlled
|
|
75
|
+
onChange?: (mode: AbThemeMode) => void; // 📣
|
|
76
|
+
defaultMode?: AbThemeMode; // 🌱 before hydration (default 'light')
|
|
77
|
+
icons?: Partial<Record<AbThemeMode, ReactNode>>; // 🖼️ override glyphs
|
|
78
|
+
size?: 'sm' | 'md'; // 📏 sm = 32px, md = 40px segments (hit area ≥ 24px either way)
|
|
79
|
+
className?: string; // 🏷️
|
|
80
|
+
style?: CSSProperties; // 🎨
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 🔣 default glyphs (AbIcons names)
|
|
84
|
+
const DEFAULT_ICON_NAMES: Record<AbThemeMode, string> = { light: 'light_mode', dark: 'dark_mode', system: 'computer' };
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @name getNextAbThemeMode
|
|
88
|
+
* @description 🔁 Radio-group arrow logic (pure): wraps, RTL flips Left/Right.
|
|
89
|
+
*/
|
|
90
|
+
export function getNextAbThemeMode(modes: readonly AbThemeMode[], current: AbThemeMode, key: string, dir: 'ltr' | 'rtl' = 'ltr'): AbThemeMode | null {
|
|
91
|
+
const i = Math.max(0, modes.indexOf(current)); // 📍
|
|
92
|
+
const forward = dir === 'rtl' ? 'ArrowLeft' : 'ArrowRight'; // ➡️
|
|
93
|
+
const backward = dir === 'rtl' ? 'ArrowRight' : 'ArrowLeft'; // ⬅️
|
|
94
|
+
if (key === forward || key === 'ArrowDown') return modes[(i + 1) % modes.length]; // ⏭️
|
|
95
|
+
if (key === backward || key === 'ArrowUp') return modes[(i - 1 + modes.length) % modes.length]; // ⏮️
|
|
96
|
+
if (key === 'Home') return modes[0]; // ⏮️⏮️
|
|
97
|
+
if (key === 'End') return modes[modes.length - 1]; // ⏭️⏭️
|
|
98
|
+
return null; // 🙅
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function AbThemeToggle(props: AbThemeToggleProps) {
|
|
102
|
+
// 🧩 props
|
|
103
|
+
const { labels, variant = 'segmented', modes = AB_THEME_MODES, value, onChange, defaultMode = 'light', icons, size = 'md', className, style } = props;
|
|
104
|
+
// 🌗 engine: persists + applies to <html>
|
|
105
|
+
const engine = useAbThemeMode(defaultMode);
|
|
106
|
+
// 🎛️ controlled or engine-driven
|
|
107
|
+
const current = (value ?? engine.mode) as AbThemeMode;
|
|
108
|
+
// 📍 refs to move focus with the selection
|
|
109
|
+
const refs = useRef<Array<HTMLButtonElement | null>>([]);
|
|
110
|
+
|
|
111
|
+
// ✍️ select a mode
|
|
112
|
+
const select = (mode: AbThemeMode) => {
|
|
113
|
+
if (value === undefined) engine.setMode(mode); // 🎚️ uncontrolled: apply + persist
|
|
114
|
+
onChange?.(mode); // 📣
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// 🖼️ glyph for a mode (decorative: the label names it)
|
|
118
|
+
const glyph = (mode: AbThemeMode) => icons?.[mode] ?? <AbIcon name={DEFAULT_ICON_NAMES[mode]} size={20} />;
|
|
119
|
+
|
|
120
|
+
// 🔘 single cycling button variant
|
|
121
|
+
if (variant === 'icon') {
|
|
122
|
+
const next = modes[(Math.max(0, modes.indexOf(current)) + 1) % modes.length]; // ⏭️
|
|
123
|
+
return (
|
|
124
|
+
<button
|
|
125
|
+
type="button" // 🧾
|
|
126
|
+
className={clsx('AbThemeToggle', styles.icon, AB_MOTION.colors, className)} // 🏷️
|
|
127
|
+
style={style} // 🎨
|
|
128
|
+
data-ab-part="theme-toggle" // 🗂️
|
|
129
|
+
data-mode={current} // 🎚️
|
|
130
|
+
data-size={size} // 📏
|
|
131
|
+
aria-label={`${labels.group}: ${labels[current]}`} // ♿ "Theme: Dark"
|
|
132
|
+
title={`${labels.group}: ${labels[current]}`} // 💬
|
|
133
|
+
onClick={() => select(next)} // 🔁
|
|
134
|
+
>
|
|
135
|
+
<span aria-hidden="true">{glyph(current)}</span>
|
|
136
|
+
</button>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ⌨️ roving radio keys
|
|
141
|
+
const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
142
|
+
const dir = (event.currentTarget.closest('[dir]')?.getAttribute('dir') === 'rtl' ? 'rtl' : 'ltr') as 'ltr' | 'rtl'; // 🌍
|
|
143
|
+
const target = getNextAbThemeMode(modes, current, event.key, dir); // 🎯
|
|
144
|
+
if (!target) return; // 🙅 other keys untouched
|
|
145
|
+
event.preventDefault(); // 🛑 no scroll
|
|
146
|
+
select(target); // ✅ selection follows focus (radio pattern)
|
|
147
|
+
refs.current[modes.indexOf(target)]?.focus(); // 🎯
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// 🎛️ segmented radiogroup
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
role="radiogroup" // ♿
|
|
154
|
+
aria-label={labels.group} // 🏷️
|
|
155
|
+
className={clsx('AbThemeToggle', styles.group, className)} // 🏷️
|
|
156
|
+
style={style} // 🎨
|
|
157
|
+
data-ab-part="theme-toggle" // 🗂️
|
|
158
|
+
data-mode={current} // 🎚️
|
|
159
|
+
data-size={size} // 📏
|
|
160
|
+
onKeyDown={onKeyDown} // ⌨️
|
|
161
|
+
>
|
|
162
|
+
{modes.map((mode, i) => {
|
|
163
|
+
const checked = mode === current; // ✅
|
|
164
|
+
return (
|
|
165
|
+
<button
|
|
166
|
+
key={mode} // 🔑
|
|
167
|
+
ref={(el) => { refs.current[i] = el; }} // 📍
|
|
168
|
+
type="button" // 🧾
|
|
169
|
+
role="radio" // ♿
|
|
170
|
+
aria-checked={checked} // ✅
|
|
171
|
+
aria-label={labels[mode]} // 🏷️
|
|
172
|
+
title={labels[mode]} // 💬
|
|
173
|
+
tabIndex={checked ? 0 : -1} // ⌨️ roving: one tab stop
|
|
174
|
+
className={clsx(styles.segment, AB_MOTION.colors)} // 🎨 + colour fade (ab-nextjs-animations)
|
|
175
|
+
data-ab-part="theme-option" // 🗂️
|
|
176
|
+
data-mode={mode} // 🎚️
|
|
177
|
+
onClick={() => select(mode)} // 🖱️
|
|
178
|
+
>
|
|
179
|
+
<span aria-hidden="true">{glyph(mode)}</span>
|
|
180
|
+
</button>
|
|
181
|
+
);
|
|
182
|
+
})}
|
|
183
|
+
</div>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// 📦 default export
|
|
188
|
+
export default AbThemeToggle;
|
|
@@ -0,0 +1,89 @@
|
|
|
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: AbThemeToggle - Styles
|
|
28
|
+
* @file: ab-theme-toggle/styles.module.css
|
|
29
|
+
* @type: CSS module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more 😜!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/* 💊 segmented pill */
|
|
40
|
+
.group {
|
|
41
|
+
display: inline-flex; /* 📐 row */
|
|
42
|
+
gap: 2px; /* 🧱 */
|
|
43
|
+
padding: 3px; /* 🧱 */
|
|
44
|
+
border-radius: 9999px; /* 💊 */
|
|
45
|
+
border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* 🖊️ */
|
|
46
|
+
background: var(--ab-color-surface-container, transparent); /* 🎨 */
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* 🔘 each option; md = 40px, sm = 32px (both ≥ 24px target, WCAG 2.5.8) */
|
|
50
|
+
.segment,
|
|
51
|
+
.icon {
|
|
52
|
+
display: inline-grid; /* 📐 */
|
|
53
|
+
place-items: center; /* 🎯 */
|
|
54
|
+
width: 40px; /* 📏 */
|
|
55
|
+
height: 40px; /* 📏 */
|
|
56
|
+
padding: 0; /* 🧹 */
|
|
57
|
+
border: 0; /* 🧹 */
|
|
58
|
+
border-radius: 9999px; /* 💊 */
|
|
59
|
+
color: var(--ab-color-on-surface-variant, currentColor); /* 🎨 */
|
|
60
|
+
background: transparent; /* 🫥 */
|
|
61
|
+
cursor: pointer; /* 👆 */
|
|
62
|
+
--ab-motion-duration: var(--ab-motion-duration-short, 160ms); /* 🎞️ colour fade = .ab-motion-colors (ab-nextjs-animations) */
|
|
63
|
+
}
|
|
64
|
+
[data-size='sm'] .segment,
|
|
65
|
+
.icon[data-size='sm'] {
|
|
66
|
+
width: 32px; /* 📏 */
|
|
67
|
+
height: 32px; /* 📏 */
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ✅ selected */
|
|
71
|
+
.segment[aria-checked='true'] {
|
|
72
|
+
color: var(--ab-color-on-primary, #fff); /* 🎨 */
|
|
73
|
+
background: var(--ab-color-primary, #A67C52); /* 🥉 bronze */
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* 🖱️ hover (unselected only) */
|
|
77
|
+
.segment[aria-checked='false']:hover,
|
|
78
|
+
.icon:hover {
|
|
79
|
+
background: color-mix(in srgb, currentColor 10%, transparent); /* 🌫️ */
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ♿ visible focus ring (theme token, G18) */
|
|
83
|
+
.segment:focus-visible,
|
|
84
|
+
.icon:focus-visible {
|
|
85
|
+
outline: 2px solid var(--ab-focus-ring, var(--ab-color-primary, #A67C52)); /* 💍 */
|
|
86
|
+
outline-offset: 2px; /* ↔️ */
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* 🧘 reduced motion: handled by ab-nextjs-animations (.ab-motion-colors) */
|
package/css/dialog.css
CHANGED
|
@@ -1,7 +1,41 @@
|
|
|
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: Dialog chrome styles (moved out of ab-nextjs-theme)
|
|
28
|
+
* @file: css/dialog.css
|
|
29
|
+
* @type: CSS
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
1
33
|
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more 😜!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
5
39
|
|
|
6
40
|
/* Dialogs */
|
|
7
41
|
#dialogs, .Dialogs {
|
|
@@ -104,6 +138,7 @@ li.dialog-list-item {
|
|
|
104
138
|
transform-origin: left;
|
|
105
139
|
opacity: var(--opacity-dialog-list-item, 0.68);
|
|
106
140
|
user-select: none;
|
|
141
|
+
/* ⚠️ named motion exception (James review): consumer-rendered markup, no component can add an ab-motion-* class; pinned in __tests__/motion-from-animations.test.tsx */
|
|
107
142
|
transition: all 0.2s ease-in-out;
|
|
108
143
|
}
|
|
109
144
|
|
package/index.ts
CHANGED
|
@@ -5,11 +5,38 @@
|
|
|
5
5
|
* ~~~~~~~~~~~~
|
|
6
6
|
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
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
|
+
*
|
|
8
26
|
* @project: ab-nextjs-components
|
|
9
27
|
* @name: Components - Package Catalog
|
|
10
28
|
* @file: index.ts
|
|
29
|
+
* @type: Package catalog + barrel
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
11
31
|
*/
|
|
12
32
|
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more 😜!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
13
40
|
import type { ComponentCatalogEntry } from './types'
|
|
14
41
|
|
|
15
42
|
/**
|
|
@@ -20,6 +47,12 @@ const supportedComponents: Array<ComponentCatalogEntry> = [
|
|
|
20
47
|
// CLIENT
|
|
21
48
|
{ name: 'AbIcon', file: 'ab-icon/index.tsx', kind: 'client', status: 'Done' },
|
|
22
49
|
{ name: 'AbLogo', file: 'ab-logo/index.tsx', kind: 'client', status: 'Done' },
|
|
50
|
+
// 📶 AbLinearProgress (ported from core; used by AbSplash)
|
|
51
|
+
{ name: 'AbLinearProgress', file: 'ab-linear-progress/index.tsx', kind: 'client', status: 'Done' },
|
|
52
|
+
// 💦 AbSplash: subpath-only (`ab-nextjs-components/ab-splash`)
|
|
53
|
+
{ name: 'AbSplash', file: 'ab-splash/index.tsx', kind: 'client', status: 'Done' },
|
|
54
|
+
// 🎠 G31 AbCarousel (Welcome v6): subpath-only (`ab-nextjs-components/ab-carousel`), needs ab-nextjs-hooks >= 0.1.6
|
|
55
|
+
{ name: 'AbCarousel', file: 'ab-carousel/index.tsx', kind: 'client', status: 'Done' },
|
|
23
56
|
{ name: 'AbButton', file: 'ab-button/index.tsx', kind: 'client', status: 'Done' },
|
|
24
57
|
{ name: 'AbIconButton', file: 'ab-icon-button/index.tsx', kind: 'client', status: 'Done' },
|
|
25
58
|
{ name: 'AbInput', file: 'ab-input/index.tsx', kind: 'client', status: 'Done' },
|
|
@@ -71,6 +104,18 @@ const supportedComponents: Array<ComponentCatalogEntry> = [
|
|
|
71
104
|
{ name: 'AbTestHello', file: 'server/ab-test-hello/index.tsx', kind: 'server', status: 'Done' },
|
|
72
105
|
{ name: 'AbKeyFeature', file: 'server/ab-key-feature/index.tsx', kind: 'server', status: 'Done' },
|
|
73
106
|
{ name: 'AbSwitchBack', file: 'server/ab-switch-back/index.tsx', kind: 'server', status: 'Done' },
|
|
107
|
+
// 🆕 Welcome v6 (AbThemeToggle)
|
|
108
|
+
{ name: 'AbThemeToggle', file: 'ab-theme-toggle/index.tsx', kind: 'client', status: 'Done' },
|
|
109
|
+
// 🆕 Welcome v6 (AbChip)
|
|
110
|
+
{ name: 'AbChip', file: 'ab-chip/index.tsx', kind: 'server', status: 'Done' },
|
|
111
|
+
// 🆕 Welcome v6 (AbPill)
|
|
112
|
+
{ name: 'AbPill', file: 'ab-pill/index.tsx', kind: 'server', status: 'Done' },
|
|
113
|
+
// 🆕 Welcome v6 (AbInstallSnippet)
|
|
114
|
+
{ name: 'AbInstallSnippet', file: 'ab-install-snippet/index.tsx', kind: 'client', status: 'Done' },
|
|
115
|
+
// 🆕 Welcome v6 (AbLocaleSwitcher)
|
|
116
|
+
{ name: 'AbLocaleSwitcher', file: 'ab-locale-switcher/index.tsx', kind: 'client', status: 'Done' },
|
|
117
|
+
// 🆕 Welcome v6 (AbFlowDiagram)
|
|
118
|
+
{ name: 'AbFlowDiagram', file: 'ab-flow-diagram/index.tsx', kind: 'server', status: 'Done' },
|
|
74
119
|
]
|
|
75
120
|
|
|
76
121
|
const abComponents = { supportedComponents }
|
|
@@ -80,6 +125,8 @@ export default abComponents
|
|
|
80
125
|
|
|
81
126
|
export { default as AbIcon } from './ab-icon/index.tsx'
|
|
82
127
|
export { default as AbLogo } from './ab-logo/index.tsx'
|
|
128
|
+
// 📶 progress bar
|
|
129
|
+
export { default as AbLinearProgress } from './ab-linear-progress/index.tsx'
|
|
83
130
|
export { default as AbButton } from './ab-button/index.tsx'
|
|
84
131
|
export { default as AbIconButton } from './ab-icon-button/index.tsx'
|
|
85
132
|
export { default as AbInput } from './ab-input/index.tsx'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ab-nextjs-components",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.10",
|
|
4
|
+
"description": "🚀 A lightweight collection of server & client React components created by Abraham Ukachi, and optimized for Next.js applications 😎.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint . --fix",
|
|
18
18
|
"test": "vitest run",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"typecheck": "tsc --noEmit -p .",
|
|
20
|
+
"build:csp": "node scripts/build-csp.mjs",
|
|
21
|
+
"check:publish": "node scripts/check-publish-deps.mjs && node scripts/check-css-assets.mjs && node scripts/build-csp.mjs --check",
|
|
22
|
+
"prepublishOnly": "node scripts/check-publish-deps.mjs && node scripts/check-css-assets.mjs && node scripts/build-csp.mjs --check",
|
|
21
23
|
"check:css-assets": "node scripts/check-css-assets.mjs"
|
|
22
24
|
},
|
|
23
25
|
"keywords": [
|
|
@@ -38,27 +40,33 @@
|
|
|
38
40
|
},
|
|
39
41
|
"license": "MIT",
|
|
40
42
|
"peerDependencies": {
|
|
43
|
+
"ab-nextjs-animations": "^0.2.4",
|
|
44
|
+
"ab-nextjs-hooks": "^0.1.6",
|
|
45
|
+
"ab-nextjs-icons": "^0.2.3",
|
|
46
|
+
"ab-nextjs-theme": "^0.3.1",
|
|
41
47
|
"clsx": "^2",
|
|
42
48
|
"next": "^16.3.4",
|
|
43
49
|
"react": "^19",
|
|
44
|
-
"react-dom": "^19"
|
|
45
|
-
"ab-nextjs-theme": "*",
|
|
46
|
-
"ab-nextjs-icons": "*",
|
|
47
|
-
"ab-nextjs-hooks": "*",
|
|
48
|
-
"ab-nextjs-animations": "*"
|
|
50
|
+
"react-dom": "^19"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
53
|
+
"@testing-library/react": "^16.3.3",
|
|
51
54
|
"@types/node": "^20",
|
|
52
55
|
"@types/react": "^19",
|
|
56
|
+
"ab-nextjs-animations": "^0.2.4",
|
|
57
|
+
"ab-nextjs-hooks": "^0.1.6",
|
|
58
|
+
"ab-nextjs-icons": "^0.2.3",
|
|
59
|
+
"ab-nextjs-theme": "^0.3.1",
|
|
60
|
+
"clsx": "^2.1.1",
|
|
61
|
+
"esbuild": "^0.28.2",
|
|
53
62
|
"eslint": "^9.39.0",
|
|
54
63
|
"eslint-config-next": "16.3.4",
|
|
64
|
+
"happy-dom": "^20.14.6",
|
|
55
65
|
"next": "16.3.4",
|
|
56
66
|
"react": "^19",
|
|
57
67
|
"react-dom": "^19",
|
|
58
68
|
"typescript": "^5",
|
|
59
|
-
"vitest": "^3"
|
|
60
|
-
"clsx": "^2.1.1",
|
|
61
|
-
"ab-nextjs-hooks": "^0.1.2"
|
|
69
|
+
"vitest": "^3"
|
|
62
70
|
},
|
|
63
71
|
"files": [
|
|
64
72
|
"index.ts",
|
|
@@ -103,6 +111,15 @@
|
|
|
103
111
|
"ab-switch-back",
|
|
104
112
|
"ab-demo-box",
|
|
105
113
|
"ab-demo-code",
|
|
114
|
+
"ab-splash",
|
|
115
|
+
"ab-linear-progress",
|
|
116
|
+
"ab-carousel",
|
|
117
|
+
"ab-flow-diagram",
|
|
118
|
+
"ab-locale-switcher",
|
|
119
|
+
"ab-install-snippet",
|
|
120
|
+
"ab-pill",
|
|
121
|
+
"ab-chip",
|
|
122
|
+
"ab-theme-toggle",
|
|
106
123
|
"ab-logo/ab-logo.svg",
|
|
107
124
|
"styles.css",
|
|
108
125
|
"css",
|
|
@@ -116,6 +133,23 @@
|
|
|
116
133
|
"./package.json": "./package.json",
|
|
117
134
|
"./ab-icon": "./ab-icon/index.tsx",
|
|
118
135
|
"./ab-logo": "./ab-logo/index.tsx",
|
|
136
|
+
"./ab-linear-progress": "./ab-linear-progress/index.tsx",
|
|
137
|
+
"./ab-splash": "./ab-splash/index.tsx",
|
|
138
|
+
"./ab-carousel": "./ab-carousel/index.tsx",
|
|
139
|
+
"./ab-carousel/helpers": "./ab-carousel/helpers.ts",
|
|
140
|
+
"./ab-theme-toggle": "./ab-theme-toggle/index.tsx",
|
|
141
|
+
"./ab-chip": "./ab-chip/index.tsx",
|
|
142
|
+
"./ab-pill": "./ab-pill/index.tsx",
|
|
143
|
+
"./ab-install-snippet": "./ab-install-snippet/index.tsx",
|
|
144
|
+
"./ab-install-snippet/helpers": "./ab-install-snippet/helpers.ts",
|
|
145
|
+
"./ab-locale-switcher": "./ab-locale-switcher/index.tsx",
|
|
146
|
+
"./ab-flow-diagram": "./ab-flow-diagram/index.tsx",
|
|
147
|
+
"./ab-flow-diagram/helpers": "./ab-flow-diagram/helpers.ts",
|
|
148
|
+
"./ab-splash/gate": "./ab-splash/gate.ts",
|
|
149
|
+
"./ab-splash/csp": {
|
|
150
|
+
"types": "./ab-splash/csp.d.ts",
|
|
151
|
+
"default": "./ab-splash/csp.mjs"
|
|
152
|
+
},
|
|
119
153
|
"./ab-button": "./ab-button/index.tsx",
|
|
120
154
|
"./ab-icon-button": "./ab-icon-button/index.tsx",
|
|
121
155
|
"./ab-input": "./ab-input/index.tsx",
|
|
@@ -176,14 +210,8 @@
|
|
|
176
210
|
"ab-nextjs-theme": {
|
|
177
211
|
"optional": true
|
|
178
212
|
},
|
|
179
|
-
"ab-nextjs-icons": {
|
|
180
|
-
"optional": true
|
|
181
|
-
},
|
|
182
213
|
"ab-nextjs-hooks": {
|
|
183
214
|
"optional": true
|
|
184
|
-
},
|
|
185
|
-
"ab-nextjs-animations": {
|
|
186
|
-
"optional": true
|
|
187
215
|
}
|
|
188
216
|
}
|
|
189
217
|
}
|