ab-nextjs-components 0.1.1 → 0.1.3

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 (109) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/LICENSE +1 -1
  3. package/README.md +91 -15
  4. package/ab-avatar/index.tsx +90 -0
  5. package/ab-avatar/styles.module.css +62 -0
  6. package/ab-balloon/index.tsx +55 -0
  7. package/ab-balloon/styles.module.css +12 -0
  8. package/ab-brand/index.tsx +88 -0
  9. package/ab-brand/styles.module.css +54 -0
  10. package/ab-button/index.tsx +164 -0
  11. package/ab-button/styles.module.css +63 -0
  12. package/ab-collapsible/index.tsx +188 -0
  13. package/ab-collapsible/styles.module.css +98 -0
  14. package/ab-color/index.tsx +84 -0
  15. package/ab-color/styles.module.css +51 -0
  16. package/ab-demo-box/index.tsx +38 -0
  17. package/ab-demo-box/styles.module.css +13 -0
  18. package/ab-demo-code/index.tsx +62 -0
  19. package/ab-demo-code/styles.module.css +41 -0
  20. package/ab-icon/index.tsx +63 -0
  21. package/ab-icon/styles.module.css +27 -0
  22. package/ab-icon-button/index.tsx +107 -0
  23. package/ab-icon-button/styles.module.css +64 -0
  24. package/ab-image/index.tsx +83 -0
  25. package/ab-image/styles.module.css +27 -0
  26. package/ab-info/index.tsx +89 -0
  27. package/ab-info/styles.module.css +87 -0
  28. package/ab-input/index.tsx +277 -0
  29. package/ab-input/styles.module.css +101 -0
  30. package/ab-key-feature/index.tsx +60 -0
  31. package/ab-key-feature/styles.module.css +47 -0
  32. package/ab-like-button/index.tsx +116 -0
  33. package/ab-like-button/styles.module.css +60 -0
  34. package/ab-logo/index.tsx +94 -0
  35. package/ab-logo/styles.module.css +30 -0
  36. package/ab-main-headline/index.tsx +57 -0
  37. package/ab-main-headline/styles.module.css +24 -0
  38. package/ab-menu/index.tsx +119 -0
  39. package/ab-menu/styles.module.css +99 -0
  40. package/ab-name/index.tsx +49 -0
  41. package/ab-name/styles.module.css +14 -0
  42. package/ab-navbar/index.tsx +68 -0
  43. package/ab-navbar/styles.module.css +35 -0
  44. package/ab-page-paginator/index.tsx +130 -0
  45. package/ab-page-paginator/styles.module.css +47 -0
  46. package/ab-page-switcher/index.tsx +121 -0
  47. package/ab-page-switcher/styles.module.css +37 -0
  48. package/ab-preview/index.tsx +78 -0
  49. package/ab-preview/styles.module.css +26 -0
  50. package/ab-price/index.tsx +109 -0
  51. package/ab-price/styles.module.css +36 -0
  52. package/ab-price-tag/index.tsx +70 -0
  53. package/ab-price-tag/styles.module.css +81 -0
  54. package/ab-product/index.tsx +128 -0
  55. package/ab-product/styles.module.css +44 -0
  56. package/ab-product-item/index.tsx +78 -0
  57. package/ab-product-item/styles.module.css +21 -0
  58. package/ab-progress-chips/index.tsx +105 -0
  59. package/ab-progress-chips/styles.module.css +43 -0
  60. package/ab-search-result/index.tsx +79 -0
  61. package/ab-search-result/styles.module.css +48 -0
  62. package/ab-searchbar/index.tsx +150 -0
  63. package/ab-searchbar/styles.module.css +77 -0
  64. package/ab-sidebar/index.tsx +72 -0
  65. package/ab-sidebar/styles.module.css +41 -0
  66. package/ab-switch-back/index.tsx +72 -0
  67. package/ab-switch-back/styles.module.css +45 -0
  68. package/ab-tab/index.tsx +101 -0
  69. package/ab-tab/styles.module.css +65 -0
  70. package/ab-tabs/index.tsx +45 -0
  71. package/ab-tabs/styles.module.css +17 -0
  72. package/ab-test-hello/index.tsx +37 -0
  73. package/ab-test-hello/styles.module.css +25 -0
  74. package/ab-text/index.tsx +36 -0
  75. package/ab-text/styles.module.css +3 -0
  76. package/index.ts +117 -0
  77. package/package.json +152 -7
  78. package/server/ab-avatar/index.tsx +85 -0
  79. package/server/ab-avatar/styles.module.css +62 -0
  80. package/server/ab-badge/index.tsx +66 -0
  81. package/server/ab-badge/styles.module.css +39 -0
  82. package/server/ab-brand/index.tsx +87 -0
  83. package/server/ab-brand/styles.module.css +54 -0
  84. package/server/ab-button/index.tsx +144 -0
  85. package/server/ab-button/styles.module.css +63 -0
  86. package/server/ab-icon/index.tsx +61 -0
  87. package/server/ab-icon/styles.module.css +27 -0
  88. package/server/ab-key-feature/index.tsx +59 -0
  89. package/server/ab-key-feature/styles.module.css +47 -0
  90. package/server/ab-logo/index.tsx +93 -0
  91. package/server/ab-logo/styles.module.css +30 -0
  92. package/server/ab-name/index.tsx +48 -0
  93. package/server/ab-name/styles.module.css +14 -0
  94. package/server/ab-nav-link/index.tsx +60 -0
  95. package/server/ab-nav-link/styles.module.css +32 -0
  96. package/server/ab-navbar/index.tsx +64 -0
  97. package/server/ab-navbar/styles.module.css +35 -0
  98. package/server/ab-polygon/index.tsx +45 -0
  99. package/server/ab-polygon/styles.module.css +11 -0
  100. package/server/ab-sidebar/index.tsx +68 -0
  101. package/server/ab-sidebar/styles.module.css +41 -0
  102. package/server/ab-switch-back/index.tsx +71 -0
  103. package/server/ab-switch-back/styles.module.css +45 -0
  104. package/server/ab-test-hello/index.tsx +35 -0
  105. package/server/ab-test-hello/styles.module.css +22 -0
  106. package/server/ab-text/index.tsx +33 -0
  107. package/server/ab-text/styles.module.css +3 -0
  108. package/server/index.ts +27 -0
  109. package/types/index.d.ts +54 -0
