ab-nextjs-components 0.1.11 โ 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +30 -0
- package/ab-app-bar/index.tsx +181 -0
- package/ab-app-bar/styles.module.css +119 -0
- package/ab-avatar/index.tsx +2 -1
- package/ab-avatar/styles.module.css +32 -0
- package/ab-balloon/index.tsx +134 -23
- package/ab-balloon/styles.module.css +84 -7
- package/ab-brand/index.tsx +1 -1
- package/ab-button/helpers.ts +3 -1
- package/ab-button/index.tsx +17 -3
- package/ab-button/styles.module.css +42 -0
- package/ab-card/index.tsx +89 -0
- package/ab-card/styles.module.css +68 -0
- package/ab-collapsible/index.tsx +1 -1
- package/ab-color/index.tsx +1 -0
- package/ab-color/styles.module.css +32 -0
- package/ab-demo-box/index.tsx +1 -0
- package/ab-demo-box/styles.module.css +32 -0
- package/ab-demo-code/index.tsx +1 -0
- package/ab-demo-code/styles.module.css +32 -0
- package/ab-icon/builtin.ts +15 -1
- package/ab-icon/helpers.ts +37 -0
- package/ab-icon/index.tsx +14 -8
- package/ab-icon/registrar.tsx +68 -0
- package/ab-icon-button/index.tsx +8 -3
- package/ab-image/index.tsx +1 -0
- package/ab-image/styles.module.css +32 -0
- package/ab-info/index.tsx +2 -1
- package/ab-info/styles.module.css +32 -0
- package/ab-input/index.tsx +1 -0
- package/ab-input/styles.module.css +1 -0
- package/ab-install-snippet/styles.module.css +32 -8
- package/ab-kbd/index.tsx +65 -0
- package/ab-kbd/styles.module.css +55 -0
- package/ab-key-feature/index.tsx +2 -1
- package/ab-key-feature/styles.module.css +32 -0
- package/ab-like-button/index.tsx +1 -1
- package/ab-link/index.tsx +112 -0
- package/ab-link/locale.ts +53 -0
- package/ab-locale-switcher/index.tsx +17 -0
- package/ab-locale-switcher/styles.module.css +11 -0
- package/ab-main-headline/index.tsx +1 -0
- package/ab-main-headline/styles.module.css +32 -0
- package/ab-menu/index.tsx +6 -5
- package/ab-menu/styles.module.css +32 -0
- package/ab-name/index.tsx +1 -0
- package/ab-name/styles.module.css +32 -0
- package/ab-navbar/index.tsx +54 -46
- package/ab-navbar/styles.module.css +84 -28
- package/ab-navbar/view.tsx +163 -0
- package/ab-package-card/index.tsx +94 -0
- package/ab-package-card/styles.module.css +41 -0
- package/ab-page-paginator/index.tsx +1 -0
- package/ab-page-paginator/styles.module.css +32 -0
- package/ab-page-switcher/index.tsx +1 -0
- package/ab-page-switcher/styles.module.css +32 -0
- package/ab-preview/index.tsx +1 -0
- package/ab-preview/styles.module.css +32 -0
- package/ab-price/index.tsx +1 -0
- package/ab-price/styles.module.css +32 -0
- package/ab-price-tag/index.tsx +1 -0
- package/ab-price-tag/styles.module.css +32 -0
- package/ab-product/index.tsx +1 -0
- package/ab-product/styles.module.css +32 -0
- package/ab-product-item/index.tsx +1 -0
- package/ab-product-item/styles.module.css +32 -0
- package/ab-search-result/index.tsx +1 -0
- package/ab-search-result/styles.module.css +32 -0
- package/ab-search-trigger/index.tsx +142 -0
- package/ab-search-trigger/styles.module.css +70 -0
- package/ab-sidebar/index.tsx +88 -49
- package/ab-sidebar/styles.module.css +136 -31
- package/ab-sidebar/view.tsx +182 -0
- package/ab-switch-back/index.tsx +2 -1
- package/ab-switch-back/styles.module.css +32 -0
- package/ab-tab/index.tsx +2 -1
- package/ab-tab/styles.module.css +32 -0
- package/ab-tabs/index.tsx +1 -0
- package/ab-tabs/styles.module.css +32 -0
- package/ab-test-hello/index.tsx +1 -0
- package/ab-test-hello/styles.module.css +32 -0
- package/ab-text/index.tsx +1 -0
- package/ab-text/styles.module.css +32 -0
- package/ab-toc/index.tsx +124 -0
- package/ab-toc/styles.module.css +54 -0
- package/css/chrome-mq.css +32 -0
- package/css/doodle.css +32 -0
- package/css/logo.css +32 -0
- package/css/spinner.css +32 -0
- package/css/toast.css +32 -0
- package/index.ts +18 -0
- package/package.json +27 -10
- package/server/ab-avatar/index.tsx +2 -1
- package/server/ab-avatar/styles.module.css +32 -0
- package/server/ab-badge/index.tsx +1 -0
- package/server/ab-badge/styles.module.css +32 -0
- package/server/ab-brand/index.tsx +1 -1
- package/server/ab-button/index.tsx +1 -1
- package/server/ab-button/styles.module.css +11 -0
- package/server/ab-icon/index.tsx +13 -8
- package/server/ab-key-feature/index.tsx +2 -1
- package/server/ab-key-feature/styles.module.css +32 -0
- package/server/ab-name/index.tsx +1 -0
- package/server/ab-name/styles.module.css +32 -0
- package/server/ab-nav-link/index.tsx +2 -1
- package/server/ab-nav-link/styles.module.css +32 -0
- package/server/ab-navbar/index.tsx +44 -45
- package/server/ab-polygon/index.tsx +1 -0
- package/server/ab-polygon/styles.module.css +32 -0
- package/server/ab-sidebar/index.tsx +44 -49
- package/server/ab-switch-back/index.tsx +2 -1
- package/server/ab-switch-back/styles.module.css +32 -0
- package/server/ab-test-hello/index.tsx +1 -0
- package/server/ab-test-hello/styles.module.css +32 -0
- package/server/ab-text/index.tsx +1 -0
- package/server/ab-text/styles.module.css +32 -0
- package/server/index.ts +1 -0
- package/styles.css +32 -0
- package/types/index.d.ts +35 -0
- package/server/ab-navbar/styles.module.css +0 -35
- package/server/ab-sidebar/styles.module.css +0 -41
|
@@ -1,12 +1,89 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-components
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-components
|
|
27
|
+
* @name: AbBalloon - Styles
|
|
28
|
+
* @file: ab-balloon/styles.module.css
|
|
29
|
+
* @type: CSS Module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more ๐!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/* ๐ wrapper: positions the tip */
|
|
2
40
|
.abBalloon {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
41
|
+
position: relative; /* ๐ */
|
|
42
|
+
display: inline-flex; /* ๐ */
|
|
43
|
+
align-items: center; /* โ๏ธ */
|
|
44
|
+
justify-content: center; /* โ๏ธ */
|
|
45
|
+
box-sizing: border-box; /* ๐ฆ */
|
|
46
|
+
max-width: 100%; /* ๐ */
|
|
47
|
+
--pop-in-animation-duration: 160ms; /* ๐ฌ quick pop (package keyframes) */
|
|
8
48
|
}
|
|
9
49
|
|
|
10
50
|
.abBalloon[data-disabled='true'] {
|
|
11
|
-
pointer-events: none;
|
|
51
|
+
pointer-events: none; /* ๐ซ */
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ๐ฌ the tip: hidden until open (JS) or focus/hover (no JS, see below) */
|
|
55
|
+
.abBalloonTip {
|
|
56
|
+
position: absolute; /* ๐ */
|
|
57
|
+
z-index: 50; /* โฌ๏ธ */
|
|
58
|
+
display: none; /* ๐ */
|
|
59
|
+
width: max-content; /* ๐ */
|
|
60
|
+
max-width: 240px; /* ๐ */
|
|
61
|
+
padding: 4px 8px; /* ๐ฆ */
|
|
62
|
+
border-radius: 8px; /* ๐ข */
|
|
63
|
+
background: var(--ab-color-inverse-surface, rgb(54 47 43)); /* ๐จ */
|
|
64
|
+
color: var(--ab-color-inverse-on-surface, rgb(251 238 233)); /* ๐๏ธ */
|
|
65
|
+
font: 500 12px/16px var(--ab-font-sans, system-ui, sans-serif); /* ๐ค */
|
|
66
|
+
pointer-events: none; /* ๐ฑ๏ธ never steals hover */
|
|
67
|
+
white-space: normal; /* โฉ๏ธ */
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ๐๏ธ open */
|
|
71
|
+
.abBalloon[data-open='true'] .abBalloonTip {
|
|
72
|
+
display: block;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ๐ซ JS off: plain CSS focus / hover */
|
|
76
|
+
@media (scripting: none) {
|
|
77
|
+
.abBalloon:focus-within .abBalloonTip,
|
|
78
|
+
.abBalloon:hover .abBalloonTip {
|
|
79
|
+
display: block;
|
|
80
|
+
}
|
|
12
81
|
}
|
|
82
|
+
|
|
83
|
+
/* ๐งญ placement */
|
|
84
|
+
.abBalloon[data-placement='top'] .abBalloonTip { bottom: calc(100% + 6px); left: 50%; translate: -50% 0; }
|
|
85
|
+
.abBalloon[data-placement='bottom'] .abBalloonTip { top: calc(100% + 6px); left: 50%; translate: -50% 0; }
|
|
86
|
+
.abBalloon[data-placement='start'] .abBalloonTip { inset-inline-end: calc(100% + 6px); top: 50%; translate: 0 -50%; }
|
|
87
|
+
.abBalloon[data-placement='end'] .abBalloonTip { inset-inline-start: calc(100% + 6px); top: 50%; translate: 0 -50%; }
|
|
88
|
+
|
|
89
|
+
/* โฟ reduced motion: the component skips the popIn class (pop-in has no reduced-motion rule of its own) */
|
package/ab-brand/index.tsx
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
'use client';
|
|
41
41
|
|
|
42
42
|
import type { CSSProperties, ReactElement } from 'react';
|
|
43
|
-
import Link from 'next/link
|
|
43
|
+
import Link from '../ab-link'; // ๐ G42: injectable via AbLinkProvider (default next/link)
|
|
44
44
|
import Image from 'next/image';
|
|
45
45
|
import clsx from 'clsx';
|
|
46
46
|
import styles from './styles.module.css';
|
package/ab-button/helpers.ts
CHANGED
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
// ๐จ visual types shared by the client + server twins
|
|
40
|
-
|
|
40
|
+
// ๐ฅ 'filled' (0.1.12): solid bronze, painted by ab-nextjs-theme โฅ 0.3.3's
|
|
41
|
+
// `button[data-type="filled"]` rule (fallback in styles.module.css โ .isFilled)
|
|
42
|
+
export type AbButtonType = 'contained' | 'filled' | 'outlined' | 'text';
|
|
41
43
|
// ๐จ colour roles
|
|
42
44
|
export type AbButtonColor = 'primary' | 'secondary' | 'tertiary' | 'white' | 'black';
|
|
43
45
|
// ๐ท๏ธ badge tones (G22): neutral grey or bronze accent
|
package/ab-button/index.tsx
CHANGED
|
@@ -63,7 +63,7 @@ export type { AbButtonBadgeTone, AbButtonColor, AbButtonType, AbButtonDisabledMo
|
|
|
63
63
|
// โ๏ธ props
|
|
64
64
|
export interface AbButtonProps {
|
|
65
65
|
id?: string; // ๐
|
|
66
|
-
type?: AbButtonType; // ๐จ contained / outlined / text
|
|
66
|
+
type?: AbButtonType; // ๐จ contained / filled ๐ฅ / outlined / text
|
|
67
67
|
htmlType?: 'button' | 'submit' | 'reset'; // ๐งพ
|
|
68
68
|
className?: string; // ๐ท๏ธ
|
|
69
69
|
spinnerClassName?: string; // โณ spinner class
|
|
@@ -91,6 +91,18 @@ export interface AbButtonProps {
|
|
|
91
91
|
badgeTone?: AbButtonBadgeTone; // ๐จ NEW: 'neutral' (default) | 'accent'
|
|
92
92
|
disabledReason?: string; // ๐ฌ NEW: SR-only reason, appended to the name while blocked
|
|
93
93
|
focusableWhenDisabled?: boolean; // โจ๏ธ NEW: force aria-disabled (true) or native disabled (false)
|
|
94
|
+
// ===== 0.1.13 (Joseph #7) =====
|
|
95
|
+
// โฟ any aria-* / data-* attribute is passed to the <button>/<a>, e.g. useAbAsideToggle().props
|
|
96
|
+
// (`aria-expanded`, `aria-controls`) or `data-testid`. Our own data-* (type, color, โฆ) still win.
|
|
97
|
+
[aria: `aria-${string}`]: string | number | boolean | undefined;
|
|
98
|
+
[data: `data-${string}`]: string | number | boolean | undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** ๐ pick the aria-* / data-* props to forward (0.1.13) */
|
|
102
|
+
function pickAbButtonPassThrough(props: object): Record<string, unknown> {
|
|
103
|
+
const out: Record<string, unknown> = {}; // ๐ฆ
|
|
104
|
+
for (const [k, v] of Object.entries(props)) if (k.startsWith('aria-') || k.startsWith('data-')) out[k] = v; // โฟ ๐๏ธ
|
|
105
|
+
return out;
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps>(function AbButton(props, ref) {
|
|
@@ -140,11 +152,13 @@ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps
|
|
|
140
152
|
className, // ๐ท๏ธ
|
|
141
153
|
rounded && styles.abButtonRounded, // ๐
|
|
142
154
|
type === 'contained' && styles.isContained, // ๐จ
|
|
155
|
+
type === 'filled' && styles.isFilled, // ๐ฅ solid bronze (theme โฅ 0.3.3 paints it, this is the fallback)
|
|
143
156
|
mode === 'native' && styles.isDisabled, // ๐ซ
|
|
144
157
|
);
|
|
145
158
|
|
|
146
|
-
// ๐๏ธ data attributes for styling/tests
|
|
159
|
+
// ๐๏ธ data attributes for styling/tests (forwarded aria-* / data-* first, so ours win)
|
|
147
160
|
const dataAttrs = {
|
|
161
|
+
...pickAbButtonPassThrough(props), // โฟ 0.1.13
|
|
148
162
|
'data-type': type, // ๐จ
|
|
149
163
|
'data-raised': raised ? 'true' : 'false', // ๐๏ธ
|
|
150
164
|
'data-shrinks': shrinks ? 'true' : 'false', // ๐ค
|
|
@@ -153,7 +167,7 @@ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps
|
|
|
153
167
|
'data-iconpos': iconPosition, // โ๏ธ
|
|
154
168
|
'data-color': color, // ๐จ
|
|
155
169
|
'data-disabled-mode': mode, // ๐ฆ
|
|
156
|
-
}
|
|
170
|
+
};
|
|
157
171
|
|
|
158
172
|
// ๐ฃ legacy Material icon (decorative)
|
|
159
173
|
const legacyIcon = withIcon && icon
|
|
@@ -62,6 +62,17 @@
|
|
|
62
62
|
|
|
63
63
|
.isContained {}
|
|
64
64
|
|
|
65
|
+
/* ๐ฅ Filled (0.1.12): solid bronze fallback for apps on ab-nextjs-theme < 0.3.3.
|
|
66
|
+
* Theme โฅ 0.3.3 ships `button[data-type="filled"]` (higher specificity), which
|
|
67
|
+
* adds the hover / focus / disabled state layers on top of this ๐จ */
|
|
68
|
+
.isFilled {
|
|
69
|
+
--material-icon-color: var(--ab-button-text-color, var(--md-sys-color-on-primary, #fff)); /* ๐จ icon = label */
|
|
70
|
+
|
|
71
|
+
background: var(--ab-button-background-color, var(--md-sys-color-primary, rgb(133 83 24)));
|
|
72
|
+
color: var(--ab-button-text-color, var(--md-sys-color-on-primary, #fff));
|
|
73
|
+
font-weight: bold;
|
|
74
|
+
}
|
|
75
|
+
|
|
65
76
|
.isDisabled {
|
|
66
77
|
pointer-events: none;
|
|
67
78
|
opacity: 0.6;
|
|
@@ -139,3 +150,34 @@
|
|
|
139
150
|
white-space: nowrap; /* ๐ซ */
|
|
140
151
|
border: 0; /* ๐งน */
|
|
141
152
|
}
|
|
153
|
+
|
|
154
|
+
/* ๐ 0.1.13 (Joseph #7): link mode. The theme paints `button[data-type]` and `a[role="button"][data-type]`,
|
|
155
|
+
* but a real link (no role=button: it navigates) matched neither, so it rendered at 20px with no padding.
|
|
156
|
+
* These mirror the theme's box rules for <a>, using the same --ab-button-* overrides. */
|
|
157
|
+
a.abButton[data-type="contained"],
|
|
158
|
+
a.abButton[data-type="text"] {
|
|
159
|
+
padding: var(--ab-button-padding, 6px 12px); /* ๐ฆ */
|
|
160
|
+
border-radius: 8px; /* ๐ฒ */
|
|
161
|
+
font-size: 18px; /* ๐ค */
|
|
162
|
+
line-height: 32px; /* ๐ 40px tall */
|
|
163
|
+
}
|
|
164
|
+
a.abButton[data-type="contained"] {
|
|
165
|
+
background: var(--ab-button-background-color, var(--primary-container-color)); /* ๐จ */
|
|
166
|
+
color: var(--ab-button-text-color, var(--on-primary-container-color)); /* ๐๏ธ */
|
|
167
|
+
}
|
|
168
|
+
a.abButton[data-type="filled"] {
|
|
169
|
+
background: var(--ab-button-background-color, var(--md-sys-color-primary)); /* ๐ฅ */
|
|
170
|
+
color: var(--ab-button-text-color, var(--md-sys-color-on-primary)); /* ๐๏ธ */
|
|
171
|
+
padding: var(--ab-button-padding, 6px 16px); /* ๐ฆ */
|
|
172
|
+
border-radius: var(--ab-button-radius, 999px); /* ๐ */
|
|
173
|
+
font-size: 18px; /* ๐ค */
|
|
174
|
+
line-height: 32px; /* ๐ */
|
|
175
|
+
}
|
|
176
|
+
a.abButton[data-type="outlined"] {
|
|
177
|
+
border: 2px solid var(--ab-button-outline-color, var(--outline-color)); /* โ */
|
|
178
|
+
border-radius: 8px; /* ๐ฒ */
|
|
179
|
+
padding: 8px 16px; /* ๐ฆ */
|
|
180
|
+
font-size: 18px; /* ๐ค */
|
|
181
|
+
line-height: 32px; /* ๐ */
|
|
182
|
+
}
|
|
183
|
+
a.abButton.abButtonRounded { border-radius: 9999px; } /* ๐ */
|
|
@@ -0,0 +1,89 @@
|
|
|
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: AbCard (G45)
|
|
28
|
+
* @file: ab-card/index.tsx
|
|
29
|
+
* @type: React Component (server-safe)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*
|
|
32
|
+
* Example usage:
|
|
33
|
+
* <AbCard href="/docs/hooks" title="Hooks" description="State, media queries and more." />
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38
|
+
* MOTTO: We'll always do more ๐!!!
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
// โ๏ธ React
|
|
43
|
+
import type { ComponentType, ReactElement, ReactNode } from 'react';
|
|
44
|
+
// ๐งต classes
|
|
45
|
+
import clsx from 'clsx';
|
|
46
|
+
// ๐ G42 link
|
|
47
|
+
import Link from '../ab-link';
|
|
48
|
+
// ๐ฌ hover colours + transform timing from the package (reduced motion โ no transition)
|
|
49
|
+
import 'ab-nextjs-animations/motion/styles.css';
|
|
50
|
+
// ๐จ styles
|
|
51
|
+
import styles from './styles.module.css';
|
|
52
|
+
|
|
53
|
+
/** โ๏ธ props */
|
|
54
|
+
export interface AbCardProps {
|
|
55
|
+
title: ReactNode; // ๐ท๏ธ also the link text (one link per card)
|
|
56
|
+
href?: string; // ๐ the whole card is clickable via the title link's overlay
|
|
57
|
+
description?: ReactNode; // ๐
|
|
58
|
+
eyebrow?: ReactNode; // ๐ small label above the title
|
|
59
|
+
media?: ReactNode; // ๐ผ๏ธ icon / image slot
|
|
60
|
+
footer?: ReactNode; // ๐ meta row (must not contain other links: one link per card)
|
|
61
|
+
headingLevel?: 2 | 3 | 4; // โฟ default 3
|
|
62
|
+
className?: string; // ๐ท๏ธ
|
|
63
|
+
as?: 'article' | 'div' | 'li'; // ๐งฑ default article
|
|
64
|
+
id?: string; // ๐ 0.1.13: e.g. an in-page anchor target
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ๐ AbCard (G45): ONE link (the title) stretched over the card, so screen readers hear one link, not a
|
|
69
|
+
* nested block of them. Hover lift is 2px, laptop and up only, and none under prefers-reduced-motion.
|
|
70
|
+
*/
|
|
71
|
+
const AbCard = ({ title, href, description, eyebrow, media, footer, headingLevel = 3, className, as = 'article', id }: AbCardProps): ReactElement => {
|
|
72
|
+
const H = `h${headingLevel}` as unknown as ComponentType<{ className?: string; children?: ReactNode }>; // โฟ
|
|
73
|
+
const Root = as as unknown as ComponentType<Record<string, unknown>>; // ๐งฑ
|
|
74
|
+
return (
|
|
75
|
+
<Root id={id} className={clsx('AbCard', styles.abCard, 'ab-motion-interactive', className)} data-ab-part="card" data-linked={href ? 'true' : 'false'}>
|
|
76
|
+
{media && <div className={styles.abCardMedia} aria-hidden="true">{media}</div>}
|
|
77
|
+
{eyebrow && <p className={styles.abCardEyebrow}>{eyebrow}</p>}
|
|
78
|
+
<H className={styles.abCardTitle}>
|
|
79
|
+
{href ? <Link href={href} className={styles.abCardLink}>{title}</Link> : title}
|
|
80
|
+
</H>
|
|
81
|
+
{description && <p className={styles.abCardDescription}>{description}</p>}
|
|
82
|
+
{footer && <div className={styles.abCardFooter}>{footer}</div>}
|
|
83
|
+
</Root>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// ๐ฆ exports
|
|
88
|
+
export default AbCard;
|
|
89
|
+
export { AbCard };
|
|
@@ -0,0 +1,68 @@
|
|
|
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: AbCard - Styles (G45)
|
|
28
|
+
* @file: ab-card/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
|
+
/* ๐ card */
|
|
40
|
+
.abCard {
|
|
41
|
+
position: relative; /* ๐ overlay anchor */
|
|
42
|
+
display: flex; /* ๐ */
|
|
43
|
+
flex-direction: column; /* โฌ๏ธ */
|
|
44
|
+
gap: 8px; /* โ๏ธ */
|
|
45
|
+
padding: 20px; /* ๐ฆ */
|
|
46
|
+
border-radius: var(--ab-pane-radius, 16px); /* ๐ข theme 0.3.4 */
|
|
47
|
+
background: var(--ab-color-surface-container-low, rgb(0 0 0 / 0.03)); /* ๐จ */
|
|
48
|
+
color: var(--ab-color-on-surface, inherit); /* ๐๏ธ */
|
|
49
|
+
box-sizing: border-box; /* ๐ฆ */
|
|
50
|
+
}
|
|
51
|
+
.abCardMedia { display: flex; color: var(--ab-color-primary, inherit); } /* ๐ผ๏ธ */
|
|
52
|
+
.abCardEyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.75; } /* ๐ */
|
|
53
|
+
.abCardTitle { margin: 0; font-size: 18px; font-weight: 600; line-height: 24px; } /* ๐ท๏ธ */
|
|
54
|
+
.abCardDescription { margin: 0; font-size: 14px; line-height: 20px; color: var(--ab-color-on-surface-variant, inherit); } /* ๐ */
|
|
55
|
+
.abCardFooter { margin-top: auto; display: flex; gap: 8px; align-items: center; font-size: 12px; } /* ๐ */
|
|
56
|
+
/* ๐ single link stretched over the card */
|
|
57
|
+
.abCardLink { color: inherit; text-decoration: none; } /* ๐ */
|
|
58
|
+
.abCardLink::after { content: ''; position: absolute; inset: 0; border-radius: inherit; } /* ๐งฒ whole card clickable */
|
|
59
|
+
.abCard[data-linked='true']:hover { background: var(--ab-color-surface-container, rgb(0 0 0 / 0.06)); } /* ๐ฑ๏ธ */
|
|
60
|
+
.abCard:focus-within:has(.abCardLink:focus-visible) {
|
|
61
|
+
outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* โฟ ring on the card */
|
|
62
|
+
outline-offset: var(--ab-focus-ring-offset, 2px); /* โฟ */
|
|
63
|
+
}
|
|
64
|
+
.abCardLink:focus-visible { outline: none; } /* โฟ the card shows the ring */
|
|
65
|
+
/* ๐ 2px lift: laptop+ with a real pointer, and only when motion is OK (gap-review: no motion when reduced) */
|
|
66
|
+
@media (min-width: 1024px) and (hover: hover) and (prefers-reduced-motion: no-preference) {
|
|
67
|
+
.abCard[data-linked='true']:hover { transform: translateY(-2px); } /* ๐ */
|
|
68
|
+
}
|
package/ab-collapsible/index.tsx
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
43
43
|
import { useState } from 'react';
|
|
44
|
-
import Link from 'next/link
|
|
44
|
+
import Link from '../ab-link'; // ๐ G42: injectable via AbLinkProvider (default next/link)
|
|
45
45
|
import clsx from 'clsx';
|
|
46
46
|
import styles from './styles.module.css';
|
|
47
47
|
import { AB_MOTION } from 'ab-nextjs-animations/motion'; // ๐ฌ transition class names (ab-nextjs-animations >= 0.2.4)
|
package/ab-color/index.tsx
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
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: styles.module.css
|
|
28
|
+
* @file: ab-color/styles.module.css
|
|
29
|
+
* @type: CSS Stylesheet
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
1
33
|
.abColor {
|
|
2
34
|
display: inline-flex;
|
|
3
35
|
flex-direction: column;
|
package/ab-demo-box/index.tsx
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
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: styles.module.css
|
|
28
|
+
* @file: ab-demo-box/styles.module.css
|
|
29
|
+
* @type: CSS Stylesheet
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
1
33
|
.abDemoBox {
|
|
2
34
|
position: relative;
|
|
3
35
|
display: flex;
|
package/ab-demo-code/index.tsx
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
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: styles.module.css
|
|
28
|
+
* @file: ab-demo-code/styles.module.css
|
|
29
|
+
* @type: CSS Stylesheet
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
1
33
|
.abDemoCode {
|
|
2
34
|
position: relative;
|
|
3
35
|
border-radius: 0.75rem;
|
package/ab-icon/builtin.ts
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
// ๐ฃ one module per icon (ab-nextjs-icons โฅ 0.2.3): bundlers keep only these
|
|
39
|
+
// ๐ฃ one module per icon (ab-nextjs-icons โฅ 0.2.3): bundlers keep only these 15
|
|
40
40
|
import arrowBack from 'ab-nextjs-icons/ab-icons/icons/arrow_back'; // โฎ๏ธ AbCarouselPrev
|
|
41
41
|
import arrowForward from 'ab-nextjs-icons/ab-icons/icons/arrow_forward'; // โญ๏ธ AbCarouselNext
|
|
42
42
|
import lightMode from 'ab-nextjs-icons/ab-icons/icons/light_mode'; // ๐ AbThemeToggle
|
|
@@ -45,6 +45,13 @@ import computer from 'ab-nextjs-icons/ab-icons/icons/computer'; // ๐ฅ๏ธ AbThe
|
|
|
45
45
|
import language from 'ab-nextjs-icons/ab-icons/icons/language'; // ๐ AbLocaleSwitcher
|
|
46
46
|
import contentCopy from 'ab-nextjs-icons/ab-icons/icons/content_copy'; // ๐ AbInstallSnippet
|
|
47
47
|
import check from 'ab-nextjs-icons/ab-icons/icons/check'; // โ
AbInstallSnippet (copied)
|
|
48
|
+
import chevronLeft from 'ab-nextjs-icons/ab-icons/icons/chevron_left'; // โ๏ธ AbSidebar collapse (0.1.13)
|
|
49
|
+
import chevronRight from 'ab-nextjs-icons/ab-icons/icons/chevron_right'; // โถ๏ธ AbSidebar expand (0.1.13)
|
|
50
|
+
import menu from 'ab-nextjs-icons/ab-icons/icons/menu'; // โฐ AbAppBar (0.1.13)
|
|
51
|
+
import moreVert from 'ab-nextjs-icons/ab-icons/icons/more_vert'; // โฎ AbAppBar "More" (0.1.13)
|
|
52
|
+
import search from 'ab-nextjs-icons/ab-icons/icons/search'; // ๐ AbSearchTrigger (0.1.13)
|
|
53
|
+
import close from 'ab-nextjs-icons/ab-icons/icons/close'; // โ๏ธ AbPage aside close (0.1.13)
|
|
54
|
+
import expandMore from 'ab-nextjs-icons/ab-icons/icons/expand_more'; // ๐ฝ AbLocaleSwitcher no-JS list (0.1.13)
|
|
48
55
|
// ๐งพ shape
|
|
49
56
|
import type { AbIconSvgData } from './helpers';
|
|
50
57
|
|
|
@@ -58,4 +65,11 @@ export const AB_ICON_BUILTINS: Record<string, AbIconSvgData> = {
|
|
|
58
65
|
language, // ๐
|
|
59
66
|
content_copy: contentCopy, // ๐
|
|
60
67
|
check, // โ
|
|
68
|
+
chevron_left: chevronLeft, // โ๏ธ
|
|
69
|
+
chevron_right: chevronRight, // โถ๏ธ
|
|
70
|
+
menu, // โฐ
|
|
71
|
+
more_vert: moreVert, // โฎ
|
|
72
|
+
search, // ๐
|
|
73
|
+
close, // โ๏ธ
|
|
74
|
+
expand_more: expandMore, // ๐ฝ
|
|
61
75
|
};
|
package/ab-icon/helpers.ts
CHANGED
|
@@ -100,3 +100,40 @@ export function toAbIconSize(size: number | string | undefined): string {
|
|
|
100
100
|
if (size == null) return '24px'; // ๐งญ default 24
|
|
101
101
|
return typeof size === 'number' ? `${size}px` : size; // ๐
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
// ๐ names we already warned about (one warning per name per page load)
|
|
106
|
+
const warned = new Set<string>()
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* โ ๏ธ 0.1.13 (G2): warns once in development when a name isn't an AbIcon (registered, explicit `svg`, or in
|
|
110
|
+
* the map). It falls back to the Material Symbols ligature, which shows the NAME as text once the font is gone.
|
|
111
|
+
* Register it with `registerAbIcons({ name: icon })` from `ab-nextjs-icons/ab-icons/icons/<name>`.
|
|
112
|
+
*/
|
|
113
|
+
export function warnAbIconMissing(name: string): void {
|
|
114
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production') return // ๐คซ silent in prod
|
|
115
|
+
if (warned.has(name)) return // ๐ once
|
|
116
|
+
warned.add(name) // ๐
|
|
117
|
+
console.warn(`[AbIcon] "${name}" is not a registered AbIcon. Register it: registerAbIcons({ ${name} }) from 'ab-nextjs-icons/ab-icons/icons/${name}'. (Falling back to the Material Symbols font ligature.)`) // โ ๏ธ
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* ๐ 0.1.13 (Joseph): scopeAbIconIds โ suffix every `id` in the markup, plus the `url(#โฆ)` / `href="#โฆ"`
|
|
122
|
+
* refs that point at it, so two filled Homes on one page (bottom bar + sidebar) never share a mask.
|
|
123
|
+
* Same rules as ab-nextjs-icons 0.2.4 `scopeAbIconSvgIds` (copied: importing it is fine, but the client
|
|
124
|
+
* bundle rule above says no icon-package imports here). `AbIcon` calls it with React `useId()`.
|
|
125
|
+
*/
|
|
126
|
+
export function scopeAbIconIds(markup: string, scope: string): string {
|
|
127
|
+
const ids = Array.from(markup.matchAll(/\sid="([^"]+)"/g), (m) => m[1]); // ๐ declared ids
|
|
128
|
+
if (ids.length === 0) return markup; // ๐
most outlined icons
|
|
129
|
+
const suffix = `-${scope.replace(/[^A-Za-z0-9_-]/g, '') || 'x'}`; // ๐งผ `:r1:` / `ยซr1ยป` โ `-r1`
|
|
130
|
+
let out = markup;
|
|
131
|
+
for (const id of new Set(ids)) {
|
|
132
|
+
const esc = id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // ๐ก๏ธ regex-escape
|
|
133
|
+
out = out
|
|
134
|
+
.replace(new RegExp(`(\\sid=")${esc}(")`, 'g'), `$1${id}${suffix}$2`) // ๐
|
|
135
|
+
.replace(new RegExp(`url\\(#${esc}\\)`, 'g'), `url(#${id}${suffix})`) // ๐ญ
|
|
136
|
+
.replace(new RegExp(`(href=")#${esc}(")`, 'g'), `$1#${id}${suffix}$2`); // ๐
|
|
137
|
+
}
|
|
138
|
+
return out; // โ
|
|
139
|
+
}
|