ab-nextjs-components 0.2.0 โ 0.2.2
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 +18 -0
- package/ab-app-bar/index.tsx +1 -1
- package/ab-balloon/index.tsx +35 -3
- package/ab-balloon/styles.module.css +8 -0
- package/ab-drawer/index.tsx +8 -3
- package/ab-drawer/kit.module.css +14 -8
- package/ab-drawer/use-ab-edge-swipe.ts +13 -3
- package/ab-package-card/index.tsx +2 -0
- package/ab-package-card/previews.tsx +110 -0
- package/ab-package-card/styles.module.css +21 -0
- package/ab-profile-avatar/index.tsx +105 -0
- package/ab-profile-avatar/styles.module.css +53 -0
- package/ab-settings-drawer/index.tsx +47 -4
- package/ab-sidebar/index.tsx +9 -1
- package/ab-sidebar/profile-button.tsx +115 -0
- package/ab-sidebar/styles.module.css +38 -0
- package/ab-sidebar/view.tsx +5 -1
- package/ab-toc/index.tsx +3 -0
- package/ab-toc/promo.tsx +74 -0
- package/ab-toc/styles.module.css +16 -0
- package/index.ts +14 -2
- package/package.json +3 -1
- package/types/index.d.ts +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 0.2.2 (Unreleased, proposed)
|
|
2
|
+
|
|
3
|
+
- ๐ AbPackagePreviewComponents `labels` ({ button, chip, switch }); English defaults unchanged, the 0.2.1 `button` / `chip` props still work
|
|
4
|
+
|
|
5
|
+
## 0.2.1
|
|
6
|
+
|
|
7
|
+
### Sidebar profile (God 02:44)
|
|
8
|
+
- โจ AbSidebar `profile` prop (opt-in): a 40px profile button at the bottom left opens AbSettingsDrawer. Signed out it shows the profile glyph; signed in the initials ("AU") on the container colour, or the photo masked to a circle, plus the name when expanded. Rendered on the server and hidden by CSS below 1180px (no flash); the collapsed rail names it with an AbBalloon tooltip. Label via `labels.profile` (default "Profile and settings")
|
|
9
|
+
- โจ New `AbSidebarProfileButton` (standalone) and `AbProfileAvatar` + `getAbInitials` (client + server)
|
|
10
|
+
- โจ AbSidebar `footer` slot (bottom left, sticky)
|
|
11
|
+
- โจ AbBalloon `strategy="fixed"`: the tip is placed in the viewport, so the collapsed sidebar rail (a scroller) can't clip it; rail items + the profile button use it
|
|
12
|
+
- โจ AbTocPromo: the aside "New" card (mock .toc-card: 12px radius + padding, card colour, 13px title, 11.5px subtitle)
|
|
13
|
+
- โจ Home preview tiles for AbPackageCard `preview`: `AbPackagePreviewCurve` (ease-out), `AbPackagePreviewCode` (`*kw*` / `~dim` lines), `AbPackagePreviewComponents` (button ยท switch ยท pill chip); preview children no longer stretch
|
|
14
|
+
- โจ `useAbEdgeSwipe({ maxWidth })` + `AB_ASIDE_DRAWER_MAX_WIDTH` (1179): the right drawer swipes on mobile and tablet only (God 02:47)
|
|
15
|
+
- ๐ Drawers: a swipe-opened drawer returns focus to the header / brand logo by default (`AB_DRAWER_RETURN_FOCUS`; AbAppBar's brand gets `data-ab-part="app-bar-brand"`) (Joseph)
|
|
16
|
+
- ๐ Drawer rows: hover tints only on hover-capable pointers, so the nav drawer opens with no highlighted row (Joseph)
|
|
17
|
+
- โจ AbSettingsDrawer: the Account section is back on top (`account`, `onAccount`, `onSignIn`), plus `onHelp` / `onAbout` rows after Language (labels `account`, `signIn`, `help`, `about`)
|
|
18
|
+
|
|
1
19
|
## 0.2.0 (Unreleased, proposed)
|
|
2
20
|
|
|
3
21
|
Includes everything planned for 0.1.15, which is not released separately.
|
package/ab-app-bar/index.tsx
CHANGED
|
@@ -148,7 +148,7 @@ const AbAppBar = ({ brand, search, nav = [], activeHref, locales, actions, compa
|
|
|
148
148
|
return (
|
|
149
149
|
<header className={clsx('AbAppBar', styles.abAppBar, className)} data-ab-part="app-bar" data-sticky={sticky ? 'true' : 'false'} data-has-compact-actions={compactActions != null ? 'true' : undefined} data-density={density === 'compact' ? 'compact' : undefined} data-more={moreMenu ? undefined : 'false'} data-compact-search={(compactSearch ?? (density === 'compact' ? 'pill' : 'icon')) === 'pill' ? 'pill' : undefined}>
|
|
150
150
|
{leading}
|
|
151
|
-
{brand && <div className={styles.abAppBarBrand}>{brand}</div>}
|
|
151
|
+
{brand && <div className={styles.abAppBarBrand} data-ab-part="app-bar-brand">{brand}</div> /* ๐ท๏ธ 0.2.1: the drawers' default return-focus target */}
|
|
152
152
|
{search && <div className={styles.abAppBarSearch} data-when={searchCompact != null ? 'wide' : undefined}>{search}</div>}
|
|
153
153
|
{searchCompact != null && <div className={styles.abAppBarSearch} data-when="compact">{searchCompact}</div> /* ๐ฑ 0.1.15 */}
|
|
154
154
|
{nav.length > 0 && (
|
package/ab-balloon/index.tsx
CHANGED
|
@@ -44,7 +44,9 @@
|
|
|
44
44
|
'use client';
|
|
45
45
|
|
|
46
46
|
// โ๏ธ React
|
|
47
|
-
import { cloneElement, isValidElement, useCallback, useEffect, useId, useRef, useState, type FocusEvent, type KeyboardEvent, type ReactElement, type ReactNode } from 'react';
|
|
47
|
+
import { cloneElement, isValidElement, useCallback, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type FocusEvent, type KeyboardEvent, type ReactElement, type ReactNode } from 'react';
|
|
48
|
+
// ๐ 0.2.1: the fixed tip goes to <body> (out of the rail's stacking context)
|
|
49
|
+
import { createPortal } from 'react-dom';
|
|
48
50
|
// ๐งต classes
|
|
49
51
|
import clsx from 'clsx';
|
|
50
52
|
// ๐ฌ the tooltip pops in with the package keyframes (reduced-motion safe in ab-nextjs-animations)
|
|
@@ -52,6 +54,9 @@ import 'ab-nextjs-animations/pop-in/styles.css';
|
|
|
52
54
|
// ๐จ styles
|
|
53
55
|
import styles from './styles.module.css';
|
|
54
56
|
|
|
57
|
+
/** ๐ a store that never changes: true on the client, false on the server */
|
|
58
|
+
const noSub = () => () => {};
|
|
59
|
+
|
|
55
60
|
/** โฑ๏ธ hover delay before the balloon shows (focus shows it at once). */
|
|
56
61
|
export const AB_BALLOON_HOVER_DELAY = 300;
|
|
57
62
|
|
|
@@ -67,6 +72,9 @@ export interface AbBalloonProps {
|
|
|
67
72
|
hidden?: boolean; // ๐ render the child alone
|
|
68
73
|
disabled?: boolean; // ๐ซ no balloon
|
|
69
74
|
children: ReactNode; // ๐ฏ the trigger (ideally ONE focusable element)
|
|
75
|
+
/** ๐ 0.2.1: `'fixed'` = the tip is placed in the viewport from the trigger's box, so a scrolling / clipped parent
|
|
76
|
+
* (e.g. the collapsed sidebar rail) can't cut it off. Default `'absolute'` (relative to the wrapper). */
|
|
77
|
+
strategy?: 'absolute' | 'fixed';
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
/**
|
|
@@ -77,7 +85,7 @@ export interface AbBalloonProps {
|
|
|
77
85
|
* - ๐ฌ `popIn` from ab-nextjs-animations (no motion under prefers-reduced-motion)
|
|
78
86
|
* - ๐ซ JS off: the balloon shows on `:focus-within` / `:hover` with CSS alone
|
|
79
87
|
*/
|
|
80
|
-
const AbBalloon = ({ title, placement = 'top', delay = AB_BALLOON_HOVER_DELAY, className, hidden = false, disabled = false, children }: AbBalloonProps): ReactElement => {
|
|
88
|
+
const AbBalloon = ({ title, placement = 'top', delay = AB_BALLOON_HOVER_DELAY, className, hidden = false, disabled = false, children, strategy = 'absolute' }: AbBalloonProps): ReactElement => {
|
|
81
89
|
// ๐ tooltip id for aria-describedby
|
|
82
90
|
const id = useId();
|
|
83
91
|
// ๐๏ธ open state
|
|
@@ -101,6 +109,21 @@ const AbBalloon = ({ title, placement = 'top', delay = AB_BALLOON_HOVER_DELAY, c
|
|
|
101
109
|
}, []);
|
|
102
110
|
// ๐งน unmount
|
|
103
111
|
useEffect(() => clear, [clear]);
|
|
112
|
+
// ๐ 0.2.1: fixed strategy: measure the trigger when it opens (6px gap, same as the CSS placements)
|
|
113
|
+
const root = useRef<HTMLSpanElement>(null);
|
|
114
|
+
const [pos, setPos] = useState<CSSProperties | undefined>(undefined);
|
|
115
|
+
const mounted = useSyncExternalStore(noSub, () => true, () => false); // ๐ portals need the DOM (false on the server)
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
if (strategy !== 'fixed' || !open || !root.current) return; // ๐ซ absolute / closed
|
|
118
|
+
const r = root.current.getBoundingClientRect(); // ๐ the trigger box
|
|
119
|
+
const at: Record<NonNullable<AbBalloonProps['placement']>, CSSProperties> = {
|
|
120
|
+
top: { left: r.left + r.width / 2, top: r.top - 6 }, // โฌ๏ธ
|
|
121
|
+
bottom: { left: r.left + r.width / 2, top: r.bottom + 6 }, // โฌ๏ธ
|
|
122
|
+
start: { left: r.left - 6, top: r.top + r.height / 2 }, // โฌ
๏ธ
|
|
123
|
+
end: { left: r.right + 6, top: r.top + r.height / 2 }, // โก๏ธ
|
|
124
|
+
};
|
|
125
|
+
setPos(at[placement]); // ๐
|
|
126
|
+
}, [strategy, open, placement]);
|
|
104
127
|
|
|
105
128
|
// ๐ nothing to show
|
|
106
129
|
if (hidden) return <>{children}</>;
|
|
@@ -145,6 +168,8 @@ const AbBalloon = ({ title, placement = 'top', delay = AB_BALLOON_HOVER_DELAY, c
|
|
|
145
168
|
data-open={open ? 'true' : 'false'} // ๐๏ธ
|
|
146
169
|
data-placement={placement} // ๐งญ
|
|
147
170
|
data-ab-part="balloon" // ๐งฉ
|
|
171
|
+
data-strategy={strategy === 'fixed' ? 'fixed' : undefined} // ๐ 0.2.1
|
|
172
|
+
ref={root} // ๐
|
|
148
173
|
onPointerEnter={onPointerEnter}
|
|
149
174
|
onPointerLeave={onPointerLeave}
|
|
150
175
|
onFocus={onFocus}
|
|
@@ -152,11 +177,18 @@ const AbBalloon = ({ title, placement = 'top', delay = AB_BALLOON_HOVER_DELAY, c
|
|
|
152
177
|
onKeyDown={onKeyDown}
|
|
153
178
|
>
|
|
154
179
|
{trigger}
|
|
155
|
-
{active && (
|
|
180
|
+
{active && strategy !== 'fixed' && (
|
|
156
181
|
<span id={id} role="tooltip" className={clsx(styles.abBalloonTip, open && !still && 'popIn')} data-ab-part="balloon-tip">
|
|
157
182
|
{title}
|
|
158
183
|
</span>
|
|
159
184
|
)}
|
|
185
|
+
{/* ๐ 0.2.1 fixed: portalled to <body> so neither a scroller's clip nor a pane's stacking context can hide it */}
|
|
186
|
+
{active && strategy === 'fixed' && mounted && createPortal(
|
|
187
|
+
<span id={id} role="tooltip" className={clsx(styles.abBalloonTip, styles.abBalloonTipFixed, open && !still && 'popIn')} data-ab-part="balloon-tip" data-open={open ? 'true' : 'false'} data-placement={placement} style={pos}>
|
|
188
|
+
{title}
|
|
189
|
+
</span>,
|
|
190
|
+
document.body,
|
|
191
|
+
)}
|
|
160
192
|
</span>
|
|
161
193
|
);
|
|
162
194
|
};
|
|
@@ -87,3 +87,11 @@
|
|
|
87
87
|
.abBalloon[data-placement='end'] .abBalloonTip { inset-inline-start: calc(100% + 6px); top: 50%; translate: 0 -50%; }
|
|
88
88
|
|
|
89
89
|
/* โฟ reduced motion: the component skips the popIn class (pop-in has no reduced-motion rule of its own) */
|
|
90
|
+
|
|
91
|
+
/* ๐ 0.2.1: strategy="fixed": portalled to <body>, viewport-placed from the trigger's box (inline top / left) */
|
|
92
|
+
.abBalloonTipFixed { position: fixed; inset: auto; z-index: 1000; } /* ๐งน the absolute insets; above the panes */
|
|
93
|
+
.abBalloonTipFixed[data-open='true'] { display: block; } /* ๐๏ธ open (it's no longer inside the wrapper) */
|
|
94
|
+
.abBalloonTipFixed[data-placement='top'] { translate: -50% -100%; } /* โฌ๏ธ */
|
|
95
|
+
.abBalloonTipFixed[data-placement='bottom'] { translate: -50% 0; } /* โฌ๏ธ */
|
|
96
|
+
.abBalloonTipFixed[data-placement='start'] { translate: -100% -50%; } /* โฌ
๏ธ */
|
|
97
|
+
.abBalloonTipFixed[data-placement='end'] { translate: 0 -50%; } /* โก๏ธ */
|
package/ab-drawer/index.tsx
CHANGED
|
@@ -64,7 +64,7 @@ import { AB_SWIPE, createAbVelocityTracker, resolveAbSheetRelease, resolveAbSide
|
|
|
64
64
|
export { useAbDrawer };
|
|
65
65
|
export type { AbDrawerScope, UseAbDrawer, AbSheetSnap };
|
|
66
66
|
// ๐ค 0.2.0: edge swipes + the pure rules, from the same entry
|
|
67
|
-
export { useAbEdgeSwipe, type UseAbEdgeSwipeOptions } from './use-ab-edge-swipe';
|
|
67
|
+
export { useAbEdgeSwipe, AB_ASIDE_DRAWER_MAX_WIDTH, type UseAbEdgeSwipeOptions } from './use-ab-edge-swipe';
|
|
68
68
|
export { AB_SWIPE, resolveAbSheetRelease, resolveAbSideRelease } from './gestures';
|
|
69
69
|
|
|
70
70
|
/** ๐ฅ drawers v2 stacking tiers (spec z-order): aside (right) < nav (left) < sheet (bottom). Unset = the old single level. */
|
|
@@ -99,7 +99,7 @@ export interface AbDrawerProps {
|
|
|
99
99
|
onSnapChange?: (snap: AbSheetSnap) => void; // ๐
|
|
100
100
|
handleLabels?: { expand: string; collapse: string }; // โฟ the handle button (default "Expand" / "Collapse")
|
|
101
101
|
centerIn?: 'main'; // ๐ป bottom only, 768px and up: centred in the main pane, min(640px, main width) wide, โค 70% tall
|
|
102
|
-
returnFocus?: string; // โฉ๏ธ selector focused on close when there was no focusable opener (an edge swipe)
|
|
102
|
+
returnFocus?: string; // โฉ๏ธ selector focused on close when there was no focusable opener (an edge swipe); default AB_DRAWER_RETURN_FOCUS (the header / brand logo)
|
|
103
103
|
closeIcon?: ReactNode; // โ the close glyph (default a text โ)
|
|
104
104
|
headerStart?: ReactNode; // ๐ท๏ธ header content that does NOT label the dialog (e.g. a logo; then use `aria-label`). `title` wins
|
|
105
105
|
className?: string; // ๐ท๏ธ
|
|
@@ -146,6 +146,9 @@ const isTopDrawer = (token: symbol): boolean => openStack[openStack.length - 1]
|
|
|
146
146
|
|
|
147
147
|
// โฟ reduced-motion check, read once per open / close on purpose: it only picks the unmount delay for THAT
|
|
148
148
|
// toggle (the slide itself is CSS, which follows the media query live), so a listener would buy nothing
|
|
149
|
+
/** โฉ๏ธ 0.2.1 (Joseph): where focus goes after a drawer that had no focusable opener closes (an edge swipe): the
|
|
150
|
+
* mobile header's logo link, else AbAppBar's brand link, else AbSidebar's logo row link. `returnFocus` overrides it. */
|
|
151
|
+
export const AB_DRAWER_RETURN_FOCUS = '[data-ab-part="mobile-header"] a[href], [data-ab-part="app-bar-brand"] a[href], [data-ab-part="sidebar-logo"] a[href]';
|
|
149
152
|
const reducedMotion = (): boolean => typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
150
153
|
|
|
151
154
|
/**
|
|
@@ -229,11 +232,13 @@ const AbDrawer = (props: AbDrawerProps): ReactElement => {
|
|
|
229
232
|
const body = panel.current.querySelector<HTMLElement>('[data-ab-part="drawer-body"]');
|
|
230
233
|
if (first && body && body.contains(first)) { const b = body.getBoundingClientRect(); const r = first.getBoundingClientRect(); if (r.bottom > b.bottom) body.scrollTop += r.bottom - b.bottom; else if (r.top < b.top) body.scrollTop -= b.top - r.top; }
|
|
231
234
|
(first ?? panel.current).focus({ preventScroll: true });
|
|
235
|
+
const node = panel.current; // ๐ this open's panel (for the cleanup)
|
|
232
236
|
return () => {
|
|
233
237
|
const had = opener.current as HTMLElement | null; // โฉ๏ธ
|
|
234
238
|
const usable = had && had !== document.body && had.isConnected ? had : null; // ๐ค a swipe has no opener
|
|
235
239
|
// โฉ๏ธ 0.2.0 fallback: the first VISIBLE match (an app often renders the logo twice, one hidden per breakpoint)
|
|
236
|
-
const
|
|
240
|
+
const pool = Array.from(document.querySelectorAll<HTMLElement>(returnFocus ?? AB_DRAWER_RETURN_FOCUS)).filter((el) => !node.contains(el)); // ๐ท๏ธ 0.2.1 (Joseph): default = the header / brand logo
|
|
241
|
+
const back = usable ?? pool.find((el) => el.getClientRects().length > 0) ?? pool[0] ?? null; // ๐ the visible one, else the first
|
|
237
242
|
// โญ๏ธ a microtask later: the inert cleanup below runs after this one, and an inert opener can't take focus
|
|
238
243
|
queueMicrotask(() => { if (back && back.isConnected && typeof back.focus === 'function') back.focus({ preventScroll: true }); });
|
|
239
244
|
};
|
package/ab-drawer/kit.module.css
CHANGED
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
.titleSm [data-ab-part='drawer-header'] > :first-child { font-size: 20px; }
|
|
84
84
|
/* โ close: 44px, 8px radius, --muted, 24px glyph */
|
|
85
85
|
.sheet [data-ab-part='drawer-close'] { inline-size: 44px; block-size: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--ab-color-muted, #6b5b50); }
|
|
86
|
-
.sheet [data-ab-part='drawer-close']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
86
|
+
@media (hover: hover) { .sheet [data-ab-part='drawer-close']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
87
87
|
.sheet [data-ab-part='drawer-close']:focus { outline: none; }
|
|
88
88
|
.sheet [data-ab-part='drawer-close']:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; }
|
|
89
89
|
/* ๐ body: 16px sides */
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
text-align: start; text-decoration: none; cursor: pointer; /* ๐ฑ๏ธ */
|
|
100
100
|
}
|
|
101
101
|
.row > svg, .row > .ic { flex: none; inline-size: 24px; block-size: 24px; color: var(--ab-color-muted, #6b5b50); }
|
|
102
|
-
.row:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
102
|
+
@media (hover: hover) { .row:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
103
103
|
.row:focus { outline: none; }
|
|
104
104
|
.row:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
105
105
|
.row[aria-checked='true'], .row[aria-current='page'] { background: var(--ab-dr-on); box-shadow: var(--ab-dr-on-ring); color: var(--ab-color-accent-text, #8b6340); font-weight: 700; } /* ๐ฏ */
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
.list { list-style: none; margin: 0; padding: 0; }
|
|
130
130
|
.nv { box-sizing: border-box; display: flex; align-items: center; gap: 12px; block-size: 44px; padding: 0 12px; border-radius: 8px; color: var(--ab-color-text, #211a16); font: 500 15px/1.2 var(--ab-font-body, 'Inter', inherit); text-decoration: none; }
|
|
131
131
|
.nv > svg { flex: none; inline-size: 22px; block-size: 22px; color: var(--ab-color-muted, #6b5b50); }
|
|
132
|
-
.nv:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
132
|
+
@media (hover: hover) { .nv:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
133
133
|
.nv:focus { outline: none; }
|
|
134
134
|
.nv:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
135
135
|
.nv[aria-current='page'] { background: var(--ab-dr-on); box-shadow: var(--ab-dr-on-ring); color: var(--ab-color-accent-text, #8b6340); font-weight: 700; }
|
|
@@ -157,11 +157,11 @@
|
|
|
157
157
|
.input::-webkit-search-cancel-button { display: none; }
|
|
158
158
|
.iconSm { flex: none; inline-size: 40px; block-size: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--ab-color-muted, #6b5b50); cursor: pointer; padding: 0; }
|
|
159
159
|
.iconSm > svg { inline-size: 20px; block-size: 20px; }
|
|
160
|
-
.iconSm:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
160
|
+
@media (hover: hover) { .iconSm:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
161
161
|
.iconSm:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
162
162
|
.results { flex: 1 1 auto; min-block-size: 0; overflow: hidden auto; overscroll-behavior: contain; }
|
|
163
163
|
.recent { gap: 12px; padding-inline-end: 0; font-size: 15px; cursor: default; }
|
|
164
|
-
.recent:hover { background: transparent; }
|
|
164
|
+
@media (hover: hover) { .recent:hover { background: transparent; } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
165
165
|
.recentGo { flex: 1 1 auto; min-inline-size: 0; border: 0; background: none; padding: 0; text-align: start; color: inherit; font: inherit; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
166
166
|
.recentGo:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; }
|
|
167
167
|
.grp2 { display: flex; align-items: baseline; gap: 8px; padding: 12px 16px 4px; margin: 0; }
|
|
@@ -169,8 +169,8 @@
|
|
|
169
169
|
.grp2 > code { font: 400 12px/16px var(--ab-font-mono, 'Roboto Mono', monospace); color: var(--ab-color-muted, #6b5b50); }
|
|
170
170
|
.sr { box-sizing: border-box; display: flex; align-items: center; gap: 12px; min-block-size: 56px; padding: 4px 12px; border-radius: 8px; color: inherit; text-decoration: none; }
|
|
171
171
|
.sr[aria-selected='true'] { background: var(--ab-dr-on); box-shadow: var(--ab-dr-on-ring); }
|
|
172
|
-
.sr:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
173
|
-
.sr[aria-selected='true']:hover { background: var(--ab-dr-on); }
|
|
172
|
+
@media (hover: hover) { .sr:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
173
|
+
@media (hover: hover) { .sr[aria-selected='true']:hover { background: var(--ab-dr-on); } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
174
174
|
.pkgIc { flex: none; inline-size: 32px; block-size: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--ab-dr-card2); color: var(--ab-color-accent-text, #8b6340); }
|
|
175
175
|
.pkgIc > svg { inline-size: 20px; block-size: 20px; }
|
|
176
176
|
.srText { flex: 1 1 auto; min-inline-size: 0; }
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
.mh > .logoRow { flex: 1 1 auto; }
|
|
191
191
|
.ibtn { flex: none; inline-size: 44px; block-size: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--ab-color-text, #211a16); cursor: pointer; padding: 0; }
|
|
192
192
|
.ibtn > svg { inline-size: 24px; block-size: 24px; }
|
|
193
|
-
.ibtn:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
193
|
+
@media (hover: hover) { .ibtn:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); } } /* ๐ฑ๏ธ 0.2.1 (Joseph): no sticky tap-hover on touch */
|
|
194
194
|
.ibtn:focus { outline: none; }
|
|
195
195
|
.ibtn:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; }
|
|
196
196
|
.verRow { display: flex; flex: none; } /* ๐ท๏ธ keeps the chip its own size */
|
|
@@ -202,3 +202,9 @@
|
|
|
202
202
|
.searchSheet[data-center='main'] .resFade { display: block; }
|
|
203
203
|
.didYouMean { justify-content: center; gap: 0; margin-top: 8px; font-size: 15px; }
|
|
204
204
|
.nores code { font-family: var(--ab-font-mono, 'Roboto Mono', monospace); }
|
|
205
|
+
/* ๐ค 0.2.1: the settings account row (avatar ยท name / email) and the Help / About block */
|
|
206
|
+
.acct { block-size: auto; min-block-size: 56px; padding-block: 8px; } /* ๐ two lines fit */
|
|
207
|
+
.acctText { display: flex; flex-direction: column; min-width: 0; gap: 2px; } /* ๐ */
|
|
208
|
+
.acctText b { font-weight: 600; } /* ๐ค the name */
|
|
209
|
+
.acctText small { font-size: 13px; color: var(--ab-color-muted, #6b5b50); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* โ๏ธ */
|
|
210
|
+
.more { display: flex; flex-direction: column; margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); } /* โ after Language */
|
|
@@ -52,8 +52,14 @@ export interface UseAbEdgeSwipeOptions {
|
|
|
52
52
|
enabled?: boolean; // ๐๏ธ e.g. false while that drawer is open, or when the page has no aside (default true)
|
|
53
53
|
width?: number; // ๐ the drawer width the 30% rule uses (default 320)
|
|
54
54
|
pointerTypes?: readonly string[]; // ๐๏ธ default touch + pen (a mouse never edge-swipes)
|
|
55
|
+
// ๐ 0.2.1 (God 02:47): only swipe while the viewport is at most this wide, e.g. AB_ASIDE_DRAWER_MAX_WIDTH (1179) for
|
|
56
|
+
// the right drawer: mobile AND tablet hide the aside and open it as the right drawer; from 1180px it's a column
|
|
57
|
+
maxWidth?: number;
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
/** ๐ 0.2.1: the widest viewport where the aside is a right drawer (mobile + tablet; the column starts at 1180px) */
|
|
61
|
+
export const AB_ASIDE_DRAWER_MAX_WIDTH = 1179;
|
|
62
|
+
|
|
57
63
|
// ๐ฑ iOS home-screen web app (the zone starts 16px in there)
|
|
58
64
|
const standalone = (): boolean => typeof navigator !== 'undefined' && (navigator as Navigator & { standalone?: boolean }).standalone === true;
|
|
59
65
|
|
|
@@ -71,7 +77,7 @@ const standalone = (): boolean => typeof navigator !== 'undefined' && (navigator
|
|
|
71
77
|
*
|
|
72
78
|
* The drawer opens on release (it doesn't follow the finger), then slides in with its normal 200ms motion.
|
|
73
79
|
*/
|
|
74
|
-
export function useAbEdgeSwipe({ edge, onOpen, enabled = true, width = 320, pointerTypes = ['touch', 'pen'] }: UseAbEdgeSwipeOptions): void {
|
|
80
|
+
export function useAbEdgeSwipe({ edge, onOpen, enabled = true, width = 320, pointerTypes = ['touch', 'pen'], maxWidth }: UseAbEdgeSwipeOptions): void {
|
|
75
81
|
const latest = useRef(onOpen); // ๐ latest callback for the listener
|
|
76
82
|
useEffect(() => { latest.current = onOpen; }, [onOpen]);
|
|
77
83
|
const types = pointerTypes.join(','); // ๐งฎ a stable dep
|
|
@@ -82,6 +88,7 @@ export function useAbEdgeSwipe({ edge, onOpen, enabled = true, width = 320, poin
|
|
|
82
88
|
const allow = types.split(','); // ๐๏ธ
|
|
83
89
|
// ๐งฑ shared start rule (pointer or touch): from the edge zone, not in a sideways scroller / opt-out / open drawer
|
|
84
90
|
const start = (x: number, y: number, t: number, target: Element): boolean => {
|
|
91
|
+
if (maxWidth != null && window.innerWidth > maxWidth) return false; // ๐ 0.2.1: too wide (e.g. the aside is a column)
|
|
85
92
|
const host = getAbDrawerHost('app', target); // ๐บ๏ธ the app box
|
|
86
93
|
const box = host === document.body ? { left: 0, right: window.innerWidth } : host.getBoundingClientRect();
|
|
87
94
|
if (!isInAbEdgeZone(x, edge, box, standalone())) return false; // ๐งฑ not from the edge
|
|
@@ -104,7 +111,10 @@ export function useAbEdgeSwipe({ edge, onOpen, enabled = true, width = 320, poin
|
|
|
104
111
|
const finish = (x: number) => {
|
|
105
112
|
const cur = d; d = null;
|
|
106
113
|
if (!cur || cur.axis !== 1) return;
|
|
107
|
-
if (resolveAbSideRelease({ distance: (x - cur.x) * sign, velocity: cur.v.velocity() * sign, width }))
|
|
114
|
+
if (resolveAbSideRelease({ distance: (x - cur.x) * sign, velocity: cur.v.velocity() * sign, width })) {
|
|
115
|
+
(document.activeElement as HTMLElement | null)?.blur?.(); // โฉ๏ธ 0.2.1 (Joseph): a swipe has no opener, so the drawer returns focus to the logo, not a stale element
|
|
116
|
+
latest.current(); // โ
|
|
117
|
+
}
|
|
108
118
|
};
|
|
109
119
|
|
|
110
120
|
// ๐๏ธ pointer path: pen (and touch only where there are no touch events)
|
|
@@ -148,7 +158,7 @@ export function useAbEdgeSwipe({ edge, onOpen, enabled = true, width = 320, poin
|
|
|
148
158
|
document.removeEventListener('touchstart', tstart, true);
|
|
149
159
|
detach();
|
|
150
160
|
};
|
|
151
|
-
}, [edge, enabled, width, types]);
|
|
161
|
+
}, [edge, enabled, width, types, maxWidth]);
|
|
152
162
|
}
|
|
153
163
|
|
|
154
164
|
// ๐ฆ default export
|
|
@@ -139,3 +139,5 @@ const AbPackageCardLegacy = ({ name, href, description, version, icon, media, id
|
|
|
139
139
|
// ๐ฆ exports
|
|
140
140
|
export default AbPackageCard;
|
|
141
141
|
export { AbPackageCard };
|
|
142
|
+
// ๐ผ๏ธ 0.2.1 (God 02:44): the Home preview tiles (mock .pv-anim / .pv-code / .pv-comp)
|
|
143
|
+
export { AbPackagePreviewCurve, AbPackagePreviewCode, AbPackagePreviewComponents, type AbPackagePreviewComponentsLabels, type AbPackagePreviewComponentsProps } from './previews';
|
|
@@ -0,0 +1,110 @@
|
|
|
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: AbPackageCard Home previews (0.2.1, God 02:44, mock .pv-*)
|
|
28
|
+
* @file: ab-package-card/previews.tsx
|
|
29
|
+
* @type: React Component (no hooks: client + server)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage (pass one as AbPackageCard `preview`):
|
|
33
|
+
* <AbPackageCard preview={<AbPackagePreviewCurve />} โฆ /> // ใฐ๏ธ Animations: ease-out curve
|
|
34
|
+
* <AbPackageCard preview={<AbPackagePreviewCode lines={['*use*Theme()', '*use*Media()']} />} โฆ /> // ๐ช Hooks
|
|
35
|
+
* <AbPackageCard preview={<AbPackagePreviewCode lines={['<*AbProvider*>', '~ {children}']} />} โฆ /> // ๐งฑ Core
|
|
36
|
+
* <AbPackageCard preview={<AbPackagePreviewComponents />} โฆ /> // ๐งฉ Components: button ยท switch ยท chip
|
|
37
|
+
* <AbPackagePreviewComponents labels={{ button: 'Bouton', chip: 'Puce', switch: 'Interrupteur' }} /> // ๐ 0.2.2
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
42
|
+
* MOTTO: We'll always do more ๐!!!
|
|
43
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
// โ๏ธ React
|
|
47
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
48
|
+
// ๐จ styles (the card's module: the previews sit in its 56px tile)
|
|
49
|
+
import styles from './styles.module.css';
|
|
50
|
+
|
|
51
|
+
/** ใฐ๏ธ Animations tile: two axes, the accent ease-out curve with its end dots, and the easing name bottom right. */
|
|
52
|
+
export function AbPackagePreviewCurve({ label = 'ease-out', path = 'M6 38 C 50 38, 58 6, 114 6' }: { label?: string; path?: string }): ReactElement {
|
|
53
|
+
return (
|
|
54
|
+
<span className={styles.pvAnim} data-ab-part="preview-curve">
|
|
55
|
+
<svg viewBox="0 0 120 44" preserveAspectRatio="none" aria-hidden="true" focusable="false">
|
|
56
|
+
<line x1="6" y1="38" x2="114" y2="38" className={styles.pvAx} /> {/* โ x axis */}
|
|
57
|
+
<line x1="6" y1="6" x2="6" y2="38" className={styles.pvAx} /> {/* โ y axis */}
|
|
58
|
+
<path d={path} className={styles.pvCrv} /> {/* ใฐ๏ธ the curve (mock: cubic 50,38 ยท 58,6) */}
|
|
59
|
+
<circle cx="114" cy="6" r="3.2" className={styles.pvDot} /> {/* ๐ด end */}
|
|
60
|
+
<circle cx="6" cy="38" r="2.4" className={styles.pvDot2} /> {/* โช start */}
|
|
61
|
+
</svg>
|
|
62
|
+
<span className={styles.pvEase}>{label}</span> {/* ๐ท๏ธ ease-out */}
|
|
63
|
+
</span>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** ๐จ one code line: `*kw*` = a keyword (accent, 600), a leading `~` = a dim line (faint). */
|
|
68
|
+
function codeLine(src: string): ReactNode {
|
|
69
|
+
const parts = src.split(/(\*[^*]+\*)/g).filter(Boolean); // โ๏ธ keywords vs text
|
|
70
|
+
return parts.map((p, i) => (p.startsWith('*') && p.endsWith('*') ? <b key={i}>{p.slice(1, -1)}</b> : p)); // ๐๏ธ
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** ๐ช๐งฑ Hooks / Core tile: left-aligned, slightly bold mono lines with the keywords syntax-coloured. */
|
|
74
|
+
export function AbPackagePreviewCode({ lines }: { lines: readonly string[] }): ReactElement {
|
|
75
|
+
return (
|
|
76
|
+
<span className={styles.pvCode} data-ab-part="preview-code">
|
|
77
|
+
{lines.map((l, i) => {
|
|
78
|
+
const dim = l.startsWith('~'); // ๐ซ๏ธ
|
|
79
|
+
const text = dim ? l.slice(1).replace(/^ +/, (m) => '\u00a0'.repeat(m.length)) : l; // โฃ keep the indent
|
|
80
|
+
return <span key={i} className={dim ? styles.pvDim : undefined}>{codeLine(text)}</span>;
|
|
81
|
+
})}
|
|
82
|
+
</span>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** ๐ 0.2.2: the Components tile's strings (English defaults) */
|
|
87
|
+
export interface AbPackagePreviewComponentsLabels {
|
|
88
|
+
button?: string; // ๐ default "Button"
|
|
89
|
+
chip?: string; // ๐ default "Chip"
|
|
90
|
+
switch?: string; // ๐๏ธ default "Switch" (the switch's name when the tile is used outside an aria-hidden card preview)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** โ๏ธ props: `labels` (0.2.2) wins over the 0.2.1 `button` / `chip` props (kept for back-compat) */
|
|
94
|
+
export interface AbPackagePreviewComponentsProps {
|
|
95
|
+
labels?: AbPackagePreviewComponentsLabels; // ๐
|
|
96
|
+
button?: string; // ๐ฐ๏ธ 0.2.1: prefer `labels.button`
|
|
97
|
+
chip?: string; // ๐ฐ๏ธ 0.2.1: prefer `labels.chip`
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** ๐งฉ Components tile: a mini button, an on switch and a pill chip, intrinsic size (no stretch), centred both ways. */
|
|
101
|
+
export function AbPackagePreviewComponents({ labels = {}, button, chip }: AbPackagePreviewComponentsProps): ReactElement {
|
|
102
|
+
const L = { button: button ?? 'Button', chip: chip ?? 'Chip', switch: 'Switch', ...labels }; // ๐ defaults < legacy props < labels
|
|
103
|
+
return (
|
|
104
|
+
<span className={styles.pvComp} data-ab-part="preview-components">
|
|
105
|
+
<span className={styles.pvBtn}>{L.button}</span> {/* ๐ 6px radius (kept) */}
|
|
106
|
+
<span className={styles.pvSw} role="img" aria-label={L.switch}><i /></span> {/* ๐๏ธ on */}
|
|
107
|
+
<span className={styles.pvChip}>{L.chip}</span> {/* ๐ pill */}
|
|
108
|
+
</span>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -79,3 +79,24 @@
|
|
|
79
79
|
.homeFoot { margin-top: 8px; }
|
|
80
80
|
}
|
|
81
81
|
@media (prefers-reduced-motion: reduce) { .home:hover { transform: none; } } /* โฟ no lift */
|
|
82
|
+
|
|
83
|
+
/* ===== ๐ผ๏ธ 0.2.1 (God 02:44): Home preview tiles, John's mock `.pv-*` (theme tokens, fallbacks = the mock) ===== */
|
|
84
|
+
.homePreview > * { flex: none; } /* ๐ซ no child stretches; the tile centres them both ways */
|
|
85
|
+
/* ใฐ๏ธ Animations */
|
|
86
|
+
.pvAnim { position: relative; display: block; box-sizing: border-box; width: 100%; height: 100%; padding: 6px 10px; } /* ๐ */
|
|
87
|
+
.pvAnim svg { display: block; width: 100%; height: 44px; } /* ๐ */
|
|
88
|
+
.pvAx { stroke: var(--ab-color-border, rgb(92 64 48 / 0.13)); stroke-width: 1; } /* โ */
|
|
89
|
+
.pvCrv { fill: none; stroke: var(--ab-color-accent, #a67c52); stroke-width: 2.2; stroke-linecap: round; } /* ใฐ๏ธ */
|
|
90
|
+
.pvDot { fill: var(--ab-color-accent, #a67c52); } /* ๐ด */
|
|
91
|
+
.pvDot2 { fill: var(--ab-color-faint, #807062); } /* โช */
|
|
92
|
+
.pvEase { position: absolute; right: 10px; bottom: 6px; font: 500 9.5px/1 var(--ab-font-code, ui-monospace, monospace); color: var(--ab-color-faint, #807062); } /* ๐ท๏ธ */
|
|
93
|
+
/* ๐ช๐งฑ Hooks / Core code */
|
|
94
|
+
.pvCode { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; justify-content: center; align-self: stretch; flex: 1 1 auto; padding: 0 12px; text-align: left; font: 500 11.5px/1.25 var(--ab-font-code, ui-monospace, monospace); color: var(--ab-color-muted, #6b5b50); } /* โฌ
๏ธ left-aligned */
|
|
95
|
+
.pvCode b { color: var(--ab-color-accent-text, #88603d); font-weight: 600; } /* ๐๏ธ keyword */
|
|
96
|
+
.pvDim { color: var(--ab-color-faint, #807062); } /* ๐ซ๏ธ */
|
|
97
|
+
/* ๐งฉ Components */
|
|
98
|
+
.pvComp { display: inline-flex; align-items: center; justify-content: center; gap: 8px; } /* ๐ฏ */
|
|
99
|
+
.pvBtn { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 6px; background: var(--ab-color-btn, #8b6340); color: var(--ab-color-btn-text, #fff); font-size: 10.5px; font-weight: 650; } /* ๐ */
|
|
100
|
+
.pvSw { position: relative; display: inline-block; width: 30px; height: 17px; border-radius: 999px; background: var(--ab-color-accent, #a67c52); } /* ๐๏ธ */
|
|
101
|
+
.pvSw i { position: absolute; right: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--ab-color-card, #fff); } /* โช knob */
|
|
102
|
+
.pvChip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); background: var(--ab-color-card, #fff); color: var(--ab-color-text, #211a16); font-size: 10.5px; font-weight: 600; } /* ๐ */
|
|
@@ -0,0 +1,105 @@
|
|
|
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: AbProfileAvatar (0.2.1)
|
|
28
|
+
* @file: ab-profile-avatar/index.tsx
|
|
29
|
+
* @type: React Component (no hooks: client + server)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* <AbProfileAvatar user={{ name: 'Abraham Ukachi' }} /> // โ "AU" in a container-coloured circle
|
|
34
|
+
* <AbProfileAvatar user={{ name: 'Abraham Ukachi', image: '/me.jpg' }} size={44} />
|
|
35
|
+
* <AbProfileAvatar /> // ๐ค signed out: the profile glyph
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
* MOTTO: We'll always do more ๐!!!
|
|
41
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
// โ๏ธ React
|
|
45
|
+
import type { ComponentType, ReactElement } from 'react';
|
|
46
|
+
// ๐งต classes
|
|
47
|
+
import clsx from 'clsx';
|
|
48
|
+
// ๐จ styles
|
|
49
|
+
import styles from './styles.module.css';
|
|
50
|
+
|
|
51
|
+
/** ๐ค who is signed in (omit / null = signed out) */
|
|
52
|
+
export interface AbProfileUser {
|
|
53
|
+
name: string; // ๐ท๏ธ "Abraham Ukachi"
|
|
54
|
+
image?: string; // ๐ผ๏ธ photo URL (masked to a circle)
|
|
55
|
+
initials?: string; // ๐ค override the computed initials
|
|
56
|
+
email?: string; // โ๏ธ shown by AbSettingsDrawer's account row
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** ๐ฃ what the avatar needs from an icon component (client and server AbIcon both fit) */
|
|
60
|
+
export type AbProfileIconComponent = ComponentType<{ name: string; size?: number; className?: string }>;
|
|
61
|
+
|
|
62
|
+
/** โ๏ธ props */
|
|
63
|
+
export interface AbProfileAvatarProps {
|
|
64
|
+
user?: AbProfileUser | null; // ๐ค
|
|
65
|
+
size?: number; // ๐ px (default 40)
|
|
66
|
+
icon?: string; // ๐ฃ signed-out glyph (default "person", the bottom nav's Profile)
|
|
67
|
+
Icon?: AbProfileIconComponent; // ๐ฃ the icon component (pass AbIcon; without it the Material ligature is used)
|
|
68
|
+
className?: string; // ๐ท๏ธ
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** ๐ค "Abraham Ukachi" โ "AU" (first + last word, max 2 letters, upper case) */
|
|
72
|
+
export function getAbInitials(name: string): string {
|
|
73
|
+
const words = name.trim().split(/\s+/).filter(Boolean); // โ๏ธ the words
|
|
74
|
+
if (!words.length) return ''; // ๐ซ nothing
|
|
75
|
+
const first = words[0][0] ?? ''; // ๐
ฐ๏ธ
|
|
76
|
+
const last = words.length > 1 ? words[words.length - 1][0] ?? '' : ''; // ๐
ฑ๏ธ
|
|
77
|
+
return (first + last).toUpperCase(); // ๐
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* ๐ค AbProfileAvatar โ a decorative (aria-hidden) circle: the photo masked to a circle (overflow hidden), else the
|
|
82
|
+
* initials on the container colour, else (signed out) the profile glyph. The surrounding control names it.
|
|
83
|
+
* (AbAvatar is a link with a next/image and an online dot, so it doesn't fit inside a button.)
|
|
84
|
+
*/
|
|
85
|
+
const AbProfileAvatar = ({ user, size = 40, icon = 'person', Icon, className }: AbProfileAvatarProps): ReactElement => {
|
|
86
|
+
const kind = user ? (user.image ? 'image' : 'initials') : 'icon'; // ๐งญ what we show
|
|
87
|
+
return (
|
|
88
|
+
<span
|
|
89
|
+
className={clsx('AbProfileAvatar', styles.abProfileAvatar, className)} // ๐ท๏ธ
|
|
90
|
+
data-ab-part="profile-avatar" // ๐งฉ
|
|
91
|
+
data-kind={kind} // ๐งญ
|
|
92
|
+
style={{ width: size, height: size, fontSize: Math.round(size * 0.38) }} // ๐ initials scale with the circle
|
|
93
|
+
aria-hidden="true" // โฟ decorative
|
|
94
|
+
>
|
|
95
|
+
{/* eslint-disable-next-line @next/next/no-img-element -- ๐ผ๏ธ a tiny avatar; the package must not require next/image's loader config in consumer apps */}
|
|
96
|
+
{kind === 'image' && <img src={user!.image} alt="" className={styles.abProfileAvatarImage} width={size} height={size} /> /* ๐ผ๏ธ */}
|
|
97
|
+
{kind === 'initials' && <span className={styles.abProfileAvatarInitials}>{user!.initials ?? getAbInitials(user!.name)}</span> /* ๐ค */}
|
|
98
|
+
{kind === 'icon' && (Icon ? <Icon name={icon} size={Math.round(size * 0.55)} /> : <span className="material-symbols-rounded">{icon}</span>) /* ๐ค */}
|
|
99
|
+
</span>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// ๐ฆ exports
|
|
104
|
+
export default AbProfileAvatar;
|
|
105
|
+
export { AbProfileAvatar };
|
|
@@ -0,0 +1,53 @@
|
|
|
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: AbProfileAvatar - Styles (0.2.1)
|
|
28
|
+
* @file: ab-profile-avatar/styles.module.css
|
|
29
|
+
* @type: CSS Module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
36
|
+
* MOTTO: We'll always do more ๐!!!
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/* ๐ค the circle: container colour, clipped */
|
|
41
|
+
.abProfileAvatar {
|
|
42
|
+
display: inline-grid; /* ๐ */
|
|
43
|
+
place-items: center; /* ๐ฏ */
|
|
44
|
+
flex: none; /* ๐ซ never squashed */
|
|
45
|
+
box-sizing: border-box; /* ๐ฆ */
|
|
46
|
+
border-radius: 50%; /* โญ */
|
|
47
|
+
overflow: hidden; /* โ๏ธ the photo mask */
|
|
48
|
+
background: var(--ab-color-tint, rgb(166 124 82 / 0.14)); /* ๐จ the container colour */
|
|
49
|
+
color: var(--ab-color-accent-text, #88603d); /* ๐๏ธ */
|
|
50
|
+
}
|
|
51
|
+
.abProfileAvatar[data-kind='icon'] { background: var(--ab-color-card2, #fbf3ec); color: var(--ab-color-muted, #6b5b50); } /* ๐ค signed out */
|
|
52
|
+
.abProfileAvatarImage { width: 100%; height: 100%; object-fit: cover; display: block; } /* ๐ผ๏ธ fills the circle */
|
|
53
|
+
.abProfileAvatarInitials { font: 700 1em/1 var(--ab-font-body, 'Inter', inherit); letter-spacing: 0.02em; } /* ๐ค */
|
|
@@ -52,6 +52,8 @@ import clsx from 'clsx';
|
|
|
52
52
|
import AbDrawer, { type AbSheetSnap } from '../ab-drawer';
|
|
53
53
|
// ๐ฃ icons
|
|
54
54
|
import AbIcon from '../ab-icon';
|
|
55
|
+
// ๐ค 0.2.1: the account row's avatar
|
|
56
|
+
import AbProfileAvatar, { type AbProfileUser } from '../ab-profile-avatar';
|
|
55
57
|
// ๐จ the drawers v2 kit
|
|
56
58
|
import kit from '../ab-drawer/kit.module.css';
|
|
57
59
|
|
|
@@ -68,6 +70,9 @@ export interface AbSettingsDrawerLabels {
|
|
|
68
70
|
light?: string; dark?: string; system?: string; // ๐
|
|
69
71
|
close?: string; // "Close settings"
|
|
70
72
|
expand?: string; collapse?: string; // โ the handle: "Expand settings" / "Collapse settings"
|
|
73
|
+
account?: string; // ๐ค 0.2.1: the section label "Account"
|
|
74
|
+
signIn?: string; // ๐ 0.2.1: the signed-out row "Sign in"
|
|
75
|
+
help?: string; about?: string; // โ โน๏ธ 0.2.1: "Help" / "About"
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
/** โ๏ธ props */
|
|
@@ -81,6 +86,13 @@ export interface AbSettingsDrawerProps {
|
|
|
81
86
|
onLocaleChange: (code: string) => void; // ๐ฃ
|
|
82
87
|
labels?: AbSettingsDrawerLabels; // ๐ท๏ธ
|
|
83
88
|
themes?: readonly AbSettingsTheme[]; // ๐๏ธ default light, dark, system
|
|
89
|
+
// ๐ค 0.2.1 (God 02:44): the account section is back, on top. `account` = signed in (avatar, name, email);
|
|
90
|
+
// signed out, pass `onSignIn` for a "Sign in" row. Neither = no section.
|
|
91
|
+
account?: AbProfileUser | null;
|
|
92
|
+
onAccount?: () => void; // ๐ค tap the signed-in row (e.g. open the profile page)
|
|
93
|
+
onSignIn?: () => void; // ๐
|
|
94
|
+
onHelp?: () => void; // โ 0.2.1: a "Help โบ" row after Language
|
|
95
|
+
onAbout?: () => void; // โน๏ธ 0.2.1: an "About โบ" row after Help
|
|
84
96
|
children?: ReactNode; // โ extra sections after Language (your own; Accessibility / About are not built in)
|
|
85
97
|
defaultSnap?: AbSheetSnap; // ๐งฒ default 'partial' (70%)
|
|
86
98
|
returnFocus?: string; // โฉ๏ธ see AbDrawer
|
|
@@ -106,8 +118,8 @@ function radioKeys<T>(e: KeyboardEvent, items: readonly T[], current: T, pick: (
|
|
|
106
118
|
|
|
107
119
|
/**
|
|
108
120
|
* โ๏ธ 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).
|
|
121
|
+
* ACCOUNT (0.2.1, optional), THEME (a Light / Dark / System segmented radiogroup, 48px) and LANGUAGE (48px radio rows, each label in its
|
|
122
|
+
* own `lang`, the checked one tinted with a check), then optional Help / About rows (0.2.1).
|
|
111
123
|
*
|
|
112
124
|
* - ๐ฑ below 768px: full width, snaps at 70% and full height via the handle (AbDrawer `snapPoints`)
|
|
113
125
|
* - ๐ป 768px and up: centred in the main pane, min(640px, main width), at most 70% tall
|
|
@@ -115,10 +127,10 @@ function radioKeys<T>(e: KeyboardEvent, items: readonly T[], current: T, pick: (
|
|
|
115
127
|
* "Change language" lands right there) and back to the opener on close; Esc / scrim / โ close it
|
|
116
128
|
* - ๐ฅ tier 'sheet': above the left and right drawers. Opening it from the left drawer? Close that one first.
|
|
117
129
|
*/
|
|
118
|
-
const AbSettingsDrawer = ({ open, onClose, theme, onThemeChange, locales, locale, onLocaleChange, labels = {}, themes = ['light', 'dark', 'system'], children, defaultSnap, returnFocus, id, className }: AbSettingsDrawerProps): ReactElement => {
|
|
130
|
+
const AbSettingsDrawer = ({ open, onClose, theme, onThemeChange, locales, locale, onLocaleChange, labels = {}, account, onAccount, onSignIn, onHelp, onAbout, themes = ['light', 'dark', 'system'], children, defaultSnap, returnFocus, id, className }: AbSettingsDrawerProps): ReactElement => {
|
|
119
131
|
const seg = useRef<HTMLDivElement>(null); // ๐๏ธ
|
|
120
132
|
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 }; // ๐ท๏ธ
|
|
133
|
+
const L = { title: 'Settings', theme: 'Theme', language: 'Language', light: 'Light', dark: 'Dark', system: 'System', close: 'Close settings', expand: 'Expand settings', collapse: 'Collapse settings', account: 'Account', signIn: 'Sign in', help: 'Help', about: 'About', ...labels }; // ๐ท๏ธ
|
|
122
134
|
const base = id ?? 'ab-settings'; // ๐
|
|
123
135
|
const codes = locales.map((l) => l.code); // ๐
|
|
124
136
|
return (
|
|
@@ -129,6 +141,30 @@ const AbSettingsDrawer = ({ open, onClose, theme, onThemeChange, locales, locale
|
|
|
129
141
|
initialFocus='[data-ab-part="settings-language"] [aria-checked="true"]' returnFocus={returnFocus}
|
|
130
142
|
className={clsx('AbSettingsDrawer', kit.sheet, className)}
|
|
131
143
|
>
|
|
144
|
+
{/* ๐ค 0.2.1: ACCOUNT (signed in: avatar ยท name ยท email; signed out: "Sign in") */}
|
|
145
|
+
{(account || onSignIn) && (
|
|
146
|
+
<section aria-labelledby={`${base}-account`} data-ab-part="settings-account">
|
|
147
|
+
<p className={kit.lbl} id={`${base}-account`}>{L.account}</p>
|
|
148
|
+
{account ? (
|
|
149
|
+
onAccount ? ( // ๐ tappable: a button with a chevron
|
|
150
|
+
<button type="button" className={clsx(kit.row, kit.acct)} onClick={onAccount} data-ab-part="settings-account-row">
|
|
151
|
+
<AbProfileAvatar user={account} size={36} Icon={AbIcon} />
|
|
152
|
+
<span className={kit.acctText}><b>{account.name}</b>{account.email && <small>{account.email}</small>}</span>
|
|
153
|
+
<AbIcon name="chevron_right" size={24} className={kit.chev} />
|
|
154
|
+
</button>
|
|
155
|
+
) : ( // ๐ชง info only: plain row, not a dead button
|
|
156
|
+
<div className={clsx(kit.row, kit.acct)} data-ab-part="settings-account-row">
|
|
157
|
+
<AbProfileAvatar user={account} size={36} Icon={AbIcon} />
|
|
158
|
+
<span className={kit.acctText}><b>{account.name}</b>{account.email && <small>{account.email}</small>}</span>
|
|
159
|
+
</div>
|
|
160
|
+
)
|
|
161
|
+
) : (
|
|
162
|
+
<button type="button" className={clsx(kit.row, kit.acct)} onClick={onSignIn} data-ab-part="settings-sign-in">
|
|
163
|
+
<AbProfileAvatar size={36} Icon={AbIcon} /><span>{L.signIn}</span><AbIcon name="chevron_right" size={24} className={kit.chev} />
|
|
164
|
+
</button>
|
|
165
|
+
)}
|
|
166
|
+
</section>
|
|
167
|
+
)}
|
|
132
168
|
<p className={kit.lbl} id={`${base}-theme`}>{L.theme}</p>
|
|
133
169
|
<div ref={seg} className={kit.seg} role="radiogroup" aria-labelledby={`${base}-theme`} data-ab-part="settings-theme">
|
|
134
170
|
{themes.map((t) => (
|
|
@@ -150,6 +186,13 @@ const AbSettingsDrawer = ({ open, onClose, theme, onThemeChange, locales, locale
|
|
|
150
186
|
);
|
|
151
187
|
})}
|
|
152
188
|
</div>
|
|
189
|
+
{/* โ โน๏ธ 0.2.1: Help and About rows (back from 0.1.x), after Language */}
|
|
190
|
+
{(onHelp || onAbout) && (
|
|
191
|
+
<div className={kit.more} data-ab-part="settings-more">
|
|
192
|
+
{onHelp && <button type="button" className={kit.row} onClick={onHelp} data-ab-part="settings-help"><AbIcon name="help" size={24} /><span>{L.help}</span><AbIcon name="chevron_right" size={24} className={kit.chev} /></button>}
|
|
193
|
+
{onAbout && <button type="button" className={kit.row} onClick={onAbout} data-ab-part="settings-about"><AbIcon name="info" size={24} /><span>{L.about}</span><AbIcon name="chevron_right" size={24} className={kit.chev} /></button>}
|
|
194
|
+
</div>
|
|
195
|
+
)}
|
|
153
196
|
{children}
|
|
154
197
|
</AbDrawer>
|
|
155
198
|
);
|
package/ab-sidebar/index.tsx
CHANGED
|
@@ -56,16 +56,21 @@ import AbIcon from '../ab-icon';
|
|
|
56
56
|
import { AbSidebarView, isAbSidebarActive, type AbSidebarBaseProps } from './view';
|
|
57
57
|
// ๐จ styles
|
|
58
58
|
import styles from './styles.module.css';
|
|
59
|
+
// ๐ค 0.2.1 (God 02:44): the bottom-left profile button (โฅ 1180px, CSS)
|
|
60
|
+
import AbSidebarProfileButton, { type AbSidebarProfileButtonProps } from './profile-button';
|
|
59
61
|
|
|
60
62
|
// ๐ฆ re-export the shared types
|
|
61
63
|
export type { AbSidebarItem, AbSidebarSection, AbSidebarLink, AbSidebarLabels } from './view';
|
|
62
64
|
export { isAbSidebarActive, toAbSidebarSections } from './view';
|
|
65
|
+
export { AbSidebarProfileButton, type AbSidebarProfileButtonProps } from './profile-button';
|
|
63
66
|
|
|
64
67
|
/** โ๏ธ Client props: the shared ones + collapse control. */
|
|
65
68
|
export interface AbSidebarProps extends AbSidebarBaseProps {
|
|
66
69
|
defaultCollapsed?: boolean; // ๐ช uncontrolled start
|
|
67
70
|
onCollapsedChange?: (collapsed: boolean) => void; // ๐
|
|
68
71
|
collapsible?: boolean; // ๐ show the collapse button (default true when sections are given)
|
|
72
|
+
// ๐ค 0.2.1 (God 02:44): opt-in; pass `user` + the AbSettingsDrawer props for a profile button at the bottom left
|
|
73
|
+
profile?: Omit<AbSidebarProfileButtonProps, 'collapsed'>;
|
|
69
74
|
collapseButtonVariant?: 'plain' | 'outlined'; // โช 0.1.14 (P9): 'outlined' = 32ร32 bordered `<<` / `>>` (default 'plain' chevron)
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -106,7 +111,10 @@ const AbSidebar = (props: AbSidebarProps): ReactElement => {
|
|
|
106
111
|
</button>
|
|
107
112
|
) : undefined;
|
|
108
113
|
|
|
109
|
-
|
|
114
|
+
// ๐ค 0.2.1: the profile button joins any custom footer (label from `labels.profile`)
|
|
115
|
+
const profileButton = props.profile ? <AbSidebarProfileButton label={labels?.profile ?? 'Profile and settings'} {...props.profile} collapsed={collapsed} /> : null;
|
|
116
|
+
const footer = profileButton || props.footer != null ? <>{profileButton}{props.footer}</> : undefined; // ๐ฆถ
|
|
117
|
+
return <AbSidebarView props={{ ...props, collapsed, footer }} Icon={AbIcon} active={active} toggle={toggle} />;
|
|
110
118
|
};
|
|
111
119
|
|
|
112
120
|
// ๐ฆ exports
|
|
@@ -0,0 +1,115 @@
|
|
|
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: AbSidebarProfileButton - Client (0.2.1, God 02:44)
|
|
28
|
+
* @file: ab-sidebar/profile-button.tsx
|
|
29
|
+
* @type: Client Component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* <AbSidebar sections={โฆ} profile={{ user: { name: 'Abraham Ukachi' }, theme, onThemeChange, locales, locale, onLocaleChange }} />
|
|
34
|
+
* <AbSidebarProfileButton user={null} theme={theme} onThemeChange={setTheme} locales={LOCALES} locale={locale} onLocaleChange={setLocale} />
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
39
|
+
* MOTTO: We'll always do more ๐!!!
|
|
40
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
'use client';
|
|
45
|
+
|
|
46
|
+
// โ๏ธ React
|
|
47
|
+
import { useId, useState, type ReactElement } from 'react';
|
|
48
|
+
// ๐งต classes
|
|
49
|
+
import clsx from 'clsx';
|
|
50
|
+
// ๐ฃ client AbIcon ("person" from ab-nextjs-icons; register it like every other app glyph)
|
|
51
|
+
import AbIcon from '../ab-icon';
|
|
52
|
+
// ๐ the collapsed-rail hover / focus label (same as the rail items)
|
|
53
|
+
import AbBalloon from '../ab-balloon';
|
|
54
|
+
// ๐ค the circle: initials, photo or the profile glyph
|
|
55
|
+
import AbProfileAvatar, { type AbProfileUser } from '../ab-profile-avatar';
|
|
56
|
+
// โ๏ธ the drawer it opens
|
|
57
|
+
import AbSettingsDrawer, { type AbSettingsDrawerProps } from '../ab-settings-drawer';
|
|
58
|
+
// ๐จ styles (shared with the sidebar)
|
|
59
|
+
import styles from './styles.module.css';
|
|
60
|
+
|
|
61
|
+
/** โ๏ธ props: everything AbSettingsDrawer needs (minus the open state, which the button owns) + who is signed in */
|
|
62
|
+
export interface AbSidebarProfileButtonProps extends Omit<AbSettingsDrawerProps, 'open' | 'onClose' | 'className' | 'account'> {
|
|
63
|
+
user?: AbProfileUser | null; // ๐ค signed in (initials / photo) or signed out (null: the profile glyph)
|
|
64
|
+
label?: string; // โฟ๐ accessible name + collapsed tooltip (default "Profile and settings")
|
|
65
|
+
collapsed?: boolean; // ๐ช the sidebar is an icon rail: avatar only + a balloon tooltip
|
|
66
|
+
size?: number; // ๐ the avatar circle in px (default 40: "fairly large", the sidebar rows are 32)
|
|
67
|
+
showAccount?: boolean; // ๐ค pass `user` on to the drawer's Account section (default true)
|
|
68
|
+
className?: string; // ๐ท๏ธ on the button
|
|
69
|
+
drawerClassName?: string; // ๐ท๏ธ on the drawer
|
|
70
|
+
onOpenChange?: (open: boolean) => void; // ๐ opened / closed
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* ๐ค AbSidebarProfileButton โ the bottom-left sidebar control (God 02:44, replaces the 0.2.1-draft settings icon
|
|
75
|
+
* button): a 40px profile circle (signed out: the profile glyph; signed in: the initials on the container colour, or
|
|
76
|
+
* the photo masked to a circle) + the name when the sidebar is expanded. Tapping it opens AbSettingsDrawer.
|
|
77
|
+
*
|
|
78
|
+
* - ๐ฅ๏ธ always rendered (server too): CSS hides it below 1180px, so there's no JS gating and no first-paint flash
|
|
79
|
+
* - ๐ collapsed rail: avatar only, and an AbBalloon names it on hover / focus
|
|
80
|
+
* - โฟ a real <button>: aria-label, aria-haspopup="dialog", aria-expanded + aria-controls the drawer
|
|
81
|
+
* - โฉ๏ธ focus goes back to the button when the drawer closes (AbDrawer remembers the opener)
|
|
82
|
+
*/
|
|
83
|
+
const AbSidebarProfileButton = ({ user = null, label = 'Profile and settings', collapsed = false, size = 40, showAccount = true, className, drawerClassName, onOpenChange, id, ...drawer }: AbSidebarProfileButtonProps): ReactElement => {
|
|
84
|
+
const [open, setOpen] = useState(false); // ๐ช
|
|
85
|
+
const auto = useId(); // ๐ SSR-stable
|
|
86
|
+
const drawerId = id ?? `ab-sidebar-profile-${auto.replace(/:/g, '')}`; // ๐ aria-controls target
|
|
87
|
+
const set = (next: boolean) => { setOpen(next); onOpenChange?.(next); }; // ๐
|
|
88
|
+
const button = (
|
|
89
|
+
<button
|
|
90
|
+
type="button" // ๐งพ
|
|
91
|
+
className={clsx('AbSidebarProfileButton', styles.abSidebarProfile, className)} // ๐จ
|
|
92
|
+
data-ab-part="sidebar-profile" // ๐งฉ
|
|
93
|
+
data-signed-in={user ? 'true' : 'false'} // ๐ค
|
|
94
|
+
data-collapsed={collapsed ? 'true' : undefined} // ๐ช
|
|
95
|
+
aria-label={label} // ๐ท๏ธ
|
|
96
|
+
aria-haspopup="dialog" // โฟ
|
|
97
|
+
aria-expanded={open} // โฟ
|
|
98
|
+
aria-controls={drawerId} // โฟ
|
|
99
|
+
onClick={() => set(!open)} // ๐ฑ๏ธ
|
|
100
|
+
>
|
|
101
|
+
<AbProfileAvatar user={user} size={size} Icon={AbIcon} /> {/* ๐ค */}
|
|
102
|
+
{!collapsed && user && <span className={styles.abSidebarProfileName} aria-hidden="true">{user.name}</span> /* ๐ท๏ธ expanded: the name (the label already says it) */}
|
|
103
|
+
</button>
|
|
104
|
+
);
|
|
105
|
+
return (
|
|
106
|
+
<>
|
|
107
|
+
{collapsed ? <AbBalloon title={label} placement="end" strategy="fixed">{button}</AbBalloon> : button /* ๐ rail tooltip (fixed: the rail scrolls / clips) */}
|
|
108
|
+
<AbSettingsDrawer {...drawer} account={showAccount ? user : undefined} id={drawerId} className={drawerClassName} open={open} onClose={() => set(false)} /> {/* ๐๏ธ */}
|
|
109
|
+
</>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// ๐ฆ exports
|
|
114
|
+
export default AbSidebarProfileButton;
|
|
115
|
+
export { AbSidebarProfileButton };
|
|
@@ -192,3 +192,41 @@
|
|
|
192
192
|
* Height follows core's --ab-header-height (60px at tablet) so it lines up with the main bar. */
|
|
193
193
|
.abSidebarLogo { flex: none; display: flex; align-items: center; box-sizing: border-box; height: var(--ab-header-height, 60px); padding: 0 20px; }
|
|
194
194
|
.abSidebar[data-collapsed='true'] .abSidebarLogo { justify-content: center; padding: 0; } /* ๐ช rail: centred */
|
|
195
|
+
|
|
196
|
+
/* ๐ฆถ 0.2.1: bottom-left slot (the profile button), pinned by margin-top: auto (the sidebar is a column) */
|
|
197
|
+
.abSidebarFooter {
|
|
198
|
+
display: flex; /* ๐ */
|
|
199
|
+
align-items: center; /* โ๏ธ */
|
|
200
|
+
gap: 8px; /* โ๏ธ */
|
|
201
|
+
margin-top: auto; /* โฌ๏ธ pinned to the bottom */
|
|
202
|
+
padding-top: 8px; /* ๐ฆ */
|
|
203
|
+
position: sticky; /* ๐ stays in view when the list scrolls */
|
|
204
|
+
bottom: 0; /* โฌ๏ธ */
|
|
205
|
+
background: inherit; /* ๐จ the pane colour behind it */
|
|
206
|
+
}
|
|
207
|
+
.abSidebar[data-collapsed='true'] .abSidebarFooter { justify-content: center; } /* ๐ช rail: centred */
|
|
208
|
+
.abSidebar { min-height: 100%; } /* ๐ fill the pane so the footer can reach the bottom */
|
|
209
|
+
.abSidebar[data-density='compact'] .abSidebarFooter { padding: 8px 10px 12px; box-sizing: border-box; width: 100%; } /* ๐ฆ compact: line up with the rows (sections pad 10px) */
|
|
210
|
+
/* ๐ค 0.2.1 (God 02:44): the profile button: avatar (+ the name when expanded), theme tokens only */
|
|
211
|
+
.abSidebarProfile {
|
|
212
|
+
display: inline-flex; /* ๐ */
|
|
213
|
+
align-items: center; /* โ๏ธ */
|
|
214
|
+
gap: 10px; /* โ๏ธ */
|
|
215
|
+
max-width: 100%; /* ๐ */
|
|
216
|
+
min-height: 44px; /* ๐ touch-size */
|
|
217
|
+
padding: 2px 10px 2px 2px; /* ๐ฆ a pill around the circle */
|
|
218
|
+
border: 0; /* ๐ซ */
|
|
219
|
+
border-radius: 999px; /* ๐ */
|
|
220
|
+
background: transparent; /* ๐จ */
|
|
221
|
+
color: var(--ab-color-text, inherit); /* ๐๏ธ */
|
|
222
|
+
font: 600 13.5px/1.2 var(--ab-font-body, inherit); /* ๐ค */
|
|
223
|
+
cursor: pointer; /* ๐ */
|
|
224
|
+
}
|
|
225
|
+
.abSidebarProfile[data-collapsed='true'], .abSidebarProfile[data-signed-in='false'] { padding: 2px; } /* โญ just the circle */
|
|
226
|
+
@media (hover: hover) { .abSidebarProfile:hover { background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); } } /* ๐ฑ๏ธ */
|
|
227
|
+
.abSidebarProfile[aria-expanded='true'] { background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); } /* โ
open */
|
|
228
|
+
.abSidebarProfile:focus { outline: none; } /* ๐ฏ */
|
|
229
|
+
.abSidebarProfile:focus-visible { outline: 2px solid var(--ab-color-accent, currentColor); outline-offset: 2px; } /* โฟ */
|
|
230
|
+
.abSidebarProfileName { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* ๐ท๏ธ */
|
|
231
|
+
/* ๐ฑ mobile + tablet reach Settings another way: hidden by CSS (rendered on the server, no flash) */
|
|
232
|
+
@media (max-width: 1179.98px) { .abSidebarProfile { display: none; } }
|
package/ab-sidebar/view.tsx
CHANGED
|
@@ -79,6 +79,7 @@ export interface AbSidebarLabels {
|
|
|
79
79
|
nav?: string; // โฟ nav aria-label (default "Sidebar")
|
|
80
80
|
collapse?: string; // โ๏ธ (default "Collapse sidebar")
|
|
81
81
|
expand?: string; // โถ๏ธ (default "Expand sidebar")
|
|
82
|
+
profile?: string; // ๐ค 0.2.1: the profile button (default "Profile and settings")
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
/** ๐ฃ What the view needs from an icon component (client and server AbIcon both fit). */
|
|
@@ -101,6 +102,7 @@ export interface AbSidebarBaseProps {
|
|
|
101
102
|
// ๐ท๏ธ 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
103
|
// where the app header is hidden (tabletHeader="main" at 768โ1179); elsewhere it always shows
|
|
103
104
|
logo?: ReactNode;
|
|
105
|
+
footer?: ReactNode; // ๐ฆถ 0.2.1: a bottom slot pinned to the bottom left (e.g. AbSidebarProfileButton)
|
|
104
106
|
// ๐ฐ๏ธ legacy API (โค 0.1.12)
|
|
105
107
|
type?: 'customer' | 'admin';
|
|
106
108
|
page?: string;
|
|
@@ -158,7 +160,7 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
|
|
|
158
160
|
return (
|
|
159
161
|
<li key={item.id ?? item.href}>
|
|
160
162
|
{/* ๐ rail: a balloon names the icon on hover / focus */}
|
|
161
|
-
{collapsed && depth === 0 ? <AbBalloon title={text ?? item.href} placement="end">{link}</AbBalloon> : link}
|
|
163
|
+
{collapsed && depth === 0 ? <AbBalloon title={text ?? item.href} placement="end" strategy="fixed">{link}</AbBalloon> : link}
|
|
162
164
|
{!collapsed && item.items?.length ? (
|
|
163
165
|
<ul className={styles.abSidebarList} data-ab-part="children">{item.items.map((c) => renderItem(c, depth + 1))}</ul>
|
|
164
166
|
) : null}
|
|
@@ -191,6 +193,8 @@ export function AbSidebarView({ props, Icon, active, toggle }: {
|
|
|
191
193
|
</section>
|
|
192
194
|
))}
|
|
193
195
|
</div>
|
|
196
|
+
{/* ๐ฆถ 0.2.1: bottom-left slot (margin-top: auto pins it) */}
|
|
197
|
+
{props.footer != null && <div className={styles.abSidebarFooter} data-ab-part="sidebar-footer">{props.footer}</div>}
|
|
194
198
|
</nav>
|
|
195
199
|
);
|
|
196
200
|
}
|
package/ab-toc/index.tsx
CHANGED
|
@@ -129,3 +129,6 @@ const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavi
|
|
|
129
129
|
// ๐ฆ exports
|
|
130
130
|
export default AbToc;
|
|
131
131
|
export { AbToc };
|
|
132
|
+
|
|
133
|
+
// ๐ 0.2.1 (God 02:44): the aside "New" card
|
|
134
|
+
export { AbTocPromo, type AbTocPromoProps } from './promo';
|
package/ab-toc/promo.tsx
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
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: AbTocPromo (0.2.1, God 02:44, mock .toc-card)
|
|
28
|
+
* @file: ab-toc/promo.tsx
|
|
29
|
+
* @type: React Component (no hooks: client + server)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage (in AbToc `footer`, or anywhere in the aside):
|
|
33
|
+
* <AbTocPromo title="BottomNav & Sheet" href="/changelog">Now in <code>ab-nextjs-components</code></AbTocPromo>
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
* MOTTO: We'll always do more ๐!!!
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
// โ๏ธ React
|
|
43
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
44
|
+
// ๐งต classes
|
|
45
|
+
import clsx from 'clsx';
|
|
46
|
+
// ๐ injectable link
|
|
47
|
+
import Link from '../ab-link';
|
|
48
|
+
// ๐จ styles
|
|
49
|
+
import styles from './styles.module.css';
|
|
50
|
+
|
|
51
|
+
/** โ๏ธ props */
|
|
52
|
+
export interface AbTocPromoProps {
|
|
53
|
+
title: ReactNode; // ๐ท๏ธ 13px bold, e.g. "BottomNav & Sheet"
|
|
54
|
+
children?: ReactNode; // ๐ the 11.5px muted subtitle (a `<code>` inside is 10.5px)
|
|
55
|
+
badge?: ReactNode; // ๐ the small chip (default "New"; `null` = none)
|
|
56
|
+
href?: string; // ๐ makes the title a link (the whole card clicks)
|
|
57
|
+
className?: string; // ๐ท๏ธ
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* ๐ AbTocPromo โ the aside's "New" card (mock `.toc-card`): a rounded (12px), evenly padded (12px) container on
|
|
62
|
+
* the card colour with a 1px border; a small "New" chip, a smaller title and a relatively smaller subtitle.
|
|
63
|
+
*/
|
|
64
|
+
const AbTocPromo = ({ title, children, badge = 'New', href, className }: AbTocPromoProps): ReactElement => (
|
|
65
|
+
<aside className={clsx('AbTocPromo', styles.abTocPromo, className)} data-ab-part="toc-promo">
|
|
66
|
+
{badge != null && <span className={styles.abTocPromoChip}>{badge}</span> /* ๐ */}
|
|
67
|
+
<b className={styles.abTocPromoTitle}>{href ? <Link href={href} className={styles.abTocPromoLink}>{title}</Link> : title}</b> {/* ๐ท๏ธ */}
|
|
68
|
+
{children != null && <small className={styles.abTocPromoText}>{children}</small> /* ๐ */}
|
|
69
|
+
</aside>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// ๐ฆ exports
|
|
73
|
+
export default AbTocPromo;
|
|
74
|
+
export { AbTocPromo };
|
package/ab-toc/styles.module.css
CHANGED
|
@@ -64,3 +64,19 @@
|
|
|
64
64
|
.abTocFooter a:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; border-radius: 4px; } /* โฟ */
|
|
65
65
|
.abTocFooter a svg { flex: none; width: 15px; height: 15px; color: var(--ab-color-faint, inherit); } /* ๐ฃ GitHub ยท north_east */
|
|
66
66
|
.abTocFooter > ul { list-style: none; margin: 0; padding: 0; }
|
|
67
|
+
|
|
68
|
+
/* ๐ 0.2.1 (God 02:44): AbTocPromo, the aside "New" card (mock .toc-card), theme tokens only */
|
|
69
|
+
.abTocPromo {
|
|
70
|
+
position: relative; /* ๐ the stretched link */
|
|
71
|
+
display: flex; flex-direction: column; align-items: flex-start; gap: 6px; /* ๐ */
|
|
72
|
+
margin-top: 16px; padding: 12px; box-sizing: border-box; /* ๐ฆ evenly padded */
|
|
73
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: 12px; /* ๐ฒ rounded */
|
|
74
|
+
background: var(--ab-color-card, #fff); color: var(--ab-color-text, #211a16); /* ๐จ */
|
|
75
|
+
}
|
|
76
|
+
.abTocPromoChip { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font: 600 11px/1 var(--ab-font-code, ui-monospace, monospace); color: var(--ab-color-accent-text, #88603d); background: var(--ab-color-tint, #f4e7db); } /* ๐ */
|
|
77
|
+
.abTocPromoTitle { font-size: 13px; font-weight: 700; line-height: 1.3; } /* ๐ท๏ธ smaller title */
|
|
78
|
+
.abTocPromoText { font-size: 11.5px; line-height: 1.4; color: var(--ab-color-muted, #6b5b50); } /* ๐ relatively smaller */
|
|
79
|
+
.abTocPromoText code { font-size: 10.5px; font-family: var(--ab-font-code, ui-monospace, monospace); } /* โจ๏ธ */
|
|
80
|
+
.abTocPromoLink { color: inherit; text-decoration: none; } /* ๐ */
|
|
81
|
+
.abTocPromoLink::after { content: ''; position: absolute; inset: 0; border-radius: inherit; } /* ๐ฑ๏ธ whole card */
|
|
82
|
+
.abTocPromo:has(.abTocPromoLink:focus-visible) { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* โฟ */
|
package/index.ts
CHANGED
|
@@ -130,6 +130,7 @@ const supportedComponents: Array<ComponentCatalogEntry> = [
|
|
|
130
130
|
{ name: 'AbPackageCard', file: 'ab-package-card/index.tsx', kind: 'server', status: 'Done' },
|
|
131
131
|
// ๐ 0.1.13 docs shell (AbToc) โ server-safe, no hooks
|
|
132
132
|
{ name: 'AbToc', file: 'ab-toc/index.tsx', kind: 'server', status: 'Done' },
|
|
133
|
+
{ name: 'AbTocPromo', file: 'ab-toc/promo.tsx', kind: 'server', status: 'Done' }, // ๐ 0.2.1 the aside "New" card
|
|
133
134
|
// ๐ 0.1.14 (G53): AbDrawer + presets
|
|
134
135
|
{ name: 'AbDrawer', file: 'ab-drawer/index.tsx', kind: 'client', status: 'Done' },
|
|
135
136
|
{ name: 'AbDrawerList', file: 'ab-drawer-list/index.tsx', kind: 'client', status: 'Done' },
|
|
@@ -140,6 +141,8 @@ const supportedComponents: Array<ComponentCatalogEntry> = [
|
|
|
140
141
|
{ name: 'AbTocDrawer', file: 'ab-toc-drawer/index.tsx', kind: 'client', status: 'Done' }, // ๐ 0.2.0 drawers v2
|
|
141
142
|
{ name: 'AbNavDrawer', file: 'ab-nav-drawer/index.tsx', kind: 'client', status: 'Done' }, // ๐ 0.2.0 drawers v2
|
|
142
143
|
{ name: 'AbSettingsDrawer', file: 'ab-settings-drawer/index.tsx', kind: 'client', status: 'Done' }, // ๐ 0.2.0 drawers v2
|
|
144
|
+
{ name: 'AbSidebarProfileButton', file: 'ab-sidebar/profile-button.tsx', kind: 'client', status: 'Done' }, // ๐ 0.2.1 bottom-left profile โ settings (โฅ 1180px)
|
|
145
|
+
{ name: 'AbProfileAvatar', file: 'ab-profile-avatar/index.tsx', kind: 'server', status: 'Done' }, // ๐ 0.2.1 initials / photo / glyph circle (no hooks: client + server)
|
|
143
146
|
{ name: 'AbVersionSwitcher', file: 'ab-version-switcher/index.tsx', kind: 'client', status: 'Done' },
|
|
144
147
|
{ name: 'AbBreadcrumbs', file: 'ab-breadcrumbs/index.tsx', kind: 'server', status: 'Done' },
|
|
145
148
|
{ name: 'AbList', file: 'ab-list/index.tsx', kind: 'server', status: 'Done' },
|
|
@@ -179,13 +182,19 @@ export { default as AbBrand } from './ab-brand/index.tsx'
|
|
|
179
182
|
export { default as AbName } from './ab-name/index.tsx'
|
|
180
183
|
export { default as AbNavbar } from './ab-navbar/index.tsx'
|
|
181
184
|
export { default as AbSidebar } from './ab-sidebar/index.tsx'
|
|
185
|
+
// ๐ค 0.2.1 (God 02:44): the bottom-left sidebar profile button โ AbSettingsDrawer (laptop + wide)
|
|
186
|
+
export { default as AbSidebarProfileButton } from './ab-sidebar/profile-button.tsx'
|
|
187
|
+
export type { AbSidebarProfileButtonProps } from './ab-sidebar/profile-button.tsx'
|
|
182
188
|
// ๐ 0.1.13 (Joseph): AbToc + the panes main-scroller helpers (also at `ab-nextjs-components/ab-toc`)
|
|
183
189
|
export { default as AbToc, getAbMainScroller, AB_MAIN_SCROLLER_SELECTOR } from './ab-toc/index.tsx'
|
|
190
|
+
// ๐ 0.2.1 (God 02:44): the aside "New" card
|
|
191
|
+
export { default as AbTocPromo } from './ab-toc/promo.tsx'
|
|
192
|
+
export type { AbTocPromoProps } from './ab-toc/promo.tsx'
|
|
184
193
|
export type { AbTocItem, AbTocProps } from './ab-toc/index.tsx'
|
|
185
194
|
// ๐๏ธ 0.1.14 (G53): AbDrawer + useAbDrawer (also at `ab-nextjs-components/ab-drawer`)
|
|
186
|
-
export { default as AbDrawer, useAbDrawer, getAbDrawerHost, AB_DRAWER_DURATION } from './ab-drawer/index.tsx'
|
|
195
|
+
export { default as AbDrawer, useAbDrawer, getAbDrawerHost, AB_DRAWER_DURATION, AB_DRAWER_RETURN_FOCUS } from './ab-drawer/index.tsx'
|
|
187
196
|
// ๐ค 0.2.0 drawers v2: edge swipes + the swipe / snap rules
|
|
188
|
-
export { useAbEdgeSwipe, AB_SWIPE, resolveAbSheetRelease, resolveAbSideRelease } from './ab-drawer/index.tsx'
|
|
197
|
+
export { useAbEdgeSwipe, AB_ASIDE_DRAWER_MAX_WIDTH, AB_SWIPE, resolveAbSheetRelease, resolveAbSideRelease } from './ab-drawer/index.tsx'
|
|
189
198
|
export type { AbDrawerTier, AbSheetSnap, UseAbEdgeSwipeOptions } from './ab-drawer/index.tsx'
|
|
190
199
|
export type { AbDrawerProps, AbDrawerSide, AbDrawerScope, UseAbDrawer } from './ab-drawer/index.tsx'
|
|
191
200
|
export { default as AbDrawerList } from './ab-drawer-list/index.tsx'
|
|
@@ -210,6 +219,9 @@ export type { AbNavDrawerProps, AbNavDrawerItem, AbNavDrawerSection } from './ab
|
|
|
210
219
|
// ๐ 0.2.0 drawers v2: AbSettingsDrawer
|
|
211
220
|
export { default as AbSettingsDrawer } from './ab-settings-drawer/index.tsx'
|
|
212
221
|
export type { AbSettingsDrawerProps, AbSettingsDrawerLabels, AbSettingsLocale, AbSettingsTheme } from './ab-settings-drawer/index.tsx'
|
|
222
|
+
// ๐ค 0.2.1: the profile circle (initials / photo / signed-out glyph)
|
|
223
|
+
export { default as AbProfileAvatar, getAbInitials } from './ab-profile-avatar/index.tsx'
|
|
224
|
+
export type { AbProfileAvatarProps, AbProfileUser } from './ab-profile-avatar/index.tsx'
|
|
213
225
|
// ๐ท๏ธ 0.1.14 (P9): AbVersionSwitcher
|
|
214
226
|
export { default as AbVersionSwitcher } from './ab-version-switcher/index.tsx'
|
|
215
227
|
export type { AbVersionOption, AbVersionSwitcherProps } from './ab-version-switcher/index.tsx'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ab-nextjs-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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",
|
|
@@ -123,6 +123,7 @@
|
|
|
123
123
|
"ab-toc-drawer",
|
|
124
124
|
"ab-nav-drawer",
|
|
125
125
|
"ab-settings-drawer",
|
|
126
|
+
"ab-profile-avatar",
|
|
126
127
|
"ab-version-switcher",
|
|
127
128
|
"ab-breadcrumbs",
|
|
128
129
|
"ab-list",
|
|
@@ -175,6 +176,7 @@
|
|
|
175
176
|
"./ab-toc-drawer": "./ab-toc-drawer/index.tsx",
|
|
176
177
|
"./ab-nav-drawer": "./ab-nav-drawer/index.tsx",
|
|
177
178
|
"./ab-settings-drawer": "./ab-settings-drawer/index.tsx",
|
|
179
|
+
"./ab-profile-avatar": "./ab-profile-avatar/index.tsx",
|
|
178
180
|
"./ab-version-switcher": "./ab-version-switcher/index.tsx",
|
|
179
181
|
"./ab-breadcrumbs": "./ab-breadcrumbs/index.tsx",
|
|
180
182
|
"./ab-list": "./ab-list/index.tsx",
|
package/types/index.d.ts
CHANGED
|
@@ -77,11 +77,14 @@ export { default as AbNavbar } from '../ab-navbar/index.tsx';
|
|
|
77
77
|
export { default as AbSidebar } from '../ab-sidebar/index.tsx';
|
|
78
78
|
// ๐ 0.1.13 (Joseph): AbToc + the panes main-scroller helpers (also at `ab-nextjs-components/ab-toc`)
|
|
79
79
|
export { default as AbToc, getAbMainScroller, AB_MAIN_SCROLLER_SELECTOR } from '../ab-toc/index.tsx';
|
|
80
|
+
// ๐ 0.2.1: the aside "New" card
|
|
81
|
+
export { default as AbTocPromo } from '../ab-toc/promo.tsx';
|
|
82
|
+
export type { AbTocPromoProps } from '../ab-toc/promo.tsx';
|
|
80
83
|
export type { AbTocItem, AbTocProps } from '../ab-toc/index.tsx';
|
|
81
84
|
// ๐๏ธ 0.1.14 (G53): AbDrawer + useAbDrawer (also at `ab-nextjs-components/ab-drawer`)
|
|
82
|
-
export { default as AbDrawer, useAbDrawer, getAbDrawerHost, AB_DRAWER_DURATION } from '../ab-drawer/index.tsx';
|
|
85
|
+
export { default as AbDrawer, useAbDrawer, getAbDrawerHost, AB_DRAWER_DURATION, AB_DRAWER_RETURN_FOCUS } from '../ab-drawer/index.tsx';
|
|
83
86
|
// ๐ค 0.2.0 drawers v2: edge swipes + the swipe / snap rules
|
|
84
|
-
export { useAbEdgeSwipe, AB_SWIPE, resolveAbSheetRelease, resolveAbSideRelease } from '../ab-drawer/index.tsx';
|
|
87
|
+
export { useAbEdgeSwipe, AB_ASIDE_DRAWER_MAX_WIDTH, AB_SWIPE, resolveAbSheetRelease, resolveAbSideRelease } from '../ab-drawer/index.tsx';
|
|
85
88
|
export type { AbDrawerTier, AbSheetSnap, UseAbEdgeSwipeOptions } from '../ab-drawer/index.tsx';
|
|
86
89
|
export type { AbDrawerProps, AbDrawerSide, AbDrawerScope, UseAbDrawer } from '../ab-drawer/index.tsx';
|
|
87
90
|
export { default as AbDrawerList } from '../ab-drawer-list/index.tsx';
|
|
@@ -106,6 +109,11 @@ export type { AbNavDrawerProps, AbNavDrawerItem, AbNavDrawerSection } from '../a
|
|
|
106
109
|
// ๐ 0.2.0 drawers v2: AbSettingsDrawer
|
|
107
110
|
export { default as AbSettingsDrawer } from '../ab-settings-drawer/index.tsx';
|
|
108
111
|
export type { AbSettingsDrawerProps, AbSettingsDrawerLabels, AbSettingsLocale, AbSettingsTheme } from '../ab-settings-drawer/index.tsx';
|
|
112
|
+
// ๐ค 0.2.1: AbSidebarProfileButton + AbProfileAvatar
|
|
113
|
+
export { default as AbSidebarProfileButton } from '../ab-sidebar/profile-button.tsx';
|
|
114
|
+
export type { AbSidebarProfileButtonProps } from '../ab-sidebar/profile-button.tsx';
|
|
115
|
+
export { default as AbProfileAvatar, getAbInitials } from '../ab-profile-avatar/index.tsx';
|
|
116
|
+
export type { AbProfileAvatarProps, AbProfileUser } from '../ab-profile-avatar/index.tsx';
|
|
109
117
|
// ๐ท๏ธ 0.1.14 (P9): AbVersionSwitcher
|
|
110
118
|
export { default as AbVersionSwitcher } from '../ab-version-switcher/index.tsx';
|
|
111
119
|
export type { AbVersionOption, AbVersionSwitcherProps } from '../ab-version-switcher/index.tsx';
|