omnira-ui 0.6.0 → 0.6.5
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/README.md +3 -3
- package/cli/omnira-init.mjs +20 -1
- package/components/ui/ActivityFeed/ActivityFeed.module.css +143 -0
- package/components/ui/ActivityFeed/ActivityFeed.tsx +94 -0
- package/components/ui/ActivityFeed/index.ts +2 -0
- package/components/ui/Button/Button.module.css +5 -5
- package/components/ui/ButtonGroup/ButtonGroup.module.css +103 -0
- package/components/ui/ButtonGroup/ButtonGroup.tsx +153 -0
- package/components/ui/ButtonGroup/index.ts +2 -0
- package/components/ui/Carousel/Carousel.module.css +95 -0
- package/components/ui/Carousel/Carousel.tsx +137 -0
- package/components/ui/Carousel/index.ts +2 -0
- package/components/ui/CommandMenu/CommandMenu.module.css +187 -0
- package/components/ui/CommandMenu/CommandMenu.tsx +205 -0
- package/components/ui/CommandMenu/index.ts +2 -0
- package/components/ui/FeaturedIcon/FeaturedIcon.module.css +212 -0
- package/components/ui/FeaturedIcon/FeaturedIcon.tsx +46 -0
- package/components/ui/FeaturedIcon/index.ts +2 -0
- package/components/ui/HeaderNavigation/HeaderNavigation.module.css +99 -0
- package/components/ui/HeaderNavigation/HeaderNavigation.tsx +103 -0
- package/components/ui/HeaderNavigation/index.ts +2 -0
- package/components/ui/InlineCTA/InlineCTA.module.css +101 -0
- package/components/ui/InlineCTA/InlineCTA.tsx +59 -0
- package/components/ui/InlineCTA/index.ts +2 -0
- package/components/ui/LineBarChart/LineBarChart.module.css +41 -0
- package/components/ui/LineBarChart/LineBarChart.tsx +191 -0
- package/components/ui/LineBarChart/index.ts +2 -0
- package/components/ui/Matrix/Matrix.module.css +54 -0
- package/components/ui/Matrix/Matrix.tsx +99 -0
- package/components/ui/Matrix/index.ts +2 -0
- package/components/ui/Messaging/Messaging.module.css +186 -0
- package/components/ui/Messaging/Messaging.tsx +168 -0
- package/components/ui/Messaging/index.ts +2 -0
- package/components/ui/Pagination/Pagination.module.css +161 -0
- package/components/ui/Pagination/Pagination.tsx +150 -0
- package/components/ui/Pagination/index.ts +2 -0
- package/components/ui/PieChart/PieChart.module.css +91 -0
- package/components/ui/PieChart/PieChart.tsx +185 -0
- package/components/ui/PieChart/index.ts +2 -0
- package/components/ui/ProgressSteps/ProgressSteps.module.css +232 -0
- package/components/ui/ProgressSteps/ProgressSteps.tsx +134 -0
- package/components/ui/ProgressSteps/index.ts +2 -0
- package/components/ui/RadarChart/RadarChart.module.css +25 -0
- package/components/ui/RadarChart/RadarChart.tsx +140 -0
- package/components/ui/RadarChart/index.ts +2 -0
- package/components/ui/SectionFooter/SectionFooter.module.css +55 -0
- package/components/ui/SectionFooter/SectionFooter.tsx +63 -0
- package/components/ui/SectionFooter/index.ts +2 -0
- package/components/ui/SectionHeader/SectionHeader.module.css +73 -0
- package/components/ui/SectionHeader/SectionHeader.tsx +121 -0
- package/components/ui/SectionHeader/index.ts +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A premium glassmorphism design system — dark-first, glass-forward, no compromi
|
|
|
4
4
|
|
|
5
5
|
30+ base components, sidebar navigation, feature cards, 1,000+ icons, and a CLI to scaffold your project with your chosen accent color and theme mode.
|
|
6
6
|
|
|
7
|
-
**[Live Documentation →](https://
|
|
7
|
+
**[Live Documentation →](https://omnira.one)**
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -75,7 +75,7 @@ export default function MyPage() {
|
|
|
75
75
|
|
|
76
76
|
Browse the full library and copy advanced components (Sidebar, Feature Cards, etc.) directly from the docs:
|
|
77
77
|
|
|
78
|
-
**[
|
|
78
|
+
**[omnira.one →](https://omnira.one)**
|
|
79
79
|
|
|
80
80
|
---
|
|
81
81
|
|
|
@@ -170,4 +170,4 @@ lib/ # Shared utilities
|
|
|
170
170
|
|
|
171
171
|
## License
|
|
172
172
|
|
|
173
|
-
MIT © [Omnira UI](https://
|
|
173
|
+
MIT © [Omnira UI](https://omnira.one)
|
package/cli/omnira-init.mjs
CHANGED
|
@@ -384,7 +384,7 @@ async function main() {
|
|
|
384
384
|
log(` ${MAGENTA}import${RESET} { Button } ${MAGENTA}from${RESET} ${WHITE}"@/components/ui/Button"${RESET};`);
|
|
385
385
|
blank();
|
|
386
386
|
log(` ${DIM}4.${RESET} Browse all components & copy advanced ones:`);
|
|
387
|
-
log(` ${CYAN}https://
|
|
387
|
+
log(` ${CYAN}https://omnira.one${RESET}`);
|
|
388
388
|
blank();
|
|
389
389
|
}
|
|
390
390
|
|
|
@@ -468,6 +468,25 @@ const PAGE_BUNDLES = {
|
|
|
468
468
|
"card": ["Card", "Button", "Badge"],
|
|
469
469
|
// Matrix
|
|
470
470
|
"matrix": ["Card"],
|
|
471
|
+
// ── Base component slug aliases (hyphenated → PascalCase folder) ──
|
|
472
|
+
"app-store-button": ["AppStoreButton"],
|
|
473
|
+
"badge-group": ["BadgeGroup"],
|
|
474
|
+
"button-group": ["ButtonGroup"],
|
|
475
|
+
"credit-card": ["CreditCard"],
|
|
476
|
+
"featured-icon": ["FeaturedIcon"],
|
|
477
|
+
"progress-indicator": ["ProgressBar"],
|
|
478
|
+
"qr-code": ["QRCode"],
|
|
479
|
+
"radio-button": ["RadioButton"],
|
|
480
|
+
"radio-group": ["RadioGroup"],
|
|
481
|
+
"social-button": ["SocialButton"],
|
|
482
|
+
"text-editor": ["TextEditor"],
|
|
483
|
+
"utility": ["ButtonUtility"],
|
|
484
|
+
"verification-code-input": ["PinInput"],
|
|
485
|
+
"video-player": ["VideoPlayer"],
|
|
486
|
+
"agent-thinking": ["AgentThinking"],
|
|
487
|
+
// ── Shared pages bundles ──
|
|
488
|
+
"login": ["AuthPage", "LoginSimple", "LoginSplitImage", "LoginSplitQuote", "LoginCardSeparated", "SocialButton", "Button", "Input", "Checkbox"],
|
|
489
|
+
"sign-up": ["SignUpSimple", "SignUpSplitImage", "SignUpSplitQuote", "SignUpCardSeparated", "SocialButton", "Button", "Input", "Checkbox"],
|
|
471
490
|
};
|
|
472
491
|
|
|
473
492
|
// ── Add command — copy a single component ───────────────────────────
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/* ── Root ── */
|
|
2
|
+
.root {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.card {
|
|
8
|
+
background: var(--color-bg-card);
|
|
9
|
+
border: 1px solid var(--color-border-standard);
|
|
10
|
+
border-radius: var(--radius-xl);
|
|
11
|
+
padding: 24px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* ── Item ── */
|
|
15
|
+
.item {
|
|
16
|
+
display: flex;
|
|
17
|
+
gap: 12px;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.default .item + .item {
|
|
22
|
+
margin-top: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.compact .item + .item {
|
|
26
|
+
margin-top: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ── Timeline Column ── */
|
|
30
|
+
.timeline {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: center;
|
|
34
|
+
flex-shrink: 0;
|
|
35
|
+
width: 36px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.avatar {
|
|
39
|
+
width: 36px;
|
|
40
|
+
height: 36px;
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
object-fit: cover;
|
|
43
|
+
flex-shrink: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.avatarFallback {
|
|
47
|
+
width: 36px;
|
|
48
|
+
height: 36px;
|
|
49
|
+
border-radius: 50%;
|
|
50
|
+
background: var(--color-bg-elevated);
|
|
51
|
+
border: 1px solid var(--color-border-standard);
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
font-weight: 600;
|
|
57
|
+
color: var(--color-text-secondary);
|
|
58
|
+
flex-shrink: 0;
|
|
59
|
+
font-family: var(--font-display);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.iconBubble {
|
|
63
|
+
width: 36px;
|
|
64
|
+
height: 36px;
|
|
65
|
+
border-radius: 50%;
|
|
66
|
+
background: var(--color-bg-lime-subtle);
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
color: var(--color-lime);
|
|
71
|
+
flex-shrink: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.connector {
|
|
75
|
+
width: 2px;
|
|
76
|
+
flex: 1;
|
|
77
|
+
min-height: 24px;
|
|
78
|
+
background: var(--color-border-standard);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* ── Compact ── */
|
|
82
|
+
.compact .timeline {
|
|
83
|
+
width: 28px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.compact .avatar,
|
|
87
|
+
.compact .avatarFallback,
|
|
88
|
+
.compact .iconBubble {
|
|
89
|
+
width: 28px;
|
|
90
|
+
height: 28px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.compact .avatarFallback {
|
|
94
|
+
font-size: 10px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.compact .connector {
|
|
98
|
+
min-height: 16px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* ── Content Column ── */
|
|
102
|
+
.content {
|
|
103
|
+
flex: 1;
|
|
104
|
+
min-width: 0;
|
|
105
|
+
padding-bottom: 24px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.compact .content {
|
|
109
|
+
padding-bottom: 16px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.item:last-child .content {
|
|
113
|
+
padding-bottom: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.header {
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: 8px;
|
|
120
|
+
margin-bottom: 4px;
|
|
121
|
+
flex-wrap: wrap;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.userName {
|
|
125
|
+
font-size: 14px;
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
color: var(--color-text-primary);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.timestamp {
|
|
131
|
+
font-size: 12px;
|
|
132
|
+
color: var(--color-text-tertiary);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.body {
|
|
136
|
+
font-size: 14px;
|
|
137
|
+
color: var(--color-text-secondary);
|
|
138
|
+
line-height: 1.5;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.body p {
|
|
142
|
+
margin: 0;
|
|
143
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { cn } from "@/lib/cn";
|
|
5
|
+
import styles from "./ActivityFeed.module.css";
|
|
6
|
+
|
|
7
|
+
/* ── Types ── */
|
|
8
|
+
|
|
9
|
+
export interface ActivityFeedItem {
|
|
10
|
+
id: string;
|
|
11
|
+
/** User display name */
|
|
12
|
+
user: string;
|
|
13
|
+
/** Avatar URL (falls back to initials) */
|
|
14
|
+
avatar?: string;
|
|
15
|
+
/** Event content — plain text or ReactNode */
|
|
16
|
+
content: React.ReactNode;
|
|
17
|
+
/** Timestamp label (e.g. "2 hours ago") */
|
|
18
|
+
timestamp: string;
|
|
19
|
+
/** Optional icon (replaces avatar dot) */
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
/** Icon background color */
|
|
22
|
+
iconBg?: string;
|
|
23
|
+
/** Event type for styling */
|
|
24
|
+
type?: "default" | "comment" | "status" | "assignment" | "commit";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ActivityFeedProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
28
|
+
items: ActivityFeedItem[];
|
|
29
|
+
/** Visual variant */
|
|
30
|
+
variant?: "default" | "compact" | "card";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ── Helpers ── */
|
|
34
|
+
|
|
35
|
+
function getInitials(name: string) {
|
|
36
|
+
return name
|
|
37
|
+
.split(" ")
|
|
38
|
+
.map((w) => w[0])
|
|
39
|
+
.join("")
|
|
40
|
+
.toUpperCase()
|
|
41
|
+
.slice(0, 2);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ── Component ── */
|
|
45
|
+
|
|
46
|
+
export const ActivityFeed = forwardRef<HTMLDivElement, ActivityFeedProps>(
|
|
47
|
+
({ items, variant = "default", className, ...props }, ref) => {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
ref={ref}
|
|
51
|
+
className={cn(styles.root, styles[variant], className)}
|
|
52
|
+
{...props}
|
|
53
|
+
>
|
|
54
|
+
{items.map((item, i) => (
|
|
55
|
+
<div key={item.id} className={styles.item}>
|
|
56
|
+
{/* Timeline column */}
|
|
57
|
+
<div className={styles.timeline}>
|
|
58
|
+
{item.icon ? (
|
|
59
|
+
<div
|
|
60
|
+
className={styles.iconBubble}
|
|
61
|
+
style={item.iconBg ? { background: item.iconBg } : undefined}
|
|
62
|
+
>
|
|
63
|
+
{item.icon}
|
|
64
|
+
</div>
|
|
65
|
+
) : item.avatar ? (
|
|
66
|
+
<img
|
|
67
|
+
src={item.avatar}
|
|
68
|
+
alt={item.user}
|
|
69
|
+
className={styles.avatar}
|
|
70
|
+
/>
|
|
71
|
+
) : (
|
|
72
|
+
<div className={styles.avatarFallback}>
|
|
73
|
+
{getInitials(item.user)}
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
{i < items.length - 1 && <div className={styles.connector} />}
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
{/* Content column */}
|
|
80
|
+
<div className={styles.content}>
|
|
81
|
+
<div className={styles.header}>
|
|
82
|
+
<span className={styles.userName}>{item.user}</span>
|
|
83
|
+
<span className={styles.timestamp}>{item.timestamp}</span>
|
|
84
|
+
</div>
|
|
85
|
+
<div className={styles.body}>{item.content}</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
))}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
ActivityFeed.displayName = "ActivityFeed";
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
.primary {
|
|
24
24
|
color: var(--color-lime-text);
|
|
25
25
|
background: var(--color-lime);
|
|
26
|
-
border-radius: var(--radius-
|
|
26
|
+
border-radius: var(--radius-md);
|
|
27
27
|
font-weight: 700;
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
border: 1.5px solid var(--color-border-standard);
|
|
40
40
|
box-shadow: var(--shadow-card-light);
|
|
41
41
|
backdrop-filter: var(--blur-standard);
|
|
42
|
-
border-radius: var(--radius-
|
|
42
|
+
border-radius: var(--radius-md);
|
|
43
43
|
font-weight: 600;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
color: var(--color-text-secondary);
|
|
55
55
|
background: transparent;
|
|
56
56
|
border: 1.5px solid transparent;
|
|
57
|
-
border-radius: var(--radius-
|
|
57
|
+
border-radius: var(--radius-md);
|
|
58
58
|
font-weight: 600;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
color: var(--color-text-secondary);
|
|
69
69
|
background: transparent;
|
|
70
70
|
border: 1.5px solid var(--color-border-medium);
|
|
71
|
-
border-radius: var(--radius-
|
|
71
|
+
border-radius: var(--radius-md);
|
|
72
72
|
font-weight: 600;
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
color: var(--color-lime);
|
|
83
83
|
background: var(--color-bg-lime-strong);
|
|
84
84
|
border: 1px solid var(--color-border-lime-medium);
|
|
85
|
-
border-radius: var(--radius-
|
|
85
|
+
border-radius: var(--radius-md);
|
|
86
86
|
font-weight: 600;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* ── Group container ── */
|
|
2
|
+
.group {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
border: 1.5px solid var(--color-border-standard);
|
|
6
|
+
border-radius: var(--radius-lg);
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
background: var(--color-bg-card);
|
|
9
|
+
box-shadow: var(--shadow-card-light);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* ── Sizes ── */
|
|
13
|
+
.sm { height: 36px; }
|
|
14
|
+
.md { height: 40px; }
|
|
15
|
+
.lg { height: 44px; }
|
|
16
|
+
|
|
17
|
+
/* ── Item ── */
|
|
18
|
+
.item {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
gap: 6px;
|
|
23
|
+
padding: 0 16px;
|
|
24
|
+
height: 100%;
|
|
25
|
+
font-family: inherit;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
color: var(--color-text-secondary);
|
|
28
|
+
background: transparent;
|
|
29
|
+
border: none;
|
|
30
|
+
border-right: 1px solid var(--color-border-standard);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
transition: all 0.15s ease;
|
|
34
|
+
outline: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.item:last-child {
|
|
38
|
+
border-right: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.item:hover:not(:disabled) {
|
|
42
|
+
background: var(--color-bg-hover);
|
|
43
|
+
color: var(--color-text-primary);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.item:focus-visible {
|
|
47
|
+
box-shadow: 0 0 0 2px var(--color-lime) inset;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.item:disabled {
|
|
51
|
+
opacity: 0.5;
|
|
52
|
+
cursor: not-allowed;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ── Item sizes ── */
|
|
56
|
+
.item-sm {
|
|
57
|
+
padding: 0 12px;
|
|
58
|
+
font-size: 13px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.item-md {
|
|
62
|
+
padding: 0 16px;
|
|
63
|
+
font-size: 14px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.item-lg {
|
|
67
|
+
padding: 0 20px;
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ── Selected state ── */
|
|
72
|
+
.selected {
|
|
73
|
+
background: var(--color-bg-elevated);
|
|
74
|
+
color: var(--color-text-primary);
|
|
75
|
+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.selected:hover:not(:disabled) {
|
|
79
|
+
background: var(--color-bg-elevated);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ── Dot indicator ── */
|
|
83
|
+
.dot {
|
|
84
|
+
width: 8px;
|
|
85
|
+
height: 8px;
|
|
86
|
+
border-radius: 50%;
|
|
87
|
+
background: var(--color-lime);
|
|
88
|
+
flex-shrink: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* ── Icon wrapper ── */
|
|
92
|
+
.iconWrapper {
|
|
93
|
+
display: inline-flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
flex-shrink: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ── Label ── */
|
|
100
|
+
.label {
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, createContext, useContext, useCallback } from "react";
|
|
4
|
+
import { cn } from "@/lib/cn";
|
|
5
|
+
import styles from "./ButtonGroup.module.css";
|
|
6
|
+
|
|
7
|
+
/* ══════════════════════════════════════
|
|
8
|
+
Context for selection state
|
|
9
|
+
══════════════════════════════════════ */
|
|
10
|
+
|
|
11
|
+
interface ButtonGroupContextValue {
|
|
12
|
+
selected: string[];
|
|
13
|
+
toggle: (value: string) => void;
|
|
14
|
+
selectionMode: "none" | "single" | "multiple";
|
|
15
|
+
size: "sm" | "md" | "lg";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ButtonGroupContext = createContext<ButtonGroupContextValue>({
|
|
19
|
+
selected: [],
|
|
20
|
+
toggle: () => {},
|
|
21
|
+
selectionMode: "none",
|
|
22
|
+
size: "md",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/* ══════════════════════════════════════
|
|
26
|
+
ButtonGroup Root
|
|
27
|
+
══════════════════════════════════════ */
|
|
28
|
+
|
|
29
|
+
export interface ButtonGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
30
|
+
/** Selection mode */
|
|
31
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
32
|
+
/** Currently selected values (controlled) */
|
|
33
|
+
selected?: string[];
|
|
34
|
+
/** Called when selection changes */
|
|
35
|
+
onSelectionChange?: (selected: string[]) => void;
|
|
36
|
+
/** Size of all items */
|
|
37
|
+
size?: "sm" | "md" | "lg";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
41
|
+
(
|
|
42
|
+
{
|
|
43
|
+
selectionMode = "none",
|
|
44
|
+
selected = [],
|
|
45
|
+
onSelectionChange,
|
|
46
|
+
size = "md",
|
|
47
|
+
className,
|
|
48
|
+
children,
|
|
49
|
+
...props
|
|
50
|
+
},
|
|
51
|
+
ref
|
|
52
|
+
) => {
|
|
53
|
+
const toggle = useCallback(
|
|
54
|
+
(value: string) => {
|
|
55
|
+
if (selectionMode === "none") return;
|
|
56
|
+
|
|
57
|
+
let next: string[];
|
|
58
|
+
if (selectionMode === "single") {
|
|
59
|
+
next = selected.includes(value) ? [] : [value];
|
|
60
|
+
} else {
|
|
61
|
+
next = selected.includes(value)
|
|
62
|
+
? selected.filter((v) => v !== value)
|
|
63
|
+
: [...selected, value];
|
|
64
|
+
}
|
|
65
|
+
onSelectionChange?.(next);
|
|
66
|
+
},
|
|
67
|
+
[selectionMode, selected, onSelectionChange]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<ButtonGroupContext.Provider value={{ selected, toggle, selectionMode, size }}>
|
|
72
|
+
<div
|
|
73
|
+
ref={ref}
|
|
74
|
+
role="group"
|
|
75
|
+
className={cn(styles.group, styles[size], className)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</div>
|
|
80
|
+
</ButtonGroupContext.Provider>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
86
|
+
|
|
87
|
+
/* ══════════════════════════════════════
|
|
88
|
+
ButtonGroupItem
|
|
89
|
+
══════════════════════════════════════ */
|
|
90
|
+
|
|
91
|
+
export interface ButtonGroupItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
92
|
+
/** Value for selection tracking */
|
|
93
|
+
value?: string;
|
|
94
|
+
/** Leading icon */
|
|
95
|
+
icon?: React.ReactNode;
|
|
96
|
+
/** Show dot indicator */
|
|
97
|
+
dot?: boolean;
|
|
98
|
+
/** Dot color */
|
|
99
|
+
dotColor?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const ButtonGroupItem = forwardRef<HTMLButtonElement, ButtonGroupItemProps>(
|
|
103
|
+
(
|
|
104
|
+
{
|
|
105
|
+
value = "",
|
|
106
|
+
icon,
|
|
107
|
+
dot,
|
|
108
|
+
dotColor,
|
|
109
|
+
disabled,
|
|
110
|
+
className,
|
|
111
|
+
children,
|
|
112
|
+
...props
|
|
113
|
+
},
|
|
114
|
+
ref
|
|
115
|
+
) => {
|
|
116
|
+
const { selected, toggle, selectionMode, size } = useContext(ButtonGroupContext);
|
|
117
|
+
const isSelected = value ? selected.includes(value) : false;
|
|
118
|
+
|
|
119
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
120
|
+
if (value) toggle(value);
|
|
121
|
+
props.onClick?.(e);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<button
|
|
126
|
+
ref={ref}
|
|
127
|
+
type="button"
|
|
128
|
+
role={selectionMode !== "none" ? "option" : undefined}
|
|
129
|
+
aria-selected={selectionMode !== "none" ? isSelected : undefined}
|
|
130
|
+
disabled={disabled}
|
|
131
|
+
className={cn(
|
|
132
|
+
styles.item,
|
|
133
|
+
styles[`item-${size}`],
|
|
134
|
+
isSelected && styles.selected,
|
|
135
|
+
className
|
|
136
|
+
)}
|
|
137
|
+
onClick={handleClick}
|
|
138
|
+
{...props}
|
|
139
|
+
>
|
|
140
|
+
{dot && (
|
|
141
|
+
<span
|
|
142
|
+
className={styles.dot}
|
|
143
|
+
style={dotColor ? { background: dotColor } : undefined}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
{icon && <span className={styles.iconWrapper}>{icon}</span>}
|
|
147
|
+
{children && <span className={styles.label}>{children}</span>}
|
|
148
|
+
</button>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
ButtonGroupItem.displayName = "ButtonGroupItem";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 16px;
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.viewport {
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.track {
|
|
13
|
+
display: flex;
|
|
14
|
+
overflow-x: auto;
|
|
15
|
+
scroll-snap-type: x mandatory;
|
|
16
|
+
scrollbar-width: none;
|
|
17
|
+
-ms-overflow-style: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.track::-webkit-scrollbar {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.track > * {
|
|
25
|
+
scroll-snap-align: start;
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ── Arrows ── */
|
|
30
|
+
.arrow {
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 50%;
|
|
33
|
+
transform: translateY(-50%);
|
|
34
|
+
z-index: 2;
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
width: 36px;
|
|
39
|
+
height: 36px;
|
|
40
|
+
border: 1px solid var(--color-border-standard);
|
|
41
|
+
background: var(--color-bg-card);
|
|
42
|
+
color: var(--color-text-secondary);
|
|
43
|
+
border-radius: 50%;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition: all 0.15s ease;
|
|
46
|
+
box-shadow: var(--shadow-card-light);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.arrow:hover {
|
|
50
|
+
color: var(--color-text-primary);
|
|
51
|
+
background: var(--color-bg-elevated);
|
|
52
|
+
border-color: var(--color-border-medium);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.arrowLeft {
|
|
56
|
+
left: -18px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.arrowRight {
|
|
60
|
+
right: -18px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.arrowHidden {
|
|
64
|
+
opacity: 0;
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* ── Dots ── */
|
|
69
|
+
.dots {
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
gap: 8px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.dot {
|
|
77
|
+
width: 8px;
|
|
78
|
+
height: 8px;
|
|
79
|
+
border-radius: 50%;
|
|
80
|
+
background: var(--color-border-standard);
|
|
81
|
+
border: none;
|
|
82
|
+
padding: 0;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
transition: all 0.2s ease;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.dot:hover {
|
|
88
|
+
background: var(--color-text-tertiary);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.dotActive {
|
|
92
|
+
background: var(--color-lime);
|
|
93
|
+
width: 24px;
|
|
94
|
+
border-radius: 100px;
|
|
95
|
+
}
|