Skip to content

Commit 87f40f8

Browse files
committed
improve usability of config
1 parent f0baf7c commit 87f40f8

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

app/components/ui/switch.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client"
2+
13
import * as React from "react"
24
import * as SwitchPrimitives from "@radix-ui/react-switch"
35

@@ -9,15 +11,15 @@ const Switch = React.forwardRef<
911
>(({ className, ...props }, ref) => (
1012
<SwitchPrimitives.Root
1113
className={cn(
12-
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
14+
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
1315
className
1416
)}
1517
{...props}
1618
ref={ref}
1719
>
1820
<SwitchPrimitives.Thumb
1921
className={cn(
20-
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
22+
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
2123
)}
2224
/>
2325
</SwitchPrimitives.Root>

app/routes/(authed)/config.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { AppNavbar } from "@/components/app-navbar";
3030
import { cn } from "@/lib/utils";
3131
import { ScrollArea } from "@/components/ui/scroll-area";
3232
import { Input } from "@/components/ui/input";
33+
import { Switch } from "@/components/ui/switch";
3334

3435
export const Route = createFileRoute("/(authed)/config")({
3536
component: ConfigComponent,
@@ -210,16 +211,23 @@ function ConfigComponent() {
210211
<button
211212
key={product.id}
212213
className={cn(
213-
"w-full px-6 py-4 flex items-center justify-between hover:bg-accent/5 transition-colors",
214-
isEnabled && "bg-accent/10"
214+
"w-full px-6 py-4 flex items-center justify-between hover:bg-secondary/50 transition-colors",
215+
isEnabled && "bg-secondary"
215216
)}
216217
onClick={() => toggleProduct(service.id, product.id)}
217218
>
218219
<div className="flex items-center gap-3">
219220
{getIconForProduct(service.id, product.id)}
220221
<span className="font-medium">{product.name}</span>
221222
</div>
222-
{isEnabled && <Check className="h-4 w-4 text-accent" />}
223+
<div className="flex items-center gap-2">
224+
<Switch
225+
checked={isEnabled}
226+
onCheckedChange={() => toggleProduct(service.id, product.id)}
227+
onClick={(e) => e.stopPropagation()}
228+
className="data-[state=checked]:bg-primary"
229+
/>
230+
</div>
223231
</button>
224232
);
225233
})}

0 commit comments

Comments
 (0)