ab-nextjs-components 0.1.13 โ 0.1.14
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 +35 -0
- package/README.md +30 -0
- package/ab-app-bar/index.tsx +39 -10
- package/ab-app-bar/styles.module.css +43 -4
- package/ab-bottom-drawer/index.tsx +71 -0
- package/ab-bottom-drawer/styles.module.css +66 -0
- package/ab-breadcrumbs/index.tsx +92 -0
- package/ab-breadcrumbs/styles.module.css +54 -0
- package/ab-button/helpers.ts +6 -1
- package/ab-button/index.tsx +8 -2
- package/ab-button/styles.module.css +39 -0
- package/ab-card/styles.module.css +1 -1
- package/ab-carousel/styles.module.css +1 -1
- package/ab-chip/index.tsx +16 -4
- package/ab-chip/styles.module.css +12 -1
- package/ab-confirm-drawer/index.tsx +97 -0
- package/ab-confirm-drawer/styles.module.css +41 -0
- package/ab-drawer/index.tsx +307 -0
- package/ab-drawer/styles.module.css +127 -0
- package/ab-drawer/use-ab-drawer.ts +89 -0
- package/ab-drawer-list/index.tsx +118 -0
- package/ab-drawer-list/styles.module.css +65 -0
- package/ab-flow-diagram/styles.module.css +2 -2
- package/ab-icon/builtin.ts +4 -0
- package/ab-icon-button/index.tsx +12 -1
- package/ab-icon-button/styles.module.css +1 -1
- package/ab-install-snippet/index.tsx +51 -29
- package/ab-install-snippet/styles.module.css +34 -2
- package/ab-kbd/styles.module.css +1 -1
- package/ab-list/index.tsx +107 -0
- package/ab-list/styles.module.css +82 -0
- package/ab-locale-switcher/index.tsx +42 -10
- package/ab-locale-switcher/styles.module.css +4 -4
- package/ab-navbar/styles.module.css +20 -2
- package/ab-navbar/view.tsx +7 -4
- package/ab-package-card/index.tsx +49 -2
- package/ab-package-card/styles.module.css +40 -0
- package/ab-search-trigger/index.tsx +17 -2
- package/ab-search-trigger/styles.module.css +27 -1
- package/ab-sidebar/index.tsx +5 -2
- package/ab-sidebar/styles.module.css +48 -5
- package/ab-sidebar/view.tsx +14 -4
- package/ab-theme-toggle/index.tsx +21 -6
- package/ab-theme-toggle/styles.module.css +18 -3
- package/ab-toc/index.tsx +9 -2
- package/ab-toc/styles.module.css +20 -8
- package/ab-version-switcher/index.tsx +143 -0
- package/ab-version-switcher/styles.module.css +76 -0
- package/index.ts +27 -0
- package/package.json +18 -3
- package/server/ab-button/index.tsx +6 -2
- package/server/ab-button/styles.module.css +39 -0
- package/types/index.d.ts +19 -0
|
@@ -0,0 +1,107 @@
|
|
|
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: AbList + AbListItem (P13)
|
|
28
|
+
* @file: ab-list/index.tsx
|
|
29
|
+
* @type: Server-safe component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbList><AbListItem href="/guides/install" media={<AbIcon name="rocket_launch" />} title="Install AbElements" meta="Getting started" trailing="chevron" /></AbList>
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
* MOTTO: We'll always do more ๐!!!
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// โ๏ธ React
|
|
44
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
45
|
+
// ๐งต classes
|
|
46
|
+
import clsx from 'clsx';
|
|
47
|
+
// ๐ the app's link
|
|
48
|
+
import Link from '../ab-link';
|
|
49
|
+
// ๐ฃ the default chevron
|
|
50
|
+
import AbIcon from '../ab-icon';
|
|
51
|
+
// ๐จ styles
|
|
52
|
+
import styles from './styles.module.css';
|
|
53
|
+
|
|
54
|
+
/** โ๏ธ AbList props */
|
|
55
|
+
export interface AbListProps {
|
|
56
|
+
children: ReactNode; // ๐ AbListItem rows
|
|
57
|
+
label?: string; // โฟ optional list name
|
|
58
|
+
className?: string; // ๐ท๏ธ
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** โ๏ธ AbListItem props */
|
|
62
|
+
export interface AbListItemProps {
|
|
63
|
+
title: ReactNode; // ๐ช 13.5/600, one line with ellipsis
|
|
64
|
+
meta?: ReactNode; // ๐งพ 12px faint subline (`<code>` inside = 11px mono muted)
|
|
65
|
+
media?: ReactNode; // ๐ผ๏ธ an icon: shown in a 30px tile (card2 bg, accent-text, 18px)
|
|
66
|
+
badge?: ReactNode; // ๐ท๏ธ a leading 64ร22 badge instead of media ("New", "Improved")
|
|
67
|
+
badgeTone?: 'primary' | 'tonal'; // ๐จ primary = button colours ("New"), tonal = tint ("Improved", default)
|
|
68
|
+
trailing?: 'chevron' | ReactNode; // โก๏ธ 'chevron' = 18px faint chevron_right
|
|
69
|
+
href?: string; // ๐ the whole row becomes one link
|
|
70
|
+
className?: string; // ๐ท๏ธ
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* ๐ AbList (P13): one bordered card of rows (Guides, What's new). Radius 14, hairline border, card bg,
|
|
75
|
+
* soft shadow, rows divided by `--div`. Server-safe.
|
|
76
|
+
*/
|
|
77
|
+
const AbList = ({ children, label, className }: AbListProps): ReactElement => (
|
|
78
|
+
<ul className={clsx('AbList', styles.abList, className)} aria-label={label} data-ab-part="list">{children}</ul>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* ๐ AbListItem: `media | badge` ยท title + meta ยท `trailing`. A row with `href` is a single link (hover
|
|
83
|
+
* `--hover`, focus-visible inset 2px accent ring). Rows are at least 44px tall (touch target).
|
|
84
|
+
*/
|
|
85
|
+
const AbListItem = ({ title, meta, media, badge, badgeTone = 'tonal', trailing, href, className }: AbListItemProps): ReactElement => {
|
|
86
|
+
const body = (
|
|
87
|
+
<>
|
|
88
|
+
{badge != null ? <span className={styles.abListBadge} data-tone={badgeTone}>{badge}</span>
|
|
89
|
+
: media != null ? <span className={styles.abListMedia} aria-hidden="true">{media}</span> : null}
|
|
90
|
+
<span className={styles.abListText}>
|
|
91
|
+
<span className={styles.abListTitle}>{title}</span>
|
|
92
|
+
{meta != null && <span className={styles.abListMeta}>{meta}</span>}
|
|
93
|
+
</span>
|
|
94
|
+
{trailing === 'chevron' ? <AbIcon name="chevron_right" size={18} className={styles.abListChevron} />
|
|
95
|
+
: trailing != null ? <span className={styles.abListTrailing}>{trailing}</span> : null}
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
return (
|
|
99
|
+
<li className={clsx('AbListItem', styles.abListItem, className)} data-ab-part="list-item">
|
|
100
|
+
{href ? <Link href={href} className={styles.abListRow} data-link="true">{body}</Link> : <div className={styles.abListRow}>{body}</div>}
|
|
101
|
+
</li>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// ๐ฆ exports
|
|
106
|
+
export default AbList;
|
|
107
|
+
export { AbList, AbListItem };
|
|
@@ -0,0 +1,82 @@
|
|
|
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: AbList styles
|
|
28
|
+
* @file: ab-list/styles.module.css
|
|
29
|
+
* @type: CSS module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more ๐!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/* ๐๏ธ knobs: mock .list / .li-ic / .badge, on the ab-nextjs-theme 0.3.5 home tokens */
|
|
41
|
+
.abList {
|
|
42
|
+
--ab-list-radius: 14px; /* โญ */
|
|
43
|
+
--ab-list-background: var(--ab-color-card, #fff); /* ๐จ --card */
|
|
44
|
+
--ab-list-border: var(--ab-color-border, rgb(92 64 48 / 0.13)); /* โ --border */
|
|
45
|
+
--ab-list-divider: var(--ab-color-div, rgb(92 64 48 / 0.11)); /* โ --div */
|
|
46
|
+
--ab-list-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* ๐ --shadow */
|
|
47
|
+
--ab-list-hover: var(--ab-color-hover, rgb(166 124 82 / 0.08)); /* ๐ฑ๏ธ --hover */
|
|
48
|
+
--ab-list-ring: var(--ab-color-accent, #a67c52); /* โฟ --accent */
|
|
49
|
+
--ab-list-text: var(--ab-color-text, #211a16); /* ๐๏ธ */
|
|
50
|
+
--ab-list-muted: var(--ab-color-muted, #6b5b50); /* ๐๏ธ */
|
|
51
|
+
--ab-list-faint: var(--ab-color-faint, #807062); /* ๐๏ธ --faint โฟ AA fallback (James) */
|
|
52
|
+
--ab-list-tile: var(--ab-color-card2, #fbf3ec); /* ๐ผ๏ธ --card2 */
|
|
53
|
+
--ab-list-accent-text: var(--ab-color-accent-text, #8b6340); /* ๐๏ธ --accent-t */
|
|
54
|
+
--ab-list-tint: var(--ab-color-tint, #f4e7db); /* ๐จ --tint */
|
|
55
|
+
--ab-list-btn: var(--ab-color-btn, #a67c52); /* ๐จ --btn */
|
|
56
|
+
--ab-list-btn-text: var(--ab-color-btn-text, #fff); /* ๐จ --btn-t */
|
|
57
|
+
margin: 0; padding: 0; list-style: none; /* ๐งน */
|
|
58
|
+
border: 1px solid var(--ab-list-border); border-radius: var(--ab-list-radius); /* โ */
|
|
59
|
+
background: var(--ab-list-background); box-shadow: var(--ab-list-shadow); overflow: hidden; /* ๐จ */
|
|
60
|
+
color: var(--ab-list-text); /* ๐๏ธ */
|
|
61
|
+
}
|
|
62
|
+
.abListItem { border-top: 1px solid var(--ab-list-divider); } /* โ */
|
|
63
|
+
.abListItem:first-child { border-top: 0; } /* ๐งน */
|
|
64
|
+
.abListRow {
|
|
65
|
+
display: flex; align-items: center; gap: 12px; /* ๐ */
|
|
66
|
+
min-height: 44px; box-sizing: border-box; padding: 11px 14px; /* ๐ฆ touch target */
|
|
67
|
+
color: inherit; text-decoration: none; /* ๐ */
|
|
68
|
+
}
|
|
69
|
+
a.abListRow:hover { background: var(--ab-list-hover); } /* ๐ฑ๏ธ */
|
|
70
|
+
a.abListRow:focus-visible { outline: 2px solid var(--ab-list-ring); outline-offset: -2px; } /* โฟ inset ring */
|
|
71
|
+
.abListItem:first-child a.abListRow:focus-visible { border-radius: calc(var(--ab-list-radius) - 1px) calc(var(--ab-list-radius) - 1px) 0 0; } /* โญ */
|
|
72
|
+
.abListItem:last-child a.abListRow:focus-visible { border-radius: 0 0 calc(var(--ab-list-radius) - 1px) calc(var(--ab-list-radius) - 1px); } /* โญ */
|
|
73
|
+
.abListMedia { flex: none; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--ab-list-tile); color: var(--ab-list-accent-text); } /* ๐ผ๏ธ */
|
|
74
|
+
.abListMedia > *, .abListMedia svg { width: 18px; height: 18px; } /* ๐ฃ 18px icon (an AbIcon, or a raw <svg> at any depth) */
|
|
75
|
+
.abListBadge { flex: none; display: flex; align-items: center; justify-content: center; width: 64px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--ab-list-tint); color: var(--ab-list-accent-text); } /* ๐ท๏ธ Improved */
|
|
76
|
+
.abListBadge[data-tone='primary'] { background: var(--ab-list-btn); color: var(--ab-list-btn-text); } /* ๐ท๏ธ New */
|
|
77
|
+
.abListText { flex: 1; min-width: 0; } /* ๐ */
|
|
78
|
+
.abListTitle { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* ๐ช */
|
|
79
|
+
.abListMeta { display: block; margin-top: 2px; font-size: 12px; line-height: 1.42; color: var(--ab-list-faint); } /* ๐งพ 1.42 (~17px): rows are 59px (first) / 60px (with the divider), like the mock */
|
|
80
|
+
.abListMeta code { font-family: var(--ab-font-code, var(--ab-font-mono, ui-monospace, monospace)); font-size: 11px; color: var(--ab-list-muted); } /* ๐งพ mono pkg */
|
|
81
|
+
.abListChevron { flex: none; width: 18px; height: 18px; color: var(--ab-list-faint); } /* โก๏ธ */
|
|
82
|
+
.abListTrailing { flex: none; color: var(--ab-list-faint); } /* โก๏ธ */
|
|
@@ -49,6 +49,10 @@ import { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
|
49
49
|
import clsx from 'clsx';
|
|
50
50
|
// ๐ฃ globe glyph
|
|
51
51
|
import AbIcon from '../ab-icon';
|
|
52
|
+
// ๐๏ธ 0.1.14 (G56): drawer presentation
|
|
53
|
+
import AbDrawerList from '../ab-drawer-list';
|
|
54
|
+
import AbBottomDrawer from '../ab-bottom-drawer';
|
|
55
|
+
import type { AbDrawerScope } from '../ab-drawer';
|
|
52
56
|
// ๐จ styles
|
|
53
57
|
import styles from './styles.module.css';
|
|
54
58
|
|
|
@@ -59,6 +63,12 @@ export interface AbLocaleOption {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
// โ๏ธ props
|
|
66
|
+
/** ๐๏ธ how a picker opens (G56): popover menu, drawer, or drawer on mobile only */
|
|
67
|
+
export type AbPresentation = 'menu' | 'drawer' | 'auto';
|
|
68
|
+
/** ๐ฑ resolve `auto` at open time (no hydration flip: the server always renders the closed trigger) */
|
|
69
|
+
export const resolveAbPresentation = (p: AbPresentation = 'menu'): 'menu' | 'drawer' =>
|
|
70
|
+
p === 'auto' ? (typeof window !== 'undefined' && window.matchMedia?.('(max-width: 767.98px)').matches ? 'drawer' : 'menu') : p;
|
|
71
|
+
|
|
62
72
|
export interface AbLocaleSwitcherProps {
|
|
63
73
|
locales: readonly AbLocaleOption[]; // ๐ choices
|
|
64
74
|
current: string; // โ
active locale code
|
|
@@ -70,6 +80,10 @@ export interface AbLocaleSwitcherProps {
|
|
|
70
80
|
icon?: ReactNode; // ๐ผ๏ธ override the globe
|
|
71
81
|
className?: string; // ๐ท๏ธ
|
|
72
82
|
style?: CSSProperties; // ๐จ
|
|
83
|
+
/** ๐๏ธ 0.1.14 (G56, D40): `menu` (default) = popover menu; `drawer` = AbDrawerList; `auto` = drawer below 768px, menu above */
|
|
84
|
+
presentation?: AbPresentation;
|
|
85
|
+
drawerScope?: AbDrawerScope; // ๐บ๏ธ default 'app'
|
|
86
|
+
drawerSide?: 'top' | 'bottom' | 'start' | 'end'; // ๐งญ default 'bottom'
|
|
73
87
|
}
|
|
74
88
|
|
|
75
89
|
/**
|
|
@@ -87,7 +101,9 @@ export function getAbTypeaheadIndex(labels: readonly string[], from: number, cha
|
|
|
87
101
|
|
|
88
102
|
export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
|
|
89
103
|
// ๐งฉ props
|
|
90
|
-
const { locales, current, label, onSelect, getHref, variant = 'icon', align = 'end', icon, className, style } = props;
|
|
104
|
+
const { locales, current, label, onSelect, getHref, variant = 'icon', align = 'end', icon, className, style, presentation = 'menu', drawerScope = 'app', drawerSide = 'bottom' } = props;
|
|
105
|
+
// ๐๏ธ how this open happens (decided on click)
|
|
106
|
+
const [mode, setMode] = useState<'menu' | 'drawer'>(presentation === 'drawer' ? 'drawer' : 'menu');
|
|
91
107
|
// ๐ช open?
|
|
92
108
|
const [open, setOpen] = useState(false);
|
|
93
109
|
// ๐ ids
|
|
@@ -110,22 +126,22 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
|
|
|
110
126
|
|
|
111
127
|
// ๐ฏ on open, focus the checked item (after paint)
|
|
112
128
|
useEffect(() => {
|
|
113
|
-
if (!open) return; // ๐ค
|
|
129
|
+
if (!open || mode !== 'menu') return; // ๐ค (the drawer manages its own focus)
|
|
114
130
|
const id = requestAnimationFrame(() => focusItem(activeIndex)); // โญ๏ธ
|
|
115
131
|
return () => cancelAnimationFrame(id); // ๐งน
|
|
116
|
-
}, [open, activeIndex]);
|
|
132
|
+
}, [open, mode, activeIndex]);
|
|
117
133
|
|
|
118
134
|
// ๐ฑ๏ธ click outside closes (no focus steal)
|
|
119
135
|
useEffect(() => {
|
|
120
|
-
if (!open) return; // ๐ค
|
|
136
|
+
if (!open || mode !== 'menu') return; // ๐ค (the drawer portals outside rootRef: it has its own scrim)
|
|
121
137
|
const onDown = (e: PointerEvent) => { if (!rootRef.current?.contains(e.target as Node)) close(false); }; // ๐ช
|
|
122
138
|
document.addEventListener('pointerdown', onDown); // ๐
|
|
123
139
|
return () => document.removeEventListener('pointerdown', onDown); // ๐งน
|
|
124
|
-
}, [open, close]);
|
|
140
|
+
}, [open, mode, close]);
|
|
125
141
|
|
|
126
142
|
// โจ๏ธ trigger: ArrowDown/Up/Enter/Space open the menu
|
|
127
143
|
const onTriggerKey = (e: KeyboardEvent<HTMLButtonElement>) => {
|
|
128
|
-
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); setOpen(true); } // โฌ๏ธ
|
|
144
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); setMode(resolveAbPresentation(presentation)); setOpen(true); } // โฌ๏ธ
|
|
129
145
|
};
|
|
130
146
|
|
|
131
147
|
// โจ๏ธ menu keys
|
|
@@ -158,12 +174,12 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
|
|
|
158
174
|
id={`${base}-trigger`} // ๐
|
|
159
175
|
type="button" // ๐งพ
|
|
160
176
|
className={clsx(styles.trigger, variant === 'menu' && styles.withText)} // ๐จ
|
|
161
|
-
aria-haspopup=
|
|
177
|
+
aria-haspopup={mode === 'drawer' ? 'dialog' : 'menu'} // โฟ
|
|
162
178
|
aria-expanded={open} // โฟ
|
|
163
|
-
aria-controls={`${base}-menu`} // ๐
|
|
179
|
+
aria-controls={mode === 'drawer' ? `${base}-drawer` : `${base}-menu`} // ๐
|
|
164
180
|
aria-label={variant === 'icon' ? `${label}: ${active?.label ?? current}` : undefined} // ๐ท๏ธ "Language: Franรงais"
|
|
165
181
|
title={label} // ๐ฌ
|
|
166
|
-
onClick={() => setOpen((o) => !o)} // ๐ฑ๏ธ
|
|
182
|
+
onClick={() => { if (!open) setMode(resolveAbPresentation(presentation)); setOpen((o) => !o); }} // ๐ฑ๏ธ (`auto` picks menu / drawer now)
|
|
167
183
|
onKeyDown={onTriggerKey} // โจ๏ธ
|
|
168
184
|
>
|
|
169
185
|
<span aria-hidden="true">{icon ?? <AbIcon name="language" size={20} />}</span>
|
|
@@ -174,7 +190,7 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
|
|
|
174
190
|
id={`${base}-menu`} // ๐
|
|
175
191
|
role="menu" // โฟ
|
|
176
192
|
aria-labelledby={`${base}-trigger`} // ๐
|
|
177
|
-
hidden={!open} // ๐
|
|
193
|
+
hidden={!open || mode !== 'menu'} // ๐
|
|
178
194
|
className={styles.menu} // ๐จ
|
|
179
195
|
onKeyDown={onMenuKey} // โจ๏ธ
|
|
180
196
|
>
|
|
@@ -205,6 +221,22 @@ export function AbLocaleSwitcher(props: AbLocaleSwitcherProps) {
|
|
|
205
221
|
);
|
|
206
222
|
})}
|
|
207
223
|
</ul>
|
|
224
|
+
{/* ๐๏ธ 0.1.14 (G56): drawer presentation. No in-flow fallback here: the <details> below already is one */}
|
|
225
|
+
{presentation !== 'menu' ? (
|
|
226
|
+
<AbDrawerList
|
|
227
|
+
id={`${base}-drawer`}
|
|
228
|
+
open={open && mode === 'drawer'}
|
|
229
|
+
onClose={() => setOpen(false)} // ๐ช the drawer puts focus back on the trigger
|
|
230
|
+
scope={drawerScope}
|
|
231
|
+
side={drawerSide}
|
|
232
|
+
as={drawerSide === 'bottom' ? AbBottomDrawer : undefined} // ๐ฑ the mobile bottom drawer look
|
|
233
|
+
title={label}
|
|
234
|
+
noJsFallback={false}
|
|
235
|
+
value={current}
|
|
236
|
+
items={locales.map((l) => ({ value: l.code, label: l.label, lang: l.code, href: getHref?.(l.code) }))}
|
|
237
|
+
onSelect={(code) => onSelect?.(code)}
|
|
238
|
+
/>
|
|
239
|
+
) : null}
|
|
208
240
|
{/* ๐ซ JS off (0.1.13, gap-review): a native <details> list of hreflang links replaces the menu.
|
|
209
241
|
Only rendered with getHref (a callback can't run without JS). CSS shows it under (scripting: none). */}
|
|
210
242
|
{getHref ? (
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
}
|
|
64
64
|
.trigger:hover,
|
|
65
65
|
.trigger[aria-expanded='true'] {
|
|
66
|
-
background: color-mix(in srgb, currentColor 10%, transparent); /* ๐ซ๏ธ */
|
|
66
|
+
background: var(--ab-color-hover, color-mix(in srgb, currentColor 10%, transparent)); /* ๐ซ๏ธ */
|
|
67
67
|
}
|
|
68
68
|
.trigger:focus-visible,
|
|
69
69
|
.item:focus-visible {
|
|
70
|
-
outline: 2px solid var(--ab-focus-ring, var(--ab-color-primary, #A67C52)); /* ๐ */
|
|
70
|
+
outline: 2px solid var(--ab-color-accent, var(--ab-focus-ring, var(--ab-color-primary, #A67C52))); /* ๐ */
|
|
71
71
|
outline-offset: 2px; /* โ๏ธ */
|
|
72
72
|
}
|
|
73
73
|
@media (pointer: coarse) {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
padding: 0.25rem; /* ๐งฑ */
|
|
86
86
|
list-style: none; /* ๐งน */
|
|
87
87
|
border-radius: 0.75rem; /* ๐ฒ */
|
|
88
|
-
border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* ๐๏ธ */
|
|
88
|
+
border: 1px solid var(--ab-color-border, var(--ab-color-outline-variant, rgb(0 0 0 / 0.12))); /* ๐๏ธ */
|
|
89
89
|
background: var(--ab-color-surface, #fff); /* ๐จ */
|
|
90
90
|
box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); /* ๐ซ๏ธ */
|
|
91
91
|
}
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
}
|
|
117
117
|
.item:hover,
|
|
118
118
|
.item:focus-visible {
|
|
119
|
-
background: color-mix(in srgb, currentColor 8%, transparent); /* ๐ซ๏ธ */
|
|
119
|
+
background: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); /* ๐ซ๏ธ */
|
|
120
120
|
}
|
|
121
121
|
.item[aria-checked='true'] {
|
|
122
122
|
font-weight: 600; /* ๐ช */
|
|
@@ -77,10 +77,10 @@
|
|
|
77
77
|
.abNavbarLink[data-active='true'],
|
|
78
78
|
.abNavbarLink[aria-expanded='true'] { color: var(--ab-color-on-surface, inherit); } /* ๐ฏ */
|
|
79
79
|
.abNavbarLink[data-active='true'] .abNavbarPill,
|
|
80
|
-
.abNavbarLink[aria-expanded='true'] .abNavbarPill { background: var(--ab-color-secondary-container, rgb(0 0 0 / 0.08)); } /* ๐ฏ */
|
|
80
|
+
.abNavbarLink[aria-expanded='true'] .abNavbarPill { background: var(--ab-color-tint, var(--ab-color-secondary-container, rgb(0 0 0 / 0.08))); } /* ๐ฏ */
|
|
81
81
|
.abNavbarLink[data-active='true'] .abNavbarLabel { font-weight: 700; } /* ๐ค */
|
|
82
82
|
.abNavbarLink:focus-visible {
|
|
83
|
-
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* โฟ */
|
|
83
|
+
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); /* โฟ */
|
|
84
84
|
outline-offset: var(--ab-focus-ring-offset, 2px); /* โฟ */
|
|
85
85
|
border-radius: 12px; /* ๐ข */
|
|
86
86
|
}
|
|
@@ -89,3 +89,21 @@
|
|
|
89
89
|
.abNavbarLink[aria-disabled='true'] { cursor: default; opacity: 0.6; } /* ๐ซ */
|
|
90
90
|
.abNavbarSoon { font-size: 10px; line-height: 12px; opacity: 0.85; } /* ๐ง tag under the label */
|
|
91
91
|
.abNavbarSrOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* ๐ถ๏ธ */
|
|
92
|
+
|
|
93
|
+
/* ===== ๐ฑ 0.1.14 (P18, Home spec ยง4 bottom nav): indicator="none" ยท blur ===== */
|
|
94
|
+
.abNavbar[data-indicator='none'] { padding-top: 8px; padding-bottom: env(safe-area-inset-bottom, 0px); min-height: calc(50px + env(safe-area-inset-bottom, 0px)); box-sizing: border-box; } /* ๐ 84px with the iPhone home indicator */
|
|
95
|
+
.abNavbar[data-indicator='none'] .abNavbarList { justify-content: space-around; }
|
|
96
|
+
.abNavbar[data-indicator='none'] .abNavbarList > li { flex: 0 1 80px; } /* โ๏ธ 4 ร 80px */
|
|
97
|
+
.abNavbar[data-indicator='none'] .abNavbarLink { width: 80px; min-width: 0; gap: 3px; color: var(--ab-color-faint, inherit); } /* ๐ */
|
|
98
|
+
.abNavbar[data-indicator='none'] .abNavbarLink .abNavbarPill { width: auto; height: auto; background: none; } /* ๐ซ pill (0,4,0 beats the active pill rules) */
|
|
99
|
+
.abNavbar[data-indicator='none'] .abNavbarLabel { font-size: 11.5px; font-weight: 550; line-height: 1.2; } /* ๐ค */
|
|
100
|
+
.abNavbar[data-indicator='none'] .abNavbarLink[data-active='true'],
|
|
101
|
+
.abNavbar[data-indicator='none'] .abNavbarLink[aria-expanded='true'] { color: var(--ab-color-accent-text, inherit); } /* ๐ฏ */
|
|
102
|
+
.abNavbar[data-indicator='none'] .abNavbarLink[data-active='true'] .abNavbarLabel { font-weight: 700; }
|
|
103
|
+
.abNavbar[data-indicator='none'] .abNavbarLink:focus-visible { outline-color: var(--ab-color-accent, #a67c52); }
|
|
104
|
+
.abNavbar[data-blur='true'] {
|
|
105
|
+
background: color-mix(in srgb, var(--ab-color-bg, #fff8f5) 92%, transparent); /* ๐ซ๏ธ */
|
|
106
|
+
-webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); /* ๐ง */
|
|
107
|
+
border-top: 1px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); /* โ */
|
|
108
|
+
}
|
|
109
|
+
:global(.dark) .abNavbar[data-blur='true'], :global([data-theme='dark']) .abNavbar[data-blur='true'] { background: #1f170f; } /* ๐ mock: solid warm */
|
package/ab-navbar/view.tsx
CHANGED
|
@@ -87,6 +87,8 @@ export interface AbNavbarBaseProps<I extends AbNavbarItem = AbNavbarItem> {
|
|
|
87
87
|
activeHref?: string; // ๐ฏ
|
|
88
88
|
locales?: readonly string[]; // ๐ 0.1.13: stripped from the pathname (default: AbLinkProvider's)
|
|
89
89
|
label?: string; // โฟ nav aria-label (default "Primary")
|
|
90
|
+
indicator?: 'pill' | 'none'; // ๐ฏ 0.1.14 (P18): 'none' = no active pill; 25px icons, accent text (the Home bottom nav). Default 'pill'
|
|
91
|
+
blur?: boolean; // ๐ซ๏ธ 0.1.14 (P18): translucent --bg + 12px backdrop blur + --div top hairline
|
|
90
92
|
// ๐ฐ๏ธ legacy
|
|
91
93
|
type?: 'customer' | 'admin';
|
|
92
94
|
page?: string;
|
|
@@ -106,13 +108,14 @@ export function AbNavbarView({ props, Icon, active }: {
|
|
|
106
108
|
Icon: AbNavbarIconComponent;
|
|
107
109
|
active: (href: string, legacyValue?: string) => boolean;
|
|
108
110
|
}): ReactElement {
|
|
109
|
-
const { className, items, links, label = 'Primary', type = 'customer' } = props;
|
|
111
|
+
const { className, items, links, label = 'Primary', type = 'customer', indicator = 'pill', blur = false } = props;
|
|
112
|
+
const iconSize = indicator === 'none' ? 25 : 24; // ๐ฃ P18
|
|
110
113
|
// ๐ฐ๏ธ legacy links โ link items
|
|
111
114
|
const list: AbNavbarItem[] = items?.length ? items : (links ?? []).map(({ href, icon, label: l }) => ({ kind: 'link', href, icon, label: l }));
|
|
112
115
|
const valueOf = (href: string) => links?.find((l) => l.href === href)?.value;
|
|
113
116
|
|
|
114
117
|
return (
|
|
115
|
-
<nav data-type={type} data-ab-part="bottomBar" className={clsx('AbNavbar', styles.abNavbar, className)} aria-label={label}>
|
|
118
|
+
<nav data-type={type} data-ab-part="bottomBar" className={clsx('AbNavbar', styles.abNavbar, className)} aria-label={label} data-indicator={indicator === 'none' ? 'none' : undefined} data-blur={blur ? 'true' : undefined}>
|
|
116
119
|
<ul className={styles.abNavbarList}>
|
|
117
120
|
{list.map((item) => {
|
|
118
121
|
if (item.kind === 'button') {
|
|
@@ -132,7 +135,7 @@ export function AbNavbarView({ props, Icon, active }: {
|
|
|
132
135
|
data-coming-soon={item.comingSoon ? 'true' : undefined} // ๐ง
|
|
133
136
|
onClick={inert ? undefined : item.onSelect}
|
|
134
137
|
>
|
|
135
|
-
<span className={styles.abNavbarPill}><Icon name={item.icon} variant={item.expanded ? 'filled' : 'outlined'} size={
|
|
138
|
+
<span className={styles.abNavbarPill}><Icon name={item.icon} variant={item.expanded ? 'filled' : 'outlined'} size={iconSize} /></span>
|
|
136
139
|
<span className={styles.abNavbarLabel}>{item.label}</span>
|
|
137
140
|
{soon && <span className={styles.abNavbarSoon} data-ab-part="badge"><span className={styles.abNavbarSrOnly}>, </span>{soon}</span>}
|
|
138
141
|
</button>
|
|
@@ -151,7 +154,7 @@ export function AbNavbarView({ props, Icon, active }: {
|
|
|
151
154
|
data-active={on ? 'true' : 'false'}
|
|
152
155
|
aria-current={on ? 'page' : undefined} // โฟ
|
|
153
156
|
>
|
|
154
|
-
<span className={styles.abNavbarPill}><Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={
|
|
157
|
+
<span className={styles.abNavbarPill}><Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={iconSize} /></span>
|
|
155
158
|
<span className={styles.abNavbarLabel}>{item.label}</span>
|
|
156
159
|
</Link>
|
|
157
160
|
</li>
|
|
@@ -40,9 +40,20 @@
|
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
42
|
// โ๏ธ React
|
|
43
|
-
import type { ReactElement, ReactNode } from 'react';
|
|
43
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
44
|
+
// ๐งต classes
|
|
45
|
+
import clsx from 'clsx';
|
|
44
46
|
// ๐ base card
|
|
45
47
|
import AbCard from '../ab-card';
|
|
48
|
+
// ๐ G42 link
|
|
49
|
+
import Link from '../ab-link';
|
|
50
|
+
// ๐ท๏ธ footer chips (0.1.14)
|
|
51
|
+
import AbChip from '../ab-chip';
|
|
52
|
+
// ๐ฃ trailing arrow
|
|
53
|
+
import AbIcon from '../ab-icon';
|
|
54
|
+
// ๐ฌ motion classes (ab-nextjs-animations โฅ 0.2.4)
|
|
55
|
+
import { AB_MOTION } from 'ab-nextjs-animations/motion';
|
|
56
|
+
import 'ab-nextjs-animations/motion/styles.css';
|
|
46
57
|
// ๐จ styles
|
|
47
58
|
import styles from './styles.module.css';
|
|
48
59
|
|
|
@@ -59,6 +70,11 @@ export interface AbPackageCardProps {
|
|
|
59
70
|
tags?: string[]; // ๐ท๏ธ e.g. ['client', 'server']
|
|
60
71
|
headingLevel?: 2 | 3 | 4; // โฟ
|
|
61
72
|
className?: string; // ๐ท๏ธ
|
|
73
|
+
// ๐ 0.1.14 (P10, Home spec ยง4 package card). Passing `preview` or `title` switches to the Home layout:
|
|
74
|
+
// 56px preview tile ยท 30px icon tile + display title + mono name ยท clamped description ยท chips + โ
|
|
75
|
+
preview?: ReactNode; // ๐ผ๏ธ decorative preview tile content (Aa Aa Aa, swatches, a curveโฆ), aria-hidden
|
|
76
|
+
title?: ReactNode; // ๐ท๏ธ display name (e.g. "Fonts"); `name` becomes the mono subtitle
|
|
77
|
+
descriptionLines?: number; // โ๏ธ clamp the description (Home: 2)
|
|
62
78
|
}
|
|
63
79
|
|
|
64
80
|
/**
|
|
@@ -70,7 +86,38 @@ export function toAbPackageNameParts(name: string): ReactNode[] {
|
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
/** ๐ฆ AbPackageCard (G45): a package tile on AbCard (one link, 2px lift on laptop+, none when reduced). */
|
|
73
|
-
const AbPackageCard = (
|
|
89
|
+
const AbPackageCard = (props: AbPackageCardProps): ReactElement => (props.preview != null || props.title != null ? <AbPackageCardHome {...props} /> : <AbPackageCardLegacy {...props} />);
|
|
90
|
+
|
|
91
|
+
/** ๐ 0.1.14 (P10): the Home layout. One link (the title, stretched over the card), focus ring on the card. */
|
|
92
|
+
function AbPackageCardHome({ name, href, description, version, icon, media, id, badge, tags, headingLevel = 3, className, preview, title, descriptionLines }: AbPackageCardProps): ReactElement {
|
|
93
|
+
const H = `h${headingLevel}` as 'h2' | 'h3' | 'h4'; // โฟ
|
|
94
|
+
const clamp = descriptionLines ? ({ '--ab-package-card-lines': descriptionLines } as CSSProperties) : undefined; // โ๏ธ
|
|
95
|
+
return (
|
|
96
|
+
<article id={id} className={clsx('AbPackageCard', styles.home, AB_MOTION.interactive, className)} data-ab-part="package-card" data-variant="home">
|
|
97
|
+
{preview != null && <div className={styles.homePreview} aria-hidden="true">{preview}</div> /* ๐ผ๏ธ decorative */}
|
|
98
|
+
<div className={styles.homeHead}>
|
|
99
|
+
{(media ?? icon) != null && <span className={styles.homeIcon} aria-hidden="true">{media ?? icon}</span>}
|
|
100
|
+
<div className={styles.homeTitles}>
|
|
101
|
+
<H className={styles.homeTitle}><Link href={href} className={styles.homeLink}>{title ?? name}</Link></H>
|
|
102
|
+
{title != null && <code className={styles.homeName}>{name}</code> /* โจ๏ธ the npm name */}
|
|
103
|
+
</div>
|
|
104
|
+
{badge != null && <span className={styles.homeBadge}>{badge}</span>}
|
|
105
|
+
</div>
|
|
106
|
+
{description != null && <p className={styles.homeDesc} data-clamp={descriptionLines ? 'true' : undefined} style={clamp}>{description}</p>}
|
|
107
|
+
{(version || tags?.length) ? (
|
|
108
|
+
<div className={styles.homeFoot}>
|
|
109
|
+
{version && <AbChip size="sm" shape="rounded" mono tone="accent">v{version}</AbChip>}
|
|
110
|
+
{tags?.map((t) => <AbChip key={t} size="sm" shape="rounded" mono tone="sage" className={styles.homeTag}>{t}</AbChip>)}
|
|
111
|
+
<span className={styles.homeGrow} />
|
|
112
|
+
<AbIcon name="arrow_forward" size={16} className={styles.homeGo} />
|
|
113
|
+
</div>
|
|
114
|
+
) : null}
|
|
115
|
+
</article>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** ๐ฐ๏ธ โค 0.1.13 layout on AbCard. */
|
|
120
|
+
const AbPackageCardLegacy = ({ name, href, description, version, icon, media, id, badge, tags, headingLevel, className }: AbPackageCardProps): ReactElement => (
|
|
74
121
|
<AbCard
|
|
75
122
|
id={id}
|
|
76
123
|
className={className}
|
|
@@ -39,3 +39,43 @@
|
|
|
39
39
|
.abPackageCardName { font-family: var(--ab-font-code, var(--ab-font-mono, ui-monospace, monospace)); font-size: 16px; overflow-wrap: anywhere; word-break: normal; hyphens: none; display: block; min-width: 0; max-width: 100%; } /* ๐ฆ 0.1.13 (Joseph): wraps at the <wbr> after a hyphen first (ab-nextjs-/components); `anywhere` only splits a part that alone is wider than a very narrow card (animations at ~70px), so it never overflows */
|
|
40
40
|
.abPackageCardVersion { font-family: var(--ab-font-code, var(--ab-font-mono, ui-monospace, monospace)); opacity: 0.8; } /* ๐ท๏ธ */
|
|
41
41
|
.abPackageCardTag { padding: 0 8px; border-radius: 999px; line-height: 20px; background: var(--ab-color-surface-container-high, rgb(0 0 0 / 0.06)); } /* ๐ท๏ธ */
|
|
42
|
+
|
|
43
|
+
/* ===== ๐ 0.1.14 (P10, Home spec ยง4 package card) ===== */
|
|
44
|
+
.home {
|
|
45
|
+
position: relative; display: flex; flex-direction: column; min-width: 0; box-sizing: border-box; /* ๐ */
|
|
46
|
+
padding: 10px 10px 12px; border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-card, 14px); /* ๐ฒ */
|
|
47
|
+
background: var(--ab-color-card, #fff); color: var(--ab-color-text, #211a16); box-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* ๐จ */
|
|
48
|
+
/* ๐๏ธ the fade + lift timing comes from ab-nextjs-animations (.ab-motion-interactive on the element) */
|
|
49
|
+
}
|
|
50
|
+
.home:hover { border-color: color-mix(in srgb, var(--ab-color-accent, #a67c52) 40%, transparent); transform: translateY(-1px); } /* ๐ฑ๏ธ */
|
|
51
|
+
.home:has(.homeLink:focus-visible) { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* โฟ ring on the card */
|
|
52
|
+
.homeLink { color: inherit; text-decoration: none; outline: none; } /* ๐ */
|
|
53
|
+
.homeLink::after { content: ''; position: absolute; inset: 0; border-radius: inherit; } /* ๐ฑ๏ธ the whole card clicks */
|
|
54
|
+
.homePreview {
|
|
55
|
+
height: 56px; border-radius: var(--ab-radius-tile, 9px); background: var(--ab-color-card2, #fbf3ec); /* ๐ผ๏ธ */
|
|
56
|
+
display: flex; align-items: center; justify-content: center; gap: 10px; overflow: hidden; color: var(--ab-color-accent-text, #88603d);
|
|
57
|
+
}
|
|
58
|
+
.homeHead { display: flex; align-items: center; gap: 9px; margin-top: 11px; padding: 0 2px; min-width: 0; } /* ๐ */
|
|
59
|
+
.homeIcon {
|
|
60
|
+
flex: none; width: 30px; height: 30px; border-radius: var(--ab-radius-row, 8px); /* ๐ฒ */
|
|
61
|
+
background: var(--ab-color-tint, #f4e7db); color: var(--ab-color-accent-text, #88603d); display: flex; align-items: center; justify-content: center;
|
|
62
|
+
}
|
|
63
|
+
.homeIcon svg { width: 18px; height: 18px; } /* ๐ฃ */
|
|
64
|
+
.homeTitles { min-width: 0; } /* โ๏ธ */
|
|
65
|
+
.homeTitle { margin: 0; font-family: var(--ab-font-title, inherit); font-size: 14px; font-weight: 800; line-height: 1.2; letter-spacing: -0.005em; } /* ๐ท๏ธ Mulish */
|
|
66
|
+
.homeName { display: block; margin-top: 1px; font: 400 11px/1.3 var(--ab-font-code, ui-monospace, monospace); color: var(--ab-color-faint, #807062); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* โจ๏ธ */
|
|
67
|
+
.homeBadge { margin-inline-start: auto; flex: none; } /* ๐ด */
|
|
68
|
+
.homeDesc { margin: 8px 0 0; padding: 0 2px; font-size: 12.5px; line-height: 1.45; color: var(--ab-color-muted, #6b5b50); min-height: 36px; } /* ๐ */
|
|
69
|
+
.homeDesc[data-clamp='true'] { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ab-package-card-lines, 2); line-clamp: var(--ab-package-card-lines, 2); overflow: hidden; } /* โ๏ธ */
|
|
70
|
+
.homeFoot { display: flex; align-items: center; margin-top: 10px; padding: 0 2px; } /* ๐ท๏ธ */
|
|
71
|
+
.homeTag { margin-inline-start: 6px; } /* ๐ฟ */
|
|
72
|
+
.homeGrow { flex: 1; } /* โ๏ธ */
|
|
73
|
+
.homeGo { width: 16px; height: 16px; color: var(--ab-color-faint, #807062); } /* โ */
|
|
74
|
+
@media (max-width: 767px) {
|
|
75
|
+
.home { padding: 8px 8px 10px; border-radius: 13px; } /* ๐ฑ */
|
|
76
|
+
.homePreview { height: 44px; }
|
|
77
|
+
.homeHead { margin-top: 9px; }
|
|
78
|
+
.homeDesc { margin-top: 6px; font-size: 12px; }
|
|
79
|
+
.homeFoot { margin-top: 8px; }
|
|
80
|
+
}
|
|
81
|
+
@media (prefers-reduced-motion: reduce) { .home:hover { transform: none; } } /* โฟ no lift */
|
|
@@ -63,6 +63,8 @@ export interface AbSearchTriggerProps {
|
|
|
63
63
|
compact?: boolean; // ๐ฑ icon-only pill (the label stays for screen readers), e.g. the mobile app bar
|
|
64
64
|
comingSoon?: boolean; // ๐ง visible but inert: aria-disabled, no hotkey
|
|
65
65
|
comingSoonLabel?: string; // ๐ท๏ธ default "Coming soon"
|
|
66
|
+
variant?: 'pill' | 'field'; // ๐ 0.1.14 (P6): 'field' = the Home 300ร36 bordered field (default 'pill', the legacy look)
|
|
67
|
+
size?: 'md' | 'sm'; // ๐ฑ 0.1.14 (P6): 'sm' = the mobile 34px "Search โK" pill (label + key cap stay visible)
|
|
66
68
|
className?: string; // ๐ท๏ธ
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -80,7 +82,7 @@ export function isAbApplePlatform(nav?: { platform?: string; userAgent?: string;
|
|
|
80
82
|
* announces `aria-keyshortcuts="Meta+K Control+K"`, and falls back to a link when there's no `onOpen`.
|
|
81
83
|
* Note: the hotkey is a local listener; G48 `useAbHotkey` is deliberately not in hooks 0.1.7.
|
|
82
84
|
*/
|
|
83
|
-
const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, compact = false, comingSoon = false, comingSoonLabel = 'Coming soon', className }: AbSearchTriggerProps): ReactElement => {
|
|
85
|
+
const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, compact = false, comingSoon = false, comingSoonLabel = 'Coming soon', variant = 'pill', size = 'md', className }: AbSearchTriggerProps): ReactElement => {
|
|
84
86
|
// ๐ SSR renders "Ctrl"; hydration then reads the platform (useSyncExternalStore: no mismatch, no effect)
|
|
85
87
|
const apple = useSyncExternalStore(
|
|
86
88
|
noopSubscribe, // ๐ the platform never changes
|
|
@@ -101,8 +103,18 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
101
103
|
return () => window.removeEventListener('keydown', onKey); // ๐งน
|
|
102
104
|
}, [listen, onOpen]);
|
|
103
105
|
|
|
106
|
+
// ๐ P6: the Home looks (field / sm pill) show ONE key cap ("โ K" / "โK") and keep "coming soon" out of the field
|
|
107
|
+
const home = variant === 'field' || size === 'sm';
|
|
108
|
+
const keyCap = (apple ? 'โ' : 'Ctrl') + (size === 'sm' ? '' : ' ') + 'K'; // โจ๏ธ mock: "โ K" (field) ยท "โK" (sm)
|
|
104
109
|
// ๐งฉ inner content
|
|
105
|
-
const inner = (
|
|
110
|
+
const inner = home ? (
|
|
111
|
+
<>
|
|
112
|
+
<AbIcon name="search" size={size === 'sm' ? 17 : 18} className={styles.abSearchTriggerIcon} />
|
|
113
|
+
<span className={styles.abSearchTriggerLabel}>{label}</span>
|
|
114
|
+
{/* ๐ง coming soon: tooltip + announced, never painted inside the field (spec ยง4) */}
|
|
115
|
+
{comingSoon ? <span className={styles.abSearchTriggerSrOnly}>, {comingSoonLabel}</span> : listen && <AbKbd className={styles.abSearchTriggerCap}>{keyCap}</AbKbd>}
|
|
116
|
+
</>
|
|
117
|
+
) : (
|
|
106
118
|
<>
|
|
107
119
|
<AbIcon name="search" size={20} className={styles.abSearchTriggerIcon} />
|
|
108
120
|
<span className={clsx(styles.abSearchTriggerLabel, compact && styles.abSearchTriggerSrOnly)}>{label}</span>
|
|
@@ -117,6 +129,9 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
117
129
|
'data-ab-part': 'search-trigger', // ๐งฉ
|
|
118
130
|
'aria-keyshortcuts': listen ? 'Meta+K Control+K' : undefined, // โฟ only announced when bound (James #3)
|
|
119
131
|
'data-compact': compact ? 'true' : undefined, // ๐ฑ
|
|
132
|
+
'data-variant': variant === 'field' ? 'field' : undefined, // ๐ P6
|
|
133
|
+
'data-size': size === 'sm' ? 'sm' : undefined, // ๐ฑ P6
|
|
134
|
+
title: home && comingSoon ? comingSoonLabel : undefined, // ๐ฌ P6: "coming soon" lives in the tooltip
|
|
120
135
|
};
|
|
121
136
|
|
|
122
137
|
// ๐ง coming soon: focusable, announced, inert
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
box-sizing: border-box; /* ๐ฆ */
|
|
57
57
|
}
|
|
58
58
|
.abSearchTrigger:focus-visible {
|
|
59
|
-
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* โฟ */
|
|
59
|
+
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); /* โฟ */
|
|
60
60
|
outline-offset: var(--ab-focus-ring-offset, 2px); /* โฟ */
|
|
61
61
|
}
|
|
62
62
|
.abSearchTrigger[aria-disabled='true'] { cursor: default; opacity: 0.72; } /* ๐ง */
|
|
@@ -68,3 +68,29 @@
|
|
|
68
68
|
.abSearchTrigger[data-compact='true'] { flex: none; width: 40px; min-width: 40px; padding: 0; justify-content: center; } /* ๐ */
|
|
69
69
|
/* ๐ถ๏ธ visually hidden, still read by screen readers */
|
|
70
70
|
.abSearchTriggerSrOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; flex: none; }
|
|
71
|
+
|
|
72
|
+
/* ===== ๐ 0.1.14 (P6, Home spec ยง4): variant="field" (300ร36) ยท size="sm" (mobile 34px pill) ===== */
|
|
73
|
+
.abSearchTrigger[data-variant='field'] {
|
|
74
|
+
width: var(--ab-search-trigger-width, 300px); max-width: 100%; height: 36px; /* ๐ desktop 360 / tablet 260 via the var */
|
|
75
|
+
gap: 8px; padding: 0 6px 0 10px; /* ๐ฆ */
|
|
76
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-button, 10px); /* ๐ฒ */
|
|
77
|
+
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); /* ๐จ */
|
|
78
|
+
font-size: 13.5px; line-height: 1; box-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* ๐ค ๐ */
|
|
79
|
+
}
|
|
80
|
+
.abSearchTrigger[data-size='sm'] {
|
|
81
|
+
flex: none; width: auto; max-width: none; height: 34px; /* ๐ */
|
|
82
|
+
gap: 6px; padding: 0 6px 0 10px; /* ๐ฆ */
|
|
83
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-pill, 999px); /* ๐ */
|
|
84
|
+
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); font-size: 13px; line-height: 1; /* ๐จ ๐ค */
|
|
85
|
+
}
|
|
86
|
+
.abSearchTrigger[data-variant='field']:hover, .abSearchTrigger[data-size='sm']:hover { border-color: color-mix(in srgb, var(--ab-color-accent, #a67c52) 40%, transparent); } /* ๐ฑ๏ธ */
|
|
87
|
+
.abSearchTrigger[data-variant='field']:focus-visible, .abSearchTrigger[data-size='sm']:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* โฟ */
|
|
88
|
+
/* โจ๏ธ the single key cap (mock `kbd`): 20px, radius 5, 2px bottom border, 11/600 --muted */
|
|
89
|
+
.abSearchTriggerCap.abSearchTriggerCap {
|
|
90
|
+
flex: none; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; /* ๐ */
|
|
91
|
+
min-width: 20px; height: 20px; padding: 0 5px; margin-left: 2px; /* ๐ */
|
|
92
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-bottom-width: 2px; border-radius: var(--ab-radius-kbd, 5px); /* ๐ฒ */
|
|
93
|
+
background: var(--ab-color-kbd, #fff); color: var(--ab-color-muted, #6b5b50); font: 600 11px/1 var(--ab-font-body, inherit); /* ๐ค Inter: fine for โ (spec ยง2) */
|
|
94
|
+
}
|
|
95
|
+
.abSearchTrigger[data-size='sm'] .abSearchTriggerCap { min-width: 18px; height: 18px; font-size: 10px; } /* ๐ฑ */
|
|
96
|
+
.abSearchTrigger[data-variant='field'][aria-disabled='true'], .abSearchTrigger[data-size='sm'][aria-disabled='true'] { opacity: 1; } /* ๐ง the Home field looks the same while search is coming soon (the tooltip says so) */
|