({
label,
description,
enabled,
onChange,
warning
}: {
label: string
description: string
enabled: boolean
onChange: (value: boolean) => void
warning?: string
})
| 2497 | } |
| 2498 | |
| 2499 | function ToggleSetting({ |
| 2500 | label, |
| 2501 | description, |
| 2502 | enabled, |
| 2503 | onChange, |
| 2504 | warning |
| 2505 | }: { |
| 2506 | label: string |
| 2507 | description: string |
| 2508 | enabled: boolean |
| 2509 | onChange: (value: boolean) => void |
| 2510 | warning?: string |
| 2511 | }) { |
| 2512 | return ( |
| 2513 | <div className="flex items-start justify-between gap-4 p-4 bg-theme-dim border border-theme-primary rounded-lg"> |
| 2514 | <div className="flex-1"> |
| 2515 | <h4 className="font-semibold">{label}</h4> |
| 2516 | <p className="text-sm theme-secondary">{description}</p> |
| 2517 | {warning && enabled && ( |
| 2518 | <p className="text-xs text-yellow-500 mt-1 flex items-center gap-1"> |
| 2519 | <AlertTriangle className="w-3 h-3" /> |
| 2520 | {warning} |
| 2521 | </p> |
| 2522 | )} |
| 2523 | </div> |
| 2524 | <button |
| 2525 | onClick={() => onChange(!enabled)} |
| 2526 | className={`w-12 h-6 rounded-full transition-colors relative flex-shrink-0 |
| 2527 | ${enabled ? 'bg-green-500' : 'bg-theme-accent'}`} |
| 2528 | > |
| 2529 | <span |
| 2530 | className={`absolute top-1 w-4 h-4 rounded-full bg-white transition-transform |
| 2531 | ${enabled ? 'left-7' : 'left-1'}`} |
| 2532 | /> |
| 2533 | </button> |
| 2534 | </div> |
| 2535 | ) |
| 2536 | } |
nothing calls this directly
no outgoing calls
no test coverage detected