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
@@ -0,0 +1,160 @@
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: AbSettingsDrawer
28
+ * @file: ab-settings-drawer/index.tsx
29
+ * @type: Client component
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> const [open, setOpen] = useState(false)
34
+ * -|> <AbSettingsDrawer open={open} onClose={() => setOpen(false)} theme={mode} onThemeChange={setMode}
35
+ * -|> locales={[{ code: 'en', label: 'English' }, { code: 'fr', label: 'FranΓ§ais' }]} locale="en" onLocaleChange={go} />
36
+ */
37
+
38
+ /*
39
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
+ * MOTTO: We'll always do more 😜!!!
41
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42
+ */
43
+
44
+
45
+ 'use client';
46
+
47
+ // βš›οΈ React
48
+ import { useRef, type KeyboardEvent, type ReactElement, type ReactNode } from 'react';
49
+ // 🧡 classes
50
+ import clsx from 'clsx';
51
+ // πŸ—„οΈ the drawer (tiers, snap points, centring)
52
+ import AbDrawer, { type AbSheetSnap } from '../ab-drawer';
53
+ // πŸ”£ icons
54
+ import AbIcon from '../ab-icon';
55
+ // 🎨 the drawers v2 kit
56
+ import kit from '../ab-drawer/kit.module.css';
57
+
58
+ /** πŸŒ— a theme choice */
59
+ export type AbSettingsTheme = 'light' | 'dark' | 'system';
60
+ /** 🌍 a language row */
61
+ export interface AbSettingsLocale { code: string; label: string } // 🏷️ `label` in its own language ("Français")
62
+
63
+ /** 🏷️ every visible / accessible string (English defaults) */
64
+ export interface AbSettingsDrawerLabels {
65
+ title?: string; // "Settings"
66
+ theme?: string; // "Theme"
67
+ language?: string; // "Language"
68
+ light?: string; dark?: string; system?: string; // πŸŒ—
69
+ close?: string; // "Close settings"
70
+ expand?: string; collapse?: string; // βž– the handle: "Expand settings" / "Collapse settings"
71
+ }
72
+
73
+ /** βš™οΈ props */
74
+ export interface AbSettingsDrawerProps {
75
+ open: boolean; // πŸšͺ
76
+ onClose: () => void; // βŽ‹
77
+ theme: AbSettingsTheme; // πŸŒ— the checked theme
78
+ onThemeChange: (theme: AbSettingsTheme) => void; // πŸ“£
79
+ locales: readonly AbSettingsLocale[]; // 🌍
80
+ locale: string; // 🎯 the checked locale code
81
+ onLocaleChange: (code: string) => void; // πŸ“£
82
+ labels?: AbSettingsDrawerLabels; // 🏷️
83
+ themes?: readonly AbSettingsTheme[]; // 🎚️ default light, dark, system
84
+ children?: ReactNode; // βž• extra sections after Language (your own; Accessibility / About are not built in)
85
+ defaultSnap?: AbSheetSnap; // 🧲 default 'partial' (70%)
86
+ returnFocus?: string; // ↩️ see AbDrawer
87
+ id?: string; // πŸ†”
88
+ className?: string; // 🏷️
89
+ }
90
+
91
+ // βœ“ the 24px 2px-stroke check (the mock's path)
92
+ const Check = () => <svg className={kit.ck} viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /></svg>;
93
+ // πŸŒ— the glyph per theme
94
+ const THEME_ICON: Record<AbSettingsTheme, string> = { light: 'light_mode', dark: 'dark_mode', system: 'brightness_auto' };
95
+
96
+ /** ⌨️ radiogroup keys: arrows move AND check (WAI-ARIA radio pattern), Home / End jump */
97
+ function radioKeys<T>(e: KeyboardEvent, items: readonly T[], current: T, pick: (v: T) => void, root: HTMLElement | null) {
98
+ const i = items.indexOf(current); let n = -1;
99
+ if (e.key === 'ArrowDown' || e.key === 'ArrowRight') n = (i + 1) % items.length;
100
+ else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') n = (i - 1 + items.length) % items.length;
101
+ else if (e.key === 'Home') n = 0; else if (e.key === 'End') n = items.length - 1;
102
+ if (n < 0) return;
103
+ e.preventDefault(); pick(items[n]); // βœ… check it
104
+ root?.querySelectorAll<HTMLElement>('[role="radio"]')[n]?.focus(); // 🎯 and move focus
105
+ }
106
+
107
+ /**
108
+ * βš™οΈ AbSettingsDrawer β€” John's Settings bottom drawer (drawers v2, spec Β§1): the default bottom sheet, holding
109
+ * THEME (a Light / Dark / System segmented radiogroup, 48px) and LANGUAGE (48px radio rows, each label in its
110
+ * own `lang`, the checked one tinted with a check).
111
+ *
112
+ * - πŸ“± below 768px: full width, snaps at 70% and full height via the handle (AbDrawer `snapPoints`)
113
+ * - πŸ’» 768px and up: centred in the main pane, min(640px, main width), at most 70% tall
114
+ * - β™Ώ `role="dialog"` labelled by the title; focus goes to the checked language on open (so the globe's
115
+ * "Change language" lands right there) and back to the opener on close; Esc / scrim / βœ• close it
116
+ * - πŸ₯ž tier 'sheet': above the left and right drawers. Opening it from the left drawer? Close that one first.
117
+ */
118
+ const AbSettingsDrawer = ({ open, onClose, theme, onThemeChange, locales, locale, onLocaleChange, labels = {}, themes = ['light', 'dark', 'system'], children, defaultSnap, returnFocus, id, className }: AbSettingsDrawerProps): ReactElement => {
119
+ const seg = useRef<HTMLDivElement>(null); // 🎚️
120
+ const langs = useRef<HTMLDivElement>(null); // 🌍
121
+ const L = { title: 'Settings', theme: 'Theme', language: 'Language', light: 'Light', dark: 'Dark', system: 'System', close: 'Close settings', expand: 'Expand settings', collapse: 'Collapse settings', ...labels }; // 🏷️
122
+ const base = id ?? 'ab-settings'; // πŸ†”
123
+ const codes = locales.map((l) => l.code); // 🌍
124
+ return (
125
+ <AbDrawer
126
+ open={open} onClose={onClose} id={id} side="bottom" scope="app" tier="sheet"
127
+ snapPoints centerIn="main" defaultSnap={defaultSnap} handleLabels={{ expand: L.expand, collapse: L.collapse }}
128
+ title={L.title} closeLabel={L.close} closeIcon={<AbIcon name="close" size={24} />}
129
+ initialFocus='[data-ab-part="settings-language"] [aria-checked="true"]' returnFocus={returnFocus}
130
+ className={clsx('AbSettingsDrawer', kit.sheet, className)}
131
+ >
132
+ <p className={kit.lbl} id={`${base}-theme`}>{L.theme}</p>
133
+ <div ref={seg} className={kit.seg} role="radiogroup" aria-labelledby={`${base}-theme`} data-ab-part="settings-theme">
134
+ {themes.map((t) => (
135
+ <button key={t} type="button" role="radio" aria-checked={t === theme} tabIndex={t === theme ? 0 : -1} className={kit.segBtn} data-value={t}
136
+ onClick={() => onThemeChange(t)} onKeyDown={(e) => radioKeys(e, themes, theme, onThemeChange, seg.current)}>
137
+ <AbIcon name={THEME_ICON[t]} size={18} />{L[t]}
138
+ </button>
139
+ ))}
140
+ </div>
141
+ <p className={kit.lbl} id={`${base}-language`}>{L.language}</p>
142
+ <div ref={langs} role="radiogroup" aria-labelledby={`${base}-language`} data-ab-part="settings-language">
143
+ {locales.map((l) => {
144
+ const on = l.code === locale; // 🎯
145
+ return (
146
+ <button key={l.code} type="button" role="radio" aria-checked={on} tabIndex={on ? 0 : -1} lang={l.code} className={kit.row} data-value={l.code}
147
+ onClick={() => onLocaleChange(l.code)} onKeyDown={(e) => radioKeys(e, codes, locale, onLocaleChange, langs.current)}>
148
+ {l.label}{on && <Check />}
149
+ </button>
150
+ );
151
+ })}
152
+ </div>
153
+ {children}
154
+ </AbDrawer>
155
+ );
156
+ };
157
+
158
+ // πŸ“¦ exports
159
+ export default AbSettingsDrawer;
160
+ export { AbSettingsDrawer };
@@ -32,7 +32,7 @@
32
32
  * Example usage:
