ab-nextjs-components 0.1.13 β†’ 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +35 -0
  3. package/ab-app-bar/index.tsx +53 -13
  4. package/ab-app-bar/styles.module.css +68 -4
  5. package/ab-bottom-drawer/index.tsx +71 -0
  6. package/ab-bottom-drawer/styles.module.css +66 -0
  7. package/ab-breadcrumbs/index.tsx +92 -0
  8. package/ab-breadcrumbs/styles.module.css +54 -0
  9. package/ab-button/helpers.ts +6 -1
  10. package/ab-button/index.tsx +8 -2
  11. package/ab-button/styles.module.css +39 -0
  12. package/ab-card/styles.module.css +1 -1
  13. package/ab-carousel/styles.module.css +1 -1
  14. package/ab-chip/index.tsx +16 -4
  15. package/ab-chip/styles.module.css +12 -1
  16. package/ab-confirm-drawer/index.tsx +97 -0
  17. package/ab-confirm-drawer/styles.module.css +41 -0
  18. package/ab-drawer/gestures.ts +134 -0
  19. package/ab-drawer/index.tsx +458 -0
  20. package/ab-drawer/kit.module.css +204 -0
  21. package/ab-drawer/styles.module.css +166 -0
  22. package/ab-drawer/use-ab-drawer.ts +89 -0
  23. package/ab-drawer/use-ab-edge-swipe.ts +155 -0
  24. package/ab-drawer-list/index.tsx +118 -0
  25. package/ab-drawer-list/styles.module.css +65 -0
  26. package/ab-flow-diagram/styles.module.css +2 -2
  27. package/ab-icon/builtin.ts +4 -0
  28. package/ab-icon-button/index.tsx +13 -2
  29. package/ab-icon-button/styles.module.css +1 -1
  30. package/ab-install-snippet/index.tsx +51 -29
  31. package/ab-install-snippet/styles.module.css +34 -2
  32. package/ab-kbd/styles.module.css +1 -1
  33. package/ab-list/index.tsx +107 -0
  34. package/ab-list/styles.module.css +82 -0
  35. package/ab-locale-switcher/index.tsx +103 -10
  36. package/ab-locale-switcher/styles.module.css +24 -4
  37. package/ab-mobile-header/index.tsx +100 -0
  38. package/ab-nav-drawer/index.tsx +158 -0
  39. package/ab-navbar/index.tsx +1 -1
  40. package/ab-navbar/styles.module.css +20 -2
  41. package/ab-navbar/view.tsx +7 -4
  42. package/ab-package-card/index.tsx +49 -2
  43. package/ab-package-card/styles.module.css +40 -0
  44. package/ab-search-drawer/index.tsx +279 -0
  45. package/ab-search-trigger/index.tsx +22 -2
  46. package/ab-search-trigger/styles.module.css +30 -1
  47. package/ab-settings-drawer/index.tsx +160 -0
  48. package/ab-sidebar/index.tsx +6 -3
  49. package/ab-sidebar/styles.module.css +53 -5
  50. package/ab-sidebar/view.tsx +18 -4
  51. package/ab-theme-toggle/index.tsx +21 -6
  52. package/ab-theme-toggle/styles.module.css +18 -3
  53. package/ab-toc/index.tsx +9 -2
  54. package/ab-toc/styles.module.css +20 -8
  55. package/ab-toc-drawer/index.tsx +129 -0
  56. package/ab-version-switcher/index.tsx +143 -0
  57. package/ab-version-switcher/styles.module.css +76 -0
  58. package/index.ts +50 -0
  59. package/package.json +28 -3
  60. package/server/ab-button/index.tsx +6 -2
  61. package/server/ab-button/styles.module.css +39 -0
  62. package/types/index.d.ts +37 -0
@@ -32,6 +32,19 @@
32
32
  * Example usage:
33
33
  * 1+|> const { switchLocale } = useAbLocaleSwitch() // 🌍 from ab-nextjs-i18n/navigation
34
34
  * -|> <AbLocaleSwitcher label={t('language')} current={locale} locales={[{ code: 'en', label: 'English' }, { code: 'fr', label: 'FranΓ§ais' }]} onSelect={switchLocale} />
35
+ *
36
+ * 🧩 0.1.15 inline, inside the mobile app drawer (John):
37
+ * 2+|> // a) mixed drawer: nav + theme first, LANGUAGE last under a 1px rule
38
+ * -|> <AbBottomDrawer open={open} onClose={close} title={t('menu')}>
39
+ * -|> <AbDrawerList … />{themeRow}
40
+ * -|> <AbLocaleSwitcher presentation="inline" divider label={t('language')} current={locale} locales={LOCALES} onSelect={switchLocale} />
41
+ * -|> </AbBottomDrawer>
42
+ * πŸ” Switching `presentation` at runtime (e.g. inline in the drawer, menu on desktop) is safe: inline and popover
43
+ * are separate components, so React remounts instead of reordering hooks. `AbLocaleSwitcherInline` is also exported.
44
+ * 3+|> // b) language only: the drawer title says it, so no uppercase label
45
+ * -|> <AbBottomDrawer open={open} onClose={close} title={t('language')}>
46
+ * -|> <AbLocaleSwitcher presentation="inline" showLabel={false} label={t('language')} current={locale} locales={LOCALES} onSelect={switchLocale} />
47
+ * -|> </AbBottomDrawer>
35
48
  */
