-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathcommon.tsx
More file actions
146 lines (142 loc) · 3.71 KB
/
Copy pathcommon.tsx
File metadata and controls
146 lines (142 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React from "react";
import { AlertCircle } from "lucide-react";
import { cn } from "../../lib/utils";
export function SectionTitle({
title,
icon: Icon,
description,
}: {
title: string;
icon: React.ElementType;
description: string;
}) {
return (
<div className="space-y-1">
<div className="flex items-center gap-3 text-primary">
<Icon className="h-5 w-5" />
<h3 className="font-bold text-xl tracking-tight text-foreground">
{title}
</h3>
</div>
<p className="text-xs text-muted-foreground font-medium">{description}</p>
</div>
);
}
export function FormField({
label,
children,
error,
description,
}: {
label: string;
children: React.ReactNode;
error?: string;
description?: string;
}) {
return (
<div className="space-y-2">
<label className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
{label}
</label>
{children}
{error && (
<p className="text-[10px] font-bold text-rose-500 flex items-center gap-1">
<AlertCircle className="h-3 w-3" /> {error}
</p>
)}
{description && !error && (
<p className="text-[10px] text-muted-foreground/60 font-medium">
{description}
</p>
)}
</div>
);
}
export function SwitchField({
label,
description,
icon: Icon,
checked,
onChange,
}: {
label: string;
description: string;
icon: React.ElementType;
checked: boolean;
onChange: (val: boolean) => void;
}) {
return (
<div className="flex items-center justify-between p-5 rounded-2xl bg-accent/20 border border-transparent hover:border-border/40 transition-all group">
<div className="flex items-center gap-4">
<div className="w-10 h-10 rounded-xl bg-card border border-border/50 flex items-center justify-center text-muted-foreground group-hover:text-primary transition-colors">
<Icon className="h-5 w-5" />
</div>
<div className="space-y-0.5">
<p className="text-sm font-bold">{label}</p>
<p className="text-[10px] text-muted-foreground font-medium">
{description}
</p>
</div>
</div>
<button
type="button"
onClick={() => onChange(!checked)}
className={cn(
"w-12 h-6 rounded-full transition-all relative",
checked ? "bg-primary" : "bg-muted",
)}
>
<div
className={cn(
"absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-all shadow-sm",
checked ? "translate-x-6" : "translate-x-0",
)}
/>
</button>
</div>
);
}
export function ThemeCard({
label,
icon: Icon,
active,
onClick,
}: {
id: string;
label: string;
icon: React.ElementType;
active: boolean;
onClick: () => void;
}) {
return (
<button
type="button"
onClick={onClick}
className={cn(
"p-6 rounded-2xl border-2 flex flex-col items-center gap-4 transition-all duration-300",
active
? "border-primary bg-primary/5 shadow-2xl shadow-primary/10 scale-105"
: "border-border/40 hover:border-border hover:bg-accent/30",
)}
>
<div
className={cn(
"w-12 h-12 rounded-xl flex items-center justify-center transition-colors",
active
? "bg-primary text-primary-foreground shadow-lg shadow-primary/30"
: "bg-accent text-muted-foreground",
)}
>
<Icon className="h-6 w-6" />
</div>
<p
className={cn(
"text-xs font-bold uppercase tracking-widest",
active ? "text-primary" : "text-muted-foreground",
)}
>
{label}
</p>
</button>
);
}