ab-nextjs-components 0.1.9 โ 0.1.11
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/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 +152 -0
- package/ab-flow-diagram/styles.module.css +158 -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 +5 -1
- package/ab-linear-progress/styles.module.css +8 -24
- package/ab-locale-switcher/index.tsx +213 -0
- package/ab-locale-switcher/styles.module.css +127 -0
- 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/index.tsx +3 -1
- package/ab-splash/styles.module.css +2 -5
- 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 +41 -0
- package/package.json +33 -17
- 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-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
|
}
|