36
49
 
37
50
  /*
@@ -49,6 +62,10 @@ import { useCallback, useEffect, useId, useRef, useState } from 'react';
49
62
  import clsx from 'clsx';
50
63
  // πŸ”£ globe glyph
51
64
  import AbIcon from '../ab-icon';
65
+ // πŸ—„οΈ 0.1.14 (G56): drawer presentation
66
+ import AbDrawerList from '../ab-drawer-list';
67
+ import AbBottomDrawer from '../ab-bottom-drawer';
68
+ import type { AbDrawerScope } from '../ab-drawer';
52
69
  // 🎨 styles
53
70
  import styles from './styles.module.css';
54
71
 
@@ -59,6 +76,12 @@ export interface AbLocaleOption {
59
76
  }
60
77
 
61
78
  // βš™οΈ props
79
+ /** πŸ—„οΈ how a picker opens (G56): popover menu, drawer, or drawer on mobile only */
80
+ export type AbPresentation = 'menu' | 'drawer' | 'auto';
81
+ /** πŸ“± resolve `auto` at open time (no hydration flip: the server always renders the closed trigger) */
82
+ export const resolveAbPresentation = (p: AbPresentation = 'menu'): 'menu' | 'drawer' =>
83
+ p === 'auto' ? (typeof window !== 'undefined' && window.matchMedia?.('(max-width: 767.98px)').matches ? 'drawer' : 'menu') : p;
84
+
62
85
  export interface AbLocaleSwitcherProps {
63
86
  locales: readonly AbLocaleOption[]; // 🌍 choices
64
87
  current: string; // βœ… active locale code
@@ -70,6 +93,19 @@ export interface AbLocaleSwitcherProps {
70
93
  icon?: ReactNode; // πŸ–ΌοΈ override the globe
71
94
  className?: string; // 🏷️
72
95
  style?: CSSProperties; // 🎨
96
+ /** πŸ—„οΈ 0.1.14 (G56, D40): `menu` (default) = popover menu; `drawer` = AbDrawerList; `auto` = drawer below 768px, menu above.
97
+ * 🧩 0.1.15 (God 00:08): `inline` = no trigger; a labelled list of rows rendered in place, e.g. inside the app drawer on mobile */
98
+ presentation?: AbPresentation | 'inline';
99
+ /** 🏷️ 0.1.15 (John): inline only. Show the small uppercase group label (default true). Set false when the language
100
+ * list is the drawer's only content and the drawer title already says "Language" (the label stays the group's name) */
101
+ showLabel?: boolean;
102
+ /** β™Ώ 0.1.15 (God 00:37): inline only. The group's accessible name. Default: `label` (e.g. "Language"), so a visible
103
+ * label and the name always agree; set it when the drawer needs a fuller name (e.g. "Choose a language") */
104
+ ariaLabel?: string;
105
+ /** βž– 0.1.15 (John): inline only. A 1px --div rule above the block, for when it follows nav / theme items (default false) */
106
+ divider?: boolean;
107
+ drawerScope?: AbDrawerScope; // πŸ—ΊοΈ default 'app'
108
+ drawerSide?: 'top' | 'bottom' | 'start' | 'end'; // 🧭 default 'bottom'
73
109
  }
74
110
 
75
111
  /**
@@ -85,9 +121,50 @@ export function getAbTypeaheadIndex(labels: readonly string[], from: number, cha
85
121
  return -1; // πŸ™…
86
122
  }
87
123
 
124
+ /**
125
+ * 🧩 0.1.15: the inline list (no trigger, no popover), e.g. inside the mobile app drawer.
126
+ * Its own component (James): AbLocaleSwitcher picks this OR the popover by type, so switching `presentation`
127
+ * at runtime remounts instead of changing the hook order. Links mark the active row with aria-current, buttons aria-pressed.
128
+ */
129
+ export function AbLocaleSwitcherInline(props: AbLocaleSwitcherProps) {
130
+ const { locales, current, label, onSelect, getHref, className, style, showLabel = true, divider = false, ariaLabel } = props;
131
+ const base = useId(); // πŸ†”
132
+ return (
133
+ <div className={clsx('AbLocaleSwitcher', styles.inline, className)} style={style} data-ab-part="locale-switcher" data-presentation="inline" data-divider={divider ? 'true' : undefined} role="group" aria-labelledby={showLabel && ariaLabel == null ? `${base}-label` : undefined} aria-label={ariaLabel ?? (showLabel ? undefined : label)}>
134
+ {showLabel && <div id={`${base}-label`} className={styles.inlineLabel}>{label}</div> /* 🏷️ hidden when the drawer title says it */}
135
+ <ul className={styles.inlineList}>
136
+ {locales.map((l) => {
137
+ const on = l.code === current; // βœ…
138
+ const inner = (<><span className={styles.inlineText}>{l.label}</span><span className={styles.inlineCheck} aria-hidden="true">{on ? <svg viewBox="0 0 18 18" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" data-ab-part="locale-check"><path d="M3.5 9.5 7.25 13 14.5 5.5" /></svg> : null}</span></>);
139
+ return (
140
+ <li key={l.code}>
141
+ {getHref ? (
142
+ <a className={styles.inlineItem} href={getHref(l.code)} hrefLang={l.code} lang={l.code} data-active={on ? 'true' : 'false'} aria-current={on ? 'true' : undefined} onClick={() => onSelect?.(l.code)}>{inner}</a>
143
+ ) : (
144
+ <button type="button" className={styles.inlineItem} lang={l.code} data-active={on ? 'true' : 'false'} aria-pressed={on} onClick={() => onSelect?.(l.code)}>{inner}</button>
145
+ )}
146
+ </li>
147
+ );
148
+ })}
149
+ </ul>
150
+ </div>
151
+ );
152
+ }
153
+
154
+ /**
155
+ * 🌍 AbLocaleSwitcher: `presentation="inline"` renders AbLocaleSwitcherInline, anything else the popover / drawer.
156
+ * πŸ” Two component types, so a runtime `presentation` change remounts cleanly (rules of hooks).
157
+ */
88
158
  export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
159
+ return props.presentation === 'inline' ? <AbLocaleSwitcherInline {...props} /> : <AbLocaleSwitcherPopover {...props} />;
160
+ }
161
+
162
+ function AbLocaleSwitcherPopover(props: AbLocaleSwitcherProps) {
89
163
  // 🧩 props
90
- const { locales, current, label, onSelect, getHref, variant = 'icon', align = 'end', icon, className, style } = props;
164
+ const { locales, current, label, onSelect, getHref, variant = 'icon', align = 'end', icon, className, style, presentation: rawPresentation = 'menu', drawerScope = 'app', drawerSide = 'bottom' } = props;
165
+ const presentation: AbPresentation = rawPresentation === 'inline' ? 'menu' : rawPresentation; // πŸ—„οΈ (never 'inline' here: see the dispatcher)
166
+ // πŸ—„οΈ how this open happens (decided on click)
167
+ const [mode, setMode] = useState<'menu' | 'drawer'>(presentation === 'drawer' ? 'drawer' : 'menu');
91
168
  // πŸšͺ open?
92
169
  const [open, setOpen] = useState(false);
93
170
  // πŸ†” ids
@@ -110,22 +187,22 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
110
187
 
111
188
  // 🎯 on open, focus the checked item (after paint)
112
189
  useEffect(() => {
113
- if (!open) return; // πŸ’€
190
+ if (!open || mode !== 'menu') return; // πŸ’€ (the drawer manages its own focus)
114
191
  const id = requestAnimationFrame(() => focusItem(activeIndex)); // ⏭️
115
192
  return () => cancelAnimationFrame(id); // 🧹
116
- }, [open, activeIndex]);
193
+ }, [open, mode, activeIndex]);
117
194
 
118
195
  // πŸ–±οΈ click outside closes (no focus steal)
119
196
  useEffect(() => {
120
- if (!open) return; // πŸ’€
197
+ if (!open || mode !== 'menu') return; // πŸ’€ (the drawer portals outside rootRef: it has its own scrim)
121
198
  const onDown = (e: PointerEvent) => { if (!rootRef.current?.contains(e.target as Node)) close(false); }; // πŸšͺ
122
199
  document.addEventListener('pointerdown', onDown); // πŸ‘‚
123
200
  return () => document.removeEventListener('pointerdown', onDown); // 🧹
124
- }, [open, close]);
201
+ }, [open, mode, close]);
125
202
 
