ab-nextjs-components 0.3.3 โ†’ 0.4.0

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.
@@ -50,5 +50,15 @@
50
50
  .abCrumbSep { width: 16px; height: 16px; flex: none; } /* โ€บ */
51
51
  .abCrumbCurrent { color: var(--ab-crumbs-current); font-weight: 650; overflow: hidden; text-overflow: ellipsis; } /* ๐ŸŽฏ */
52
52
  .abCrumbLink { color: inherit; text-decoration: none; border-radius: 4px; } /* ๐Ÿ”— */
53
+ /* ๐Ÿ‘† 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 */
54
+ .abCrumbLink,
55
+ .abCrumbCurrent {
56
+ display: inline-flex; /* ๐Ÿ“ */
57
+ align-items: center; /* โ†•๏ธ */
58
+ justify-content: center; /* โ†”๏ธ short labels ("Docs") centre in the 24px box */
59
+ min-width: 24px; /* ๐Ÿ‘† */
60
+ min-height: 24px; /* ๐Ÿ‘† */
61
+ box-sizing: border-box; /* ๐Ÿ“ฆ */
62
+ }
53
63
  .abCrumbLink:hover { color: var(--ab-crumbs-hover); } /* ๐Ÿ–ฑ๏ธ */
54
64
  .abCrumbLink:focus-visible { outline: 2px solid var(--ab-crumbs-ring); outline-offset: 2px; } /* โ™ฟ */
@@ -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,72 @@
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
+ .abCalloutTitle { margin: 0 0 4px; font-weight: 700; } /* ๐Ÿท๏ธ */
71
+ .abCalloutText > :first-child { margin-top: 0; } /* โฌ†๏ธ */
72
+ .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, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;'); // ๐Ÿงน
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,59 @@
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
+ }
48
+ /* ๐Ÿท๏ธ header: title ยท filename ยท language badge */
49
+ .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); } /* ๐Ÿ“ */
50
+ .abCodeBlockTitle { font-weight: 600; } /* ๐Ÿท๏ธ */
51
+ .abCodeBlockFile { font-family: var(--ab-font-code, ui-monospace, monospace); opacity: 0.85; } /* ๐Ÿ“„ */
52
+ .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 */
53
+ /* ๐Ÿงฑ body: the code + the copy button in its top-end corner */
54
+ .abCodeBlockBody { position: relative; } /* ๐Ÿ“Œ */
55
+ .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 */
56
+ .abCodeBlockCode :where(pre):focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: -2px; } /* โ™ฟ */
57
+ .abCodeBlockCode :where(code) { font: inherit; } /* ๐Ÿ”ค */
58
+ .abCodeBlockCopy { position: absolute; inset-block-start: 4px; inset-inline-end: 4px; color: inherit; } /* ๐Ÿ“‹ 44px button (AbIconButton) */
59
+ .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 */
@@ -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, // โ—€๏ธ
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.3",
3
+ "version": "0.4.0",
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.7",
46
+ "ab-nextjs-theme": "^0.3.8",
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.7",
59
+ "ab-nextjs-theme": "^0.3.8",
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';