ab-nextjs-components 0.1.8 โ 0.1.10
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 +42 -0
- package/ab-brand/index.tsx +30 -1
- package/ab-brand/styles.module.css +40 -1
- package/ab-button/helpers.ts +90 -0
- package/ab-button/index.tsx +164 -87
- package/ab-button/styles.module.css +79 -1
- package/ab-carousel/helpers.ts +146 -0
- package/ab-carousel/index.tsx +643 -0
- package/ab-carousel/styles.module.css +206 -0
- package/ab-chip/index.tsx +75 -0
- package/ab-chip/styles.module.css +87 -0
- package/ab-collapsible/index.tsx +30 -1
- package/ab-collapsible/styles.module.css +40 -1
- package/ab-flow-diagram/helpers.ts +77 -0
- package/ab-flow-diagram/index.tsx +141 -0
- package/ab-flow-diagram/styles.module.css +141 -0
- package/ab-icon/builtin.ts +61 -0
- package/ab-icon/helpers.ts +102 -0
- package/ab-icon/index.tsx +77 -16
- package/ab-icon/styles.module.css +53 -9
- package/ab-icon-button/index.tsx +110 -46
- package/ab-icon-button/styles.module.css +28 -10
- package/ab-install-snippet/helpers.ts +62 -0
- package/ab-install-snippet/index.tsx +170 -0
- package/ab-install-snippet/styles.module.css +104 -0
- package/ab-like-button/index.tsx +33 -1
- package/ab-like-button/styles.module.css +41 -6
- package/ab-linear-progress/index.tsx +129 -0
- package/ab-linear-progress/styles.module.css +105 -0
- package/ab-locale-switcher/index.tsx +213 -0
- package/ab-locale-switcher/styles.module.css +127 -0
- package/ab-logo/index.tsx +88 -30
- package/ab-logo/styles.module.css +79 -11
- package/ab-pill/index.tsx +74 -0
- package/ab-progress-chips/index.tsx +30 -1
- package/ab-progress-chips/styles.module.css +40 -1
- package/ab-searchbar/index.tsx +33 -2
- package/ab-searchbar/styles.module.css +41 -5
- package/ab-splash/csp.d.ts +54 -0
- package/ab-splash/csp.mjs +82 -0
- package/ab-splash/csp.ts +60 -0
- package/ab-splash/gate.ts +216 -0
- package/ab-splash/index.tsx +140 -0
- package/ab-splash/styles.module.css +103 -0
- package/ab-theme-toggle/index.tsx +188 -0
- package/ab-theme-toggle/styles.module.css +89 -0
- package/css/dialog.css +38 -3
- package/index.ts +47 -0
- package/package.json +46 -18
- package/server/ab-brand/index.tsx +29 -1
- package/server/ab-brand/styles.module.css +40 -1
- package/server/ab-button/index.tsx +96 -79
- package/server/ab-button/styles.module.css +79 -1
- package/server/ab-icon/index.tsx +68 -16
- package/server/ab-icon/styles.module.css +53 -9
- package/server/ab-logo/index.tsx +88 -29
- package/server/ab-logo/styles.module.css +79 -11
- package/types/css.d.ts +43 -0
- package/types/index.d.ts +2 -0
|
@@ -5,9 +5,35 @@
|
|
|
5
5
|
* ~~~~~~~~~~~~
|
|
6
6
|
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
7
|
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
8
26
|
* @project: ab-nextjs-components
|
|
9
27
|
* @name: AbBrand - Server (port of lyd-brand)
|
|
10
28
|
* @file: server/ab-brand/index.tsx
|
|
29
|
+
* @type: TypeScript (React)
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more ๐!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
11
37
|
*/
|
|
12
38
|
|
|
13
39
|
|
|
@@ -16,6 +42,8 @@ import Link from 'next/link';
|
|
|
16
42
|
import Image from 'next/image';
|
|
17
43
|
import clsx from 'clsx';
|
|
18
44
|
import styles from './styles.module.css';
|
|
45
|
+
import { AB_MOTION } from 'ab-nextjs-animations/motion'; // ๐ฌ transition class names (ab-nextjs-animations >= 0.2.4)
|
|
46
|
+
import 'ab-nextjs-animations/motion/styles.css'; // ๐จ .ab-motion-*
|
|
19
47
|
|
|
20
48
|
export interface AbBrandProps {
|
|
21
49
|
className?: string;
|
|
@@ -70,7 +98,7 @@ const AbBrand = ({
|
|
|
70
98
|
style={style}
|
|
71
99
|
>
|
|
72
100
|
<div className={styles.abBrandImageWrap}>
|
|
73
|
-
<Image className={styles.abBrandImage} src={image} alt={imageAlt ?? name} width={640} height={360} unoptimized />
|
|
101
|
+
<Image className={clsx(styles.abBrandImage, AB_MOTION.transform)} src={image} alt={imageAlt ?? name} width={640} height={360} unoptimized />
|
|
74
102
|
</div>
|
|
75
103
|
<div className={styles.abBrandMeta}>
|
|
76
104
|
<Image className={styles.abBrandLogo} src={logo} alt={logoAlt ?? shortName} width={40} height={40} unoptimized />
|
|
@@ -1,3 +1,42 @@
|
|
|
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: ab-brand - styles
|
|
28
|
+
* @file: server/ab-brand/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
|
+
|
|
1
40
|
.abBrand {
|
|
2
41
|
position: relative;
|
|
3
42
|
display: flex;
|
|
@@ -28,7 +67,7 @@
|
|
|
28
67
|
object-fit: cover;
|
|
29
68
|
width: 100%;
|
|
30
69
|
height: 100%;
|
|
31
|
-
|
|
70
|
+
--ab-motion-duration: 350ms; /* ๐ zoom tween = .ab-motion-transform (ab-nextjs-animations) */
|
|
32
71
|
}
|
|
33
72
|
.abBrandLogo {
|
|
34
73
|
width: 2.5rem;
|
|
@@ -22,117 +22,133 @@
|
|
|
22
22
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
23
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
24
|
* SOFTWARE.
|
|
25
|
-
|
|
26
25
|
*
|
|
27
26
|
* @project: ab-nextjs-components
|
|
28
27
|
* @name: AbButton - Server (no onClick; hrefโ<a> or submit)
|
|
29
28
|
* @file: server/ab-button/index.tsx
|
|
29
|
+
* @type: Server component โ G22 parity with the client twin
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more ๐!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
30
37
|
*/
|
|
31
38
|
|
|
39
|
+
// โ๏ธ types
|
|
32
40
|
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
41
|
+
// ๐งต class joiner
|
|
33
42
|
import clsx from 'clsx';
|
|
43
|
+
// ๐จ styles (server copy)
|
|
34
44
|
import styles from './styles.module.css';
|
|
45
|
+
// ๐งฎ the SAME rules as the client twin
|
|
46
|
+
import {
|
|
47
|
+
getAbButtonDisabledMode,
|
|
48
|
+
getAbButtonSrReason,
|
|
49
|
+
type AbButtonBadgeTone,
|
|
50
|
+
type AbButtonColor,
|
|
51
|
+
type AbButtonType,
|
|
52
|
+
} from '../../ab-button/helpers';
|
|
35
53
|
|
|
36
|
-
|
|
37
|
-
export type
|
|
54
|
+
// ๐ฆ shared types
|
|
55
|
+
export type { AbButtonBadgeTone, AbButtonColor, AbButtonType, AbButtonDisabledMode } from '../../ab-button/helpers';
|
|
38
56
|
|
|
57
|
+
// โ๏ธ props (no onClick on the server)
|
|
39
58
|
export interface AbButtonProps {
|
|
40
|
-
id?: string;
|
|
41
|
-
type?: AbButtonType;
|
|
42
|
-
htmlType?: 'button' | 'submit' | 'reset';
|
|
43
|
-
className?: string;
|
|
44
|
-
hidden?: boolean;
|
|
45
|
-
style?: CSSProperties;
|
|
46
|
-
rounded?: boolean;
|
|
47
|
-
raised?: boolean;
|
|
48
|
-
shrinks?: boolean;
|
|
49
|
-
expands?: boolean;
|
|
50
|
-
withIcon?: boolean;
|
|
51
|
-
disabled?: boolean;
|
|
52
|
-
iconPosition?: 'left' | 'right';
|
|
53
|
-
label: string;
|
|
54
|
-
icon?: string;
|
|
55
|
-
color?: AbButtonColor;
|
|
56
|
-
href?: string;
|
|
57
|
-
children?: ReactNode;
|
|
59
|
+
id?: string; // ๐
|
|
60
|
+
type?: AbButtonType; // ๐จ
|
|
61
|
+
htmlType?: 'button' | 'submit' | 'reset'; // ๐งพ
|
|
62
|
+
className?: string; // ๐ท๏ธ
|
|
63
|
+
hidden?: boolean; // ๐
|
|
64
|
+
style?: CSSProperties; // ๐จ
|
|
65
|
+
rounded?: boolean; // ๐
|
|
66
|
+
raised?: boolean; // ๐๏ธ
|
|
67
|
+
shrinks?: boolean; // ๐ค
|
|
68
|
+
expands?: boolean; // ๐
|
|
69
|
+
withIcon?: boolean; // ๐ฃ
|
|
70
|
+
disabled?: boolean; // ๐ซ
|
|
71
|
+
iconPosition?: 'left' | 'right'; // โ๏ธ
|
|
72
|
+
label: string; // ๐ท๏ธ
|
|
73
|
+
icon?: string; // ๐ฃ
|
|
74
|
+
color?: AbButtonColor; // ๐จ
|
|
75
|
+
href?: string; // ๐
|
|
76
|
+
children?: ReactNode; // ๐งฉ
|
|
77
|
+
startIcon?: ReactNode; // ๐ผ๏ธ G22
|
|
78
|
+
endIcon?: ReactNode; // ๐ผ๏ธ G22
|
|
79
|
+
badge?: ReactNode; // ๐ท๏ธ G22
|
|
80
|
+
badgeTone?: AbButtonBadgeTone; // ๐จ G22
|
|
81
|
+
disabledReason?: string; // ๐ฌ G22
|
|
82
|
+
focusableWhenDisabled?: boolean; // โจ๏ธ G22
|
|
58
83
|
}
|
|
59
84
|
|
|
60
|
-
/** Server AbButton
|
|
85
|
+
/** ๐ฅ๏ธ Server AbButton: no onClick. Use href for links or htmlType for form submit. No-JS safe. */
|
|
61
86
|
const AbButton = ({
|
|
62
|
-
id,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
className,
|
|
66
|
-
hidden = false,
|
|
67
|
-
style,
|
|
68
|
-
rounded = true,
|
|
69
|
-
raised = false,
|
|
70
|
-
shrinks = false,
|
|
71
|
-
expands = false,
|
|
72
|
-
withIcon = false,
|
|
73
|
-
disabled = false,
|
|
74
|
-
iconPosition = 'left',
|
|
75
|
-
label,
|
|
76
|
-
icon,
|
|
77
|
-
color = 'primary',
|
|
78
|
-
href,
|
|
79
|
-
children,
|
|
87
|
+
id, type = 'contained', htmlType = 'button', className, hidden = false, style, rounded = true, raised = false,
|
|
88
|
+
shrinks = false, expands = false, withIcon = false, disabled = false, iconPosition = 'left', label, icon,
|
|
89
|
+
color = 'primary', href, children, startIcon, endIcon, badge, badgeTone = 'neutral', disabledReason, focusableWhenDisabled,
|
|
80
90
|
}: AbButtonProps): ReactElement => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
rounded && styles.abButtonRounded,
|
|
86
|
-
disabled && styles.isDisabled,
|
|
87
|
-
);
|
|
91
|
+
// ๐ฆ shared disabled rules
|
|
92
|
+
const mode = getAbButtonDisabledMode({ disabled, badge, disabledReason, focusableWhenDisabled });
|
|
93
|
+
// ๐ฌ hidden reason
|
|
94
|
+
const srReason = getAbButtonSrReason({ disabled, disabledReason });
|
|
88
95
|
|
|
96
|
+
// ๐ท๏ธ classes
|
|
97
|
+
const classNames = clsx('AbButton', styles.abButton, className, rounded && styles.abButtonRounded, mode === 'native' && styles.isDisabled);
|
|
98
|
+
|
|
99
|
+
// ๐๏ธ data attributes
|
|
89
100
|
const dataAttrs = {
|
|
90
|
-
'data-type': type,
|
|
91
|
-
'data-raised': raised ? 'true' : 'false',
|
|
92
|
-
'data-shrinks': shrinks ? 'true' : 'false',
|
|
93
|
-
'data-expands': expands ? 'true' : 'false',
|
|
94
|
-
'data-rounded': rounded ? 'true' : 'false',
|
|
95
|
-
'data-iconpos': iconPosition,
|
|
96
|
-
'data-color': color,
|
|
101
|
+
'data-type': type, // ๐จ
|
|
102
|
+
'data-raised': raised ? 'true' : 'false', // ๐๏ธ
|
|
103
|
+
'data-shrinks': shrinks ? 'true' : 'false', // ๐ค
|
|
104
|
+
'data-expands': expands ? 'true' : 'false', // ๐
|
|
105
|
+
'data-rounded': rounded ? 'true' : 'false', // ๐
|
|
106
|
+
'data-iconpos': iconPosition, // โ๏ธ
|
|
107
|
+
'data-color': color, // ๐จ
|
|
108
|
+
'data-disabled-mode': mode, // ๐ฆ
|
|
97
109
|
} as const;
|
|
98
110
|
|
|
111
|
+
// ๐ฃ legacy icon (decorative)
|
|
112
|
+
const legacyIcon = withIcon && icon ? <span className={clsx('material-symbols-rounded', 'icon')} aria-hidden="true">{icon}</span> : null;
|
|
113
|
+
|
|
114
|
+
// ๐งฑ content (same order as the client twin)
|
|
99
115
|
const content = (
|
|
100
116
|
<>
|
|
101
|
-
{
|
|
102
|
-
|
|
103
|
-
) : null}
|
|
117
|
+
{iconPosition === 'left' ? legacyIcon : null}
|
|
118
|
+
{startIcon ? <span className={styles.abButtonSlot} aria-hidden="true">{startIcon}</span> : null}
|
|
104
119
|
<span>{children ?? label}</span>
|
|
105
|
-
{
|
|
106
|
-
|
|
120
|
+
{badge ? (
|
|
121
|
+
<>
|
|
122
|
+
<span className={styles.srOnly}>, </span>
|
|
123
|
+
<span className={styles.abButtonBadge} data-tone={badgeTone} data-ab-part="badge" aria-hidden={srReason ? true : undefined}>{badge}</span>
|
|
124
|
+
</>
|
|
107
125
|
) : null}
|
|
126
|
+
{srReason ? <span className={styles.srOnly}>, {srReason}</span> : null}
|
|
127
|
+
{endIcon ? <span className={styles.abButtonSlot} aria-hidden="true">{endIcon}</span> : null}
|
|
128
|
+
{iconPosition === 'right' ? legacyIcon : null}
|
|
108
129
|
</>
|
|
109
130
|
);
|
|
110
131
|
|
|
132
|
+
// ๐ link mode
|
|
111
133
|
if (href) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
style={style}
|
|
119
|
-
hidden={hidden}
|
|
120
|
-
aria-disabled={disabled}
|
|
121
|
-
{...dataAttrs}
|
|
122
|
-
>
|
|
123
|
-
{content}
|
|
124
|
-
</a>
|
|
125
|
-
);
|
|
134
|
+
if (mode !== 'none') {
|
|
135
|
+
// ๐ซ blocked link: no href, role=link, focusable only in aria mode
|
|
136
|
+
return <span id={id} role="link" aria-disabled="true" tabIndex={mode === 'aria' ? 0 : -1} className={classNames} style={style} hidden={hidden} {...dataAttrs}>{content}</span>;
|
|
137
|
+
}
|
|
138
|
+
// โ
a link is a link (no role=button)
|
|
139
|
+
return <a id={id} href={href} className={classNames} style={style} hidden={hidden} {...dataAttrs}>{content}</a>;
|
|
126
140
|
}
|
|
127
141
|
|
|
142
|
+
// ๐ button: aria mode is type="button" so a disabled CTA can never submit, even without JS
|
|
128
143
|
return (
|
|
129
144
|
<button
|
|
130
|
-
id={id}
|
|
131
|
-
type={htmlType}
|
|
132
|
-
className={classNames}
|
|
133
|
-
style={style}
|
|
134
|
-
hidden={hidden}
|
|
135
|
-
disabled={
|
|
145
|
+
id={id} // ๐
|
|
146
|
+
type={mode === 'aria' ? 'button' : htmlType} // ๐งพ
|
|
147
|
+
className={classNames} // ๐ท๏ธ
|
|
148
|
+
style={style} // ๐จ
|
|
149
|
+
hidden={hidden} // ๐
|
|
150
|
+
disabled={mode === 'native'} // ๐ซ
|
|
151
|
+
aria-disabled={mode === 'aria' ? true : undefined} // ๐ฆ
|
|
136
152
|
{...dataAttrs}
|
|
137
153
|
>
|
|
138
154
|
{content}
|
|
@@ -140,5 +156,6 @@ const AbButton = ({
|
|
|
140
156
|
);
|
|
141
157
|
};
|
|
142
158
|
|
|
159
|
+
// ๐ฆ exports
|
|
143
160
|
export default AbButton;
|
|
144
161
|
export { AbButton };
|
|
@@ -2,7 +2,32 @@
|
|
|
2
2
|
* @license MIT
|
|
3
3
|
* ~~~~~~~~~~~~
|
|
4
4
|
* ab-nextjs-components
|
|
5
|
-
*
|
|
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: server/ab-button/styles.module.css
|
|
29
|
+
* @type: CSS
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
6
31
|
*/
|
|
7
32
|
|
|
8
33
|
/*
|
|
@@ -11,6 +36,7 @@
|
|
|
11
36
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
12
37
|
*/
|
|
13
38
|
|
|
39
|
+
|
|
14
40
|
.abButton {
|
|
15
41
|
position: relative;
|
|
16
42
|
display: inline-flex;
|
|
@@ -61,3 +87,55 @@
|
|
|
61
87
|
|
|
62
88
|
.hidden { display: none !important; }
|
|
63
89
|
.invisible { visibility: hidden; }
|
|
90
|
+
|
|
91
|
+
/* ===== G22: start/end icons, badge, aria-disabled ===== */
|
|
92
|
+
|
|
93
|
+
/* ๐ผ๏ธ icon slots (any ReactNode, e.g. <AbIcon name="github" />) */
|
|
94
|
+
.abButtonSlot {
|
|
95
|
+
display: inline-flex; /* ๐ align with label */
|
|
96
|
+
flex: none; /* ๐ซ never squash */
|
|
97
|
+
width: 1.25em; /* ๐ icon box */
|
|
98
|
+
height: 1.25em; /* ๐ */
|
|
99
|
+
align-items: center; /* โ๏ธ */
|
|
100
|
+
justify-content: center; /* โ๏ธ */
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* ๐ท๏ธ "Coming soon" style badge inside the button */
|
|
104
|
+
.abButtonBadge {
|
|
105
|
+
display: inline-flex; /* ๐ */
|
|
106
|
+
align-items: center; /* โ๏ธ */
|
|
107
|
+
padding: 0.125rem 0.5rem; /* ๐งฑ */
|
|
108
|
+
border-radius: 9999px; /* ๐ */
|
|
109
|
+
font-size: 0.75rem; /* ๐ก small */
|
|
110
|
+
font-weight: 600; /* ๐ช */
|
|
111
|
+
line-height: 1.2; /* ๐ */
|
|
112
|
+
white-space: nowrap; /* ๐ซ no wrap */
|
|
113
|
+
/* โช neutral tone (default) */
|
|
114
|
+
color: var(--ab-color-on-surface-variant, currentColor);
|
|
115
|
+
background: var(--ab-color-surface-variant, rgb(0 0 0 / 0.06));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ๐ฅ accent tone: small text โ the AA bronze text token (theme 0.3.1) */
|
|
119
|
+
.abButtonBadge[data-tone="accent"] {
|
|
120
|
+
color: var(--ab-color-bronze-text, #8A6440); /* โฟ 5.02:1 on #fff8f3 */
|
|
121
|
+
background: color-mix(in srgb, var(--ab-color-bronze, #A67C52) 14%, transparent); /* ๐จ soft wash */
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ๐ฆ aria-disabled: looks disabled, stays focusable (no pointer-events:none so tooltips/focus still work) */
|
|
125
|
+
.abButton[aria-disabled="true"] {
|
|
126
|
+
cursor: not-allowed; /* ๐ซ */
|
|
127
|
+
opacity: 0.6; /* ๐ซ๏ธ */
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* ๐ visually hidden, still announced */
|
|
131
|
+
.srOnly {
|
|
132
|
+
position: absolute; /* ๐ */
|
|
133
|
+
width: 1px; /* ๐ */
|
|
134
|
+
height: 1px; /* ๐ */
|
|
135
|
+
padding: 0; /* ๐งน */
|
|
136
|
+
margin: -1px; /* ๐งน */
|
|
137
|
+
overflow: hidden; /* โ๏ธ */
|
|
138
|
+
clip: rect(0 0 0 0); /* โ๏ธ */
|
|
139
|
+
white-space: nowrap; /* ๐ซ */
|
|
140
|
+
border: 0; /* ๐งน */
|
|
141
|
+
}
|
package/server/ab-icon/index.tsx
CHANGED
|
@@ -22,40 +22,92 @@
|
|
|
22
22
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
23
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
24
|
* SOFTWARE.
|
|
25
|
-
|
|
26
25
|
*
|
|
27
26
|
* @project: ab-nextjs-components
|
|
28
|
-
* @name: AbIcon - Server
|
|
27
|
+
* @name: AbIcon - Server (G2)
|
|
29
28
|
* @file: server/ab-icon/index.tsx
|
|
29
|
+
* @type: Server component โ any AbIcons name, zero client JS
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more ๐!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
30
37
|
*/
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
// โ๏ธ types
|
|
40
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
41
|
+
// ๐งต classes
|
|
33
42
|
import clsx from 'clsx';
|
|
43
|
+
// ๐บ๏ธ full icon map: fine here, server components ship no JS to the browser
|
|
44
|
+
import { getAbIconSvg } from 'ab-nextjs-icons/ab-icons';
|
|
45
|
+
// ๐งฎ shared helpers (same rules as the client twin)
|
|
46
|
+
import { getAbIconStroke, getRegisteredAbIcon, pickAbIconMarkup, toAbIconSize, type AbIconSvgData, type AbIconVariant, type AbIconWeight } from '../../ab-icon/helpers';
|
|
47
|
+
// ๐จ styles (server copy)
|
|
34
48
|
import styles from './styles.module.css';
|
|
35
49
|
|
|
50
|
+
// โ๏ธ props
|
|
36
51
|
export interface AbIconProps {
|
|
37
|
-
name: string;
|
|
38
|
-
|
|
39
|
-
filled?: boolean;
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
name: string; // ๐๏ธ AbIcons name (snake_case); Material ligature fallback if unknown
|
|
53
|
+
variant?: AbIconVariant; // ๐๏ธ outlined (default) | filled
|
|
54
|
+
filled?: boolean; // ๐ฐ๏ธ legacy alias for variant="filled"
|
|
55
|
+
weight?: AbIconWeight | number; // ๐ 100โ700 (outlined), default 200
|
|
56
|
+
size?: number | string; // ๐ default 24px
|
|
57
|
+
label?: string; // โฟ NEW: accessible name; omitted = decorative (aria-hidden)
|
|
58
|
+
title?: string; // ๐ฌ legacy tooltip + name
|
|
59
|
+
svg?: AbIconSvgData; // ๐งพ NEW: explicit markup (tree-shaken per-icon import)
|
|
60
|
+
className?: string; // ๐ท๏ธ
|
|
61
|
+
style?: CSSProperties; // ๐จ
|
|
42
62
|
}
|
|
43
63
|
|
|
44
|
-
/**
|
|
45
|
-
const AbIcon = ({ name,
|
|
64
|
+
/** ๐ฃ AbIcons SVG icon (server / RSC): `svg` prop โ registry โ full AbIcons map โ Material ligature. */
|
|
65
|
+
const AbIcon = ({ name, variant, filled = false, weight, size, label, title, svg, className, style }: AbIconProps): ReactElement => {
|
|
66
|
+
// ๐๏ธ variant for lookup
|
|
67
|
+
const want: AbIconVariant = variant ?? (filled ? 'filled' : 'outlined');
|
|
68
|
+
// ๐ explicit โ registered โ whole map (weight is applied by CSS, so ask for the raw markup)
|
|
69
|
+
const markup = pickAbIconMarkup(svg ?? getRegisteredAbIcon(name), want) ?? getAbIconSvg(name, want);
|
|
70
|
+
// ๐๏ธ legacy `filled` โ variant
|
|
71
|
+
const v: AbIconVariant = variant ?? (filled ? 'filled' : 'outlined');
|
|
72
|
+
// ๐ท๏ธ accessible name: `label` (new) or `title` (legacy)
|
|
73
|
+
const name_ = label ?? title;
|
|
74
|
+
// ๐จ size + weight as CSS variables (weight overrides SVG stroke-width via CSS)
|
|
75
|
+
const vars = { ...style, '--ab-icon-size': toAbIconSize(size), '--ab-icon-stroke': String(getAbIconStroke(weight)) } as CSSProperties;
|
|
76
|
+
// โฟ labelled = image, else decorative
|
|
77
|
+
const a11y = name_ ? { role: 'img' as const, 'aria-label': name_ } : { 'aria-hidden': true as const };
|
|
78
|
+
|
|
79
|
+
// โ
AbIcons SVG
|
|
80
|
+
if (markup) {
|
|
81
|
+
return (
|
|
82
|
+
<span
|
|
83
|
+
className={clsx('AbIcon', styles.abIcon, className)} // ๐ท๏ธ
|
|
84
|
+
style={vars} // ๐จ
|
|
85
|
+
data-variant={v} // ๐๏ธ
|
|
86
|
+
data-icon={name} // ๐๏ธ
|
|
87
|
+
title={title} // ๐ฌ legacy tooltip only
|
|
88
|
+
{...a11y} // โฟ
|
|
89
|
+
// ๐ trusted, package-generated static markup (never user input)
|
|
90
|
+
dangerouslySetInnerHTML={{ __html: markup }}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ๐ฐ๏ธ fallback: Material Symbols ligature (pre-G2 behaviour) for names not in AbIcons
|
|
46
96
|
return (
|
|
47
97
|
<span
|
|
48
|
-
className={clsx('material-symbols-rounded', 'icon', styles.
|
|
49
|
-
style={
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
98
|
+
className={clsx('material-symbols-rounded', 'icon', styles.abIconFont, className)} // ๐ท๏ธ
|
|
99
|
+
style={{ ...style, fontSize: toAbIconSize(size) }} // ๐
|
|
100
|
+
data-filled={v === 'filled' ? 'true' : 'false'} // ๐๏ธ
|
|
101
|
+
data-icon={name} // ๐๏ธ
|
|
102
|
+
data-ab-icon-fallback="font" // ๐ easy to audit
|
|
103
|
+
title={title} // ๐ฌ
|
|
104
|
+
{...a11y} // โฟ
|
|
54
105
|
>
|
|
55
106
|
{name}
|
|
56
107
|
</span>
|
|
57
108
|
);
|
|
58
109
|
};
|
|
59
110
|
|
|
111
|
+
// ๐ฆ exports
|
|
60
112
|
export default AbIcon;
|
|
61
113
|
export { AbIcon };
|
|
@@ -4,7 +4,30 @@
|
|
|
4
4
|
* ab-nextjs-components
|
|
5
5
|
* ~~~~~~~~~~~~
|
|
6
6
|
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-components
|
|
27
|
+
* @name: AbIcon - Styles (G2)
|
|
28
|
+
* @file: server/ab-icon/styles.module.css
|
|
29
|
+
* @type: CSS module
|
|
30
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
8
31
|
*/
|
|
9
32
|
|
|
10
33
|
/*
|
|
@@ -13,15 +36,36 @@
|
|
|
13
36
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
14
37
|
*/
|
|
15
38
|
|
|
39
|
+
/* ๐ฃ SVG icon box */
|
|
16
40
|
.abIcon {
|
|
17
|
-
display: inline-flex;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
line-height:
|
|
22
|
-
|
|
41
|
+
display: inline-flex; /* ๐ */
|
|
42
|
+
flex: none; /* ๐ซ squash */
|
|
43
|
+
width: var(--ab-icon-size, 24px); /* ๐ */
|
|
44
|
+
height: var(--ab-icon-size, 24px); /* ๐ */
|
|
45
|
+
line-height: 0; /* ๐งน no baseline gap */
|
|
46
|
+
color: inherit; /* ๐จ currentColor flows into the SVG */
|
|
23
47
|
}
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
/* ๐ the inline SVG fills the box */
|
|
50
|
+
.abIcon > svg {
|
|
51
|
+
width: 100%; /* โ๏ธ */
|
|
52
|
+
height: 100%; /* โ๏ธ */
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ๐ weight: CSS beats SVG presentation attributes, outlined only (filled stay solid) */
|
|
56
|
+
.abIcon[data-variant='outlined'] > svg [stroke] {
|
|
57
|
+
stroke-width: var(--ab-icon-stroke, 1.25); /* โ๏ธ */
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* ๐ฐ๏ธ Material Symbols fallback (unchanged from pre-G2) */
|
|
61
|
+
.abIconFont {
|
|
62
|
+
display: inline-flex; /* ๐ */
|
|
63
|
+
align-items: center; /* โ๏ธ */
|
|
64
|
+
justify-content: center; /* โ๏ธ */
|
|
65
|
+
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; /* ๐ค */
|
|
66
|
+
line-height: 1; /* ๐ */
|
|
67
|
+
user-select: none; /* ๐ซ */
|
|
68
|
+
}
|
|
69
|
+
.abIconFont[data-filled='true'] {
|
|
70
|
+
font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; /* โฌ */
|
|
27
71
|
}
|