ab-nextjs-components 0.1.12 โ 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 +64 -0
- package/README.md +52 -0
- package/ab-app-bar/index.tsx +210 -0
- package/ab-app-bar/styles.module.css +158 -0
- package/ab-avatar/index.tsx +2 -1
- package/ab-avatar/styles.module.css +32 -0
- package/ab-balloon/index.tsx +134 -23
- package/ab-balloon/styles.module.css +84 -7
- package/ab-bottom-drawer/index.tsx +71 -0
- package/ab-bottom-drawer/styles.module.css +66 -0
- package/ab-brand/index.tsx +1 -1
- 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 +23 -4
- package/ab-button/styles.module.css +70 -0
- package/ab-card/index.tsx +89 -0
- package/ab-card/styles.module.css +68 -0
- 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-collapsible/index.tsx +1 -1
- package/ab-color/index.tsx +1 -0
- package/ab-color/styles.module.css +32 -0
- package/ab-confirm-drawer/index.tsx +97 -0
- package/ab-confirm-drawer/styles.module.css +41 -0
- package/ab-demo-box/index.tsx +1 -0
- package/ab-demo-box/styles.module.css +32 -0
- package/ab-demo-code/index.tsx +1 -0
- package/ab-demo-code/styles.module.css +32 -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 +19 -1
- package/ab-icon/helpers.ts +37 -0
- package/ab-icon/index.tsx +14 -8
- package/ab-icon/registrar.tsx +68 -0
- package/ab-icon-button/index.tsx +19 -3
- package/ab-icon-button/styles.module.css +1 -1
- package/ab-image/index.tsx +1 -0
- package/ab-image/styles.module.css +32 -0
- package/ab-info/index.tsx +2 -1
- package/ab-info/styles.module.css +32 -0
- package/ab-input/index.tsx +1 -0
- package/ab-input/styles.module.css +1 -0
- package/ab-install-snippet/index.tsx +51 -29
- package/ab-install-snippet/styles.module.css +50 -4
- package/ab-kbd/index.tsx +65 -0
- package/ab-kbd/styles.module.css +55 -0
- package/ab-key-feature/index.tsx +2 -1
- package/ab-key-feature/styles.module.css +32 -0
- package/ab-like-button/index.tsx +1 -1
- package/ab-link/index.tsx +112 -0
- package/ab-link/locale.ts +53 -0
- package/ab-list/index.tsx +107 -0
- package/ab-list/styles.module.css +82 -0
- package/ab-locale-switcher/index.tsx +59 -10
- package/ab-locale-switcher/styles.module.css +15 -4
- package/ab-main-headline/index.tsx +1 -0
- package/ab-main-headline/styles.module.css +32 -0
- package/ab-menu/index.tsx +6 -5
- package/ab-menu/styles.module.css +32 -0
- package/ab-name/index.tsx +1 -0
- package/ab-name/styles.module.css +32 -0
- package/ab-navbar/index.tsx +54 -46
- package/ab-navbar/styles.module.css +102 -28
- package/ab-navbar/view.tsx +166 -0
- package/ab-package-card/index.tsx +141 -0
- package/ab-package-card/styles.module.css +81 -0
- package/ab-page-paginator/index.tsx +1 -0
- package/ab-page-paginator/styles.module.css +32 -0
- package/ab-page-switcher/index.tsx +1 -0
- package/ab-page-switcher/styles.module.css +32 -0
- package/ab-preview/index.tsx +1 -0
- package/ab-preview/styles.module.css +32 -0
- package/ab-price/index.tsx +1 -0
- package/ab-price/styles.module.css +32 -0
- package/ab-price-tag/index.tsx +1 -0
- package/ab-price-tag/styles.module.css +32 -0
- package/ab-product/index.tsx +1 -0
- package/ab-product/styles.module.css +32 -0
- package/ab-product-item/index.tsx +1 -0
- package/ab-product-item/styles.module.css +32 -0
- package/ab-search-result/index.tsx +1 -0
- package/ab-search-result/styles.module.css +32 -0
- package/ab-search-trigger/index.tsx +157 -0
- package/ab-search-trigger/styles.module.css +96 -0
- package/ab-sidebar/index.tsx +91 -49
- package/ab-sidebar/styles.module.css +179 -31
- package/ab-sidebar/view.tsx +192 -0
- package/ab-switch-back/index.tsx +2 -1
- package/ab-switch-back/styles.module.css +32 -0
- package/ab-tab/index.tsx +2 -1
- package/ab-tab/styles.module.css +32 -0
- package/ab-tabs/index.tsx +1 -0
- package/ab-tabs/styles.module.css +32 -0
- package/ab-test-hello/index.tsx +1 -0
- package/ab-test-hello/styles.module.css +32 -0
- package/ab-text/index.tsx +1 -0
- package/ab-text/styles.module.css +32 -0
- package/ab-theme-toggle/index.tsx +21 -6
- package/ab-theme-toggle/styles.module.css +18 -3
- package/ab-toc/index.tsx +131 -0
- package/ab-toc/styles.module.css +66 -0
- package/ab-version-switcher/index.tsx +143 -0
- package/ab-version-switcher/styles.module.css +76 -0
- package/css/chrome-mq.css +32 -0
- package/css/doodle.css +32 -0
- package/css/logo.css +32 -0
- package/css/spinner.css +32 -0
- package/css/toast.css +32 -0
- package/index.ts +45 -0
- package/package.json +42 -10
- package/server/ab-avatar/index.tsx +2 -1
- package/server/ab-avatar/styles.module.css +32 -0
- package/server/ab-badge/index.tsx +1 -0
- package/server/ab-badge/styles.module.css +32 -0
- package/server/ab-brand/index.tsx +1 -1
- package/server/ab-button/index.tsx +6 -2
- package/server/ab-button/styles.module.css +39 -0
- package/server/ab-icon/index.tsx +13 -8
- package/server/ab-key-feature/index.tsx +2 -1
- package/server/ab-key-feature/styles.module.css +32 -0
- package/server/ab-name/index.tsx +1 -0
- package/server/ab-name/styles.module.css +32 -0
- package/server/ab-nav-link/index.tsx +2 -1
- package/server/ab-nav-link/styles.module.css +32 -0
- package/server/ab-navbar/index.tsx +44 -45
- package/server/ab-polygon/index.tsx +1 -0
- package/server/ab-polygon/styles.module.css +32 -0
- package/server/ab-sidebar/index.tsx +44 -49
- package/server/ab-switch-back/index.tsx +2 -1
- package/server/ab-switch-back/styles.module.css +32 -0
- package/server/ab-test-hello/index.tsx +1 -0
- package/server/ab-test-hello/styles.module.css +32 -0
- package/server/ab-text/index.tsx +1 -0
- package/server/ab-text/styles.module.css +32 -0
- package/server/index.ts +1 -0
- package/styles.css +32 -0
- package/types/index.d.ts +54 -0
- package/server/ab-navbar/styles.module.css +0 -35
- package/server/ab-sidebar/styles.module.css +0 -41
package/ab-balloon/index.tsx
CHANGED
|
@@ -5,51 +5,162 @@
|
|
|
5
5
|
* ~~~~~~~~~~~~
|
|
6
6
|
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
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
|
+
*
|
|
8
26
|
* @project: ab-nextjs-components
|
|
9
|
-
* @name: AbBalloon
|
|
27
|
+
* @name: AbBalloon
|
|
10
28
|
* @file: ab-balloon/index.tsx
|
|
29
|
+
* @type: Client Component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* <AbBalloon title="Clear">
|
|
34
|
+
* <button aria-label="Clear">ร</button>
|
|
35
|
+
* </AbBalloon>
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
* MOTTO: We'll always do more ๐!!!
|
|
41
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
11
42
|
*/
|
|
12
43
|
|
|
13
44
|
'use client';
|
|
14
45
|
|
|
15
|
-
|
|
46
|
+
// โ๏ธ React
|
|
47
|
+
import { cloneElement, isValidElement, useCallback, useEffect, useId, useRef, useState, type FocusEvent, type KeyboardEvent, type ReactElement, type ReactNode } from 'react';
|
|
48
|
+
// ๐งต classes
|
|
16
49
|
import clsx from 'clsx';
|
|
50
|
+
// ๐ฌ the tooltip pops in with the package keyframes (reduced-motion safe in ab-nextjs-animations)
|
|
51
|
+
import 'ab-nextjs-animations/pop-in/styles.css';
|
|
52
|
+
// ๐จ styles
|
|
17
53
|
import styles from './styles.module.css';
|
|
18
54
|
|
|
55
|
+
/** โฑ๏ธ hover delay before the balloon shows (focus shows it at once). */
|
|
56
|
+
export const AB_BALLOON_HOVER_DELAY = 300;
|
|
57
|
+
|
|
58
|
+
// โ๏ธ props
|
|
19
59
|
export interface AbBalloonProps {
|
|
20
|
-
/**
|
|
60
|
+
/** ๐ฌ tooltip text (same prop name as before: `title=`). */
|
|
21
61
|
title?: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
62
|
+
/** ๐งญ side of the trigger (default `top`). */
|
|
63
|
+
placement?: 'top' | 'bottom' | 'start' | 'end';
|
|
64
|
+
/** โฑ๏ธ hover delay in ms (default 300). */
|
|
65
|
+
delay?: number;
|
|
66
|
+
className?: string; // ๐ท๏ธ
|
|
67
|
+
hidden?: boolean; // ๐ render the child alone
|
|
68
|
+
disabled?: boolean; // ๐ซ no balloon
|
|
69
|
+
children: ReactNode; // ๐ฏ the trigger (ideally ONE focusable element)
|
|
26
70
|
}
|
|
27
71
|
|
|
28
72
|
/**
|
|
29
|
-
* AbBalloon โ
|
|
30
|
-
*
|
|
73
|
+
* ๐ AbBalloon (0.1.13, accessible) โ a real tooltip instead of the native `title=`:
|
|
74
|
+
* - โฟ `role="tooltip"` + `aria-describedby` on the trigger (added to a single element child)
|
|
75
|
+
* - โจ๏ธ shows on keyboard focus at once, hides on blur and Escape
|
|
76
|
+
* - ๐ฑ๏ธ shows after a 300ms hover delay, hides on leave
|
|
77
|
+
* - ๐ฌ `popIn` from ab-nextjs-animations (no motion under prefers-reduced-motion)
|
|
78
|
+
* - ๐ซ JS off: the balloon shows on `:focus-within` / `:hover` with CSS alone
|
|
31
79
|
*/
|
|
32
|
-
const AbBalloon = ({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
80
|
+
const AbBalloon = ({ title, placement = 'top', delay = AB_BALLOON_HOVER_DELAY, className, hidden = false, disabled = false, children }: AbBalloonProps): ReactElement => {
|
|
81
|
+
// ๐ tooltip id for aria-describedby
|
|
82
|
+
const id = useId();
|
|
83
|
+
// ๐๏ธ open state
|
|
84
|
+
const [open, setOpen] = useState(false);
|
|
85
|
+
// โฑ๏ธ hover timer
|
|
86
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
87
|
+
// ๐งน clear the timer
|
|
88
|
+
const clear = useCallback(() => {
|
|
89
|
+
if (timer.current) clearTimeout(timer.current); // โน๏ธ
|
|
90
|
+
timer.current = null;
|
|
91
|
+
}, []);
|
|
92
|
+
// โฟ reduced motion: no popIn (ab-nextjs-animations/pop-in has no reduced-motion rule)
|
|
93
|
+
const [still, setStill] = useState(false);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const mq = window.matchMedia?.('(prefers-reduced-motion: reduce)'); // ๐
|
|
96
|
+
if (!mq) return;
|
|
97
|
+
const sync = () => setStill(mq.matches); // ๐
|
|
98
|
+
sync();
|
|
99
|
+
mq.addEventListener?.('change', sync); // ๐
|
|
100
|
+
return () => mq.removeEventListener?.('change', sync); // ๐งน
|
|
101
|
+
}, []);
|
|
102
|
+
// ๐งน unmount
|
|
103
|
+
useEffect(() => clear, [clear]);
|
|
104
|
+
|
|
105
|
+
// ๐ nothing to show
|
|
106
|
+
if (hidden) return <>{children}</>;
|
|
107
|
+
const active = !disabled && !!title; // โ
|
|
108
|
+
|
|
109
|
+
// ๐ฑ๏ธ hover in: wait `delay` ms
|
|
110
|
+
const onPointerEnter = () => {
|
|
111
|
+
if (!active) return;
|
|
112
|
+
clear();
|
|
113
|
+
timer.current = setTimeout(() => setOpen(true), delay); // โฑ๏ธ
|
|
114
|
+
};
|
|
115
|
+
// ๐ฑ๏ธ hover out
|
|
116
|
+
const onPointerLeave = () => {
|
|
117
|
+
clear();
|
|
118
|
+
setOpen(false); // ๐
|
|
119
|
+
};
|
|
120
|
+
// โจ๏ธ focus in: show now
|
|
121
|
+
const onFocus = () => {
|
|
122
|
+
if (active) setOpen(true);
|
|
123
|
+
};
|
|
124
|
+
// โจ๏ธ focus left the whole balloon
|
|
125
|
+
const onBlur = (e: FocusEvent<HTMLSpanElement>) => {
|
|
126
|
+
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setOpen(false);
|
|
127
|
+
};
|
|
128
|
+
// โ Escape dismisses (WCAG 1.4.13)
|
|
129
|
+
const onKeyDown = (e: KeyboardEvent<HTMLSpanElement>) => {
|
|
130
|
+
if (e.key === 'Escape' && open) {
|
|
131
|
+
clear();
|
|
132
|
+
setOpen(false);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// ๐ describe the trigger: a single element child gets aria-describedby
|
|
137
|
+
const trigger = active && isValidElement<{ 'aria-describedby'?: string }>(children)
|
|
138
|
+
? cloneElement(children, { 'aria-describedby': clsx(children.props['aria-describedby'], id) || undefined })
|
|
139
|
+
: children;
|
|
42
140
|
|
|
43
141
|
return (
|
|
44
142
|
<span
|
|
45
|
-
className={clsx('AbBalloon', styles.abBalloon, className)}
|
|
46
|
-
|
|
47
|
-
data-
|
|
143
|
+
className={clsx('AbBalloon', styles.abBalloon, className)} // ๐ท๏ธ
|
|
144
|
+
data-disabled={disabled ? 'true' : 'false'} // ๐ซ
|
|
145
|
+
data-open={open ? 'true' : 'false'} // ๐๏ธ
|
|
146
|
+
data-placement={placement} // ๐งญ
|
|
147
|
+
data-ab-part="balloon" // ๐งฉ
|
|
148
|
+
onPointerEnter={onPointerEnter}
|
|
149
|
+
onPointerLeave={onPointerLeave}
|
|
150
|
+
onFocus={onFocus}
|
|
151
|
+
onBlur={onBlur}
|
|
152
|
+
onKeyDown={onKeyDown}
|
|
48
153
|
>
|
|
49
|
-
{
|
|
154
|
+
{trigger}
|
|
155
|
+
{active && (
|
|
156
|
+
<span id={id} role="tooltip" className={clsx(styles.abBalloonTip, open && !still && 'popIn')} data-ab-part="balloon-tip">
|
|
157
|
+
{title}
|
|
158
|
+
</span>
|
|
159
|
+
)}
|
|
50
160
|
</span>
|
|
51
161
|
);
|
|
52
162
|
};
|
|
53
163
|
|
|
164
|
+
// ๐ฆ exports
|
|
54
165
|
export default AbBalloon;
|
|
55
166
|
export { AbBalloon };
|
|
@@ -1,12 +1,89 @@
|
|
|
1
|
-
/*
|
|
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: AbBalloon - Styles
|
|
28
|
+
* @file: ab-balloon/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
|
+
/* ๐ wrapper: positions the tip */
|
|
2
40
|
.abBalloon {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
41
|
+
position: relative; /* ๐ */
|
|
42
|
+
display: inline-flex; /* ๐ */
|
|
43
|
+
align-items: center; /* โ๏ธ */
|
|
44
|
+
justify-content: center; /* โ๏ธ */
|
|
45
|
+
box-sizing: border-box; /* ๐ฆ */
|
|
46
|
+
max-width: 100%; /* ๐ */
|
|
47
|
+
--pop-in-animation-duration: 160ms; /* ๐ฌ quick pop (package keyframes) */
|
|
8
48
|
}
|
|
9
49
|
|
|
10
50
|
.abBalloon[data-disabled='true'] {
|
|
11
|
-
pointer-events: none;
|
|
51
|
+
pointer-events: none; /* ๐ซ */
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ๐ฌ the tip: hidden until open (JS) or focus/hover (no JS, see below) */
|
|
55
|
+
.abBalloonTip {
|
|
56
|
+
position: absolute; /* ๐ */
|
|
57
|
+
z-index: 50; /* โฌ๏ธ */
|
|
58
|
+
display: none; /* ๐ */
|
|
59
|
+
width: max-content; /* ๐ */
|
|
60
|
+
max-width: 240px; /* ๐ */
|
|
61
|
+
padding: 4px 8px; /* ๐ฆ */
|
|
62
|
+
border-radius: 8px; /* ๐ข */
|
|
63
|
+
background: var(--ab-color-inverse-surface, rgb(54 47 43)); /* ๐จ */
|
|
64
|
+
color: var(--ab-color-inverse-on-surface, rgb(251 238 233)); /* ๐๏ธ */
|
|
65
|
+
font: 500 12px/16px var(--ab-font-sans, system-ui, sans-serif); /* ๐ค */
|
|
66
|
+
pointer-events: none; /* ๐ฑ๏ธ never steals hover */
|
|
67
|
+
white-space: normal; /* โฉ๏ธ */
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ๐๏ธ open */
|
|
71
|
+
.abBalloon[data-open='true'] .abBalloonTip {
|
|
72
|
+
display: block;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ๐ซ JS off: plain CSS focus / hover */
|
|
76
|
+
@media (scripting: none) {
|
|
77
|
+
.abBalloon:focus-within .abBalloonTip,
|
|
78
|
+
.abBalloon:hover .abBalloonTip {
|
|
79
|
+
display: block;
|
|
80
|
+
}
|
|
12
81
|
}
|
|
82
|
+
|
|
83
|
+
/* ๐งญ placement */
|
|
84
|
+
.abBalloon[data-placement='top'] .abBalloonTip { bottom: calc(100% + 6px); left: 50%; translate: -50% 0; }
|
|
85
|
+
.abBalloon[data-placement='bottom'] .abBalloonTip { top: calc(100% + 6px); left: 50%; translate: -50% 0; }
|
|
86
|
+
.abBalloon[data-placement='start'] .abBalloonTip { inset-inline-end: calc(100% + 6px); top: 50%; translate: 0 -50%; }
|
|
87
|
+
.abBalloon[data-placement='end'] .abBalloonTip { inset-inline-start: calc(100% + 6px); top: 50%; translate: 0 -50%; }
|
|
88
|
+
|
|
89
|
+
/* โฟ reduced motion: the component skips the popIn class (pop-in has no reduced-motion rule of its own) */
|
|
@@ -0,0 +1,71 @@
|
|
|
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: AbBottomDrawer (mobile bottom drawer)
|
|
28
|
+
* @file: ab-bottom-drawer/index.tsx
|
|
29
|
+
* @type: Client component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbBottomDrawer {...d.drawerProps} title="Language">โฆ</AbBottomDrawer>
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
* MOTTO: We'll always do more ๐!!!
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
'use client';
|
|
44
|
+
|
|
45
|
+
// โ๏ธ React
|
|
46
|
+
import type { ReactElement } from 'react';
|
|
47
|
+
// ๐งต classes
|
|
48
|
+
import clsx from 'clsx';
|
|
49
|
+
// ๐๏ธ built on AbDrawer
|
|
50
|
+
import AbDrawer, { type AbDrawerProps } from '../ab-drawer';
|
|
51
|
+
// ๐จ styles
|
|
52
|
+
import styles from './styles.module.css';
|
|
53
|
+
|
|
54
|
+
/** โ๏ธ props: AbDrawer's, minus `side` (always bottom); scope defaults to the whole app */
|
|
55
|
+
export interface AbBottomDrawerProps extends Omit<AbDrawerProps, 'side'> {
|
|
56
|
+
side?: AbDrawerProps['side']; // ๐ accepted for drop-in use (AbDrawerList `as`), always rendered as bottom
|
|
57
|
+
handle?: boolean; // โ grab handle at the top (default true; decorative)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* ๐ฑ AbBottomDrawer: the mobile bottom sheet (God's plan: the language picker on mobile, D40). AbDrawer
|
|
62
|
+
* with `side="bottom"`, `scope="app"`, the Home tokens (card surface, hairline top edge, 20px top radius,
|
|
63
|
+
* grab handle, safe-area padding) and at most 560px wide, centred, above 768px.
|
|
64
|
+
*/
|
|
65
|
+
const AbBottomDrawer = ({ handle = true, scope = 'app', initialFocus = 'panel', className, ...rest }: AbBottomDrawerProps): ReactElement => (
|
|
66
|
+
<AbDrawer {...rest} scope={scope} initialFocus={initialFocus} side="bottom" className={clsx('AbBottomDrawer', styles.abBottomDrawer, handle && styles.withHandle, className)} />
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// ๐ฆ exports
|
|
70
|
+
export default AbBottomDrawer;
|
|
71
|
+
export { AbBottomDrawer };
|
|
@@ -0,0 +1,66 @@
|
|
|
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: AbBottomDrawer styles
|
|
28
|
+
* @file: ab-bottom-drawer/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
|
+
/* ๐ฑ the sheet: doubled class beats AbDrawer's `.abDrawer[data-side='bottom']` without !important (John's spec) */
|
|
41
|
+
.abBottomDrawer.abBottomDrawer {
|
|
42
|
+
--ab-bottom-drawer-radius: 20px; /* โญ = the gapped pane radius */
|
|
43
|
+
--ab-bottom-drawer-max-width: 560px; /* ๐ tablet+ */
|
|
44
|
+
background: var(--ab-color-card, #fff); /* ๐จ --card */
|
|
45
|
+
color: var(--ab-color-text, #211a16); /* ๐๏ธ --text */
|
|
46
|
+
border-top: 1px solid var(--ab-color-sheet-edge, transparent); /* โ dark: rgba(255,248,245,.08) via theme 0.3.5 */
|
|
47
|
+
border-radius: var(--ab-bottom-drawer-radius) var(--ab-bottom-drawer-radius) 0 0; /* โญ */
|
|
48
|
+
box-shadow: 0 -8px 28px rgb(25 18 12 / 0.12); /* ๐ */
|
|
49
|
+
padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); /* ๐ฑ 16px + home indicator */
|
|
50
|
+
outline: none; /* ๐ฏ the sheet takes focus on open: no ring on the sheet itself */
|
|
51
|
+
}
|
|
52
|
+
/* โ grab handle (decorative): 36ร4, radius 2 */
|
|
53
|
+
.withHandle.withHandle::before {
|
|
54
|
+
content: ''; display: block; flex: none; /* ๐งฑ */
|
|
55
|
+
width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; /* ๐ */
|
|
56
|
+
background: var(--ab-color-handle, rgb(25 18 12 / 0.18)); /* ๐จ dark: rgba(255,248,245,.18) via theme */
|
|
57
|
+
}
|
|
58
|
+
.abBottomDrawer h2 { font-family: var(--ab-font-title, inherit); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; } /* ๐ท๏ธ */
|
|
59
|
+
/* โ close: 44px hit area, no border, 8px-radius hover tint (the Home icon buttons); ring on keyboard focus only */
|
|
60
|
+
.abBottomDrawer [data-ab-part='drawer-close'] { inline-size: 44px; block-size: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--ab-color-muted, #6b5b50); }
|
|
61
|
+
.abBottomDrawer [data-ab-part='drawer-close']:hover { background: var(--ab-color-hover, rgb(166 124 82 / 0.08)); }
|
|
62
|
+
.abBottomDrawer [data-ab-part='drawer-close']:focus { outline: none; }
|
|
63
|
+
.abBottomDrawer [data-ab-part='drawer-close']:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; }
|
|
64
|
+
@media (min-width: 768px) {
|
|
65
|
+
.abBottomDrawer.abBottomDrawer { inset-inline: 0; margin-inline: auto; max-width: var(--ab-bottom-drawer-max-width); } /* ๐ centred */
|
|
66
|
+
}
|
package/ab-brand/index.tsx
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
'use client';
|
|
41
41
|
|
|
42
42
|
import type { CSSProperties, ReactElement } from 'react';
|
|
43
|
-
import Link from 'next/link
|
|
43
|
+
import Link from '../ab-link'; // ๐ G42: injectable via AbLinkProvider (default next/link)
|
|
44
44
|
import Image from 'next/image';
|
|
45
45
|
import clsx from 'clsx';
|
|
46
46
|
import styles from './styles.module.css';
|
|
@@ -0,0 +1,92 @@
|
|
|
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: AbBreadcrumbs (P2)
|
|
28
|
+
* @file: ab-breadcrumbs/index.tsx
|
|
29
|
+
* @type: Server-safe component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbBreadcrumbs items={[{ label: "Docs", href: "/docs" }, { label: "Home" }]} />
|
|
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 (AbLinkProvider)
|
|
48
|
+
import Link from '../ab-link';
|
|
49
|
+
// ๐ฃ separators
|
|
50
|
+
import AbIcon from '../ab-icon';
|
|
51
|
+
// ๐จ styles
|
|
52
|
+
import styles from './styles.module.css';
|
|
53
|
+
|
|
54
|
+
/** ๐ one crumb */
|
|
55
|
+
export interface AbBreadcrumbItem {
|
|
56
|
+
label: ReactNode; // ๐ท๏ธ
|
|
57
|
+
href?: string; // ๐ omitted on the last (current) crumb
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** โ๏ธ props */
|
|
61
|
+
export interface AbBreadcrumbsProps {
|
|
62
|
+
items: readonly AbBreadcrumbItem[]; // ๐ first โ current
|
|
63
|
+
label?: string; // โฟ nav name (default "Breadcrumb")
|
|
64
|
+
className?: string; // ๐ท๏ธ
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ๐ AbBreadcrumbs (P2): the tablet main bar's "Docs โบ **Home**". 13px faint links, the last crumb is the
|
|
69
|
+
* current page (650, text colour, `aria-current="page"`), 16px `chevron_right` separators (hidden from AT).
|
|
70
|
+
* Server-safe: no hooks.
|
|
71
|
+
*/
|
|
72
|
+
const AbBreadcrumbs = ({ items, label = 'Breadcrumb', className }: AbBreadcrumbsProps): ReactElement => (
|
|
73
|
+
<nav aria-label={label} className={clsx('AbBreadcrumbs', styles.abCrumbs, className)} data-ab-part="breadcrumbs">
|
|
74
|
+
<ol className={styles.abCrumbsList}>
|
|
75
|
+
{items.map((it, i) => {
|
|
76
|
+
const last = i === items.length - 1; // ๐ฏ current page
|
|
77
|
+
return (
|
|
78
|
+
<li key={i} className={styles.abCrumb}>
|
|
79
|
+
{i > 0 && <AbIcon name="chevron_right" size={16} className={styles.abCrumbSep} />}
|
|
80
|
+
{last ? <span className={styles.abCrumbCurrent} aria-current="page">{it.label}</span>
|
|
81
|
+
: it.href ? <Link href={it.href} className={styles.abCrumbLink}>{it.label}</Link>
|
|
82
|
+
: <span>{it.label}</span>}
|
|
83
|
+
</li>
|
|
84
|
+
);
|
|
85
|
+
})}
|
|
86
|
+
</ol>
|
|
87
|
+
</nav>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// ๐ฆ exports
|
|
91
|
+
export default AbBreadcrumbs;
|
|
92
|
+
export { AbBreadcrumbs };
|
|
@@ -0,0 +1,54 @@
|
|
|
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: AbBreadcrumbs styles
|
|
28
|
+
* @file: ab-breadcrumbs/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 .crumb; theme tokens from ab-nextjs-theme 0.3.5) */
|
|
41
|
+
.abCrumbs {
|
|
42
|
+
--ab-crumbs-color: var(--ab-color-faint, #807062); /* ๐๏ธ --faint โฟ AA fallback (James) */
|
|
43
|
+
--ab-crumbs-current: var(--ab-color-text, var(--ab-color-on-surface, #211a16)); /* ๐๏ธ --text */
|
|
44
|
+
--ab-crumbs-hover: var(--ab-color-accent-text, var(--ab-color-bronze-text, #8b6340)); /* ๐ฑ๏ธ --accent-t */
|
|
45
|
+
--ab-crumbs-ring: var(--ab-color-accent, var(--ab-color-bronze, #a67c52)); /* โฟ --accent */
|
|
46
|
+
min-width: 0; font-size: 13px; color: var(--ab-crumbs-color); /* ๐ค */
|
|
47
|
+
}
|
|
48
|
+
.abCrumbsList { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; min-width: 0; } /* ๐ */
|
|
49
|
+
.abCrumb { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; } /* ๐ */
|
|
50
|
+
.abCrumbSep { width: 16px; height: 16px; flex: none; } /* โบ */
|
|
51
|
+
.abCrumbCurrent { color: var(--ab-crumbs-current); font-weight: 650; overflow: hidden; text-overflow: ellipsis; } /* ๐ฏ */
|
|
52
|
+
.abCrumbLink { color: inherit; text-decoration: none; border-radius: 4px; } /* ๐ */
|
|
53
|
+
.abCrumbLink:hover { color: var(--ab-crumbs-hover); } /* ๐ฑ๏ธ */
|
|
54
|
+
.abCrumbLink:focus-visible { outline: 2px solid var(--ab-crumbs-ring); outline-offset: 2px; } /* โฟ */
|
package/ab-button/helpers.ts
CHANGED
|
@@ -39,7 +39,12 @@
|
|
|
39
39
|
// ๐จ visual types shared by the client + server twins
|
|
40
40
|
// ๐ฅ 'filled' (0.1.12): solid bronze, painted by ab-nextjs-theme โฅ 0.3.3's
|
|
41
41
|
// `button[data-type="filled"]` rule (fallback in styles.module.css โ .isFilled)
|
|
42
|
-
|
|
42
|
+
// โช 'secondary' (0.1.14, P16): the Home "Browse packages" button: --card bg, 1px --border hairline, --text
|
|
43
|
+
export type AbButtonType = 'contained' | 'filled' | 'outlined' | 'text' | 'secondary';
|
|
44
|
+
// ๐ท 0.1.14 (P16): 'pill' = the legacy 999px look (default) ยท 'rounded' = the Home 10px button
|
|
45
|
+
export type AbButtonShape = 'pill' | 'rounded';
|
|
46
|
+
// ๐ 0.1.14 (P16): 'md' = 40px (44px under 768px, the touch CTA); undefined keeps the legacy sizing
|
|
47
|
+
export type AbButtonSize = 'md';
|
|
43
48
|
// ๐จ colour roles
|
|
44
49
|
export type AbButtonColor = 'primary' | 'secondary' | 'tertiary' | 'white' | 'black';
|
|
45
50
|
// ๐ท๏ธ badge tones (G22): neutral grey or bronze accent
|
package/ab-button/index.tsx
CHANGED
|
@@ -54,11 +54,11 @@ import {
|
|
|
54
54
|
getAbButtonSrReason,
|
|
55
55
|
type AbButtonBadgeTone,
|
|
56
56
|
type AbButtonColor,
|
|
57
|
-
type AbButtonType,
|
|
57
|
+
type AbButtonType, type AbButtonShape, type AbButtonSize,
|
|
58
58
|
} from './helpers';
|
|
59
59
|
|
|
60
60
|
// ๐ฆ re-export the shared types (pre-G22 import paths keep working)
|
|
61
|
-
export type { AbButtonBadgeTone, AbButtonColor, AbButtonType, AbButtonDisabledMode } from './helpers';
|
|
61
|
+
export type { AbButtonBadgeTone, AbButtonColor, AbButtonType, AbButtonDisabledMode, AbButtonShape, AbButtonSize } from './helpers';
|
|
62
62
|
|
|
63
63
|
// โ๏ธ props
|
|
64
64
|
export interface AbButtonProps {
|
|
@@ -71,6 +71,8 @@ export interface AbButtonProps {
|
|
|
71
71
|
style?: CSSProperties; // ๐จ
|
|
72
72
|
iconStyle?: CSSProperties; // ๐จ Material icon style
|
|
73
73
|
rounded?: boolean; // ๐
|
|
74
|
+
shape?: AbButtonShape; // ๐ท 0.1.14 (P16): 'rounded' = Home 10px radius (overrides `rounded`)
|
|
75
|
+
size?: AbButtonSize; // ๐ 0.1.14 (P16): 'md' = 40px / 44px on touch widths
|
|
74
76
|
raised?: boolean; // ๐๏ธ
|
|
75
77
|
shrinks?: boolean; // ๐ค
|
|
76
78
|
expands?: boolean; // ๐
|
|
@@ -91,6 +93,18 @@ export interface AbButtonProps {
|
|
|
91
93
|
badgeTone?: AbButtonBadgeTone; // ๐จ NEW: 'neutral' (default) | 'accent'
|
|
92
94
|
disabledReason?: string; // ๐ฌ NEW: SR-only reason, appended to the name while blocked
|
|
93
95
|
focusableWhenDisabled?: boolean; // โจ๏ธ NEW: force aria-disabled (true) or native disabled (false)
|
|
96
|
+
// ===== 0.1.13 (Joseph #7) =====
|
|
97
|
+
// โฟ any aria-* / data-* attribute is passed to the <button>/<a>, e.g. useAbAsideToggle().props
|
|
98
|
+
// (`aria-expanded`, `aria-controls`) or `data-testid`. Our own data-* (type, color, โฆ) still win.
|
|
99
|
+
[aria: `aria-${string}`]: string | number | boolean | undefined;
|
|
100
|
+
[data: `data-${string}`]: string | number | boolean | undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** ๐ pick the aria-* / data-* props to forward (0.1.13) */
|
|
104
|
+
function pickAbButtonPassThrough(props: object): Record<string, unknown> {
|
|
105
|
+
const out: Record<string, unknown> = {}; // ๐ฆ
|
|
106
|
+
for (const [k, v] of Object.entries(props)) if (k.startsWith('aria-') || k.startsWith('data-')) out[k] = v; // โฟ ๐๏ธ
|
|
107
|
+
return out;
|
|
94
108
|
}
|
|
95
109
|
|
|
96
110
|
const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps>(function AbButton(props, ref) {
|
|
@@ -105,6 +119,8 @@ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps
|
|
|
105
119
|
style, // ๐จ
|
|
106
120
|
iconStyle, // ๐จ
|
|
107
121
|
rounded = true, // ๐
|
|
122
|
+
shape, // ๐ท
|
|
123
|
+
size, // ๐
|
|
108
124
|
raised = false, // ๐๏ธ
|
|
109
125
|
shrinks = false, // ๐ค
|
|
110
126
|
expands = false, // ๐
|
|
@@ -144,8 +160,9 @@ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps
|
|
|
144
160
|
mode === 'native' && styles.isDisabled, // ๐ซ
|
|
145
161
|
);
|
|
146
162
|
|
|
147
|
-
// ๐๏ธ data attributes for styling/tests
|
|
163
|
+
// ๐๏ธ data attributes for styling/tests (forwarded aria-* / data-* first, so ours win)
|
|
148
164
|
const dataAttrs = {
|
|
165
|
+
...pickAbButtonPassThrough(props), // โฟ 0.1.13
|
|
149
166
|
'data-type': type, // ๐จ
|
|
150
167
|
'data-raised': raised ? 'true' : 'false', // ๐๏ธ
|
|
151
168
|
'data-shrinks': shrinks ? 'true' : 'false', // ๐ค
|
|
@@ -154,7 +171,9 @@ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps
|
|
|
154
171
|
'data-iconpos': iconPosition, // โ๏ธ
|
|
155
172
|
'data-color': color, // ๐จ
|
|
156
173
|
'data-disabled-mode': mode, // ๐ฆ
|
|
157
|
-
|
|
174
|
+
'data-shape': shape, // ๐ท P16 (omitted when undefined)
|
|
175
|
+
'data-size': size, // ๐ P16
|
|
176
|
+
};
|
|
158
177
|
|
|
159
178
|
// ๐ฃ legacy Material icon (decorative)
|
|
160
179
|
const legacyIcon = withIcon && icon
|