126
203
  // ⌨️ trigger: ArrowDown/Up/Enter/Space open the menu
127
204
  const onTriggerKey = (e: KeyboardEvent<HTMLButtonElement>) => {
128
- if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); setOpen(true); } // ⬇️
205
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); setMode(resolveAbPresentation(presentation)); setOpen(true); } // ⬇️
129
206
  };
130
207
 
131
208
  // ⌨️ menu keys
@@ -158,12 +235,12 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
158
235
  id={`${base}-trigger`} // πŸ†”
159
236
  type="button" // 🧾
160
237
  className={clsx(styles.trigger, variant === 'menu' && styles.withText)} // 🎨
161
- aria-haspopup="menu" // β™Ώ
238
+ aria-haspopup={mode === 'drawer' ? 'dialog' : 'menu'} // β™Ώ
162
239
  aria-expanded={open} // β™Ώ
163
- aria-controls={`${base}-menu`} // πŸ”—
240
+ aria-controls={mode === 'drawer' ? `${base}-drawer` : `${base}-menu`} // πŸ”—
164
241
  aria-label={variant === 'icon' ? `${label}: ${active?.label ?? current}` : undefined} // 🏷️ "Language: FranΓ§ais"
165
242
  title={label} // πŸ’¬
166
- onClick={() => setOpen((o) => !o)} // πŸ–±οΈ
243
+ onClick={() => { if (!open) setMode(resolveAbPresentation(presentation)); setOpen((o) => !o); }} // πŸ–±οΈ (`auto` picks menu / drawer now)
167
244
  onKeyDown={onTriggerKey} // ⌨️
168
245
  >
169
246
  <span aria-hidden="true">{icon ?? <AbIcon name="language" size={20} />}</span>
@@ -174,7 +251,7 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
174
251
  id={`${base}-menu`} // πŸ†”
175
252
  role="menu" // β™Ώ
176
253
  aria-labelledby={`${base}-trigger`} // πŸ”—
177
- hidden={!open} // πŸ™ˆ
254
+ hidden={!open || mode !== 'menu'} // πŸ™ˆ
178
255
  className={styles.menu} // 🎨
179
256
  onKeyDown={onMenuKey} // ⌨️
