ab-nextjs-components 0.3.1 → 0.3.3
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/ab-drawer/kit.module.css +3 -1
- package/ab-icon/builtin.ts +3 -1
- package/ab-mobile-header/index.tsx +13 -6
- package/ab-navbar/styles.module.css +3 -0
- package/ab-search-trigger/styles.module.css +5 -1
- package/ab-theme-mode/index.tsx +8 -0
- package/ab-theme-toggle/index.tsx +9 -6
- package/ab-theme-toggle/styles.module.css +25 -1
- package/ab-toc/promo.tsx +17 -7
- package/index.ts +1 -1
- package/package.json +3 -3
- package/types/index.d.ts +1 -1
package/ab-drawer/kit.module.css
CHANGED
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
|
|
119
119
|
/* ⬅️ the nav drawer: logo header, the version chip, a scrolling nav (44px rows, 15px) with a 72px fade, a pinned footer */
|
|
120
120
|
.logoRow { display: flex; align-items: center; min-inline-size: 0; }
|
|
121
|
-
.logoRow a { display: flex; align-items: center; color: inherit; }
|
|
121
|
+
.logoRow a { display: flex; align-items: center; color: inherit; min-block-size: 44px; } /* 👆 0.3.2 (God, 0.2.23 gaps): the logo link is a 44px-tall tap target (was 25px); the glyph keeps its size */
|
|
122
122
|
.ver { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; block-size: 32px; padding: 0 8px 0 10px; margin: 0 0 8px 8px; box-sizing: border-box; border-radius: 8px; border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); background: var(--ab-dr-card); color: var(--ab-color-muted, #6b5b50); font: 500 13px/1 var(--ab-font-body, 'Inter', inherit); }
|
|
123
123
|
.ver b { font-family: var(--ab-font-mono, 'Roboto Mono', monospace); color: var(--ab-color-accent-text, #8b6340); font-weight: 600; }
|
|
124
124
|
.ver > svg { inline-size: 18px; block-size: 18px; }
|
|
@@ -197,6 +197,8 @@
|
|
|
197
197
|
buttons keep their hit area and the end inset stays 4px so the last one lines up with the 44px grid */
|
|
198
198
|
/* 🧩 0.2.3 no-JS language list: <details> around the globe; the list drops below it, end-aligned */
|
|
199
199
|
.langDetails { position: relative; flex: none; } /* 📌 anchor */
|
|
200
|
+
/* 🔎 0.3.2 (Joseph): AbMobileHeader `search` slot, before the theme button; never shrinks, 4px from its neighbours */
|
|
201
|
+
.mhSearch { flex: none; display: inline-flex; align-items: center; margin-inline: 4px; } /* 📐 */
|
|
200
202
|
.langDetails > summary { list-style: none; } /* 🙈 no disclosure triangle */
|
|
201
203
|
.langDetails > summary::-webkit-details-marker { display: none; } /* 🙈 Safari */
|
|
202
204
|
.langList { position: absolute; inset-inline-end: 0; inset-block-start: 100%; z-index: 30; margin: 4px 0 0; padding: 6px; min-inline-size: 180px; list-style: none; background: var(--ab-color-card, #fff); border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: 12px; box-shadow: 0 8px 24px rgb(25 18 12 / 0.12); } /* 📋 */
|
package/ab-icon/builtin.ts
CHANGED
|
@@ -42,6 +42,7 @@ import arrowForward from 'ab-nextjs-icons/ab-icons/icons/arrow_forward'; // ⏭
|
|
|
42
42
|
import lightMode from 'ab-nextjs-icons/ab-icons/icons/light_mode'; // 🌞 AbThemeToggle
|
|
43
43
|
import darkMode from 'ab-nextjs-icons/ab-icons/icons/dark_mode'; // 🌙 AbThemeToggle
|
|
44
44
|
import computer from 'ab-nextjs-icons/ab-icons/icons/computer'; // 🖥️ AbThemeToggle (system)
|
|
45
|
+
import brightnessAuto from 'ab-nextjs-icons/ab-icons/icons/brightness_auto'; // 🌗🅰️ 0.3.2: system theme (AbThemeToggle, AbMobileHeader, AbSettingsDrawer; icons ≥ 0.2.7)
|
|
45
46
|
import language from 'ab-nextjs-icons/ab-icons/icons/language'; // 🌐 AbLocaleSwitcher
|
|
46
47
|
import contentCopy from 'ab-nextjs-icons/ab-icons/icons/content_copy'; // 📋 AbInstallSnippet
|
|
47
48
|
import check from 'ab-nextjs-icons/ab-icons/icons/check'; // ✅ AbInstallSnippet (copied)
|
|
@@ -63,7 +64,8 @@ export const AB_ICON_BUILTINS: Record<string, AbIconSvgData> = {
|
|
|
63
64
|
arrow_forward: arrowForward, // ⏭️
|
|
64
65
|
light_mode: lightMode, // 🌞
|
|
65
66
|
dark_mode: darkMode, // 🌙
|
|
66
|
-
computer, // 🖥️
|
|
67
|
+
computer, // 🖥️ (kept for apps that still ask for it)
|
|
68
|
+
brightness_auto: brightnessAuto, // 🌗🅰️ 0.3.2: the system theme glyph
|
|
67
69
|
language, // 🌐
|
|
68
70
|
content_copy: contentCopy, // 📋
|
|
69
71
|
check, // ✅
|
|
@@ -59,14 +59,14 @@ import AbIcon from '../ab-icon';
|
|
|
59
59
|
// 🎨 the drawers v2 kit
|
|
60
60
|
import kit from '../ab-drawer/kit.module.css';
|
|
61
61
|
// 🌗 0.2.3: the shared theme state (AbThemeModeProvider)
|
|
62
|
-
import { useAbThemeModeContext } from '../ab-theme-mode';
|
|
62
|
+
import { useAbThemeModeContext, AB_THEME_MODE_ICONS, AB_THEME_ICON_BUTTON_GLYPH } from '../ab-theme-mode';
|
|
63
63
|
|
|
64
64
|
/** 🌗 0.2.3: the three theme modes (same names as ab-nextjs-hooks' AbThemeMode) */
|
|
65
65
|
export type AbMobileHeaderThemeMode = 'light' | 'dark' | 'system';
|
|
66
66
|
/** 🔁 0.2.3: the 3-state cycle order */
|
|
67
67
|
export const AB_MOBILE_HEADER_THEME_CYCLE: readonly AbMobileHeaderThemeMode[] = ['light', 'dark', 'system'];
|
|
68
|
-
// 🔣 the glyph of each mode
|
|
69
|
-
const THEME_ICON: Record<AbMobileHeaderThemeMode, string
|
|
68
|
+
// 🔣 the glyph of each mode: 0.3.2 the shared map, the same one AbThemeToggle uses
|
|
69
|
+
const THEME_ICON: Readonly<Record<AbMobileHeaderThemeMode, string>> = AB_THEME_MODE_ICONS;
|
|
70
70
|
|
|
71
71
|
/** 🌍 0.2.3: one entry of the no-JS language list */
|
|
72
72
|
export interface AbMobileHeaderLanguage {
|
|
@@ -87,6 +87,9 @@ export interface AbMobileHeaderProps {
|
|
|
87
87
|
theme?: 'light' | 'dark'; // 🌗 the resolved theme now
|
|
88
88
|
onThemeChange?: (next: 'light' | 'dark') => void; // 🌗 the toggle (it shows the mode it switches TO: a moon in light)
|
|
89
89
|
actions?: ReactNode; // ➕ more 44px buttons after the two (none in John's frame)
|
|
90
|
+
// 🔎 0.3.2 (Joseph, 0.2.23 gaps): a search pill (e.g. <AbSearchTrigger size="sm" />) placed after the globe and
|
|
91
|
+
// BEFORE the theme button
|
|
92
|
+
search?: ReactNode;
|
|
90
93
|
labels?: { language?: string; toDark?: string; toLight?: string; toSystem?: string; header?: string }; // 🌍 "Change language", "Switch to dark theme", "Switch to light theme", (0.2.3) "Use the system theme", "Main header"
|
|
91
94
|
languageExpanded?: boolean; // ♿ aria-expanded on the globe while its sheet is open
|
|
92
95
|
// 🌗 0.2.3: the 3-state theme (light → dark → system → light). When `onThemeModeChange` is set it replaces the
|
|
@@ -124,7 +127,7 @@ export interface AbMobileHeaderProps {
|
|
|
124
127
|
* no menu button (the left drawer opens with an edge swipe). Put it in AbMainLayout's `mainHeader` with core
|
|
125
128
|
* ≥ 0.2.1 `mobileHeader="main"`: the 56px row, its divider and the hidden app header come from core.
|
|
126
129
|
*/
|
|
127
|
-
const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, themeMode = 'system', onThemeModeChange, actions, row, labels = {}, languageExpanded, languageControls, languageRef, languageHref, languages, size = 'default', barAt = 'auto', className }: AbMobileHeaderProps): ReactElement => {
|
|
130
|
+
const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, themeMode = 'system', onThemeModeChange, actions, search, row, labels = {}, languageExpanded, languageControls, languageRef, languageHref, languages, size = 'default', barAt = 'auto', className }: AbMobileHeaderProps): ReactElement => {
|
|
128
131
|
const L = { language: 'Change language', toDark: 'Switch to dark theme', toLight: 'Switch to light theme', toSystem: 'Use the system theme', header: 'Main header', ...labels }; // 🌍
|
|
129
132
|
const name: Record<AbMobileHeaderThemeMode, string> = { light: L.toLight, dark: L.toDark, system: L.toSystem }; // ♿ "switch TO" names
|
|
130
133
|
// 🌗 0.2.3: under an AbThemeModeProvider with no theme props, the button is the 3-state cycle on the SHARED state
|
|
@@ -141,7 +144,7 @@ const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, them
|
|
|
141
144
|
? AB_MOBILE_HEADER_THEME_CYCLE[(Math.max(0, AB_MOBILE_HEADER_THEME_CYCLE.indexOf(mode3)) + 1) % AB_MOBILE_HEADER_THEME_CYCLE.length] // 🔁
|
|
142
145
|
: theme === 'dark' ? 'light' : 'dark'; // 🌗 the target
|
|
143
146
|
const showTheme = three || !!onThemeChange; // 👀
|
|
144
|
-
// 🧱 the 56px bar: logo · globe · theme · actions
|
|
147
|
+
// 🧱 the 56px bar: logo · globe · (0.3.2) search · theme · actions
|
|
145
148
|
const bar = (
|
|
146
149
|
<>
|
|
147
150
|
<span className={kit.logoRow}>{logo}</span>
|
|
@@ -199,6 +202,10 @@ const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, them
|
|
|
199
202
|
<AbIcon name="language" size={24} />
|
|
200
203
|
</button>
|
|
201
204
|
)}
|
|
205
|
+
{search != null && (
|
|
206
|
+
// 🔎 0.3.2: the search pill slot, right before the theme button
|
|
207
|
+
<span className={kit.mhSearch} data-ab-part="mobile-header-search">{search}</span>
|
|
208
|
+
)}
|
|
202
209
|
{showTheme && (
|
|
203
210
|
<button
|
|
204
211
|
type="button"
|
|
@@ -208,7 +215,7 @@ const AbMobileHeader = ({ logo, onLanguage, theme = 'light', onThemeChange, them
|
|
|
208
215
|
data-ab-part="mobile-header-theme"
|
|
209
216
|
data-theme-mode={three ? mode3 : undefined} // 🧪 0.2.3: the current mode (3-state only)
|
|
210
217
|
>
|
|
211
|
-
<AbIcon name={THEME_ICON[next]} size={
|
|
218
|
+
<AbIcon name={THEME_ICON[next]} size={AB_THEME_ICON_BUTTON_GLYPH} />
|
|
212
219
|
</button>
|
|
213
220
|
)}
|
|
214
221
|
{actions}
|
|
@@ -59,6 +59,9 @@
|
|
|
59
59
|
align-items: center; /* ↔️ */
|
|
60
60
|
gap: 4px; /* ↕️ */
|
|
61
61
|
min-width: 64px; /* 👆 */
|
|
62
|
+
min-height: 44px; /* 👆 0.3.2 (God, 0.2.23 gaps): a 44px tap target (WCAG 2.5.5), was ~42px with indicator="none" */
|
|
63
|
+
justify-content: center; /* 🎯 0.3.2: the pill + label stay centred in the taller target */
|
|
64
|
+
box-sizing: border-box; /* 📦 0.3.2: the 44px counts the padding */
|
|
62
65
|
border: 0; /* 🚫 (buttons) */
|
|
63
66
|
background: none; /* 🚫 */
|
|
64
67
|
font: inherit; /* 🔤 */
|
|
@@ -78,11 +78,15 @@
|
|
|
78
78
|
font-size: 13.5px; line-height: 1; box-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* 🔤 🌗 */
|
|
79
79
|
}
|
|
80
80
|
.abSearchTrigger[data-size='sm'] {
|
|
81
|
-
flex: none; width: auto; max-width: none; height: 34px; /* 📏 */
|
|
81
|
+
flex: none; width: auto; max-width: none; height: 34px; /* 📏 the pill still LOOKS 34px (mock) */
|
|
82
|
+
position: relative; /* 📌 0.3.2: anchors the invisible hit area below */
|
|
82
83
|
gap: 6px; padding: 0 6px 0 10px; /* 📦 */
|
|
83
84
|
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-pill, 999px); /* 💊 */
|
|
84
85
|
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); font-size: 13px; line-height: 1; /* 🎨 🔤 */
|
|
85
86
|
}
|
|
87
|
+
/* 👆 0.3.2 (God, 0.2.23 gaps): an invisible 44px-tall hit area around the 34px pill (0.3.3: 6px above + below), so the
|
|
88
|
+
tap target is ≥ 44px (WCAG 2.5.5) without changing the look */
|
|
89
|
+
.abSearchTrigger[data-size='sm']::after { content: ''; position: absolute; inset: -6px 0; } /* 🫥 hit area: 0.3.3 6px above + below → 46px, safely ≥ 44 */
|
|
86
90
|
.abSearchTrigger[data-variant='field']:hover, .abSearchTrigger[data-size='sm']:hover { border-color: color-mix(in srgb, var(--ab-color-accent, #a67c52) 40%, transparent); } /* 🖱️ */
|
|
87
91
|
.abSearchTrigger[data-variant='field']:focus-visible, .abSearchTrigger[data-size='sm']:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* ♿ */
|
|
88
92
|
/* ⌨️ the single key cap (mock `kbd`): 20px, radius 5, 2px bottom border, 11/600 --muted */
|
package/ab-theme-mode/index.tsx
CHANGED
|
@@ -79,4 +79,12 @@ export function useAbThemeModeContext(): AbThemeModeContextValue | null {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// 📦 exports
|
|
82
|
+
/**
|
|
83
|
+
* 🔣 0.3.2 (Joseph, 0.2.23 gaps): the ONE glyph per theme mode, shared by AbMobileHeader's theme button and
|
|
84
|
+
* AbThemeToggle, so the two never drift apart (AbIcons names)
|
|
85
|
+
*/
|
|
86
|
+
export const AB_THEME_MODE_ICONS: Readonly<Record<AbThemeMode, string>> = { light: 'light_mode', dark: 'dark_mode', system: 'brightness_auto' }; // 🌞 🌙 🌗🅰️ (0.3.2, God: brightness_auto everywhere, was 'computer')
|
|
87
|
+
/** 📏 0.3.2: the glyph size of a single theme icon button (AbMobileHeader + AbThemeToggle variant="icon") */
|
|
88
|
+
export const AB_THEME_ICON_BUTTON_GLYPH = 24; // 📐 px
|
|
89
|
+
|
|
82
90
|
export default AbThemeModeProvider;
|
|
@@ -53,7 +53,7 @@ import AbIcon from '../ab-icon';
|
|
|
53
53
|
// 🎨 styles
|
|
54
54
|
import styles from './styles.module.css';
|
|
55
55
|
// 🌗 0.2.3: the shared theme state (AbThemeModeProvider), when there is one
|
|
56
|
-
import { useAbThemeModeContext, type AbThemeModeContextValue } from '../ab-theme-mode';
|
|
56
|
+
import { useAbThemeModeContext, AB_THEME_MODE_ICONS, AB_THEME_ICON_BUTTON_GLYPH, type AbThemeModeContextValue } from '../ab-theme-mode';
|
|
57
57
|
import { AB_MOTION } from 'ab-nextjs-animations/motion'; // 🎬 transition class names (ab-nextjs-animations >= 0.2.4)
|
|
58
58
|
import 'ab-nextjs-animations/motion/styles.css'; // 🎨 .ab-motion-*
|
|
59
59
|
|
|
@@ -83,14 +83,15 @@ export interface AbThemeToggleProps {
|
|
|
83
83
|
size?: 'sm' | 'md'; // 📏 sm = 32px, md = 40px segments (hit area ≥ 24px either way)
|
|
84
84
|
appearance?: 'fill' | 'thumb'; // 🌗 0.1.14 (P7): 'thumb' = the Home pill (28px segments, raised card thumb, filled active glyph). Default 'fill'
|
|
85
85
|
// 🎯 0.1.14 (John): icon variant only. 'target' = glyph + name of the mode a click switches TO
|
|
86
|
-
// (moon in light, sun in dark, like the Home mock).
|
|
86
|
+
// (moon in light, sun in dark, like the Home mock). 0.3.2 (God): default 'target' for every appearance (was 'current' for fill)
|
|
87
87
|
iconShows?: 'current' | 'target';
|
|
88
88
|
className?: string; // 🏷️
|
|
89
89
|
style?: CSSProperties; // 🎨
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// 🔣 default glyphs (AbIcons names)
|
|
93
|
-
|
|
93
|
+
// 🔗 0.3.2 (Joseph): the shared map, so the glyphs match AbMobileHeader's theme button
|
|
94
|
+
const DEFAULT_ICON_NAMES: Readonly<Record<AbThemeMode, string>> = AB_THEME_MODE_ICONS;
|
|
94
95
|
|
|
95
96
|
/**
|
|
96
97
|
* @name getNextAbThemeMode
|
|
@@ -142,14 +143,16 @@ function AbThemeToggleView(props: AbThemeToggleProps & { engine: Pick<AbThemeMod
|
|
|
142
143
|
};
|
|
143
144
|
|
|
144
145
|
// 🖼️ glyph for a mode (decorative: the label names it)
|
|
145
|
-
// P7 thumb: 17px
|
|
146
|
+
// P7 thumb: 17px segments, filled while active (spec §2 icons)
|
|
147
|
+
// 0.3.2 (Joseph): variant="icon" uses the header's 24px glyph (was 22 thumb / 20), so it matches AbMobileHeader
|
|
148
|
+
const glyphSize = variant === 'icon' ? AB_THEME_ICON_BUTTON_GLYPH : thumb ? 17 : 20; // 📏
|
|
146
149
|
const glyph = (mode: AbThemeMode, active = false) =>
|
|
147
|
-
icons?.[mode] ?? <AbIcon name={DEFAULT_ICON_NAMES[mode]} size={
|
|
150
|
+
icons?.[mode] ?? <AbIcon name={DEFAULT_ICON_NAMES[mode]} size={glyphSize} variant={thumb && active ? 'filled' : undefined} />;
|
|
148
151
|
|
|
149
152
|
// 🔘 single cycling button variant
|
|
150
153
|
if (variant === 'icon') {
|
|
151
154
|
const next = modes[(Math.max(0, modes.indexOf(current)) + 1) % modes.length]; // ⏭️
|
|
152
|
-
const target = (iconShows ??
|
|
155
|
+
const target = (iconShows ?? 'target') === 'target'; // 🎯 0.3.2 (God): always the target by default, like AbMobileHeader (was 'current' for fill)
|
|
153
156
|
const name = target ? (labels.switchTo?.[next] ?? `${labels.group}: ${labels[next]}`) : `${labels.group}: ${labels[current]}`; // ♿
|
|
154
157
|
return (
|
|
155
158
|
<button
|
|
@@ -61,12 +61,36 @@
|
|
|
61
61
|
cursor: pointer; /* 👆 */
|
|
62
62
|
--ab-motion-duration: var(--ab-motion-duration-short, 160ms); /* 🎞️ colour fade = .ab-motion-colors (ab-nextjs-animations) */
|
|
63
63
|
}
|
|
64
|
+
/* 👆 0.3.2 (God, 0.2.23 gaps): the single icon button is a 44px tap target (was 40px), the same 44×44 as
|
|
65
|
+
AbMobileHeader's theme button; the segments keep 40/32px (radios inside one pill) */
|
|
66
|
+
.icon {
|
|
67
|
+
width: 44px; /* 📏 */
|
|
68
|
+
height: 44px; /* 📏 */
|
|
69
|
+
}
|
|
64
70
|
[data-size='sm'] .segment,
|
|
65
71
|
.icon[data-size='sm'] {
|
|
66
72
|
width: 32px; /* 📏 */
|
|
67
73
|
height: 32px; /* 📏 */
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
/* 👆 0.3.2 (God): every radio segment and the sm icon button get an invisible 44×44 hit area centred on them, so
|
|
77
|
+
the 40/32/28px visuals stay while the tap target is ≥ 44px (WCAG 2.5.5). Neighbouring areas overlap by a few px;
|
|
78
|
+
the later segment wins there, which is fine for adjacent radios */
|
|
79
|
+
.segment,
|
|
80
|
+
.icon {
|
|
81
|
+
position: relative; /* 📌 anchors the hit area */
|
|
82
|
+
}
|
|
83
|
+
.segment::after,
|
|
84
|
+
.icon[data-size='sm']::after {
|
|
85
|
+
content: ''; /* 🫥 invisible */
|
|
86
|
+
position: absolute; /* 📌 */
|
|
87
|
+
left: 50%; /* ↔️ centred */
|
|
88
|
+
top: 50%; /* ↕️ centred */
|
|
89
|
+
width: 44px; /* 👆 */
|
|
90
|
+
height: 44px; /* 👆 */
|
|
91
|
+
transform: translate(-50%, -50%); /* 🎯 */
|
|
92
|
+
}
|
|
93
|
+
|
|
70
94
|
/* ✅ selected */
|
|
71
95
|
.segment[aria-checked='true'] {
|
|
72
96
|
color: var(--ab-color-on-primary, #fff); /* 🎨 */
|
|
@@ -100,5 +124,5 @@
|
|
|
100
124
|
}
|
|
101
125
|
.group[data-appearance='thumb'] .segment[aria-checked='false']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } /* 🖱️ */
|
|
102
126
|
.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:
|
|
127
|
+
.icon[data-appearance='thumb'] { width: 44px; height: 44px; border-radius: var(--ab-radius-button, 10px); color: var(--ab-color-muted, #6b5b50); } /* 📱 0.3.2: 44×44 (was 40), 24px glyph like the header */
|
|
104
128
|
.icon[data-appearance='thumb']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
package/ab-toc/promo.tsx
CHANGED
|
@@ -54,6 +54,9 @@ export interface AbTocPromoProps {
|
|
|
54
54
|
children?: ReactNode; // 📝 the 11.5px muted subtitle (a `<code>` inside is 10.5px)
|
|
55
55
|
badge?: ReactNode; // 🆕 the small chip (default "New"; `null` = none)
|
|
56
56
|
href?: string; // 🔗 makes the title a link (the whole card clicks)
|
|
57
|
+
// ♿ 0.3.2 (God, 0.2.23 gaps): the card sits INSIDE the page aside, so by default its root is a plain <div> (no
|
|
58
|
+
// unnamed nested <aside> landmark). With `label` it becomes a NAMED <aside aria-label={label}> instead
|
|
59
|
+
label?: string;
|
|
57
60
|
className?: string; // 🏷️
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -61,13 +64,20 @@ export interface AbTocPromoProps {
|
|
|
61
64
|
* 🆕 AbTocPromo — the aside's "New" card (mock `.toc-card`): a rounded (12px), evenly padded (12px) container on
|
|
62
65
|
* the card colour with a 1px border; a small "New" chip, a smaller title and a relatively smaller subtitle.
|
|
63
66
|
*/
|
|
64
|
-
const AbTocPromo = ({ title, children, badge = 'New', href, className }: AbTocPromoProps): ReactElement =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const AbTocPromo = ({ title, children, badge = 'New', href, label, className }: AbTocPromoProps): ReactElement => {
|
|
68
|
+
const Root = label ? 'aside' : 'div'; // ♿ 0.3.2: a landmark only when it has a name
|
|
69
|
+
return (
|
|
70
|
+
<Root
|
|
71
|
+
className={clsx('AbTocPromo', styles.abTocPromo, className)} // 🎨
|
|
72
|
+
aria-label={label || undefined} // 🏷️ 0.3.2: names the <aside> (absent on the <div>)
|
|
73
|
+
data-ab-part="toc-promo" // 🗂️
|
|
74
|
+
>
|
|
75
|
+
{badge != null && <span className={styles.abTocPromoChip}>{badge}</span> /* 🆕 */}
|
|
76
|
+
<b className={styles.abTocPromoTitle}>{href ? <Link href={href} className={styles.abTocPromoLink}>{title}</Link> : title}</b> {/* 🏷️ */}
|
|
77
|
+
{children != null && <small className={styles.abTocPromoText}>{children}</small> /* 📝 */}
|
|
78
|
+
</Root>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
71
81
|
|
|
72
82
|
// 📦 exports
|
|
73
83
|
export default AbTocPromo;
|
package/index.ts
CHANGED
|
@@ -212,7 +212,7 @@ export { default as AbMobileHeader } from './ab-mobile-header/index.tsx'
|
|
|
212
212
|
export type { AbMobileHeaderProps, AbMobileHeaderThemeMode, AbMobileHeaderLanguage } from './ab-mobile-header/index.tsx'
|
|
213
213
|
export { AB_MOBILE_HEADER_THEME_CYCLE } from './ab-mobile-header/index.tsx' // 🌗 0.2.3
|
|
214
214
|
// 🌗 0.2.3 (Joseph, Welcome 0.2.21): one shared theme mode for every toggle
|
|
215
|
-
export { AbThemeModeProvider, useAbThemeModeContext } from './ab-theme-mode/index.tsx'
|
|
215
|
+
export { AbThemeModeProvider, useAbThemeModeContext, AB_THEME_MODE_ICONS, AB_THEME_ICON_BUTTON_GLYPH } from './ab-theme-mode/index.tsx' // 🔣 0.3.2: + the shared theme glyphs
|
|
216
216
|
export type { AbThemeModeProviderProps, AbThemeModeContextValue } from './ab-theme-mode/index.tsx'
|
|
217
217
|
// 🆕 0.2.0 drawers v2: AbSearchDrawer
|
|
218
218
|
export { default as AbSearchDrawer, addAbSearchRecent, highlightAbSearch, AB_SEARCH_RECENT_KEY } from './ab-search-drawer/index.tsx'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ab-nextjs-components",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "🚀 A lightweight collection of server & client React components created by Abraham Ukachi, and optimized for Next.js applications 😎.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"ab-nextjs-animations": "^0.2.5",
|
|
44
44
|
"ab-nextjs-hooks": "^0.1.7",
|
|
45
|
-
"ab-nextjs-icons": "^0.2.
|
|
45
|
+
"ab-nextjs-icons": "^0.2.7",
|
|
46
46
|
"ab-nextjs-theme": "^0.3.7",
|
|
47
47
|
"clsx": "^2",
|
|
48
48
|
"next": "^16.3.4",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@types/react": "^19",
|
|
56
56
|
"ab-nextjs-animations": "^0.2.5",
|
|
57
57
|
"ab-nextjs-hooks": "^0.1.7",
|
|
58
|
-
"ab-nextjs-icons": "^0.2.
|
|
58
|
+
"ab-nextjs-icons": "^0.2.7",
|
|
59
59
|
"ab-nextjs-theme": "^0.3.7",
|
|
60
60
|
"clsx": "^2.1.1",
|
|
61
61
|
"esbuild": "^0.28.2",
|
package/types/index.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ export { default as AbMobileHeader } from '../ab-mobile-header/index.tsx';
|
|
|
105
105
|
export type { AbMobileHeaderProps, AbMobileHeaderThemeMode, AbMobileHeaderLanguage } from '../ab-mobile-header/index.tsx';
|
|
106
106
|
export { AB_MOBILE_HEADER_THEME_CYCLE } from '../ab-mobile-header/index.tsx'; // 🌗 0.2.3
|
|
107
107
|
// 🌗 0.2.3 (Joseph, Welcome 0.2.21): one shared theme mode for every toggle
|
|
108
|
-
export { AbThemeModeProvider, useAbThemeModeContext } from '../ab-theme-mode/index.tsx';
|
|
108
|
+
export { AbThemeModeProvider, useAbThemeModeContext, AB_THEME_MODE_ICONS, AB_THEME_ICON_BUTTON_GLYPH } from '../ab-theme-mode/index.tsx';
|
|
109
109
|
export type { AbThemeModeProviderProps, AbThemeModeContextValue } from '../ab-theme-mode/index.tsx';
|
|
110
110
|
// 🆕 0.2.0 drawers v2: AbSearchDrawer
|
|
111
111
|
export { default as AbSearchDrawer, addAbSearchRecent, highlightAbSearch, AB_SEARCH_RECENT_KEY } from '../ab-search-drawer/index.tsx';
|