ab-nextjs-components 0.3.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ab-breadcrumbs/index.tsx +5 -3
- package/ab-breadcrumbs/styles.module.css +24 -1
- package/ab-callout/index.tsx +95 -0
- package/ab-callout/styles.module.css +75 -0
- package/ab-code-block/copy.tsx +76 -0
- package/ab-code-block/index.tsx +130 -0
- package/ab-code-block/styles.module.css +60 -0
- package/ab-content-tabs/index.tsx +144 -0
- package/ab-content-tabs/styles.module.css +61 -0
- package/ab-doc-pager/index.tsx +95 -0
- package/ab-doc-pager/styles.module.css +49 -0
- package/ab-icon/builtin.ts +8 -0
- package/ab-search-trigger/styles.module.css +1 -0
- package/index.ts +19 -0
- package/package.json +14 -5
- package/types/index.d.ts +14 -0
package/ab-breadcrumbs/index.tsx
CHANGED
|
@@ -77,9 +77,11 @@ const AbBreadcrumbs = ({ items, label = 'Breadcrumb', className }: AbBreadcrumbs
|
|
|
77
77
|
return (
|
|
78
78
|
<li key={i} className={styles.abCrumb}>
|
|
79
79
|
{i > 0 && <AbIcon name="chevron_right" size={16} className={styles.abCrumbSep} />}
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
{/* ✂️ 0.4.1 (Joseph 0.2.24, gap 4 v3): the label sits in its own text box, so a squeezed crumb ellipsizes on the
|
|
81
|
+
right ("Installa…") while the inline-flex target box (24px min) stays as it is */}
|
|
82
|
+
{last ? <span className={styles.abCrumbCurrent} aria-current="page"><span className={styles.abCrumbText}>{it.label}</span></span>
|
|
83
|
+
: it.href ? <Link href={it.href} className={styles.abCrumbLink}><span className={styles.abCrumbText}>{it.label}</span></Link>
|
|
84
|
+
: <span className={styles.abCrumbText}>{it.label}</span>}
|
|
83
85
|
</li>
|
|
84
86
|
);
|
|
85
87
|
})}
|
|
@@ -43,12 +43,35 @@
|
|
|
43
43
|
--ab-crumbs-current: var(--ab-color-text, var(--ab-color-on-surface, #211a16)); /* 🖋️ --text */
|
|
44
44
|
--ab-crumbs-hover: var(--ab-color-accent-text, var(--ab-color-bronze-text, #8b6340)); /* 🖱️ --accent-t */
|
|
45
45
|
--ab-crumbs-ring: var(--ab-color-accent, var(--ab-color-bronze, #a67c52)); /* ♿ --accent */
|
|
46
|
-
|
|
46
|
+
font-size: 13px; color: var(--ab-crumbs-color); /* 🔤 */
|
|
47
|
+
flex: 1 1 auto; /* ↔️ 0.4.1 (Joseph 0.2.24, gap 4): in a header row it takes the space left */
|
|
48
|
+
min-width: var(--ab-crumbs-min-width, 96px); /* 📏 0.4.1 v2: never collapses to 0, so the first crumb always fits */
|
|
49
|
+
flex-shrink: 1; /* 🗜️ a neighbour with a bigger flex-shrink (the search field) gives way first */
|
|
47
50
|
}
|
|
48
51
|
.abCrumbsList { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; min-width: 0; } /* 📐 */
|
|
52
|
+
/* ✂️ 0.4.1 (Joseph 0.2.24, gap 4): at 768px the trail ran under the search field. Now it never paints past its own box:
|
|
53
|
+
it clips (with 4px of room so the focus ring still shows) and each crumb may shrink instead of pushing out. */
|
|
54
|
+
.abCrumbsList { overflow: clip; overflow-clip-margin: 4px; flex-wrap: nowrap; } /* ✂️ */
|
|
49
55
|
.abCrumb { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; } /* 🍞 */
|
|
56
|
+
.abCrumb { flex: 0 1 auto; } /* 🗜️ 0.4.1: crumbs shrink (min-width: 0 above) rather than overflow */
|
|
57
|
+
.abCrumb:first-child { flex: none; } /* 🏠 0.4.1 v2: the first crumb (e.g. Docs) never shrinks: full 24px target */
|
|
58
|
+
.abCrumb:not(:first-child) { overflow: hidden; } /* ✂️ middle + current crumbs clip inside their own box */
|
|
59
|
+
.abCrumbLink { overflow: hidden; } /* ✂️ a squeezed parent crumb clips inside its own box */
|
|
50
60
|
.abCrumbSep { width: 16px; height: 16px; flex: none; } /* › */
|
|
51
61
|
.abCrumbCurrent { color: var(--ab-crumbs-current); font-weight: 650; overflow: hidden; text-overflow: ellipsis; } /* 🎯 */
|
|
52
62
|
.abCrumbLink { color: inherit; text-decoration: none; border-radius: 4px; } /* 🔗 */
|
|
63
|
+
/* 👆 0.3.4 (Joseph, 0.2.24 docs): every crumb is at least 24×24 (WCAG 2.5.8 target size), centred in its box */
|
|
64
|
+
.abCrumbLink,
|
|
65
|
+
.abCrumbCurrent {
|
|
66
|
+
display: inline-flex; /* 📐 */
|
|
67
|
+
align-items: center; /* ↕️ */
|
|
68
|
+
justify-content: safe center; /* ↔️ short labels ("Docs") centre in the 24px box; 0.4.1 v3: `safe` falls back to start on overflow (plain centre clipped both ends: "stallatio") */
|
|
69
|
+
min-width: 24px; /* 👆 */
|
|
70
|
+
min-height: 24px; /* 👆 */
|
|
71
|
+
box-sizing: border-box; /* 📦 */
|
|
72
|
+
}
|
|
53
73
|
.abCrumbLink:hover { color: var(--ab-crumbs-hover); } /* 🖱️ */
|
|
54
74
|
.abCrumbLink:focus-visible { outline: 2px solid var(--ab-crumbs-ring); outline-offset: 2px; } /* ♿ */
|
|
75
|
+
|
|
76
|
+
/* ✂️ 0.4.1 (Joseph 0.2.24, gap 4 v3): the label's own box ellipsizes on the right, anchored at the start */
|
|
77
|
+
.abCrumbText { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* ✂️ */
|
|
@@ -0,0 +1,95 @@
|
|
|
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: AbCallout (0.3.4, Joseph 0.2.24 MDX docs)
|
|
28
|
+
* @file: ab-callout/index.tsx
|
|
29
|
+
* @type: Server component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbCallout variant="warning" title="Heads up">Next 16 only.</AbCallout>
|
|
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
|
+
// 🔣 the server-safe icon (built-in AbIcons: info, lightbulb, warning, error)
|
|
47
|
+
import AbIcon from '../server/ab-icon';
|
|
48
|
+
// 🎨 styles
|
|
49
|
+
import styles from './styles.module.css';
|
|
50
|
+
|
|
51
|
+
/** 🎨 the four kinds */
|
|
52
|
+
export type AbCalloutVariant = 'note' | 'tip' | 'warning' | 'danger';
|
|
53
|
+
/** 🔣 the icon of each kind (AbIcons names, all built in) */
|
|
54
|
+
export const AB_CALLOUT_ICONS: Readonly<Record<AbCalloutVariant, string>> = { note: 'info', tip: 'lightbulb', warning: 'warning', danger: 'error' };
|
|
55
|
+
|
|
56
|
+
/** ⚙️ props */
|
|
57
|
+
export interface AbCalloutProps {
|
|
58
|
+
variant?: AbCalloutVariant; // 🎨 default 'note'
|
|
59
|
+
title?: ReactNode; // 🏷️ bold first line (also names the region)
|
|
60
|
+
children?: ReactNode; // 📝 the body (MDX content)
|
|
61
|
+
icon?: string | null; // 🔣 override the glyph (`null` = none)
|
|
62
|
+
// ♿ default 'note' for every kind: a callout is static aside content, NOT a live message. Pass role="alert"
|
|
63
|
+
// only for something that appears dynamically (it interrupts screen readers)
|
|
64
|
+
role?: 'note' | 'alert' | 'status' | 'region';
|
|
65
|
+
label?: string; // ♿ an accessible name when there is no title (e.g. "Warning")
|
|
66
|
+
className?: string; // 🏷️
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 💡 AbCallout — an MDX admonition: an icon, an optional title and the body on a tinted card. Server-safe.
|
|
71
|
+
* The root is role="note" (a static aside to the text, not a live alert) named by its title, and the kind is
|
|
72
|
+
* also said in words for screen readers when there is no title, so meaning never rests on colour or icon alone.
|
|
73
|
+
*/
|
|
74
|
+
const AbCallout = ({ variant = 'note', title, children, icon, role = 'note', label, className }: AbCalloutProps): ReactElement => {
|
|
75
|
+
const glyph = icon === undefined ? AB_CALLOUT_ICONS[variant] : icon; // 🔣
|
|
76
|
+
return (
|
|
77
|
+
<div
|
|
78
|
+
role={role} // ♿
|
|
79
|
+
aria-label={title == null ? (label ?? variant[0].toUpperCase() + variant.slice(1)) : undefined} // 🏷️ "Warning" etc.
|
|
80
|
+
className={clsx('AbCallout', styles.abCallout, className)} // 🎨 the body keeps theme .ab-prose styles
|
|
81
|
+
data-ab-part="callout" // 🗂️
|
|
82
|
+
data-variant={variant} // 🎨 the colour set
|
|
83
|
+
>
|
|
84
|
+
{glyph && <span className={styles.abCalloutIcon} aria-hidden="true"><AbIcon name={glyph} size={20} /></span> /* 🔣 decorative */}
|
|
85
|
+
<div className={styles.abCalloutBody}>
|
|
86
|
+
{title != null && <p className={styles.abCalloutTitle} data-ab-part="callout-title">{title}</p> /* 🏷️ */}
|
|
87
|
+
{children != null && <div className={styles.abCalloutText}>{children}</div> /* 📝 */}
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// 📦 exports
|
|
94
|
+
export default AbCallout;
|
|
95
|
+
export { AbCallout };
|
|
@@ -0,0 +1,75 @@
|
|
|
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: AbCallout styles (0.3.4)
|
|
28
|
+
* @file: ab-callout/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
|
+
/* 💡 the card: a start accent bar + a tint; each variant only sets the two knobs */
|
|
40
|
+
.abCallout {
|
|
41
|
+
--ab-callout-accent: var(--ab-color-accent, #a67c52); /* 🥉 note = brand bronze */
|
|
42
|
+
--ab-callout-tint: var(--ab-color-tint, #f4e7db); /* 🎨 */
|
|
43
|
+
display: flex; /* 📐 icon · body */
|
|
44
|
+
gap: 12px; /* ↔️ */
|
|
45
|
+
margin: 0 0 1.25em; /* ↕️ prose rhythm */
|
|
46
|
+
padding: 12px 16px; /* 📦 */
|
|
47
|
+
border: 1px solid color-mix(in srgb, var(--ab-callout-accent) 30%, transparent); /* 🔲 */
|
|
48
|
+
border-inline-start-width: 4px; /* ▌ the accent bar (RTL-safe) */
|
|
49
|
+
border-inline-start-color: var(--ab-callout-accent); /* 🎨 */
|
|
50
|
+
border-radius: var(--ab-radius-row, 8px); /* 🟢 */
|
|
51
|
+
background: var(--ab-callout-tint); /* 🎨 */
|
|
52
|
+
color: var(--ab-callout-text, var(--ab-color-text, #211a16)); /* 🖋️ AA on every tint (warning/danger: their on-container token) */
|
|
53
|
+
}
|
|
54
|
+
.abCallout[data-variant='tip'] { --ab-callout-accent: var(--ab-color-sage-accent, #4f7a4a); --ab-callout-tint: color-mix(in srgb, var(--ab-color-sage-accent, #4f7a4a) 10%, var(--ab-color-card, #fff)); } /* 🌿 */
|
|
55
|
+
/* ⚠️ 0.4.0: theme ≥ 0.3.8 status tokens (AA in every scheme, AAA in high contrast); fallbacks = the light values */
|
|
56
|
+
.abCallout[data-variant='warning'] {
|
|
57
|
+
--ab-callout-accent: var(--ab-color-warning, #8a5300); /* ⚠️ the start bar (≥ 4.5:1 on the page) */
|
|
58
|
+
--ab-callout-tint: var(--ab-color-warning-container, #ffddb3); /* 🎨 soft fill */
|
|
59
|
+
--ab-callout-icon: var(--ab-color-on-warning-container, #2b1700); /* 🔣 ♿ on-container: ≥ 4.5:1 on the fill in every scheme (the accent is not, in high contrast) */
|
|
60
|
+
--ab-callout-text: var(--ab-color-on-warning-container, #2b1700); /* 🖋️ text on the fill */
|
|
61
|
+
}
|
|
62
|
+
.abCallout[data-variant='danger'] {
|
|
63
|
+
--ab-callout-accent: var(--ab-color-danger, #904a43); /* 🛑 the start bar (≥ 4.5:1 on the page) */
|
|
64
|
+
--ab-callout-tint: var(--ab-color-danger-container, #ffdad6); /* 🎨 soft fill */
|
|
65
|
+
--ab-callout-icon: var(--ab-color-on-danger-container, #3b0907); /* 🔣 ♿ on-container: ≥ 4.5:1 on the fill in every scheme (the accent is not, in high contrast) */
|
|
66
|
+
--ab-callout-text: var(--ab-color-on-danger-container, #3b0907); /* 🖋️ text on the fill */
|
|
67
|
+
}
|
|
68
|
+
.abCalloutIcon { flex: none; display: inline-flex; padding-top: 2px; color: var(--ab-callout-icon, var(--ab-callout-accent)); } /* 🔣 */
|
|
69
|
+
.abCalloutBody { flex: 1 1 auto; min-width: 0; } /* 📝 */
|
|
70
|
+
/* 🔠 0.4.1 (Joseph 0.2.24, gap 1): theme's base `body, p { font-size: 24px }` hit the title + text <p>s, even outside
|
|
71
|
+
.ab-prose. They inherit the callout's own size + leading instead (theme ≥ 0.3.8 .ab-prose fix covers prose pages). */
|
|
72
|
+
.abCalloutBody :where(p) { font-size: inherit; line-height: inherit; letter-spacing: inherit; word-spacing: inherit; } /* 🔠 */
|
|
73
|
+
.abCalloutTitle { margin: 0 0 4px; font-weight: 700; } /* 🏷️ */
|
|
74
|
+
.abCalloutText > :first-child { margin-top: 0; } /* ⬆️ */
|
|
75
|
+
.abCalloutText > :last-child { margin-bottom: 0; } /* ⬇️ */
|
|
@@ -0,0 +1,76 @@
|
|
|
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: AbCodeBlockCopy (0.3.4)
|
|
28
|
+
* @file: ab-code-block/copy.tsx
|
|
29
|
+
* @type: Client component (the AbCodeBlock copy island)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more 😜!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
'use client';
|
|
40
|
+
|
|
41
|
+
// ⚛️ React
|
|
42
|
+
import { useRef, type ReactElement } from 'react';
|
|
43
|
+
// 📋 clipboard (hooks ≥ 0.1.6, deep import)
|
|
44
|
+
import { useAbClipboard } from 'ab-nextjs-hooks/useAbClipboard';
|
|
45
|
+
// 🔘 the shared icon button
|
|
46
|
+
import AbIconButton from '../ab-icon-button';
|
|
47
|
+
// 🎨 styles
|
|
48
|
+
import styles from './styles.module.css';
|
|
49
|
+
|
|
50
|
+
/** ⚙️ props */
|
|
51
|
+
export interface AbCodeBlockCopyProps {
|
|
52
|
+
code?: string; // 📋 the raw source (else the block's <pre> text)
|
|
53
|
+
label: string; // ♿ "Copy code"
|
|
54
|
+
copiedLabel: string; // ✅ "Copied"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 📋 the copy button: copies `code`, or the text of its own block's code; "Copied" is announced politely */
|
|
58
|
+
const AbCodeBlockCopy = ({ code, label, copiedLabel }: AbCodeBlockCopyProps): ReactElement => {
|
|
59
|
+
const ref = useRef<HTMLSpanElement>(null); // 📍 to find the block around us
|
|
60
|
+
const { copy, copied } = useAbClipboard(); // 📋 resets after 2s
|
|
61
|
+
const onCopy = () => {
|
|
62
|
+
const block = ref.current?.closest('[data-ab-part="code-block"]'); // 🧱 our AbCodeBlock
|
|
63
|
+
const text = code ?? block?.querySelector('[data-ab-part="code-block-code"]')?.textContent ?? ''; // 📝 what to copy
|
|
64
|
+
void copy(text.replace(/\n$/, '')); // 📋 (no trailing newline)
|
|
65
|
+
};
|
|
66
|
+
return (
|
|
67
|
+
<span ref={ref} className={styles.abCodeBlockCopy} data-ab-part="code-block-copy">
|
|
68
|
+
<AbIconButton icon={copied ? 'check' : 'content_copy'} label={label} naked onClick={onCopy} /> {/* 🔘 name stays the action */}
|
|
69
|
+
<span className={styles.srOnly} role="status" aria-live="polite">{copied ? copiedLabel : ''}</span> {/* 📣 */}
|
|
70
|
+
</span>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// 📦 exports
|
|
75
|
+
export default AbCodeBlockCopy;
|
|
76
|
+
export { AbCodeBlockCopy };
|
|
@@ -0,0 +1,130 @@
|
|
|
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: AbCodeBlock (0.3.4, Joseph 0.2.24 MDX docs)
|
|
28
|
+
* @file: ab-code-block/index.tsx
|
|
29
|
+
* @type: Server component (no hooks; the copy button is a client island)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbCodeBlock filename="app/page.tsx" language="tsx" code={source} html={await codeToHtml(source, …)} />
|
|
34
|
+
* 2+|> <AbCodeBlock language="bash" copyLabel={t('copy')} copiedLabel={t('copied')}><pre><code>pnpm add ab-nextjs-components</code></pre></AbCodeBlock>
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
39
|
+
* MOTTO: We'll always do more 😜!!!
|
|
40
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
// ⚛️ React
|
|
44
|
+
import { Children, cloneElement, isValidElement, type ReactElement, type ReactNode } from 'react';
|
|
45
|
+
// 🧵 classes
|
|
46
|
+
import clsx from 'clsx';
|
|
47
|
+
// 📋 the copy button (the only client part)
|
|
48
|
+
import AbCodeBlockCopy from './copy';
|
|
49
|
+
// 🎨 styles
|
|
50
|
+
import styles from './styles.module.css';
|
|
51
|
+
|
|
52
|
+
// 🔤 escape a name for an HTML attribute (the `html` path)
|
|
53
|
+
const escAttr = (v: string) => v.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<'); // 🧹
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* ⌨️ 0.4.0 (God): a plain <pre> gets tabIndex 0 (keyboard users can scroll long lines with the arrow keys) and a name.
|
|
57
|
+
* Shiki's <pre tabindex="0"> keeps its own tabindex (never doubled); an existing aria-label is never replaced.
|
|
58
|
+
*/
|
|
59
|
+
function withAbFocusablePre(children: ReactNode, name?: string): ReactNode {
|
|
60
|
+
return Children.map(children, (c) => {
|
|
61
|
+
if (!isValidElement<Record<string, unknown>>(c) || c.type !== 'pre') return c; // 🙅 only a direct <pre>
|
|
62
|
+
const extra: Record<string, unknown> = {}; // 🧩 what we add
|
|
63
|
+
if (c.props.tabIndex == null && c.props.tabindex == null) extra.tabIndex = 0; // ⌨️ focusable
|
|
64
|
+
if (name && c.props['aria-label'] == null && c.props['aria-labelledby'] == null) extra['aria-label'] = name; // 🏷️ named
|
|
65
|
+
return Object.keys(extra).length ? cloneElement(c, extra) : c; // ✅
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 🧾 the same for an `html` string: patch the FIRST <pre …> tag only */
|
|
70
|
+
function withAbFocusablePreHtml(html: string, name?: string): string {
|
|
71
|
+
return html.replace(/<pre\b([^>]*)>/i, (tag, attrs: string) => {
|
|
72
|
+
let a = attrs; // 🧩
|
|
73
|
+
if (!/\stabindex\s*=/i.test(a)) a += ' tabindex="0"'; // ⌨️ Shiki already has one → untouched
|
|
74
|
+
if (name && !/\saria-label(ledby)?\s*=/i.test(a)) a += ` aria-label="${escAttr(name)}"`; // 🏷️
|
|
75
|
+
return `<pre${a}>`; // ✅
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** ⚙️ props */
|
|
80
|
+
export interface AbCodeBlockProps {
|
|
81
|
+
children?: ReactNode; // 🖍️ Shiki-rendered (or plain) <pre><code>…</code></pre>, e.g. from rehype-pretty-code in MDX
|
|
82
|
+
html?: string; // 🧾 OR a pre-rendered HTML string (Shiki `codeToHtml`), trusted: YOU render it, never user input
|
|
83
|
+
code?: string; // 📋 the raw source to copy (best). Without it the button copies the rendered <pre>'s text
|
|
84
|
+
title?: ReactNode; // 🏷️ a caption in the header bar (e.g. "Install")
|
|
85
|
+
filename?: string; // 📄 a file name in the header bar (mono), e.g. "app/page.tsx"
|
|
86
|
+
language?: string; // 🔤 e.g. "tsx": a small badge + data-language (+ the region's name when there is no title)
|
|
87
|
+
copyLabel?: string; // ♿ the copy button's name (default "Copy code")
|
|
88
|
+
copiedLabel?: string; // ✅ announced after a copy (default "Copied")
|
|
89
|
+
copy?: boolean; // 📋 show the copy button (default true)
|
|
90
|
+
className?: string; // 🏷️
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 💻 AbCodeBlock — a server-rendered code block for MDX docs: an optional header (title / filename · language),
|
|
95
|
+
* the highlighted code (children or an `html` string, both from Shiki), and a small client copy button. It is a
|
|
96
|
+
* <figure> (with a <figcaption> when there is a header), so the caption names the code for assistive tech; the
|
|
97
|
+
* <pre> is focusable (Shiki's tabindex kept, a plain one gets tabIndex 0) and named, so keyboard users can scroll it.
|
|
98
|
+
*/
|
|
99
|
+
const AbCodeBlock = ({ children, html, code, title, filename, language, copyLabel = 'Copy code', copiedLabel = 'Copied', copy = true, className }: AbCodeBlockProps): ReactElement => {
|
|
100
|
+
const hasHeader = title != null || !!filename || !!language; // 🏷️ a header bar?
|
|
101
|
+
const caption = (title ?? filename) != null; // 💬 a visible name for the figure
|
|
102
|
+
// 🏷️ the scroller's name: the title (if text), else the filename, else "<language> code"
|
|
103
|
+
const preName = typeof title === 'string' ? title : filename || (language ? `${language} code` : undefined);
|
|
104
|
+
return (
|
|
105
|
+
<figure
|
|
106
|
+
className={clsx('AbCodeBlock', 'ab-prose-none', styles.abCodeBlock, className)} // 🎨 (opts out of theme .ab-prose)
|
|
107
|
+
data-ab-part="code-block" // 🗂️ the copy island finds its <pre> through this
|
|
108
|
+
data-language={language || undefined} // 🔤
|
|
109
|
+
aria-label={!caption && language ? `${language} code` : undefined} // ♿ a name when nothing else gives one
|
|
110
|
+
>
|
|
111
|
+
{hasHeader && (
|
|
112
|
+
<figcaption className={styles.abCodeBlockHead} data-ab-part="code-block-head">
|
|
113
|
+
{title != null && <span className={styles.abCodeBlockTitle}>{title}</span> /* 🏷️ */}
|
|
114
|
+
{filename && <span className={styles.abCodeBlockFile} translate="no">{filename}</span> /* 📄 */}
|
|
115
|
+
{language && <span className={styles.abCodeBlockLang} aria-hidden={caption ? undefined : true} translate="no">{language}</span> /* 🔤 */}
|
|
116
|
+
</figcaption>
|
|
117
|
+
)}
|
|
118
|
+
<div className={styles.abCodeBlockBody}>
|
|
119
|
+
{html != null
|
|
120
|
+
? <div className={styles.abCodeBlockCode} data-ab-part="code-block-code" dangerouslySetInnerHTML={{ __html: withAbFocusablePreHtml(html, preName) }} /> // 🧾 Shiki string (+ a focusable, named <pre>)
|
|
121
|
+
: <div className={styles.abCodeBlockCode} data-ab-part="code-block-code">{withAbFocusablePre(children, preName)}</div> /* 🖍️ Shiki children (+ a focusable, named <pre>) */}
|
|
122
|
+
{copy && <AbCodeBlockCopy code={code} label={copyLabel} copiedLabel={copiedLabel} /> /* 📋 client island */}
|
|
123
|
+
</div>
|
|
124
|
+
</figure>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// 📦 exports
|
|
129
|
+
export default AbCodeBlock;
|
|
130
|
+
export { AbCodeBlock };
|
|
@@ -0,0 +1,60 @@
|
|
|
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: AbCodeBlock styles (0.3.4)
|
|
28
|
+
* @file: ab-code-block/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
|
+
/* 💻 the block: dark code surface tokens (theme ≥ 0.3.4), rounded, clipped */
|
|
40
|
+
.abCodeBlock {
|
|
41
|
+
margin: 0 0 1.25em; /* ↕️ prose rhythm */
|
|
42
|
+
overflow: hidden; /* ✂️ rounded corners clip the header + code */
|
|
43
|
+
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); /* 🔲 */
|
|
44
|
+
border-radius: var(--ab-radius-code, 12px); /* 🟢 */
|
|
45
|
+
background: var(--ab-color-code-surface, #231a14); /* 🎨 */
|
|
46
|
+
color: var(--ab-color-on-code-surface, #f4ece5); /* 🖋️ */
|
|
47
|
+
color-scheme: dark; /* 🌑 0.4.1 (Joseph 0.2.24, gap 3): scrollbars, selection + the copy button match the dark surface in every page scheme */
|
|
48
|
+
}
|
|
49
|
+
/* 🏷️ header: title · filename · language badge */
|
|
50
|
+
.abCodeBlockHead { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px 0 16px; border-bottom: 1px solid rgb(255 255 255 / 0.08); font: 500 12.5px/1.2 var(--ab-font-body, system-ui, sans-serif); } /* 📐 */
|
|
51
|
+
.abCodeBlockTitle { font-weight: 600; } /* 🏷️ */
|
|
52
|
+
.abCodeBlockFile { font-family: var(--ab-font-code, ui-monospace, monospace); opacity: 0.85; } /* 📄 */
|
|
53
|
+
.abCodeBlockLang { margin-inline-start: auto; padding: 2px 6px; border-radius: 4px; background: rgb(255 255 255 / 0.08); font: 600 11px/1 var(--ab-font-code, ui-monospace, monospace); text-transform: lowercase; } /* 🔤 badge */
|
|
54
|
+
/* 🧱 body: the code + the copy button in its top-end corner */
|
|
55
|
+
.abCodeBlockBody { position: relative; } /* 📌 */
|
|
56
|
+
.abCodeBlockCode :where(pre) { margin: 0; padding: 14px 56px 14px 16px; overflow-x: auto; background: transparent !important; font: 13.5px/1.6 var(--ab-font-code, ui-monospace, monospace); } /* ↔️ scrolls; room for the button; Shiki's inline bg yields to ours */
|
|
57
|
+
.abCodeBlockCode :where(pre):focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; } /* ♿ */
|
|
58
|
+
.abCodeBlockCode :where(code) { font: inherit; } /* 🔤 */
|
|
59
|
+
.abCodeBlockCopy { position: absolute; inset-block-start: 4px; inset-inline-end: 4px; color: inherit; } /* 📋 44px button (AbIconButton) */
|
|
60
|
+
.srOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* 🕶️ */
|
|
@@ -0,0 +1,144 @@
|
|
|
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: AbContentTabs + AbContentTab (0.3.4, Joseph 0.2.24 MDX docs)
|
|
28
|
+
* @file: ab-content-tabs/index.tsx
|
|
29
|
+
* @type: Client component
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> // mdx-components.tsx: { Tabs: AbContentTabs, Tab: AbContentTab }
|
|
34
|
+
* 2+|> <Tabs label="Package manager"><Tab label="pnpm">…</Tab><Tab label="npm">…</Tab></Tabs>
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
39
|
+
* MOTTO: We'll always do more 😜!!!
|
|
40
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
'use client';
|
|
44
|
+
|
|
45
|
+
// ⚛️ React
|
|
46
|
+
import { Children, isValidElement, useId, useRef, useState, type KeyboardEvent, type ReactElement, type ReactNode } from 'react';
|
|
47
|
+
// 🧵 classes
|
|
48
|
+
import clsx from 'clsx';
|
|
49
|
+
// 🎨 styles
|
|
50
|
+
import styles from './styles.module.css';
|
|
51
|
+
|
|
52
|
+
/** ⚙️ one tab (a marker element: AbContentTabs reads its props, it renders only its children) */
|
|
53
|
+
export interface AbContentTabProps {
|
|
54
|
+
label: ReactNode; // 🏷️ the tab's text, e.g. "pnpm"
|
|
55
|
+
value?: string; // 🔑 a stable key (default: the label text or the index), for `defaultValue`
|
|
56
|
+
children?: ReactNode; // 📝 the panel content (MDX)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 📄 AbContentTab — one panel of an AbContentTabs (MDX `<Tab>`). On its own it just renders its children. */
|
|
60
|
+
const AbContentTab = ({ children }: AbContentTabProps): ReactElement => <>{children}</>;
|
|
61
|
+
|
|
62
|
+
/** ⚙️ props */
|
|
63
|
+
export interface AbContentTabsProps {
|
|
64
|
+
children?: ReactNode; // 📄 AbContentTab elements (anything else is ignored)
|
|
65
|
+
label?: string; // ♿ the tablist's name, e.g. "Package manager"
|
|
66
|
+
defaultValue?: string; // 🎯 the tab open first (default the first)
|
|
67
|
+
onChange?: (value: string) => void; // 📣 after a switch
|
|
68
|
+
className?: string; // 🏷️
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 🔑 a tab's value: its `value`, else its string label, else its index
|
|
72
|
+
const valueOf = (p: AbContentTabProps, i: number) => p.value ?? (typeof p.label === 'string' ? p.label : String(i));
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 🗂️ AbContentTabs — the WAI-ARIA tabs pattern for MDX `<Tabs>`: a role="tablist" of buttons (roving tabindex,
|
|
76
|
+
* ←/→ wrap and flip in RTL, Home/End; selection follows focus) over role="tabpanel"s linked by aria-controls /
|
|
77
|
+
* aria-labelledby. Every panel is in the HTML (inactive ones `hidden`), so the server render already has the
|
|
78
|
+
* content. AbTabs is a nav strip of links, so this is its own small component. No motion (the switch is instant).
|
|
79
|
+
*/
|
|
80
|
+
const AbContentTabs = ({ children, label, defaultValue, onChange, className }: AbContentTabsProps): ReactElement => {
|
|
81
|
+
const id = useId(); // 🆔 tab + panel ids
|
|
82
|
+
// 📄 the AbContentTab children (MDX passes them through as elements)
|
|
83
|
+
const tabs = Children.toArray(children).filter((c): c is ReactElement<AbContentTabProps> => isValidElement(c) && (c.type === AbContentTab || (c.props as Partial<AbContentTabProps>)?.label != null)); // 🛟 also any element with a `label` (e.g. a wrapped Tab across the RSC boundary)
|
|
84
|
+
const values = tabs.map((t, i) => valueOf(t.props, i)); // 🔑
|
|
85
|
+
const [selected, setSelected] = useState(() => (defaultValue && values.includes(defaultValue) ? defaultValue : values[0])); // 🎯
|
|
86
|
+
const current = values.includes(selected) ? selected : values[0]; // 🛟 children changed
|
|
87
|
+
const refs = useRef<Array<HTMLButtonElement | null>>([]); // 📍 to move focus
|
|
88
|
+
const select = (v: string) => { setSelected(v); onChange?.(v); }; // ✅
|
|
89
|
+
// ⌨️ roving keys on the tablist
|
|
90
|
+
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
91
|
+
const rtl = e.currentTarget.closest('[dir]')?.getAttribute('dir') === 'rtl'; // 🌍
|
|
92
|
+
const i = values.indexOf(current); const n = values.length; // 📍
|
|
93
|
+
const next = rtl ? 'ArrowLeft' : 'ArrowRight'; const prev = rtl ? 'ArrowRight' : 'ArrowLeft'; // ↔️
|
|
94
|
+
const j = e.key === next ? (i + 1) % n : e.key === prev ? (i - 1 + n) % n : e.key === 'Home' ? 0 : e.key === 'End' ? n - 1 : -1; // 🎯
|
|
95
|
+
if (j < 0) return; // 🙅 other keys
|
|
96
|
+
e.preventDefault(); // 🛑 no scroll
|
|
97
|
+
select(values[j]); // ✅ automatic activation
|
|
98
|
+
refs.current[j]?.focus(); // 🎯
|
|
99
|
+
};
|
|
100
|
+
return (
|
|
101
|
+
<div className={clsx('AbContentTabs', styles.abContentTabs, className)} data-ab-part="content-tabs">
|
|
102
|
+
<div role="tablist" aria-label={label} className={styles.abContentTabsList} onKeyDown={onKeyDown}>
|
|
103
|
+
{tabs.map((t, i) => {
|
|
104
|
+
const on = values[i] === current; // ✅
|
|
105
|
+
return (
|
|
106
|
+
<button
|
|
107
|
+
key={values[i]} // 🔑
|
|
108
|
+
ref={(el) => { refs.current[i] = el; }} // 📍
|
|
109
|
+
type="button" // 🧾
|
|
110
|
+
role="tab" // ♿
|
|
111
|
+
id={`${id}-tab-${i}`} // 🆔
|
|
112
|
+
aria-selected={on} // ✅
|
|
113
|
+
aria-controls={`${id}-panel-${i}`} // 🔗
|
|
114
|
+
tabIndex={on ? 0 : -1} // ⌨️ one tab stop
|
|
115
|
+
className={styles.abContentTab} // 🎨
|
|
116
|
+
data-ab-part="content-tab" // 🗂️
|
|
117
|
+
onClick={() => select(values[i])} // 🖱️
|
|
118
|
+
>
|
|
119
|
+
{t.props.label}
|
|
120
|
+
</button>
|
|
121
|
+
);
|
|
122
|
+
})}
|
|
123
|
+
</div>
|
|
124
|
+
{tabs.map((t, i) => (
|
|
125
|
+
<div
|
|
126
|
+
key={values[i]} // 🔑
|
|
127
|
+
role="tabpanel" // ♿
|
|
128
|
+
id={`${id}-panel-${i}`} // 🆔
|
|
129
|
+
aria-labelledby={`${id}-tab-${i}`} // 🔗
|
|
130
|
+
hidden={values[i] !== current} // 🙈 inactive
|
|
131
|
+
tabIndex={0} // ⌨️ reachable even when it has no focusable content (APG)
|
|
132
|
+
className={styles.abContentTabsPanel} // 🎨
|
|
133
|
+
data-ab-part="content-tab-panel" // 🗂️
|
|
134
|
+
>
|
|
135
|
+
{t.props.children}
|
|
136
|
+
</div>
|
|
137
|
+
))}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// 📦 exports
|
|
143
|
+
export default AbContentTabs;
|
|
144
|
+
export { AbContentTabs, AbContentTab };
|
|
@@ -0,0 +1,61 @@
|
|
|
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: AbContentTabs styles (0.3.4)
|
|
28
|
+
* @file: ab-content-tabs/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
|
+
.abContentTabs { margin: 0 0 1.25em; } /* ↕️ prose rhythm */
|
|
40
|
+
/* 🗂️ the tab row: a hairline under, scrolls when narrow */
|
|
41
|
+
.abContentTabsList { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--ab-color-div, rgb(92 64 48 / 0.11)); } /* 📐 */
|
|
42
|
+
/* 🔘 a tab: 44px tall target, an underline when selected (not colour alone) */
|
|
43
|
+
.abContentTab {
|
|
44
|
+
flex: none; /* 📏 */
|
|
45
|
+
min-height: 44px; /* 👆 */
|
|
46
|
+
padding: 0 14px; /* 📦 */
|
|
47
|
+
margin-bottom: -1px; /* ➖ sits on the hairline */
|
|
48
|
+
border: 0; /* 🧹 */
|
|
49
|
+
border-bottom: 2px solid transparent; /* ➖ the selected bar's slot */
|
|
50
|
+
background: none; /* 🧹 */
|
|
51
|
+
color: var(--ab-color-muted, #6b5b50); /* 🖋️ */
|
|
52
|
+
font: 500 14px/1 var(--ab-font-body, inherit); /* 🔤 */
|
|
53
|
+
cursor: pointer; /* 👆 */
|
|
54
|
+
}
|
|
55
|
+
.abContentTab[aria-selected='true'] { border-bottom-color: var(--ab-color-accent, #a67c52); color: var(--ab-color-text, #211a16); font-weight: 650; } /* ✅ */
|
|
56
|
+
@media (hover: hover) { .abContentTab:hover { color: var(--ab-color-text, #211a16); } } /* 🖱️ */
|
|
57
|
+
.abContentTab:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; border-radius: 6px; } /* ♿ */
|
|
58
|
+
.abContentTabsPanel { padding-top: 12px; } /* 📦 */
|
|
59
|
+
.abContentTabsPanel:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; border-radius: 6px; } /* ♿ */
|
|
60
|
+
.abContentTabsPanel > :first-child { margin-top: 0; } /* ⬆️ */
|
|
61
|
+
.abContentTabsPanel > :last-child { margin-bottom: 0; } /* ⬇️ */
|
|
@@ -0,0 +1,95 @@
|
|
|
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: AbDocPager (0.3.4, Joseph 0.2.24 MDX docs)
|
|
28
|
+
* @file: ab-doc-pager/index.tsx
|
|
29
|
+
* @type: Server-safe component (links via AbLinkProvider)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* 1+|> <AbDocPager prev={{ href: '/docs/install', title: 'Install' }} next={{ href: '/docs/theme', title: 'Theme' }} />
|
|
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
|
+
// 🔗 the app's link (AbLinkProvider, e.g. the i18n Link)
|
|
47
|
+
import Link from '../ab-link';
|
|
48
|
+
// 🔣 the arrows (server-safe icon)
|
|
49
|
+
import AbIcon from '../server/ab-icon';
|
|
50
|
+
// 🎨 styles
|
|
51
|
+
import styles from './styles.module.css';
|
|
52
|
+
|
|
53
|
+
/** 🔗 one side of the pager */
|
|
54
|
+
export interface AbDocPagerLink {
|
|
55
|
+
href: string; // 🔗
|
|
56
|
+
title: ReactNode; // 🏷️ the page's title
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** ⚙️ props */
|
|
60
|
+
export interface AbDocPagerProps {
|
|
61
|
+
prev?: AbDocPagerLink | null; // ⬅️ the previous page (none on the first)
|
|
62
|
+
next?: AbDocPagerLink | null; // ➡️ the next page (none on the last)
|
|
63
|
+
labels?: { nav?: string; prev?: string; next?: string }; // 🌍 "Pages", "Previous", "Next"
|
|
64
|
+
className?: string; // 🏷️
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ⏮️⏭️ AbDocPager — the "Previous / Next" cards at the end of a docs page. A <nav> named "Pages"; each card is
|
|
69
|
+
* one link (≥ 44px tall) whose name reads "Previous: Install" (the small label is part of the link text).
|
|
70
|
+
* rel="prev" / rel="next" for crawlers. Server-safe: no hooks of its own.
|
|
71
|
+
*/
|
|
72
|
+
const AbDocPager = ({ prev, next, labels = {}, className }: AbDocPagerProps): ReactElement | null => {
|
|
73
|
+
const L = { nav: 'Pages', prev: 'Previous', next: 'Next', ...labels }; // 🌍
|
|
74
|
+
if (!prev && !next) return null; // 🙅 nothing to show
|
|
75
|
+
return (
|
|
76
|
+
<nav aria-label={L.nav} className={clsx('AbDocPager', 'ab-prose-none', styles.abDocPager, className)} data-ab-part="doc-pager">
|
|
77
|
+
{prev ? (
|
|
78
|
+
<Link href={prev.href} rel="prev" className={styles.abDocPagerLink} data-ab-part="doc-pager-prev">
|
|
79
|
+
<span className={styles.abDocPagerHint}><AbIcon name="arrow_back" size={16} />{L.prev}<span className={styles.srOnly}>: </span></span>
|
|
80
|
+
<span className={styles.abDocPagerTitle}>{prev.title}</span>
|
|
81
|
+
</Link>
|
|
82
|
+
) : <span aria-hidden="true" />}
|
|
83
|
+
{next && (
|
|
84
|
+
<Link href={next.href} rel="next" className={clsx(styles.abDocPagerLink, styles.abDocPagerNext)} data-ab-part="doc-pager-next">
|
|
85
|
+
<span className={styles.abDocPagerHint}>{L.next}<span className={styles.srOnly}>: </span><AbIcon name="arrow_forward" size={16} /></span>
|
|
86
|
+
<span className={styles.abDocPagerTitle}>{next.title}</span>
|
|
87
|
+
</Link>
|
|
88
|
+
)}
|
|
89
|
+
</nav>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// 📦 exports
|
|
94
|
+
export default AbDocPager;
|
|
95
|
+
export { AbDocPager };
|
|
@@ -0,0 +1,49 @@
|
|
|
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: AbDocPager styles (0.3.4)
|
|
28
|
+
* @file: ab-doc-pager/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
|
+
.abDocPager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 2em 0 0; } /* 📐 two equal cards */
|
|
40
|
+
@media (width < 560px) { .abDocPager { grid-template-columns: 1fr; } } /* 📱 stacked */
|
|
41
|
+
.abDocPagerLink { display: flex; flex-direction: column; gap: 4px; min-height: 44px; padding: 12px 16px; border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-card, 14px); background: var(--ab-color-card, #fff); color: var(--ab-color-text, #211a16); text-decoration: none; } /* 🃏 */
|
|
42
|
+
.abDocPagerNext { grid-column: 2; align-items: flex-end; text-align: end; } /* ➡️ always on the end side */
|
|
43
|
+
@media (width < 560px) { .abDocPagerNext { grid-column: 1; } } /* 📱 */
|
|
44
|
+
@media (hover: hover) { .abDocPagerLink:hover { border-color: var(--ab-color-accent, #a67c52); } } /* 🖱️ */
|
|
45
|
+
.abDocPagerLink:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* ♿ */
|
|
46
|
+
.abDocPagerHint { display: inline-flex; align-items: center; gap: 4px; color: var(--ab-color-muted, #6b5b50); font-size: 12.5px; } /* 🏷️ */
|
|
47
|
+
.abDocPagerTitle { font-weight: 650; } /* 🏷️ */
|
|
48
|
+
.srOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* 🕶️ */
|
|
49
|
+
[dir="rtl"] .abDocPagerHint > :global(.AbIcon) { transform: scaleX(-1); } /* 🌍 arrows point the reading way */
|
package/ab-icon/builtin.ts
CHANGED
|
@@ -43,6 +43,10 @@ import lightMode from 'ab-nextjs-icons/ab-icons/icons/light_mode'; // 🌞 AbThe
|
|
|
43
43
|
import darkMode from 'ab-nextjs-icons/ab-icons/icons/dark_mode'; // 🌙 AbThemeToggle
|
|
44
44
|
import computer from 'ab-nextjs-icons/ab-icons/icons/computer'; // 🖥️ AbThemeToggle (system)
|
|
45
45
|
import brightnessAuto from 'ab-nextjs-icons/ab-icons/icons/brightness_auto'; // 🌗🅰️ 0.3.2: system theme (AbThemeToggle, AbMobileHeader, AbSettingsDrawer; icons ≥ 0.2.7)
|
|
46
|
+
import info from 'ab-nextjs-icons/ab-icons/icons/info'; // ℹ️ 0.3.4 AbCallout note
|
|
47
|
+
import lightbulb from 'ab-nextjs-icons/ab-icons/icons/lightbulb'; // 💡 0.3.4 AbCallout tip
|
|
48
|
+
import warning from 'ab-nextjs-icons/ab-icons/icons/warning'; // ⚠️ 0.3.4 AbCallout warning
|
|
49
|
+
import error from 'ab-nextjs-icons/ab-icons/icons/error'; // 🛑 0.3.4 AbCallout danger
|
|
46
50
|
import language from 'ab-nextjs-icons/ab-icons/icons/language'; // 🌐 AbLocaleSwitcher
|
|
47
51
|
import contentCopy from 'ab-nextjs-icons/ab-icons/icons/content_copy'; // 📋 AbInstallSnippet
|
|
48
52
|
import check from 'ab-nextjs-icons/ab-icons/icons/check'; // ✅ AbInstallSnippet (copied)
|
|
@@ -67,6 +71,10 @@ export const AB_ICON_BUILTINS: Record<string, AbIconSvgData> = {
|
|
|
67
71
|
computer, // 🖥️ (kept for apps that still ask for it)
|
|
68
72
|
brightness_auto: brightnessAuto, // 🌗🅰️ 0.3.2: the system theme glyph
|
|
69
73
|
language, // 🌐
|
|
74
|
+
info, // ℹ️ 0.3.4 AbCallout
|
|
75
|
+
lightbulb, // 💡 0.3.4 AbCallout
|
|
76
|
+
warning, // ⚠️ 0.3.4 AbCallout
|
|
77
|
+
error, // 🛑 0.3.4 AbCallout
|
|
70
78
|
content_copy: contentCopy, // 📋
|
|
71
79
|
check, // ✅
|
|
72
80
|
chevron_left: chevronLeft, // ◀️
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-button, 10px); /* 🔲 */
|
|
77
77
|
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); /* 🎨 */
|
|
78
78
|
font-size: 13.5px; line-height: 1; box-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* 🔤 🌗 */
|
|
79
|
+
flex: 0 8 auto; min-width: var(--ab-search-trigger-min-width, 160px); /* 🔎 0.4.1 (Joseph 0.2.24, gap 4): its own space in a flex row; v2: shrinks first (flex-shrink 8) down to 160px, never under */
|
|
79
80
|
}
|
|
80
81
|
.abSearchTrigger[data-size='sm'] {
|
|
81
82
|
flex: none; width: auto; max-width: none; height: 34px; /* 📏 the pill still LOOKS 34px (mock) */
|
package/index.ts
CHANGED
|
@@ -142,6 +142,11 @@ const supportedComponents: Array<ComponentCatalogEntry> = [
|
|
|
142
142
|
{ name: 'AbProfileAvatar', file: 'ab-profile-avatar/index.tsx', kind: 'server', status: 'Done' }, // 🆕 0.2.1 initials / photo / glyph circle (no hooks: client + server)
|
|
143
143
|
{ name: 'AbVersionSwitcher', file: 'ab-version-switcher/index.tsx', kind: 'client', status: 'Done' },
|
|
144
144
|
{ name: 'AbBreadcrumbs', file: 'ab-breadcrumbs/index.tsx', kind: 'server', status: 'Done' },
|
|
145
|
+
{ name: 'AbDocPager', file: 'ab-doc-pager/index.tsx', kind: 'server', status: 'Done' }, // ⏮️⏭️ 0.3.4 (Joseph, 0.2.24 MDX docs): AbDocPager
|
|
146
|
+
{ name: 'AbContentTabs', file: 'ab-content-tabs/index.tsx', kind: 'client', status: 'Done' }, // 🗂️ 0.3.4 (Joseph, 0.2.24 MDX docs): AbContentTabs + AbContentTab (MDX <Tabs>/<Tab>)
|
|
147
|
+
{ name: 'AbContentTab', file: 'ab-content-tabs/index.tsx', kind: 'client', status: 'Done' }, // 🗂️ 0.3.4 (Joseph, 0.2.24 MDX docs): AbContentTabs + AbContentTab (MDX <Tabs>/<Tab>)
|
|
148
|
+
{ name: 'AbCodeBlock', file: 'ab-code-block/index.tsx', kind: 'server', status: 'Done' }, // 💻 0.3.4 (Joseph, 0.2.24 MDX docs): AbCodeBlock (+ its copy island)
|
|
149
|
+
{ name: 'AbCallout', file: 'ab-callout/index.tsx', kind: 'server', status: 'Done' }, // 💡 0.3.4 (Joseph, 0.2.24 MDX docs): AbCallout
|
|
145
150
|
{ name: 'AbList', file: 'ab-list/index.tsx', kind: 'server', status: 'Done' },
|
|
146
151
|
]
|
|
147
152
|
|
|
@@ -244,3 +249,17 @@ export { default as AbProductItem } from './ab-product-item/index.tsx'
|
|
|
244
249
|
export { default as AbDemoBox } from './ab-demo-box/index.tsx'
|
|
245
250
|
export { default as AbDemoCode } from './ab-demo-code/index.tsx'
|
|
246
251
|
export { default as AbPolygon } from './server/ab-polygon/index.tsx'
|
|
252
|
+
// 💡 0.3.4 (Joseph, 0.2.24 MDX docs): AbCallout
|
|
253
|
+
export { default as AbCallout, AB_CALLOUT_ICONS } from './ab-callout/index.tsx'
|
|
254
|
+
export type { AbCalloutProps, AbCalloutVariant } from './ab-callout/index.tsx'
|
|
255
|
+
// 💻 0.3.4 (Joseph, 0.2.24 MDX docs): AbCodeBlock (+ its copy island)
|
|
256
|
+
export { default as AbCodeBlock } from './ab-code-block/index.tsx'
|
|
257
|
+
export { default as AbCodeBlockCopy } from './ab-code-block/copy.tsx'
|
|
258
|
+
export type { AbCodeBlockCopyProps } from './ab-code-block/copy.tsx'
|
|
259
|
+
export type { AbCodeBlockProps } from './ab-code-block/index.tsx'
|
|
260
|
+
// 🗂️ 0.3.4 (Joseph, 0.2.24 MDX docs): AbContentTabs + AbContentTab (MDX <Tabs>/<Tab>)
|
|
261
|
+
export { default as AbContentTabs, AbContentTab } from './ab-content-tabs/index.tsx'
|
|
262
|
+
export type { AbContentTabsProps, AbContentTabProps } from './ab-content-tabs/index.tsx'
|
|
263
|
+
// ⏮️⏭️ 0.3.4 (Joseph, 0.2.24 MDX docs): AbDocPager
|
|
264
|
+
export { default as AbDocPager } from './ab-doc-pager/index.tsx'
|
|
265
|
+
export type { AbDocPagerProps, AbDocPagerLink } from './ab-doc-pager/index.tsx'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ab-nextjs-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"ab-nextjs-animations": "^0.2.5",
|
|
44
44
|
"ab-nextjs-hooks": "^0.1.7",
|
|
45
45
|
"ab-nextjs-icons": "^0.2.7",
|
|
46
|
-
"ab-nextjs-theme": "^0.3.
|
|
46
|
+
"ab-nextjs-theme": "^0.3.9",
|
|
47
47
|
"clsx": "^2",
|
|
48
48
|
"next": "^16.3.4",
|
|
49
49
|
"react": "^19",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"ab-nextjs-animations": "^0.2.5",
|
|
57
57
|
"ab-nextjs-hooks": "^0.1.7",
|
|
58
58
|
"ab-nextjs-icons": "^0.2.7",
|
|
59
|
-
"ab-nextjs-theme": "^0.3.
|
|
59
|
+
"ab-nextjs-theme": "^0.3.9",
|
|
60
60
|
"clsx": "^2.1.1",
|
|
61
61
|
"esbuild": "^0.28.2",
|
|
62
62
|
"eslint": "^9.39.0",
|
|
@@ -141,7 +141,11 @@
|
|
|
141
141
|
"ab-card",
|
|
142
142
|
"ab-package-card",
|
|
143
143
|
"ab-toc",
|
|
144
|
-
"ab-error-hero"
|
|
144
|
+
"ab-error-hero",
|
|
145
|
+
"ab-callout",
|
|
146
|
+
"ab-code-block",
|
|
147
|
+
"ab-content-tabs",
|
|
148
|
+
"ab-doc-pager"
|
|
145
149
|
],
|
|
146
150
|
"exports": {
|
|
147
151
|
".": {
|
|
@@ -241,7 +245,12 @@
|
|
|
241
245
|
"./ab-toc": "./ab-toc/index.tsx",
|
|
242
246
|
"./ab-error-hero": "./ab-error-hero/index.tsx",
|
|
243
247
|
"./ab-sidebar/view": "./ab-sidebar/view.tsx",
|
|
244
|
-
"./ab-navbar/view": "./ab-navbar/view.tsx"
|
|
248
|
+
"./ab-navbar/view": "./ab-navbar/view.tsx",
|
|
249
|
+
"./ab-callout": "./ab-callout/index.tsx",
|
|
250
|
+
"./ab-code-block": "./ab-code-block/index.tsx",
|
|
251
|
+
"./ab-code-block/copy": "./ab-code-block/copy.tsx",
|
|
252
|
+
"./ab-content-tabs": "./ab-content-tabs/index.tsx",
|
|
253
|
+
"./ab-doc-pager": "./ab-doc-pager/index.tsx"
|
|
245
254
|
},
|
|
246
255
|
"peerDependenciesMeta": {
|
|
247
256
|
"ab-nextjs-theme": {
|
package/types/index.d.ts
CHANGED
|
@@ -139,3 +139,17 @@ export { default as AbProductItem } from '../ab-product-item/index.tsx';
|
|
|
139
139
|
export { default as AbDemoBox } from '../ab-demo-box/index.tsx';
|
|
140
140
|
export { default as AbDemoCode } from '../ab-demo-code/index.tsx';
|
|
141
141
|
export { default as AbPolygon } from '../server/ab-polygon/index.tsx';
|
|
142
|
+
// 💡 0.3.4 (Joseph, 0.2.24 MDX docs): AbCallout
|
|
143
|
+
export { default as AbCallout, AB_CALLOUT_ICONS } from '../ab-callout/index.tsx';
|
|
144
|
+
export type { AbCalloutProps, AbCalloutVariant } from '../ab-callout/index.tsx';
|
|
145
|
+
// 💻 0.3.4 (Joseph, 0.2.24 MDX docs): AbCodeBlock (+ its copy island)
|
|
146
|
+
export { default as AbCodeBlock } from '../ab-code-block/index.tsx';
|
|
147
|
+
export { default as AbCodeBlockCopy } from '../ab-code-block/copy.tsx';
|
|
148
|
+
export type { AbCodeBlockCopyProps } from '../ab-code-block/copy.tsx';
|
|
149
|
+
export type { AbCodeBlockProps } from '../ab-code-block/index.tsx';
|
|
150
|
+
// 🗂️ 0.3.4 (Joseph, 0.2.24 MDX docs): AbContentTabs + AbContentTab (MDX <Tabs>/<Tab>)
|
|
151
|
+
export { default as AbContentTabs, AbContentTab } from '../ab-content-tabs/index.tsx';
|
|
152
|
+
export type { AbContentTabsProps, AbContentTabProps } from '../ab-content-tabs/index.tsx';
|
|
153
|
+
// ⏮️⏭️ 0.3.4 (Joseph, 0.2.24 MDX docs): AbDocPager
|
|
154
|
+
export { default as AbDocPager } from '../ab-doc-pager/index.tsx';
|
|
155
|
+
export type { AbDocPagerProps, AbDocPagerLink } from '../ab-doc-pager/index.tsx';
|