Skip to content

Commit 968807a

Browse files
committed
Refactor UI components for consistent design system
Updated badge, progress, scroll-area, spinner, toggle-group, and toggle components to use a more unified and simplified design system. This includes standardizing border radii, spacing, color schemes, and removing complex or custom visual effects in favor of design token-based styling. The changes improve maintainability and visual consistency across the UI component library.
1 parent f7a3279 commit 968807a

File tree

6 files changed

+23
-78
lines changed

6 files changed

+23
-78
lines changed

packages/components/src/ui/badge.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ import { cva, type VariantProps } from "class-variance-authority"
55
import { cn } from "../lib/utils"
66

77
const badgeVariants = cva(
8-
"inline-flex items-center justify-center rounded-sm border px-2.5 py-0.5 text-[10px] font-mono font-bold uppercase tracking-widest w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1.5 [&>svg]:pointer-events-none focus-visible:border-cyan-500 focus-visible:ring-cyan-500/50 focus-visible:ring-[1px] transition-all duration-300 overflow-hidden backdrop-blur-sm select-none",
8+
"inline-flex items-center justify-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
99
{
1010
variants: {
1111
variant: {
1212
default:
13-
"border-cyan-500/50 bg-cyan-950/40 text-cyan-300 shadow-[0_0_10px_-4px_rgba(6,182,212,0.6)] [a&]:hover:bg-cyan-900/60 [a&]:hover:shadow-[0_0_15px_-2px_rgba(6,182,212,0.8)] [a&]:hover:border-cyan-400",
13+
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
1414
secondary:
15-
"border-slate-700 bg-slate-800/60 text-slate-300 shadow-sm [a&]:hover:bg-slate-700/80 [a&]:hover:text-slate-200",
15+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
1616
destructive:
17-
"border-red-500/40 bg-red-950/40 text-red-400 shadow-[0_0_10px_-4px_rgba(239,68,68,0.6)] [a&]:hover:bg-red-900/60 [a&]:hover:border-red-400 [a&]:hover:shadow-[0_0_15px_-2px_rgba(239,68,68,0.8)]",
18-
outline:
19-
"text-cyan-400 border-cyan-800 bg-transparent shadow-[inset_0_0_5px_rgba(6,182,212,0.1)] [a&]:hover:bg-cyan-950/30 [a&]:hover:border-cyan-500 [a&]:hover:text-cyan-200 [a&]:hover:shadow-[0_0_10px_-5px_cyan]",
17+
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
18+
outline: "text-foreground",
2019
},
2120
},
2221
defaultVariants: {

packages/components/src/ui/progress.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,16 @@ function Progress({
1212
<ProgressPrimitive.Root
1313
data-slot="progress"
1414
className={cn(
15-
"relative h-3 w-full overflow-hidden rounded-sm bg-slate-950/60 border border-slate-800/60 shadow-inner",
15+
"relative h-2 w-full overflow-hidden rounded-full bg-primary/20",
1616
className
1717
)}
1818
{...props}
1919
>
20-
{/* Background Grid Pattern for empty track */}
21-
<div className="absolute inset-0 bg-[linear-gradient(90deg,transparent_2px,rgba(6,182,212,0.1)_2px),linear-gradient(0deg,transparent_2px,rgba(6,182,212,0.1)_2px)] bg-[size:10px_10px] opacity-20" />
22-
2320
<ProgressPrimitive.Indicator
2421
data-slot="progress-indicator"
25-
className="h-full w-full flex-1 transition-all bg-cyan-500 relative shadow-[0_0_15px_cyan]"
22+
className="h-full w-full flex-1 bg-primary transition-all"
2623
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
27-
>
28-
{/* Pulse / Flow Effect Overlay */}
29-
<div className="absolute inset-0 bg-linear-to-r from-transparent via-white/30 to-transparent -translate-x-full animate-[shimmer_1.5s_infinite_linear]" />
30-
31-
{/* Leading Edge Hotspot */}
32-
<div className="absolute right-0 top-0 bottom-0 w-0.5 bg-white shadow-[0_0_10px_2px_white] z-10" />
33-
34-
{/* Scanlines on the bar */}
35-
<div className="absolute inset-0 bg-[linear-gradient(transparent_50%,rgba(0,0,0,0.2)_50%)] bg-[size:4px_4px]" />
36-
</ProgressPrimitive.Indicator>
24+
/>
3725
</ProgressPrimitive.Root>
3826
)
3927
}

packages/components/src/ui/scroll-area.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function ScrollBar({
4949
>
5050
<ScrollAreaPrimitive.ScrollAreaThumb
5151
data-slot="scroll-area-thumb"
52-
className="relative flex-1 rounded-full bg-cyan-900/40 hover:bg-cyan-500/60 transition-colors duration-300"
52+
className="relative flex-1 rounded-full bg-border"
5353
/>
5454
</ScrollAreaPrimitive.ScrollAreaScrollbar>
5555
)

packages/components/src/ui/spinner.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
11
import * as React from "react"
22
import { cn } from "../lib/utils"
3+
import { Loader2 } from "lucide-react"
34

45
function Spinner({ className, ...props }: React.ComponentProps<"div">) {
56
return (
67
<div
78
role="status"
89
aria-label="Loading"
9-
className={cn("relative flex items-center justify-center shrink-0", className)}
10+
className={cn("flex items-center justify-center", className)}
1011
{...props}
1112
>
12-
<div className="relative aspect-square h-full w-full min-w-[1em] min-h-[1em]">
13-
{/* Outer Atmosphere / Fire (Fast Spin) */}
14-
<div className="absolute inset-0 rounded-full border-[15%] border-transparent border-t-orange-500 border-r-red-600 animate-[spin_0.8s_linear_infinite] shadow-[0_0_15px_-4px_rgba(234,88,12,0.8)]"
15-
style={{ borderWidth: "2px" }}
16-
/>
17-
18-
{/* Turbulence Layer (Reverse Spin) */}
19-
<div className="absolute inset-[10%] rounded-full border-[15%] border-transparent border-b-yellow-400/80 border-l-orange-500/80 animate-[spin_1.5s_ease-in-out_infinite_reverse]"
20-
style={{ borderWidth: "2px" }}
21-
/>
22-
23-
{/* Core Planet (Internal) */}
24-
<div className="absolute inset-[25%] rounded-full overflow-hidden bg-slate-950 shadow-[inset_0_0_4px_rgba(0,0,0,0.8)]">
25-
{/* Molten Core Texture (Rotating) */}
26-
<div className="absolute top-[-50%] left-[-50%] w-[200%] h-[200%] animate-[spin_3s_linear_infinite]">
27-
<div className="w-full h-full bg-[conic-gradient(from_180deg,#1e293b_0deg,#0e7490_80deg,#7c3aed_160deg,#be123c_240deg,#ea580c_300deg,#1e293b_360deg)] opacity-90 blur-[1px]" />
28-
</div>
29-
30-
{/* Surface Reflection & Shadow (Spherical look) */}
31-
<div className="absolute inset-0 bg-[radial-gradient(circle_at_30%_30%,rgba(255,255,255,0.4)_0%,transparent_50%,rgba(0,0,0,0.9)_100%)] z-10" />
32-
</div>
33-
</div>
13+
<Loader2 className="animate-spin text-muted-foreground w-full h-full min-w-4 min-h-4" />
3414
</div>
3515
)
3616
}

packages/components/src/ui/toggle-group.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,32 @@ import { cn } from "../lib/utils"
66
import { toggleVariants } from "./toggle"
77

88
const ToggleGroupContext = React.createContext<
9-
VariantProps<typeof toggleVariants> & {
10-
spacing?: number
11-
}
9+
VariantProps<typeof toggleVariants>
1210
>({
1311
size: "default",
1412
variant: "default",
15-
spacing: 0,
1613
})
1714

1815
function ToggleGroup({
1916
className,
2017
variant,
2118
size,
22-
spacing = 0,
2319
children,
2420
...props
2521
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
26-
VariantProps<typeof toggleVariants> & {
27-
spacing?: number
28-
}) {
22+
VariantProps<typeof toggleVariants>) {
2923
return (
3024
<ToggleGroupPrimitive.Root
3125
data-slot="toggle-group"
3226
data-variant={variant}
3327
data-size={size}
34-
data-spacing={spacing}
35-
style={{ "--gap": spacing } as React.CSSProperties}
3628
className={cn(
37-
"group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md bg-slate-950/20 p-1 border border-slate-800/50 shadow-inner",
29+
"flex justify-center flex-row gap-1 items-center",
3830
className
3931
)}
4032
{...props}
4133
>
42-
<ToggleGroupContext.Provider value={{ variant, size, spacing }}>
34+
<ToggleGroupContext.Provider value={{ variant, size }}>
4335
{children}
4436
</ToggleGroupContext.Provider>
4537
</ToggleGroupPrimitive.Root>
@@ -61,20 +53,11 @@ function ToggleGroupItem({
6153
data-slot="toggle-group-item"
6254
data-variant={context.variant || variant}
6355
data-size={context.size || size}
64-
data-spacing={context.spacing}
6556
className={cn(
6657
toggleVariants({
6758
variant: context.variant || variant,
6859
size: context.size || size,
6960
}),
70-
"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10",
71-
// Force rounded-sm logic for group items when spacing is 0
72-
"data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-sm data-[spacing=0]:last:rounded-r-sm",
73-
// Handle borders for connected items
74-
"data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",
75-
// Add separating line for non-outline items if needed, or rely on gaps.
76-
// For Outline variant in Future Tech, we might want to keep them distinct or joined.
77-
// Current logic keeps them joined.
7861
className
7962
)}
8063
{...props}

packages/components/src/ui/toggle.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,18 @@ import { cva, type VariantProps } from "class-variance-authority"
55
import { cn } from "../lib/utils"
66

77
const toggleVariants = cva(
8-
"inline-flex items-center justify-center gap-2 rounded-sm text-sm font-medium transition-all duration-300 hover:text-cyan-400 focus-visible:ring-1 focus-visible:ring-cyan-400/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 outline-none aria-invalid:ring-destructive/20 aria-invalid:border-destructive whitespace-nowrap",
8+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0",
99
{
1010
variants: {
1111
variant: {
12-
default: [
13-
"bg-transparent hover:bg-cyan-950/20",
14-
"data-[state=on]:bg-cyan-950/40 data-[state=on]:text-cyan-300 data-[state=on]:border data-[state=on]:border-cyan-500/30 data-[state=on]:shadow-[0_0_12px_-3px_rgba(6,182,212,0.4)]",
15-
],
16-
outline: [
17-
"border border-cyan-900/60 bg-transparent shadow-xs hover:bg-cyan-950/30 hover:text-cyan-300 hover:border-cyan-500/50",
18-
"data-[state=on]:bg-cyan-600 data-[state=on]:text-white data-[state=on]:border-cyan-400 data-[state=on]:shadow-[0_0_15px_rgba(6,182,212,0.6)]",
19-
],
12+
default: "bg-transparent",
13+
outline:
14+
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
2015
},
2116
size: {
22-
default: "h-9 px-3 min-w-9",
23-
sm: "h-8 px-2 min-w-8 text-xs",
24-
lg: "h-10 px-3 min-w-10",
17+
default: "h-9 px-2 min-w-9",
18+
sm: "h-8 px-1.5 min-w-8",
19+
lg: "h-10 px-2.5 min-w-10",
2520
},
2621
},
2722
defaultVariants: {

0 commit comments

Comments
 (0)