33
33
  * <AbSidebar
34
34
  * activeHref="/docs/components"
35
- * sections={[{ id: 'docs', label: 'Docs', items: [{ href: '/docs/components', icon: 'widgets', label: 'Components' }] }]}
35
+ * sections={[{ id: 'gs', label: 'Getting started', items: [{ href: '/introduction', icon: 'description', label: 'Introduction' }] }]}
36
36
  * />
37
37
  */
38
38
 
@@ -66,6 +66,7 @@ export interface AbSidebarProps extends AbSidebarBaseProps {
66
66
  defaultCollapsed?: boolean; // πŸšͺ uncontrolled start
67
67
  onCollapsedChange?: (collapsed: boolean) => void; // πŸ””
68
68
  collapsible?: boolean; // πŸ”˜ show the collapse button (default true when sections are given)
69
+ collapseButtonVariant?: 'plain' | 'outlined'; // βͺ 0.1.14 (P9): 'outlined' = 32Γ—32 bordered `<<` / `>>` (default 'plain' chevron)
69
70
  }
70
71
 
71
72
  /**
@@ -73,7 +74,8 @@ export interface AbSidebarProps extends AbSidebarBaseProps {
73
74
  * tooltips, and a collapse button (aria-expanded + aria-controls; hidden when JS is off).
74
75
  */
