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.
- package/CHANGELOG.md +70 -0
- package/README.md +35 -0
- package/ab-app-bar/index.tsx +53 -13
- package/ab-app-bar/styles.module.css +68 -4
- package/ab-bottom-drawer/index.tsx +71 -0
- package/ab-bottom-drawer/styles.module.css +66 -0
- package/ab-breadcrumbs/index.tsx +92 -0
- package/ab-breadcrumbs/styles.module.css +54 -0
- package/ab-button/helpers.ts +6 -1
- package/ab-button/index.tsx +8 -2
- package/ab-button/styles.module.css +39 -0
- package/ab-card/styles.module.css +1 -1
- package/ab-carousel/styles.module.css +1 -1
- package/ab-chip/index.tsx +16 -4
- package/ab-chip/styles.module.css +12 -1
- package/ab-confirm-drawer/index.tsx +97 -0
- package/ab-confirm-drawer/styles.module.css +41 -0
- package/ab-drawer/gestures.ts +134 -0
- package/ab-drawer/index.tsx +458 -0
- package/ab-drawer/kit.module.css +204 -0
- package/ab-drawer/styles.module.css +166 -0
- package/ab-drawer/use-ab-drawer.ts +89 -0
- package/ab-drawer/use-ab-edge-swipe.ts +155 -0
- package/ab-drawer-list/index.tsx +118 -0
- package/ab-drawer-list/styles.module.css +65 -0
- package/ab-flow-diagram/styles.module.css +2 -2
- package/ab-icon/builtin.ts +4 -0
- package/ab-icon-button/index.tsx +13 -2
- package/ab-icon-button/styles.module.css +1 -1
- package/ab-install-snippet/index.tsx +51 -29
- package/ab-install-snippet/styles.module.css +34 -2
- package/ab-kbd/styles.module.css +1 -1
- package/ab-list/index.tsx +107 -0
- package/ab-list/styles.module.css +82 -0
- package/ab-locale-switcher/index.tsx +103 -10
- package/ab-locale-switcher/styles.module.css +24 -4
- package/ab-mobile-header/index.tsx +100 -0
- package/ab-nav-drawer/index.tsx +158 -0
- package/ab-navbar/index.tsx +1 -1
- package/ab-navbar/styles.module.css +20 -2
- package/ab-navbar/view.tsx +7 -4
- package/ab-package-card/index.tsx +49 -2
- package/ab-package-card/styles.module.css +40 -0
- package/ab-search-drawer/index.tsx +279 -0
- package/ab-search-trigger/index.tsx +22 -2
- package/ab-search-trigger/styles.module.css +30 -1
- package/ab-settings-drawer/index.tsx +160 -0
- package/ab-sidebar/index.tsx +6 -3
- package/ab-sidebar/styles.module.css +53 -5
- package/ab-sidebar/view.tsx +18 -4
- package/ab-theme-toggle/index.tsx +21 -6
- package/ab-theme-toggle/styles.module.css +18 -3
- package/ab-toc/index.tsx +9 -2
- package/ab-toc/styles.module.css +20 -8
- package/ab-toc-drawer/index.tsx +129 -0
- package/ab-version-switcher/index.tsx +143 -0
- package/ab-version-switcher/styles.module.css +76 -0
- package/index.ts +50 -0
- package/package.json +28 -3
- package/server/ab-button/index.tsx +6 -2
- package/server/ab-button/styles.module.css +39 -0
- 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=
|
|
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 };
|
package/ab-navbar/index.tsx
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
31
|
*
|
|
32
32
|
* Example usage:
|
|
33
|
-
* <AbNavbar activeHref="/
|
|
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 */
|
package/ab-navbar/view.tsx
CHANGED
|
@@ -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={
|
|
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={
|
|
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>
|