@@ -0,0 +1,164 @@
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
+ *
27
+ * @project: ab-nextjs-components
28
+ * @name: AbButton - Client (port of lyd-button)
29
+ * @file: ab-button/index.tsx
30
+ */
31
+
32
+ 'use client';
33
+
34
+ import type { CSSProperties, MouseEvent, ReactNode } from 'react';
35
+ import { forwardRef } from 'react';
36
+ import clsx from 'clsx';
37
+ import styles from './styles.module.css';
38
+
39
+ export type AbButtonType = 'contained' | 'outlined' | 'text';
40
+ export type AbButtonColor = 'primary' | 'secondary' | 'tertiary' | 'white' | 'black';
41
+
42
+ export interface AbButtonProps {
43
+ id?: string;
44
+ type?: AbButtonType;
45
+ htmlType?: 'button' | 'submit' | 'reset';
46
+ className?: string;
47
+ spinnerClassName?: string;
48
+ hidden?: boolean;
49
+ style?: CSSProperties;
50
+ iconStyle?: CSSProperties;
51
+ rounded?: boolean;
52
+ raised?: boolean;
53
+ shrinks?: boolean;
54
+ expands?: boolean;
55
+ withIcon?: boolean;
56
+ disabled?: boolean;
57
+ isLoading?: boolean;
58
+ iconPosition?: 'left' | 'right';
59
+ label: string;
60
+ icon?: string;
61
+ color?: AbButtonColor;
62
+ href?: string;
63
+ children?: ReactNode;
64
+ onClick?: (event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
65
+ }
66
+
67
+ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps>(function AbButton(props, ref) {
68
+ const {
69
+ id,
70
+ type = 'contained',
71
+ htmlType = 'button',
72
+ className,
73
+ spinnerClassName,
74
+ hidden = false,
75
+ style,
76
+ iconStyle,
77
+ rounded = true,
78
+ raised = false,
79
+ shrinks = false,
80
+ expands = false,
81
+ withIcon = false,
82
+ disabled = false,
83
+ isLoading = false,
84
+ iconPosition = 'left',
85
+ label,
86
+ icon,
87
+ color = 'primary',
88
+ href,
89
+ children,
90
+ onClick,
91
+ } = props;
92
+
93
+ const classNames = clsx(
94
+ 'AbButton',
95
+ styles.abButton,
96
+ className,
97
+ rounded && styles.abButtonRounded,
98
+ type === 'contained' && styles.isContained,
99
+ (disabled || isLoading) && styles.isDisabled,
100
+ );
101
+
102
+ const dataAttrs = {
103
+ 'data-type': type,
104
+ 'data-raised': raised ? 'true' : 'false',
105
+ 'data-shrinks': shrinks ? 'true' : 'false',
106
+ 'data-expands': expands ? 'true' : 'false',
107
+ 'data-rounded': rounded ? 'true' : 'false',
108
+ 'data-iconpos': iconPosition,
109
+ 'data-color': color,
110
+ } as const;
111
+
112
+ const content = (
113
+ <>
114
+ {withIcon && iconPosition === 'left' && icon ? (
115
+ <span className={clsx('material-symbols-rounded', 'icon', styles.abButtonIcon)} style={iconStyle}>{icon}</span>
116
+ ) : null}
117
+ <span className={clsx(styles.abButtonSpinnerSlot, !isLoading && styles.hidden)}>
118
+ <span className={clsx('spinner', 'dot-3', styles.abButtonSpinner, spinnerClassName)} />
119
+ </span>
120
+ <span className={clsx(isLoading && styles.invisible)}>{children ?? label}</span>
121
+ {withIcon && iconPosition === 'right' && icon ? (
122
+ <span className={clsx('material-symbols-rounded', 'icon', styles.abButtonIcon)} style={iconStyle}>{icon}</span>
123
+ ) : null}
124
+ </>
125
+ );
126
+
127
+ if (href) {
128
+ return (
129
+ <a
130
+ ref={ref as React.Ref<HTMLAnchorElement>}
131
+ id={id}
132
+ href={disabled ? undefined : href}
133
+ role="button"
134
+ className={classNames}
135
+ style={style}
136
+ hidden={hidden}
137
+ aria-disabled={disabled || isLoading}
138
+ onClick={onClick}
139
+ {...dataAttrs}
140
+ >
141
+ {content}
142
+ </a>
143
+ );
144
+ }
145
+
146
+ return (
147
+ <button
148
+ ref={ref as React.Ref<HTMLButtonElement>}
149
+ id={id}
150
+ type={htmlType}
151
+ className={classNames}
152
+ style={style}
153
+ hidden={hidden}
154
+ disabled={disabled || isLoading}
155
+ onClick={onClick}
156
+ {...dataAttrs}
157
+ >
158
+ {content}
159
+ </button>
160
+ );
161
+ });
162
+
163
+ export default AbButton;
164
+ export { AbButton };
@@ -0,0 +1,63 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * Plain CSS modules — no Tailwind Tailwind apply (Turbopack-safe).
6
+ */
7
+
8
+ /*
9
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10
+ * MOTTO: We'll always do more 😜!!!
11
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
+ */
13
+
14
+ .abButton {
15
+ position: relative;
16
+ display: inline-flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ gap: 0.5rem;
20
+ width: fit-content;
21
+ height: fit-content;
22
+ margin: 0;
23
+ overflow: hidden;
24
+ font-size: 1rem;
25
+ line-height: 1.25;
26
+ text-decoration: none;
27
+ cursor: pointer;
28
+ border: none;
29
+ background: transparent;
30
+ color: inherit;
31
+ }
32
+
33
+ .abButtonRounded {
34
+ border-radius: 9999px;
35
+ }
36
+
37
+ .isContained {}
38
+
39
+ .isDisabled {
40
+ pointer-events: none;
41
+ opacity: 0.6;
42
+ }
43
+
44
+ .abButtonIcon {
45
+ font-size: 1.25rem;
46
+ line-height: 1;
47
+ }
48
+
49
+ .abButtonSpinnerSlot {
50
+ position: absolute;
51
+ inset: 0;
52
+ z-index: 10;
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: center;
56
+ }
57
+
58
+ .abButtonSpinner {
59
+ /* themed via --ab-button-spinner-color when present */
60
+ }
61
+
62
+ .hidden { display: none !important; }
63
+ .invisible { visibility: hidden; }
@@ -0,0 +1,188 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * @project: ab-nextjs-components
9
+ * @name: AbCollapsible - Client (port of lyd-collapsible)
10
+ * @file: ab-collapsible/index.tsx
11
+ */
12
+
13
+ 'use client';
14
+
15
+ import type { CSSProperties, ReactElement, ReactNode } from 'react';
16
+ import { useState } from 'react';
17
+ import Link from 'next/link';
18
+ import clsx from 'clsx';
19
+ import styles from './styles.module.css';
20
+
21
+ export interface AbCollapsibleProps {
22
+ href?: string | null;
23
+ className?: string;
24
+ style?: CSSProperties;
25
+ hidden?: boolean;
26
+ type?: 'contained' | 'outlined';
27
+ effect?: 'normal' | 'morph' | 'translucent';
28
+ title: string;
29
+ subtitle?: string;
30
+ icon?: string;
31
+ resetIcon?: string;
32
+ expandIcon?: string;
33
+ isOpen?: boolean;
34
+ defaultOpen?: boolean;
35
+ isActive?: boolean;
36
+ autoActiveIcon?: boolean;
37
+ autoHideSubtitle?: boolean;
38
+ hideResetIcon?: boolean;
39
+ hideSubtitle?: boolean;
40
+ subtitleAsCaption?: boolean;
41
+ titleBold?: boolean;
42
+ titleCapitalize?: boolean;
43
+ expands?: boolean;
44
+ titleExpands?: boolean;
45
+ shrinks?: boolean;
46
+ children?: ReactNode;
47
+ onToggle?: (open: boolean) => void;
48
+ onReset?: () => void;
49
+ }
50
+
51
+ const AbCollapsible = ({
52
+ href = null,
53
+ className,
54
+ style,
55
+ hidden = false,
56
+ type = 'contained',
57
+ effect = 'normal',
58
+ title,
59
+ subtitle,
60
+ icon,
61
+ resetIcon = 'close',
62
+ expandIcon = 'expand_more',
63
+ isOpen,
64
+ defaultOpen = false,
65
+ isActive = false,
66
+ autoActiveIcon = true,
67
+ autoHideSubtitle = true,
68
+ hideResetIcon = true,
69
+ hideSubtitle = false,
70
+ subtitleAsCaption = false,
71
+ titleBold = true,
72
+ titleCapitalize = false,
73
+ expands = false,
74
+ titleExpands = false,
75
+ shrinks = false,
76
+ children,
77
+ onToggle,
78
+ onReset,
79
+ }: AbCollapsibleProps): ReactElement => {
80
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
81
+ const open = isOpen ?? internalOpen;
82
+
83
+ const setOpen = (next: boolean) => {
84
+ if (isOpen === undefined) setInternalOpen(next);
85
+ onToggle?.(next);
86
+ };
87
+
88
+ const headerInner = (
89
+ <>
90
+ {icon ? (
91
+ <span
92
+ className={clsx(
93
+ 'material-symbols-rounded',
94
+ styles.abCollapsibleIcon,
95
+ autoActiveIcon && open && styles.iconActive,
96
+ )}
97
+ aria-hidden
98
+ >
99
+ {icon}
100
+ </span>
101
+ ) : null}
102
+ <span className={styles.abCollapsibleTitles}>
103
+ <span
104
+ className={clsx(
105
+ styles.abCollapsibleTitle,
106
+ titleBold && styles.titleBold,
107
+ titleCapitalize && styles.titleCapitalize,
108
+ titleExpands && styles.titleExpands,
109
+ )}
110
+ >
111
+ {title}
112
+ </span>
113
+ {subtitle && !hideSubtitle && !(autoHideSubtitle && !open) ? (
114
+ <span
115
+ className={clsx(
116
+ styles.abCollapsibleSubtitle,
117
+ subtitleAsCaption && styles.subtitleCaption,
118
+ )}
119
+ >
120
+ {subtitle}
121
+ </span>
122
+ ) : null}
123
+ </span>
124
+ {!hideResetIcon ? (
125
+ <button
126
+ type="button"
127
+ className={styles.abCollapsibleReset}
128
+ aria-label="Reset"
129
+ onClick={(e) => {
130
+ e.stopPropagation();
131
+ onReset?.();
132
+ }}
133
+ >
134
+ <span className="material-symbols-rounded" aria-hidden>
135
+ {resetIcon}
136
+ </span>
137
+ </button>
138
+ ) : null}
139
+ <span
140
+ className={clsx('material-symbols-rounded', styles.abCollapsibleExpand, open && styles.expanded)}
141
+ aria-hidden
142
+ >
143
+ {expandIcon}
144
+ </span>
145
+ </>
146
+ );
147
+
148
+ return (
149
+ <div
150
+ hidden={hidden}
151
+ style={style}
152
+ data-type={type}
153
+ data-effect={effect}
154
+ data-open={open ? 'true' : 'false'}
155
+ data-active={isActive ? 'true' : 'false'}
156
+ data-expands={expands ? 'true' : 'false'}
157
+ data-shrinks={shrinks ? 'true' : 'false'}
158
+ className={clsx(
159
+ 'AbCollapsible',
160
+ styles.abCollapsible,
161
+ open && styles.isOpen,
162
+ isActive && styles.isActive,
163
+ expands && styles.expands,
164
+ shrinks && styles.shrinks,
165
+ className,
166
+ )}
167
+ >
168
+ {href ? (
169
+ <Link href={href} className={styles.abCollapsibleHeader}>
170
+ {headerInner}
171
+ </Link>
172
+ ) : (
173
+ <button
174
+ type="button"
175
+ className={styles.abCollapsibleHeader}
176
+ aria-expanded={open}
177
+ onClick={() => setOpen(!open)}
178
+ >
179
+ {headerInner}
180
+ </button>
181
+ )}
182
+ {open ? <div className={styles.abCollapsibleBody}>{children}</div> : null}
183
+ </div>
184
+ );
185
+ };
186
+
187
+ export default AbCollapsible;
188
+ export { AbCollapsible };
@@ -0,0 +1,98 @@
1
+ .abCollapsible {
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ border-radius: 0.75rem;
6
+ background: var(--ab-surface-container, #f3edf7);
7
+ color: var(--ab-on-surface, #1c1b1f);
8
+ overflow: hidden;
9
+ }
10
+
11
+ .abCollapsible[data-type='outlined'] {
12
+ background: transparent;
13
+ border: 1px solid color-mix(in srgb, var(--ab-outline, #79747e) 40%, transparent);
14
+ }
15
+
16
+ .abCollapsibleHeader {
17
+ display: flex;
18
+ align-items: center;
19
+ gap: 0.75rem;
20
+ width: 100%;
21
+ padding: 0.875rem 1rem;
22
+ border: none;
23
+ background: transparent;
24
+ color: inherit;
25
+ font: inherit;
26
+ text-align: left;
27
+ text-decoration: none;
28
+ cursor: pointer;
29
+ }
30
+
31
+ .abCollapsibleIcon {
32
+ font-size: 1.5rem;
33
+ line-height: 1;
34
+ opacity: 0.85;
35
+ }
36
+
37
+ .iconActive {
38
+ color: var(--ab-primary, #a67c52);
39
+ opacity: 1;
40
+ }
41
+
42
+ .abCollapsibleTitles {
43
+ display: flex;
44
+ flex: 1;
45
+ flex-direction: column;
46
+ gap: 0.125rem;
47
+ min-width: 0;
48
+ }
49
+
50
+ .abCollapsibleTitle {
51
+ overflow: hidden;
52
+ text-overflow: ellipsis;
53
+ white-space: nowrap;
54
+ }
55
+
56
+ .titleBold { font-weight: 700; }
57
+ .titleCapitalize { text-transform: capitalize; }
58
+ .titleExpands { white-space: normal; }
59
+
60
+ .abCollapsibleSubtitle {
61
+ font-size: 0.875rem;
62
+ opacity: 0.75;
63
+ }
64
+
65
+ .subtitleCaption {
66
+ font-size: 0.75rem;
67
+ opacity: 0.65;
68
+ }
69
+
70
+ .abCollapsibleReset,
71
+ .abCollapsibleExpand {
72
+ display: inline-flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ border: none;
76
+ background: transparent;
77
+ color: inherit;
78
+ cursor: pointer;
79
+ }
80
+
81
+ .abCollapsibleExpand {
82
+ transition: transform 0.2s ease;
83
+ }
84
+
85
+ .abCollapsibleExpand.expanded {
86
+ transform: rotate(180deg);
87
+ }
88
+
89
+ .abCollapsibleBody {
90
+ padding: 0 1rem 1rem;
91
+ }
92
+
93
+ .isActive {
94
+ box-shadow: inset 0 0 0 2px var(--ab-primary, #a67c52);
95
+ }
96
+
97
+ .expands { width: 100%; }
98
+ .shrinks { width: fit-content; }
@@ -0,0 +1,84 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * @project: ab-nextjs-components
9
+ * @name: AbColor - Client (port of lyd-color)
10
+ * @file: ab-color/index.tsx
11
+ */
12
+
13
+ 'use client';
14
+
15
+ import type { MouseEvent, ReactElement } from 'react';
16
+ import clsx from 'clsx';
17
+ import styles from './styles.module.css';
18
+
19
+ export interface AbColorProps {
20
+ className?: string;
21
+ hidden?: boolean;
22
+ disabled?: boolean;
23
+ shape?: 'circle' | 'square';
24
+ name: string;
25
+ colors: string[];
26
+ isActive?: boolean;
27
+ expands?: boolean;
28
+ shrinks?: boolean;
29
+ onClick?: (event?: MouseEvent<HTMLButtonElement>) => void;
30
+ }
31
+
32
+ const AbColor = ({
33
+ className,
34
+ hidden = false,
35
+ disabled = false,
36
+ shape = 'circle',
37
+ name,
38
+ colors,
39
+ isActive = false,
40
+ expands = false,
41
+ shrinks = false,
42
+ onClick,
43
+ }: AbColorProps): ReactElement => {
44
+ const swatches = colors.slice(0, 4);
45
+
46
+ return (
47
+ <button
48
+ type="button"
49
+ hidden={hidden}
50
+ disabled={disabled}
51
+ aria-label={name}
52
+ aria-pressed={isActive}
53
+ data-shape={shape}
54
+ data-active={isActive ? 'true' : 'false'}
55
+ data-expands={expands ? 'true' : 'false'}
56
+ data-shrinks={shrinks ? 'true' : 'false'}
57
+ className={clsx(
58
+ 'AbColor',
59
+ styles.abColor,
60
+ shape === 'square' && styles.square,
61
+ isActive && styles.isActive,
62
+ expands && styles.expands,
63
+ shrinks && styles.shrinks,
64
+ disabled && styles.isDisabled,
65
+ className,
66
+ )}
67
+ onClick={onClick}
68
+ >
69
+ <span className={styles.abColorSwatches} aria-hidden>
70
+ {swatches.map((c, i) => (
71
+ <span
72
+ key={`${name}-${i}`}
73
+ className={styles.abColorSwatch}
74
+ style={{ background: c }}
75
+ />
76
+ ))}
77
+ </span>
78
+ <span className={styles.abColorName}>{name}</span>
79
+ </button>
80
+ );
81
+ };
82
+
83
+ export default AbColor;
84
+ export { AbColor };
@@ -0,0 +1,51 @@
1
+ .abColor {
2
+ display: inline-flex;
3
+ flex-direction: column;
4
+ align-items: center;
5
+ gap: 0.375rem;
6
+ padding: 0.5rem;
7
+ border: 2px solid transparent;
8
+ border-radius: 0.75rem;
9
+ background: transparent;
10
+ color: inherit;
11
+ font: inherit;
12
+ cursor: pointer;
13
+ }
14
+
15
+ .abColorSwatches {
16
+ display: grid;
17
+ grid-template-columns: 1fr 1fr;
18
+ width: 2.5rem;
19
+ height: 2.5rem;
20
+ overflow: hidden;
21
+ border-radius: 9999px;
22
+ }
23
+
24
+ .square .abColorSwatches {
25
+ border-radius: 0.375rem;
26
+ }
27
+
28
+ .abColorSwatch {
29
+ width: 100%;
30
+ height: 100%;
31
+ }
32
+
33
+ .abColorName {
34
+ max-width: 4.5rem;
35
+ overflow: hidden;
36
+ font-size: 0.75rem;
37
+ text-overflow: ellipsis;
38
+ white-space: nowrap;
39
+ }
40
+
41
+ .isActive {
42
+ border-color: var(--ab-primary, #a67c52);
43
+ }
44
+
45
+ .isDisabled {
46
+ opacity: 0.5;
47
+ pointer-events: none;
48
+ }
49
+
50
+ .expands { width: 100%; }
51
+ .shrinks { width: fit-content; }
@@ -0,0 +1,38 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * @project: ab-nextjs-components
9
+ * @name: AbDemoBox - Client (port of lyd-demo-box)
10
+ * @file: ab-demo-box/index.tsx
11
+ */
12
+
13
+ 'use client';
14
+
15
+ import type { ReactElement, ReactNode } from 'react';
16
+ import { forwardRef } from 'react';
17
+ import clsx from 'clsx';
18
+ import styles from './styles.module.css';
19
+
20
+ export interface AbDemoBoxProps {
21
+ className?: string;
22
+ hidden?: boolean;
23
+ children?: ReactNode;
24
+ }
25
+
26
+ const AbDemoBox = forwardRef<HTMLDivElement, AbDemoBoxProps>(function AbDemoBox(
27
+ { className, hidden = false, children },
28
+ ref,
29
+ ): ReactElement {
30
+ return (
31
+ <div ref={ref} hidden={hidden} className={clsx('AbDemoBox', styles.abDemoBox, className)}>
32
+ {children}
33
+ </div>
34
+ );
35
+ });
36
+
37
+ export default AbDemoBox;
38
+ export { AbDemoBox };
@@ -0,0 +1,13 @@
1
+ .abDemoBox {
2
+ position: relative;
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: 1rem;
6
+ padding: 1.25rem;
7
+ border-radius: 1rem;
8
+ border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
9
+ background:
10
+ radial-gradient(circle at top right, color-mix(in srgb, var(--ab-primary, #6750a4) 10%, transparent), transparent 45%),
11
+ var(--ab-surface, #fff);
12
+ overflow: hidden;
13
+ }