75
76
  const AbSidebar = (props: AbSidebarProps): ReactElement => {
76
- const { collapsed: controlled, defaultCollapsed = false, onCollapsedChange, collapsible, activeHref, page, labels, id = 'ab-sidebar-list' } = props;
77
+ const { collapsed: controlled, defaultCollapsed = false, onCollapsedChange, collapsible, collapseButtonVariant = 'plain', activeHref, page, labels, id = 'ab-sidebar-list' } = props;
78
+ const outlined = collapseButtonVariant === 'outlined'; // βͺ P9
77
79
  // 🧭 route
78
80
  const appLocales = useAbLocales(); // 🌍 from AbLinkProvider
79
81
  const pathname = stripAbLocalePrefix(usePathname() ?? '', props.locales ?? appLocales); // 🧭 `/fr/docs` β†’ `/docs`
@@ -94,12 +96,13 @@ const AbSidebar = (props: AbSidebarProps): ReactElement => {
94
96
  type="button"
95
97
  className={styles.abSidebarToggle} // πŸ™ˆ hidden under (scripting: none)
96
98
  data-ab-part="collapse"
99
+ data-variant={outlined ? 'outlined' : undefined} // βͺ P9
97
100
  aria-expanded={!collapsed} // β™Ώ
98
101
  aria-controls={id} // β™Ώ
99
102
  aria-label={toggleLabel} // 🏷️
100
103
  onClick={() => setCollapsed(!collapsed)}
101
104
  >
102
- <AbIcon name={collapsed ? 'chevron_right' : 'chevron_left'} size={20} />
105
+ <AbIcon name={outlined ? (collapsed ? 'keyboard_double_arrow_right' : 'keyboard_double_arrow_left') : collapsed ? 'chevron_right' : 'chevron_left'} size={outlined ? 18 : 20} />
103
106
  </button>
104
107
  ) : undefined;
105
108
 
@@ -76,10 +76,10 @@
76
76
  color: inherit; /* πŸ–‹οΈ */
77
77
  cursor: pointer; /* πŸ‘† */
78
78
  }
79
- .abSidebarToggle:hover { background: color-mix(in srgb, currentColor 8%, transparent); } /* πŸ–±οΈ */
79
+ .abSidebarToggle:hover { background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); } /* πŸ–±οΈ */
80
80
  .abSidebarToggle:focus-visible,
81
81
  .abSidebarLink:focus-visible {
82
- outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* β™Ώ */
82
+ outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); /* β™Ώ */
83
83
  outline-offset: var(--ab-focus-ring-offset, 2px); /* β™Ώ */
84
84
  }
85
85
  @media (scripting: none) {
@@ -125,10 +125,10 @@
125
125
  }
126
126
  .abSidebarLabel { min-width: 0; overflow-wrap: anywhere; } /* 🚫 no overflow, ReactNode-friendly */
127
127
  .abSidebarLink[data-depth='1'] { padding-inline-start: 44px; font-size: 14px; } /* 🌳 */
