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.
Files changed (49) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/ab-brand/index.tsx +30 -1
  3. package/ab-brand/styles.module.css +40 -1
  4. package/ab-button/helpers.ts +90 -0
  5. package/ab-button/index.tsx +164 -87
  6. package/ab-button/styles.module.css +79 -1
  7. package/ab-carousel/helpers.ts +146 -0
  8. package/ab-carousel/index.tsx +643 -0
  9. package/ab-carousel/styles.module.css +206 -0
  10. package/ab-chip/index.tsx +75 -0
  11. package/ab-chip/styles.module.css +87 -0
  12. package/ab-collapsible/index.tsx +30 -1
  13. package/ab-collapsible/styles.module.css +40 -1
  14. package/ab-flow-diagram/helpers.ts +77 -0
  15. package/ab-flow-diagram/index.tsx +152 -0
  16. package/ab-flow-diagram/styles.module.css +158 -0
  17. package/ab-icon/builtin.ts +61 -0
  18. package/ab-icon/helpers.ts +102 -0
  19. package/ab-icon/index.tsx +77 -16
  20. package/ab-icon/styles.module.css +53 -9
  21. package/ab-icon-button/index.tsx +110 -46
  22. package/ab-icon-button/styles.module.css +28 -10
  23. package/ab-install-snippet/helpers.ts +62 -0
  24. package/ab-install-snippet/index.tsx +170 -0
  25. package/ab-install-snippet/styles.module.css +104 -0
  26. package/ab-like-button/index.tsx +33 -1
  27. package/ab-like-button/styles.module.css +41 -6
  28. package/ab-linear-progress/index.tsx +5 -1
  29. package/ab-linear-progress/styles.module.css +8 -24
  30. package/ab-locale-switcher/index.tsx +213 -0
  31. package/ab-locale-switcher/styles.module.css +127 -0
  32. package/ab-pill/index.tsx +74 -0
  33. package/ab-progress-chips/index.tsx +30 -1
  34. package/ab-progress-chips/styles.module.css +40 -1
  35. package/ab-searchbar/index.tsx +33 -2
  36. package/ab-searchbar/styles.module.css +41 -5
  37. package/ab-splash/index.tsx +3 -1
  38. package/ab-splash/styles.module.css +2 -5
  39. package/ab-theme-toggle/index.tsx +188 -0
  40. package/ab-theme-toggle/styles.module.css +89 -0
  41. package/css/dialog.css +38 -3
  42. package/index.ts +41 -0
  43. package/package.json +33 -17
  44. package/server/ab-brand/index.tsx +29 -1
  45. package/server/ab-brand/styles.module.css +40 -1
  46. package/server/ab-button/index.tsx +96 -79
  47. package/server/ab-button/styles.module.css +79 -1
  48. package/server/ab-icon/index.tsx +68 -16
  49. package/server/ab-icon/styles.module.css +53 -9
@@ -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
- import type { ReactElement } from 'react';
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
- className?: string;
39
- filled?: boolean;
40
- size?: number | string;
41
- title?: string;
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
- /** Material Symbols ligature icon (server / RSC). */
45
- const AbIcon = ({ name, className, filled = false, size, title }: AbIconProps): ReactElement => {
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.abIcon, className)}
49
- style={size != null ? { fontSize: typeof size === 'number' ? `${size}px` : size } : undefined}
50
- title={title}
51
- aria-hidden={title ? undefined : true}
52
- role={title ? 'img' : undefined}
53
- data-filled={filled ? 'true' : 'false'}
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
- * Plain CSS modules โ€” no Tailwind Tailwind apply (Turbopack-safe).
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
- align-items: center;
19
- justify-content: center;
20
- font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
21
- line-height: 1;
22
- user-select: none;
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
- .abIcon[data-filled='true'] {
26
- font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
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
  }