180
257
  >
@@ -205,6 +282,22 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
205
282
  );
206
283
  })}
207
284
  </ul>
285
+ {/* πŸ—„οΈ 0.1.14 (G56): drawer presentation. No in-flow fallback here: the <details> below already is one */}
286
+ {presentation !== 'menu' ? (
287
+ <AbDrawerList
288
+ id={`${base}-drawer`}
289
+ open={open && mode === 'drawer'}
290
+ onClose={() => setOpen(false)} // πŸšͺ the drawer puts focus back on the trigger
291
+ scope={drawerScope}
292
+ side={drawerSide}
293
+ as={drawerSide === 'bottom' ? AbBottomDrawer : undefined} // πŸ“± the mobile bottom drawer look
294
+ title={label}
295
+ noJsFallback={false}
296
+ value={current}
297
+ items={locales.map((l) => ({ value: l.code, label: l.label, lang: l.code, href: getHref?.(l.code) }))}
298
+ onSelect={(code) => onSelect?.(code)}
299
+ />
300
+ ) : null}
208
301
  {/* 🚫 JS off (0.1.13, gap-review): a native <details> list of hreflang links replaces the menu.
209
302
  Only rendered with getHref (a callback can't run without JS). CSS shows it under (scripting: none). */}
210
303
  {getHref ? (
@@ -63,11 +63,11 @@
63
63
  }
64
64
  .trigger:hover,
65
65
  .trigger[aria-expanded='true'] {
66
- background: color-mix(in srgb, currentColor 10%, transparent); /* 🌫️ */
66
+ background: var(--ab-color-hover, color-mix(in srgb, currentColor 10%, transparent)); /* 🌫️ */
67
67
  }
68
68
  .trigger:focus-visible,
69
69
  .item:focus-visible {
70
- outline: 2px solid var(--ab-focus-ring, var(--ab-color-primary, #A67C52)); /* πŸ’ */
70
+ outline: 2px solid var(--ab-color-accent, var(--ab-focus-ring, var(--ab-color-primary, #A67C52))); /* πŸ’ */
71
71
  outline-offset: 2px; /* ↔️ */
72
72
  }
73
73
  @media (pointer: coarse) {
@@ -85,7 +85,7 @@
85
85
  padding: 0.25rem; /* 🧱 */
86
86
  list-style: none; /* 🧹 */
87
87
  border-radius: 0.75rem; /* πŸ”² */
88
- border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* πŸ–ŠοΈ */
88
+ border: 1px solid var(--ab-color-border, var(--ab-color-outline-variant, rgb(0 0 0 / 0.12))); /* πŸ–ŠοΈ */
89
89
  background: var(--ab-color-surface, #fff); /* 🎨 */
90
90
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); /* 🌫️ */
91
91
  }
@@ -116,7 +116,7 @@
116
116
  }
117
117
  .item:hover,
118
118
  .item:focus-visible {
119
- background: color-mix(in srgb, currentColor 8%, transparent); /* 🌫️ */
119
+ background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); /* 🌫️ */
120
120
  }
121
121
  .item[aria-checked='true'] {
122
122
  font-weight: 600; /* πŸ’ͺ */
@@ -136,3 +136,23 @@
136
136
  .root > .menu { display: none; } /* πŸ™ˆ needs JS */
137
137
  .noJs { display: block; } /* πŸ‘οΈ */
138
138
  }
139
+
140
+ /* ===== 🧩 0.1.15 (God 00:08): presentation="inline", the language list inside the mobile app drawer =====
141
+ * Rows match AbDrawerList / the Home drawer: 48px, 12px padding, radius 8, --tint + --accent-text + 650 when active. */
142
+ .inline { display: grid; gap: 4px; } /* πŸ“ */
143
+ .inlineLabel { padding: 14px 12px 6px; font-size: 11px; font-weight: 700; line-height: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ab-color-faint, #807062); } /* 🏷️ = sidebar group label */
144
+ .inlineList { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; } /* πŸ“œ John: 8px between rows */
145
+ .inlineList > li { display: block; margin: 0; padding: 0; line-height: 0; } /* 🧹 no inherited li spacing / line box: the row is the box */
146
+ .inlineItem {
147
+ display: flex; align-items: center; gap: 12px; box-sizing: border-box; inline-size: 100%; block-size: 48px; min-block-size: 44px; /* πŸ‘† John: exactly 48px (β‰₯ 44px hit area) */
148
+ padding: 8px 12px; border: 0; border-radius: var(--ab-radius-row, 8px); background: none; /* 🧹 */
149
+ font: inherit; font-size: 16px; line-height: 20px; text-align: start; color: var(--ab-color-text, #211a16); text-decoration: none; cursor: pointer; /* πŸ”€ */
150
+ }
151
+ .inlineItem:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } /* πŸ–±οΈ */
152
+ .inlineItem[data-active='true'] { background: var(--ab-color-tint, #f4e7db); color: var(--ab-color-accent-text, #88603d); font-weight: 650; } /* 🎯 */
153
+ .inlineItem:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; } /* β™Ώ */
154
+ .inlineText { flex: 1 1 auto; min-width: 0; } /* 🏷️ */
155
+ .inlineCheck { flex: none; display: inline-flex; inline-size: 18px; block-size: 18px; color: var(--ab-locale-check-color, var(--ab-color-btn, #8b6340)); } /* βœ“ John: bronze 2px stroke, 18px (James P2: the --ab-color-btn token) */
156
+ :global(.dark) .inlineCheck, :global([data-theme='dark']) .inlineCheck { color: var(--ab-locale-check-color, var(--ab-color-accent, #c29a6f)); } /* πŸŒ™ the warm accent */
157
+ /* βž– 0.1.15 (John): language goes LAST in a drawer with nav / theme items, under a 1px --div rule */
158
+ .inline[data-divider='true'] { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); }
@@ -0,0 +1,100 @@
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: AbMobileHeader
28
+ * @file: ab-mobile-header/index.tsx
29
+ * @type: Client component
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> <AbAppLayout variant="panes" mobileHeader="main" content={<AbMainLayout
34
+ * -|> mainHeader={<AbMobileHeader logo={<a href="/" id="home-logo">…</a>} onLanguage={openLanguage}
35
+ * -|> theme={mode} onThemeChange={setMode} />} … />} />
36
+ *
37
+ * πŸ“Œ Requires ab-nextjs-core β‰₯ 0.2.1 with `mobileHeader="main"` on AbAppLayout. That hides the app header below
38
+ * 768px and turns the main header slot into this 56px bar; older core shows it inside the normal main header.
39
+ */
40
+
41
+ /*
42
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43
+ * MOTTO: We'll always do more 😜!!!
44
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
45
+ */
46
+
47
+
48
+ 'use client';
49
+
50
+ // βš›οΈ React
51
+ import type { ReactElement, ReactNode } from 'react';
52
+ // 🧡 classes
53
+ import clsx from 'clsx';
54
+ // πŸ”£ icons
55
+ import AbIcon from '../ab-icon';
56
+ // 🎨 the drawers v2 kit
57
+ import kit from '../ab-drawer/kit.module.css';
58
+
59
+ /** βš™οΈ props */
60
+ export interface AbMobileHeaderProps {
61
+ logo: ReactNode; // 🏷️ the logoname (22px), usually a link home: the focus target after a swipe-opened drawer closes
62
+ onLanguage?: () => void; // 🌍 the globe: open the Settings sheet with the language list in view
63
+ theme?: 'light' | 'dark'; // πŸŒ— the resolved theme now
64
+ onThemeChange?: (next: 'light' | 'dark') => void; // πŸŒ— the toggle (it shows the mode it switches TO: a moon in light)
65
+ actions?: ReactNode; // βž• more 44px buttons after the two (none in John's frame)
66
+ labels?: { language?: string; toDark?: string; toLight?: string; header?: string }; // 🌍 "Change language", "Switch to dark theme", "Switch to light theme", "Main header"
67
+ languageExpanded?: boolean; // β™Ώ aria-expanded on the globe while its sheet is open
68
+ className?: string; // 🏷️
69
+ }
70
+
71
+ /**
72
+ * πŸ“± AbMobileHeader β€” John's mobile main header (drawers v2): logo left; a globe ("Change language",
73
+ * `aria-haspopup="dialog"`) and a theme toggle right, each 44Γ—44. No search (the bottom nav has a Search tab) and
74
+ * no menu button (the left drawer opens with an edge swipe). Put it in AbMainLayout's `mainHeader` with core
75
+ * β‰₯ 0.2.1 `mobileHeader="main"`: the 56px row, its divider and the hidden app header come from core.
76
+ */
77
+ const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, actions, labels = {}, languageExpanded, className }: AbMobileHeaderProps): ReactElement => {
78
+ const L = { language: 'Change language', toDark: 'Switch to dark theme', toLight: 'Switch to light theme', header: 'Main header', ...labels }; // 🌍
79
+ const next = theme === 'dark' ? 'light' : 'dark'; // πŸŒ— the target
80
+ return (
81
+ <div className={clsx('AbMobileHeader', kit.mh, className)} role="group" aria-label={L.header} data-ab-part="mobile-header">
82
+ <span className={kit.logoRow}>{logo}</span>
83
+ {onLanguage && (
84
+ <button type="button" className={kit.ibtn} aria-label={L.language} aria-haspopup="dialog" aria-expanded={languageExpanded} onClick={onLanguage} data-ab-part="mobile-header-language">
85
+ <AbIcon name="language" size={24} />
86
+ </button>
87
+ )}
88
+ {onThemeChange && (
89
+ <button type="button" className={kit.ibtn} aria-label={next === 'dark' ? L.toDark : L.toLight} onClick={() => onThemeChange(next)} data-ab-part="mobile-header-theme">
90
+ <AbIcon name={next === 'dark' ? 'dark_mode' : 'light_mode'} size={24} />
91
+ </button>
92
+ )}
93
+ {actions}
94
+ </div>
95
+ );
96
+ };
97
+
98
+ // πŸ“¦ exports
99
+ export default AbMobileHeader;
100
+ export { AbMobileHeader };
@@ -0,0 +1,158 @@
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: AbNavDrawer
28
+ * @file: ab-nav-drawer/index.tsx
29
+ * @type: Client component
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> useAbEdgeSwipe({ edge: 'left', onOpen: () => setNav(true), enabled: !nav })
34
+ * -|> <AbNavDrawer open={nav} onClose={() => setNav(false)} logo={<AbLogo />} version="v0.2.x"
35
+ * -|> sections={[{ id: 'top', items: [{ href: '/', label: 'Home', icon: 'home' }] }]} activeHref="/"
36
+ * -|> footer={[{ href: '/changelog', label: 'Changelog', icon: 'history' }]} onSettings={openSettings} />
37
+ */
38
+
39
+ /*
40
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
+ * MOTTO: We'll always do more 😜!!!
42
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43
+ */
44
+
45
+
46
+ 'use client';
47
+
48
+ // βš›οΈ React
49
+ import type { MouseEvent, ReactElement, ReactNode } from 'react';
50
+ // 🧡 classes
51
+ import clsx from 'clsx';
52
+ // πŸ—„οΈ the drawer
53
+ import AbDrawer from '../ab-drawer';
54
+ // πŸ”£ icons
55
+ import AbIcon from '../ab-icon';
56
+ // πŸ”— the app's link (AbLinkProvider: next/link, or a locale-aware one)
57
+ import Link from '../ab-link';
58
+ // 🎯 the same active rule as the laptop sidebar
59
+ import { isAbSidebarActive } from '../ab-sidebar/view';
60
+ // 🎨 the drawers v2 kit
61
+ import kit from '../ab-drawer/kit.module.css';
62
+
63
+ /** πŸ”— one nav row */
64
+ export interface AbNavDrawerItem {
65
+ href: string; // πŸ”—
66
+ label: string; // 🏷️
67
+ icon?: string; // πŸ”£ an AbIcons name
68
+ meta?: string; // 🏷️ trailing mono text, e.g. a version
69
+ }
70
+ /** πŸ—‚οΈ one group: an optional uppercase label (a heading for its list) + rows */
71
+ export interface AbNavDrawerSection { id: string; label?: string; items: readonly AbNavDrawerItem[] }
72
+
73
+ /** βš™οΈ props */
74
+ export interface AbNavDrawerProps {
75
+ open: boolean; // πŸšͺ
76
+ onClose: () => void; // βŽ‹ scrim, Esc, βœ•, a swipe back, or choosing a link
77
+ logo: ReactNode; // 🏷️ the logoname (a link home, usually)
78
+ version?: ReactNode; // 🏷️ a string = the mono version chip ("v0.2.x βŒ„"); or your own picker node
79
+ onVersionClick?: () => void; // πŸ”½ the chip as a button (e.g. open a version menu)
80
+ sections: readonly AbNavDrawerSection[]; // πŸ—‚οΈ same content as the laptop sidebar
81
+ activeHref?: string; // 🎯 exact match or parent prefix ("/" only matches itself)
82
+ footer?: readonly AbNavDrawerItem[]; // πŸ“Œ pinned 48px rows (e.g. Changelog)
83
+ onSettings?: () => void; // βš™οΈ adds a "Settings β€Ί" row; close this drawer, then open the Settings sheet
84
+ onNavigate?: (href: string) => void; // πŸ”” after a link is chosen (the drawer closes either way)
85
+ labels?: { title?: string; close?: string; settings?: string; version?: string }; // 🌍 "Site navigation", "Close navigation", "Settings", "Version"
86
+ returnFocus?: string; // ↩️ e.g. the main header logo link (where focus goes after a swipe-open)
87
+ id?: string; // πŸ†”
88
+ className?: string; // 🏷️
89
+ }
90
+
91
+ /**
92
+ * ⬅️ AbNavDrawer β€” John's left drawer (drawers v2 Β§2): the mobile sidebar.
93
+ *
94
+ * - πŸ“ 320px, full height, 0 16 16 0 radius; header = logo + 44px βœ•; the version chip; a scrolling nav
95
+ * (44px rows, uppercase group headings, a 72px fade); a pinned footer of 48px rows
96
+ * - 🀏 opens with `useAbEdgeSwipe({ edge: 'left' })`; closes with a right-to-left swipe on the sheet (AbDrawer `swipe`),
97
+ * the scrim, Esc, βœ•, or choosing a link
98
+ * - β™Ώ `role="dialog"` + aria-modal, aria-label "Site navigation"; `aria-current="page"` on the active row; each
99
+ * group label is a heading that labels its list
100
+ * - πŸ₯ž tier 'nav': in front of the right drawer, under the bottom sheet
101
+ */
102
+ const AbNavDrawer = ({ open, onClose, logo, version, onVersionClick, sections, activeHref, footer = [], onSettings, onNavigate, labels = {}, returnFocus, id = 'ab-nav-drawer', className }: AbNavDrawerProps): ReactElement => {
103
+ const L = { title: 'Site navigation', close: 'Close navigation', settings: 'Settings', version: 'Version', ...labels }; // 🌍
104
+ const choose = (href: string) => (e: MouseEvent) => { if (e.defaultPrevented) return; onNavigate?.(href); onClose(); }; // πŸ”— then close
105
+ const row = (it: AbNavDrawerItem, cls: string) => {
106
+ const on = isAbSidebarActive(it.href, activeHref); // 🎯
107
+ return (
108
+ <Link href={it.href} className={cls} aria-current={on ? 'page' : undefined} onClick={choose(it.href)}>
109
+ {it.icon && <AbIcon name={it.icon} filled={on} size={cls === kit.row ? 24 : 22} />}
110
+ <span>{it.label}</span>
111
+ {it.meta && <span className={kit.mini}>{it.meta}</span>}
112
+ </Link>
113
+ );
114
+ };
115
+ // 🏷️ a string version = the mock chip (mono, accent), optionally a button
116
+ const chip = typeof version === 'string'
117
+ ? (onVersionClick
118
+ ? <button type="button" className={kit.ver} aria-label={`${L.version} ${version}`} aria-haspopup="menu" onClick={onVersionClick}><b>{version}</b><AbIcon name="expand_more" size={18} /></button>
119
+ : <span className={kit.ver} aria-label={`${L.version} ${version}`}><b>{version}</b><AbIcon name="expand_more" size={18} /></span>)
120
+ : version;
121
+ return (
122
+ <AbDrawer
123
+ open={open} onClose={onClose} id={id} side="left" scope="app" tier="nav" swipe size="320px"
124
+ headerStart={<span className={kit.logoRow}>{logo}</span>} aria-label={L.title}
125
+ closeLabel={L.close} closeIcon={<AbIcon name="close" size={24} />} initialFocus="panel" returnFocus={returnFocus}
126
+ className={clsx('AbNavDrawer', kit.sheet, className)}
127
+ >
128
+ {chip != null && <div className={kit.verRow}>{chip}</div>}
129
+ <div className={kit.navWrap}>
130
+ <nav className={kit.nav} aria-label={L.title} data-ab-part="nav-drawer-nav">
131
+ {sections.map((s) => (
132
+ <div key={s.id} role="group" aria-labelledby={s.label ? `${id}-${s.id}` : undefined}>
133
+ {s.label && <h3 id={`${id}-${s.id}`} className={kit.grp}>{s.label}</h3>}
134
+ <ul className={kit.list} aria-labelledby={s.label ? `${id}-${s.id}` : undefined}>
135
+ {s.items.map((it) => <li key={it.href}>{row(it, kit.nv)}</li>)}
136
+ </ul>
137
+ </div>
138
+ ))}
139
+ </nav>
140
+ <div className={kit.fade} aria-hidden="true" />
141
+ </div>
142
+ {(footer.length > 0 || onSettings) && (
143
+ <div className={kit.navFoot} data-ab-part="nav-drawer-footer">
144
+ {footer.map((it) => <div key={it.href}>{row(it, kit.row)}</div>)}
145
+ {onSettings && (
146
+ <button type="button" className={kit.row} aria-haspopup="dialog" onClick={() => { onClose(); onSettings(); }}>
147
+ <AbIcon name="settings" size={24} /><span>{L.settings}</span><AbIcon name="chevron_right" size={24} className={kit.chev} />
148
+ </button>
149
+ )}
150
+ </div>
151
+ )}
152
+ </AbDrawer>
153
+ );
154
+ };
155
+
156
+ // πŸ“¦ exports
157
+ export default AbNavDrawer;
158
+ export { AbNavDrawer };
@@ -30,7 +30,7 @@
30
30
  * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
31
  *
32
32
  * Example usage:
33
- * <AbNavbar activeHref="/docs" items={[
33
+ * <AbNavbar activeHref="/" items={[
34
34
  * { kind: 'link', href: '/', icon: 'home', label: 'Home' },
35
35
  * { kind: 'button', id: 'menu', icon: 'menu', label: 'Menu', onSelect: openSheet },
36
36
  * ]} />
@@ -77,10 +77,10 @@
77
77
  .abNavbarLink[data-active='true'],
78
78
  .abNavbarLink[aria-expanded='true'] { color: var(--ab-color-on-surface, inherit); } /* 🎯 */
79
79
  .abNavbarLink[data-active='true'] .abNavbarPill,
80
- .abNavbarLink[aria-expanded='true'] .abNavbarPill { background: var(--ab-color-secondary-container, rgb(0 0 0 / 0.08)); } /* 🎯 */
80
+ .abNavbarLink[aria-expanded='true'] .abNavbarPill { background: var(--ab-color-tint, var(--ab-color-secondary-container, rgb(0 0 0 / 0.08))); } /* 🎯 */
81
81
  .abNavbarLink[data-active='true'] .abNavbarLabel { font-weight: 700; } /* πŸ”€ */
82
82
  .abNavbarLink:focus-visible {
83
- outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* β™Ώ */
83
+ outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); /* β™Ώ */
84
84
  outline-offset: var(--ab-focus-ring-offset, 2px); /* β™Ώ */
85
85
  border-radius: 12px; /* 🟒 */
86
86
  }
@@ -89,3 +89,21 @@
89
89
  .abNavbarLink[aria-disabled='true'] { cursor: default; opacity: 0.6; } /* 🚫 */
90
90
  .abNavbarSoon { font-size: 10px; line-height: 12px; opacity: 0.85; } /* 🚧 tag under the label */
91
91
  .abNavbarSrOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* πŸ•ΆοΈ */
92
+
93
+ /* ===== πŸ“± 0.1.14 (P18, Home spec Β§4 bottom nav): indicator="none" Β· blur ===== */
94
+ .abNavbar[data-indicator='none'] { padding-top: 8px; padding-bottom: env(safe-area-inset-bottom, 0px); min-height: calc(50px + env(safe-area-inset-bottom, 0px)); box-sizing: border-box; } /* πŸ“ 84px with the iPhone home indicator */
95
+ .abNavbar[data-indicator='none'] .abNavbarList { justify-content: space-around; }
96
+ .abNavbar[data-indicator='none'] .abNavbarList > li { flex: 0 1 80px; } /* ↔️ 4 Γ— 80px */
97
+ .abNavbar[data-indicator='none'] .abNavbarLink { width: 80px; min-width: 0; gap: 3px; color: var(--ab-color-faint, inherit); } /* πŸ”— */
98
+ .abNavbar[data-indicator='none'] .abNavbarLink .abNavbarPill { width: auto; height: auto; background: none; } /* 🚫 pill (0,4,0 beats the active pill rules) */
99
+ .abNavbar[data-indicator='none'] .abNavbarLabel { font-size: 11.5px; font-weight: 550; line-height: 1.2; } /* πŸ”€ */
100
+ .abNavbar[data-indicator='none'] .abNavbarLink[data-active='true'],
101
+ .abNavbar[data-indicator='none'] .abNavbarLink[aria-expanded='true'] { color: var(--ab-color-accent-text, inherit); } /* 🎯 */
102
+ .abNavbar[data-indicator='none'] .abNavbarLink[data-active='true'] .abNavbarLabel { font-weight: 700; }
103
+ .abNavbar[data-indicator='none'] .abNavbarLink:focus-visible { outline-color: var(--ab-color-accent, #a67c52); }
104
+ .abNavbar[data-blur='true'] {
105
+ background: color-mix(in srgb, var(--ab-color-bg, #fff8f5) 92%, transparent); /* 🌫️ */
106
+ -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); /* 🧊 */
107
+ border-top: 1px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); /* βž– */
108
+ }
109
+ :global(.dark) .abNavbar[data-blur='true'], :global([data-theme='dark']) .abNavbar[data-blur='true'] { background: #1f170f; } /* πŸŒ™ mock: solid warm */
@@ -87,6 +87,8 @@ export interface AbNavbarBaseProps<I extends AbNavbarItem = AbNavbarItem> {
87
87
  activeHref?: string; // 🎯
88
88
  locales?: readonly string[]; // 🌍 0.1.13: stripped from the pathname (default: AbLinkProvider's)
89
89
  label?: string; // β™Ώ nav aria-label (default "Primary")
90
+ indicator?: 'pill' | 'none'; // 🎯 0.1.14 (P18): 'none' = no active pill; 25px icons, accent text (the Home bottom nav). Default 'pill'
91
+ blur?: boolean; // 🌫️ 0.1.14 (P18): translucent --bg + 12px backdrop blur + --div top hairline
90
92
  // πŸ•°οΈ legacy
91
93
  type?: 'customer' | 'admin';
92
94
  page?: string;
@@ -106,13 +108,14 @@ export function AbNavbarView({ props, Icon, active }: {
106
108
  Icon: AbNavbarIconComponent;
107
109
  active: (href: string, legacyValue?: string) => boolean;
108
110
  }): ReactElement {
109
- const { className, items, links, label = 'Primary', type = 'customer' } = props;
111
+ const { className, items, links, label = 'Primary', type = 'customer', indicator = 'pill', blur = false } = props;
112
+ const iconSize = indicator === 'none' ? 25 : 24; // πŸ”£ P18
110
113
  // πŸ•°οΈ legacy links β†’ link items
111
114
  const list: AbNavbarItem[] = items?.length ? items : (links ?? []).map(({ href, icon, label: l }) => ({ kind: 'link', href, icon, label: l }));
112
115
  const valueOf = (href: string) => links?.find((l) => l.href === href)?.value;
113
116
 
114
117
  return (
115
- <nav data-type={type} data-ab-part="bottomBar" className={clsx('AbNavbar', styles.abNavbar, className)} aria-label={label}>
118
+ <nav data-type={type} data-ab-part="bottomBar" className={clsx('AbNavbar', styles.abNavbar, className)} aria-label={label} data-indicator={indicator === 'none' ? 'none' : undefined} data-blur={blur ? 'true' : undefined}>
116
119
  <ul className={styles.abNavbarList}>
117
120
  {list.map((item) => {
118
121
  if (item.kind === 'button') {
@@ -132,7 +135,7 @@ export function AbNavbarView({ props, Icon, active }: {
132
135
  data-coming-soon={item.comingSoon ? 'true' : undefined} // 🚧
133
136
  onClick={inert ? undefined : item.onSelect}
134
137
  >
135
- <span className={styles.abNavbarPill}><Icon name={item.icon} variant={item.expanded ? 'filled' : 'outlined'} size={24} /></span>
138
+ <span className={styles.abNavbarPill}><Icon name={item.icon} variant={item.expanded ? 'filled' : 'outlined'} size={iconSize} /></span>
136
139
  <span className={styles.abNavbarLabel}>{item.label}</span>
137
140
  {soon && <span className={styles.abNavbarSoon} data-ab-part="badge"><span className={styles.abNavbarSrOnly}>, </span>{soon}</span>}
138
141
  </button>
@@ -151,7 +154,7 @@ export function AbNavbarView({ props, Icon, active }: {
151
154
  data-active={on ? 'true' : 'false'}
152
155
  aria-current={on ? 'page' : undefined} // β™Ώ
153
156
  >
154
- <span className={styles.abNavbarPill}><Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={24} /></span>
157
+ <span className={styles.abNavbarPill}><Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={iconSize} /></span>
155
158
  <span className={styles.abNavbarLabel}>{item.label}</span>
156
159
  </Link>
157
160
  </li>