128
- .abSidebarLink:hover { background: color-mix(in srgb, currentColor 8%, transparent); } /* πŸ–±οΈ */
128
+ .abSidebarLink:hover { background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); } /* πŸ–±οΈ */
129
129
  .abSidebarLink[data-active='true'] {
130
- background: var(--ab-color-secondary-container, color-mix(in srgb, #8f4c38 14%, transparent)); /* 🎯 */
131
- color: var(--ab-color-on-secondary-container, inherit); /* πŸ–‹οΈ */
130
+ background: var(--ab-color-tint, var(--ab-color-secondary-container, color-mix(in srgb, #8f4c38 14%, transparent))); /* 🎯 */
131
+ color: var(--ab-color-accent-text, var(--ab-color-on-secondary-container, inherit)); /* πŸ–‹οΈ */
132
132
  font-weight: 600; /* πŸ”€ */
133
133
  }
134
134
  .abSidebarIcon { flex: none; } /* πŸ”£ */
@@ -144,3 +144,51 @@
144
144
  .abSidebar[data-collapsed='true'] .abSidebarLink { width: 48px; justify-content: center; padding: 0; }
145
145
  .abSidebar[data-collapsed='true'] .abSidebarLabel,
146
146
  .abSidebar[data-collapsed='true'] .abSidebarBadge { display: none; }
147
+
148
+ /* ===== 🏠 0.1.14 (P8/P9, Home spec §4 sidebar) ===== */
149
+ .abSidebar[data-density='compact'] { max-width: none; gap: 0; padding: 0; } /* πŸ“ the pane sets the width (248 / 260 / 288) */
150
+ .abSidebar[data-density='compact'] .abSidebarHeader { min-height: 0; padding: 12px 10px 6px 16px; } /* 🏷️ version switcher + collapse */
151
+ .abSidebar[data-density='compact'] .abSidebarSections { gap: 1px; padding: 4px 10px 16px; box-sizing: border-box; } /* πŸ“¦ mock nav: 1px between every row and label */
152
+ .abSidebar[data-density='compact'] .abSidebarSection { gap: 1px; }
153
+ .abSidebar[data-density='compact'] .abSidebarList { gap: 1px; }
154
+ .abSidebar[data-density='compact'] .abSidebarHeading {
155
+ padding: 14px 10px 6px; font-size: 11px; font-weight: 700; line-height: 15px; letter-spacing: 0.06em; /* πŸ”€ 35px label row, like the mock */
156
+ color: var(--ab-color-faint, #807062); opacity: 1; /* 🎨 AA faint */
157
+ }
158
+ .abSidebar[data-density='compact'] .abSidebarLink {
159
+ gap: 10px; min-height: 0; height: 32px; padding: 0 10px; box-sizing: border-box; /* πŸ“ */
160
+ font-family: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2; letter-spacing: 0; /* πŸ”€ Inter body */
161
+ color: var(--ab-color-muted, #6b5b50); /* πŸ–‹οΈ */
162
+ }
163
+ .abSidebar[data-density='compact'] .abSidebarLink[data-size='sm'] { height: 30px; } /* πŸ“¦ packages */
164
+ .abSidebar[data-density='compact'] .abSidebarLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; } /* βœ‚οΈ one line */
165
+ .abSidebar[data-density='compact'] .abSidebarIcon { color: var(--ab-color-faint, #807062); } /* πŸ”£ */
166
+ .abSidebar[data-density='compact'] .abSidebarLink:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } /* πŸ–±οΈ */
167
+ .abSidebar[data-active-shape='rounded'] .abSidebarLink { border-radius: var(--ab-radius-row, 8px); } /* πŸ”· */
168
+ .abSidebar[data-active-shape='rounded'] .abSidebarLink[data-active='true'] {
169
+ background: var(--ab-color-tint, #f4e7db); color: var(--ab-color-accent-text, #88603d); font-weight: 650; /* 🎯 */
170
+ }
171
+ .abSidebar[data-active-shape='rounded'] .abSidebarLink[data-active='true'] .abSidebarIcon { color: inherit; } /* πŸ”£ filled, accent */
172
+ .abSidebar[data-density='compact'] .abSidebarLink:focus-visible,
173
+ .abSidebar[data-density='compact'] .abSidebarToggle:focus-visible { outline-color: var(--ab-color-accent, #a67c52); outline-offset: -2px; } /* β™Ώ inside the pane */
174
+ .abSidebar[data-badge='text'] .abSidebarBadge {
175
+ padding: 0; border-radius: 0; background: none; line-height: 1; /* 🧹 no chip */
176
+ font: 500 10.5px var(--ab-font-code, 'Roboto Mono', ui-monospace, monospace); color: var(--ab-color-faint, #807062); /* ⌨️ */
177
+ }
178
+ /* β™Ώ James: faint on --tint is 3.9:1, so on the active row the text badge takes the row's --accent-text (β‰₯ 4.5:1 on tint) */
179
+ .abSidebar[data-badge='text'] .abSidebarLink[data-active='true'] .abSidebarBadge { color: inherit; }
180
+ /* βͺ P9: outlined collapse, 32Γ—32, radius 8, 1px --border, --card, --muted */
181
+ .abSidebarToggle[data-variant='outlined'] {
182
+ width: 32px; height: 32px; box-sizing: border-box; flex: none; /* πŸ“ */
183
+ border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-row, 8px); /* πŸ”² */
184
+ background: var(--ab-color-card, #fff); color: var(--ab-color-muted, #6b5b50); /* 🎨 */
185
+ }
186
+ .abSidebarToggle[data-variant='outlined']:hover { background: linear-gradient(var(--ab-color-hover, rgb(166 124 82 / 0.08)), var(--ab-color-hover, rgb(166 124 82 / 0.08))), var(--ab-color-card, #fff); } /* πŸ–±οΈ */
187
+ .abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarHeader { padding: 12px 0 6px; justify-content: center; } /* πŸšͺ rail */
188
+ .abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarSections { padding-inline: 8px; }
189
+ .abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarLink { width: 40px; height: 40px; } /* πŸ‘† */
190
+
191
+ /* 🏷️ 0.1.15 (God 00:08): the tablet logo row, mock 06 `.sb-logo` = 60px, 0 20px, centred, never shrinks.
192
+ * Height follows core's --ab-header-height (60px at tablet) so it lines up with the main bar. */
193
+ .abSidebarLogo { flex: none; display: flex; align-items: center; box-sizing: border-box; height: var(--ab-header-height, 60px); padding: 0 20px; }
194
+ .abSidebar[data-collapsed='true'] .abSidebarLogo { justify-content: center; padding: 0; } /* πŸšͺ rail: centred */
@@ -63,6 +63,7 @@ export interface AbSidebarSection {
63
63
  id: string; // πŸ†”
64
64
  label?: string; // 🏷️ heading (omit for an unlabelled group)
65
65
  items: AbSidebarItem[]; // πŸ”—
66
+ itemSize?: 'md' | 'sm'; // πŸ“ 0.1.14 (P8): 'sm' = 30px rows + 16px icons (the Home PACKAGES group)
66
67
  }
67
68
 
68
69
  /** πŸ•°οΈ Legacy (≀ 0.1.12) link shape; still accepted via `links`. */
@@ -93,6 +94,13 @@ export interface AbSidebarBaseProps {
93
94
  header?: ReactNode; // 🏷️ top slot (brand, workspace switcher…)
94
95
  labels?: AbSidebarLabels; // 🌍
95
96
  locales?: readonly string[]; // 🌍 0.1.13: stripped from the pathname (default: AbLinkProvider's)
97
+ // 🏠 0.1.14 (P8, Home spec §4 sidebar)
98
+ density?: 'comfortable' | 'compact'; // πŸ“ 'compact' = 32px rows, 13.5/500, 18px icons, 11px group labels
99
+ activeShape?: 'pill' | 'rounded'; // πŸ”· 'rounded' = 8px-radius --tint row (default 'pill')
100
+ badgeVariant?: 'chip' | 'text'; // 🏷️ 'text' = plain mono 10.5 --faint meta (e.g. a version), no chip
101
+ // 🏷️ 0.1.15 (God 00:08): a 60px logo row above `header` (mock 06 `.sb-logo`). With core β‰₯ 0.2.1 panes it only shows
102
+ // where the app header is hidden (tabletHeader="main" at 768–1179); elsewhere it always shows
103
+ logo?: ReactNode;
96
104
  // πŸ•°οΈ legacy API (≀ 0.1.12)
97
105
  type?: 'customer' | 'admin';
98
106
  page?: string;
@@ -121,13 +129,14 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
121
129
  active: (href: string, legacyValue?: string) => boolean;
122
130
  toggle?: ReactNode;
123
131
  }): ReactElement {
124
- const { className, id = 'ab-sidebar-list', sections, collapsed = false, header, labels, type = 'customer', links, brandHref = '/', brandLabel = 'abElements' } = props;
132
+ const { className, id = 'ab-sidebar-list', sections, collapsed = false, header, labels, type = 'customer', links, brandHref = '/', brandLabel = 'abElements', density = 'comfortable', activeShape = 'pill', badgeVariant = 'chip' } = props;
133
+ const compact = density === 'compact'; // πŸ“ P8
125
134
  const groups = toAbSidebarSections(sections, links); // πŸ—‚οΈ
126
135
  // πŸ•°οΈ legacy value lookup (page === link.value)
127
136
  const valueOf = (href: string) => links?.find((l) => l.href === href)?.value;
128
137
 
129
138
  // πŸ”— one item (+ children)
130
- const renderItem = (item: AbSidebarItem, depth: number): ReactElement => {
139
+ const renderItem = (item: AbSidebarItem, depth: number, small = false): ReactElement => {
131
140
  const on = active(item.href, valueOf(item.href)); // 🎯
132
141
  const text = item.labelText ?? (typeof item.label === 'string' ? item.label : undefined); // β™Ώ plain name
133
142
  const link = (
@@ -137,10 +146,11 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
137
146
  data-ab-part="item"
138
147
  data-active={on ? 'true' : 'false'}
139
148
  data-depth={depth}
149
+ data-size={small ? 'sm' : undefined} // πŸ“ P8
140
150
  aria-current={on ? 'page' : undefined} // β™Ώ
141
151
  aria-label={collapsed ? text : undefined} // β™Ώ rail: the label is visually hidden
142
152
  >
143
- {item.icon && <Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={20} className={styles.abSidebarIcon} />}
153
+ {item.icon && <Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={compact ? (small ? 16 : 18) : 20} className={styles.abSidebarIcon} />}
144
154
  <span className={styles.abSidebarLabel}>{item.label}</span>
145
155
  {item.badge != null && <span className={styles.abSidebarBadge} data-ab-part="badge">{item.badge}</span>}
146
156
  </Link>
@@ -162,8 +172,12 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
162
172
  data-ab-part={collapsed ? 'rail' : 'sidebar'} // 🧩
163
173
  data-collapsed={collapsed ? 'true' : 'false'} // πŸšͺ
164
174
  className={clsx('AbSidebar', styles.abSidebar, className)} // 🏷️
175
+ data-density={compact ? 'compact' : undefined} // πŸ“ P8
176
+ data-active-shape={activeShape === 'rounded' ? 'rounded' : undefined} // πŸ”· P8
177
+ data-badge={badgeVariant === 'text' ? 'text' : undefined} // 🏷️ P8
165
178
  aria-label={labels?.nav ?? 'Sidebar'} // β™Ώ
166
179
  >
180
+ {props.logo != null && <div className={styles.abSidebarLogo} data-ab-part="sidebar-logo">{props.logo}</div> /* 🏷️ 0.1.15 */}
167
181
  {/* 🏷️ header slot, or the legacy brand link */}
168
182
  <div className={styles.abSidebarHeader}>
169
183
  {header ?? (links?.length && !sections?.length ? <Link href={brandHref} className={styles.abSidebarBrand}>{brandLabel}</Link> : null)}
@@ -173,7 +187,7 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
173
187
  {groups.map((g) => (
174
188
  <section key={g.id} className={styles.abSidebarSection} data-ab-part="section" aria-labelledby={g.label ? `${id}-${g.id}` : undefined}>
175
189
  {g.label && <h2 id={`${id}-${g.id}`} className={styles.abSidebarHeading}>{g.label}</h2>}
176
- <ul className={styles.abSidebarList}>{g.items.map((it) => renderItem(it, 0))}</ul>
190
+ <ul className={styles.abSidebarList}>{g.items.map((it) => renderItem(it, 0, g.itemSize === 'sm'))}</ul>
177
191
  </section>
178
192
  ))}
179
193
  </div>
@@ -64,6 +64,9 @@ export interface AbThemeToggleLabels {
64
64
  light: string; // 🌞 "Light"
65
65
  dark: string; // πŸŒ™ "Dark"
66
66
  system: string; // πŸ–₯️ "System"
67
+ // 🎯 0.1.14 (John): action names for the icon button when it shows the target mode,
68
+ // e.g. { dark: 'Switch to dark theme', light: 'Switch to light theme' }. Falls back to "Theme: Dark"
69
+ switchTo?: Partial<Record<AbThemeMode, string>>;
67
70
  }
68
71
 
69
72
  // βš™οΈ props
@@ -76,6 +79,10 @@ export interface AbThemeToggleProps {
76
79
  defaultMode?: AbThemeMode; // 🌱 before hydration (default 'light')
77
80
  icons?: Partial<Record<AbThemeMode, ReactNode>>; // πŸ–ΌοΈ override glyphs
78
81
  size?: 'sm' | 'md'; // πŸ“ sm = 32px, md = 40px segments (hit area β‰₯ 24px either way)
82
+ appearance?: 'fill' | 'thumb'; // πŸŒ— 0.1.14 (P7): 'thumb' = the Home pill (28px segments, raised card thumb, filled active glyph). Default 'fill'
83
+ // 🎯 0.1.14 (John): icon variant only. 'target' = glyph + name of the mode a click switches TO
84
+ // (moon in light, sun in dark, like the Home mock). Default 'target' with appearance="thumb", else 'current' (unchanged)
85
+ iconShows?: 'current' | 'target';
79
86
  className?: string; // 🏷️
80
87
  style?: CSSProperties; // 🎨
81
88
  }
@@ -100,7 +107,8 @@ export function getNextAbThemeMode(modes: readonly AbThemeMode[], current: AbThe
100
107
 
101
108
  export function AbThemeToggle(props: AbThemeToggleProps) {
102
109
  // 🧩 props
103
- const { labels, variant = 'segmented', modes = AB_THEME_MODES, value, onChange, defaultMode = 'light', icons, size = 'md', className, style } = props;
110
+ const { labels, variant = 'segmented', modes = AB_THEME_MODES, value, onChange, defaultMode = 'light', icons, size = 'md', appearance = 'fill', iconShows, className, style } = props;
111
+ const thumb = appearance === 'thumb'; // πŸŒ— P7
104
112
  // πŸŒ— engine: persists + applies to <html>
105
113
  const engine = useAbThemeMode(defaultMode);
106
114
  // πŸŽ›οΈ controlled or engine-driven
@@ -115,11 +123,15 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
115
123
  };
116
124
 
117
125
  // πŸ–ΌοΈ glyph for a mode (decorative: the label names it)
118
- const glyph = (mode: AbThemeMode) => icons?.[mode] ?? <AbIcon name={DEFAULT_ICON_NAMES[mode]} size={20} />;
126
+ // P7 thumb: 17px (segments) / 22px (mobile icon), filled while active (spec Β§2 icons)
127
+ const glyph = (mode: AbThemeMode, active = false) =>
128
+ icons?.[mode] ?? <AbIcon name={DEFAULT_ICON_NAMES[mode]} size={thumb ? (variant === 'icon' ? 22 : 17) : 20} variant={thumb && active ? 'filled' : undefined} />;
119
129
 
120
130
  // πŸ”˜ single cycling button variant
121
131
  if (variant === 'icon') {
122
132
  const next = modes[(Math.max(0, modes.indexOf(current)) + 1) % modes.length]; // ⏭️
133
+ const target = (iconShows ?? (thumb ? 'target' : 'current')) === 'target'; // 🎯 John: Home mock shows the target
134
+ const name = target ? (labels.switchTo?.[next] ?? `${labels.group}: ${labels[next]}`) : `${labels.group}: ${labels[current]}`; // β™Ώ
123
135
  return (
124
136
  <button
125
137
  type="button" // 🧾
@@ -128,11 +140,13 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
128
140
  data-ab-part="theme-toggle" // πŸ—‚οΈ
129
141
  data-mode={current} // 🎚️
130
142
  data-size={size} // πŸ“
131
- aria-label={`${labels.group}: ${labels[current]}`} // β™Ώ "Theme: Dark"
132
- title={`${labels.group}: ${labels[current]}`} // πŸ’¬
143
+ data-appearance={thumb ? 'thumb' : undefined} // πŸŒ— P7
144
+ data-shows={target ? 'target' : 'current'} // 🎯
145
+ aria-label={name} // β™Ώ "Switch to dark theme" (target) / "Theme: Dark" (current)
146
+ title={name} // πŸ’¬
133
147
  onClick={() => select(next)} // πŸ”
134
148
  >
135
- <span aria-hidden="true">{glyph(current)}</span>
149
+ <span aria-hidden="true">{glyph(target ? next : current)}</span>
136
150
  </button>
137
151
  );
138
152
  }
@@ -157,6 +171,7 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
157
171
  data-ab-part="theme-toggle" // πŸ—‚οΈ
158
172
  data-mode={current} // 🎚️
159
173
  data-size={size} // πŸ“
174
+ data-appearance={thumb ? 'thumb' : undefined} // πŸŒ— P7
160
175
  onKeyDown={onKeyDown} // ⌨️
161
176
  >
162
177
  {modes.map((mode, i) => {
@@ -176,7 +191,7 @@ export function AbThemeToggle(props: AbThemeToggleProps) {
176
191
  data-mode={mode} // 🎚️
177
192
  onClick={() => select(mode)} // πŸ–±οΈ
178
193
  >
179
- <span aria-hidden="true">{glyph(mode)}</span>
194
+ <span aria-hidden="true">{glyph(mode, checked)}</span>
180
195
  </button>
181
196
  );
182
197
  })}
@@ -42,7 +42,7 @@
42
42
  gap: 2px; /* 🧱 */
43
43
  padding: 3px; /* 🧱 */
44
44
  border-radius: 9999px; /* πŸ’Š */
45
- border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* πŸ–ŠοΈ */
45
+ border: 1px solid var(--ab-color-border, var(--ab-color-outline-variant, rgb(0 0 0 / 0.12))); /* πŸ–ŠοΈ */
46
46
  background: var(--ab-color-surface-container, transparent); /* 🎨 */
47
47
  }
48
48
 
@@ -76,14 +76,29 @@
76
76
  /* πŸ–±οΈ hover (unselected only) */
77
77
  .segment[aria-checked='false']:hover,
78
78
  .icon:hover {
79
- background: color-mix(in srgb, currentColor 10%, transparent); /* 🌫️ */
79
+ background: var(--ab-color-hover, color-mix(in srgb, currentColor 10%, transparent)); /* 🌫️ */
80
80
  }
81
81
 
82
82
  /* β™Ώ visible focus ring (theme token, G18) */
83
83
  .segment:focus-visible,
84
84
  .icon:focus-visible {
85
- outline: 2px solid var(--ab-focus-ring, var(--ab-color-primary, #A67C52)); /* πŸ’ */
85
+ outline: 2px solid var(--ab-color-accent, var(--ab-focus-ring, var(--ab-color-primary, #A67C52))); /* πŸ’ */
86
86
  outline-offset: 2px; /* ↔️ */
87
87
  }
88
88
 
89
89
  /* 🧘 reduced motion: handled by ab-nextjs-animations (.ab-motion-colors) */
90
+
91
+ /* ===== πŸŒ— 0.1.14 (P7, Home spec Β§4): appearance="thumb" ===== */
92
+ .group[data-appearance='thumb'] {
93
+ gap: 2px; padding: 3px; border-radius: var(--ab-radius-pill, 999px); /* πŸ’Š */
94
+ border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); background: var(--ab-color-card2, #fbf3ec); /* 🎨 */
95
+ }
96
+ .group[data-appearance='thumb'] .segment { width: 28px; height: 28px; color: var(--ab-color-faint, #807062); } /* πŸ“ β‰₯ 24px target */
97
+ .group[data-appearance='thumb'] .segment[aria-checked='true'] {
98
+ background: var(--ab-color-thumb, #fff); color: var(--ab-color-accent-text, #88603d); /* πŸŒ— dark thumb #3a2b1f (theme) */
99
+ box-shadow: var(--ab-shadow-thumb, 0 1px 3px rgb(33 26 22 / 0.12)); /* ✨ */
100
+ }
101
+ .group[data-appearance='thumb'] .segment[aria-checked='false']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } /* πŸ–±οΈ */
102
+ .group[data-appearance='thumb'] .segment:focus-visible, .icon[data-appearance='thumb']:focus-visible { outline-color: var(--ab-color-accent, #a67c52); } /* β™Ώ */
103
+ .icon[data-appearance='thumb'] { width: 40px; height: 40px; border-radius: var(--ab-radius-button, 10px); color: var(--ab-color-muted, #6b5b50); } /* πŸ“± mobile 40Γ—40, 22px glyph */
104
+ .icon[data-appearance='thumb']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
package/ab-toc/index.tsx CHANGED
@@ -45,7 +45,7 @@
45
45
  */
46
46
 
47
47
  // βš›οΈ React
48
- import type { ReactElement } from 'react';
48
+ import type { ReactElement, ReactNode } from 'react';
49
49
  // 🧡 classes
50
50
  import clsx from 'clsx';
51
51
  // 🎨 styles
@@ -84,6 +84,7 @@ export interface AbTocProps {
84
84
  onNavigate?: (id: string) => void; // πŸ”” e.g. scrollToAbSection(id, { container }) (hooks 0.1.7); without it a plain #id jump, which scrolls the nearest scroller (the main pane in core 0.1.6 panes)
85
85
  id?: string; // πŸ†” root id (default "ab-toc"); the title gets `${id}-title`
86
86
  className?: string; // 🏷️
87
+ footer?: ReactNode; // 🧩 0.1.14 (P14): below the list after a 1px rule (Edit this page · Changelog · a promo card); links get the 12.5px Home style
87
88
  }
88
89
 
89
90
  /**
@@ -91,7 +92,7 @@ export interface AbTocProps {
91
92
  * aria-current="location". Pair with `useAbScrollSpy` from ab-nextjs-hooks 0.1.7 for `activeId`.
92
93
  * No hooks here, so it also renders on the server.
93
94
  */
94
- const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavigate, id = 'ab-toc', className }: AbTocProps): ReactElement | null => {
95
+ const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavigate, id = 'ab-toc', className, footer }: AbTocProps): ReactElement | null => {
95
96
  if (!items.length) return null; // πŸ™ˆ nothing to list
96
97
  const headingId = `${id}-title`; // πŸ†”
97
98
  return (
@@ -115,6 +116,12 @@ const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavi
115
116
  );
116
117
  })}
117
118
  </ol>
119
+ {footer != null && (
120
+ <>
121
+ <hr className={styles.abTocSep} />{/* βž– mock .toc-sep */}
122
+ <div className={styles.abTocFooter} data-ab-part="toc-footer">{footer}</div>
123
+ </>
124
+ )}
118
125
  </nav>
119
126
  );
120
127
  };
@@ -36,19 +36,31 @@
36
36
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
37
  */
38
38
 
39
- .abToc { font-size: 14px; } /* πŸ“‘ */
40
- .abTocTitle { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.75; } /* 🏷️ */
41
- .abTocList { list-style: none; margin: 0; padding: 0; border-inline-start: var(--ab-divider-hairline, 1px solid rgb(0 0 0 / 0.12)); } /* βž– */
39
+ /* πŸ“‘ 0.1.14 (P14 + token move): the Home TOC (spec Β§4), on the theme 0.3.5 tokens, M3 fallbacks kept */
40
+ .abToc { font-size: 13px; } /* πŸ“‘ */
41
+ .abTocTitle { margin: 0 0 10px; font-size: 11px; font-weight: 700; line-height: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ab-color-faint, var(--ab-color-on-surface-variant, inherit)); } /* 🏷️ "ON THIS PAGE" */
42
+ .abTocList { list-style: none; margin: 0; padding: 0; border-inline-start: 1px solid var(--ab-color-div, rgb(0 0 0 / 0.12)); } /* βž– rail */
42
43
  .abTocList > li[data-level='3'] { padding-inline-start: 12px; } /* πŸ“ */
43
44
  .abTocList > li[data-level='4'] { padding-inline-start: 24px; } /* πŸ“ */
44
45
  .abTocLink {
45
46
  display: block; /* πŸ“ */
46
47
  margin-inline-start: -1px; /* βž– sit on the rail */
47
- padding: 4px 12px; /* πŸ“¦ */
48
+ padding: 6px 0 6px 14px; /* πŸ“¦ mock */
49
+ line-height: 18px; /* πŸ“ 30px rows (WebKit-measured against the mock) */
48
50
  border-inline-start: 2px solid transparent; /* βž– */
49
- color: var(--ab-color-on-surface-variant, inherit); /* πŸ–‹οΈ */
51
+ color: var(--ab-color-muted, var(--ab-color-on-surface-variant, inherit)); /* πŸ–‹οΈ */
50
52
  text-decoration: none; /* 🚫 */
51
53
  }
52
- .abTocLink:hover { color: var(--ab-color-on-surface, inherit); } /* πŸ–±οΈ */
53
- .abTocLink[data-active='true'] { border-inline-start-color: var(--ab-color-primary, currentColor); color: var(--ab-color-primary, inherit); font-weight: 600; } /* 🎯 */
54
- .abTocLink:focus-visible { outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); outline-offset: var(--ab-focus-ring-offset, 2px); } /* β™Ώ */
54
+ .abTocLink:hover { color: var(--ab-color-text, var(--ab-color-on-surface, inherit)); } /* πŸ–±οΈ */
55
+ .abTocLink[data-active='true'] { border-inline-start-color: var(--ab-color-accent, var(--ab-color-primary, currentColor)); color: var(--ab-color-accent-text, var(--ab-color-primary, inherit)); font-weight: 650; } /* 🎯 */
56
+ .abTocLink:focus-visible { outline: 2px solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); outline-offset: -2px; } /* β™Ώ */
57
+ /* 🧩 P14 footer */
58
+ .abTocSep { height: 1px; margin: 18px 0 12px; border: 0; background: var(--ab-color-div, rgb(0 0 0 / 0.12)); } /* βž– */
59
+ .abTocFooter > a, .abTocFooter > p > a, .abTocFooter > ul > li > a {
60
+ display: flex; align-items: center; gap: 8px; padding: 5px 0; /* πŸ“ */
61
+ font-size: 12.5px; line-height: 17px; color: var(--ab-color-muted, inherit); text-decoration: none; /* πŸ”€ 27px rows */
62
+ }
63
+ .abTocFooter a:hover { color: var(--ab-color-accent-text, inherit); } /* πŸ–±οΈ */
64
+ .abTocFooter a:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; border-radius: 4px; } /* β™Ώ */
65
+ .abTocFooter a svg { flex: none; width: 15px; height: 15px; color: var(--ab-color-faint, inherit); } /* πŸ”£ GitHub Β· north_east */
66
+ .abTocFooter > ul { list-style: none; margin: 0; padding: 0; }