"use client" import { useState } from "react" import { Switch } from "@/components/ui/switch" import { Label } from "@/components/ui/label" import { ComponentContainer } from "@/components/ui/component-container" import { SectionHeading } from "@/components/ui/section-heading" import { PageBreadcrumb } from "@/components/page-breadcrumb" export function SwitchSection() { const [basicToggle, setBasicToggle] = useState(false) const [labelToggle, setLabelToggle] = useState(true) const [formToggle, setFormToggle] = useState(false) // Properties for the interactive switch const [switchChecked, setSwitchChecked] = useState(false) const [labelText, setLabelText] = useState("Enable notifications") const [descriptionText, setDescriptionText] = useState("Receive notifications about new updates and features") const [switchDisabled, setSwitchDisabled] = useState(false) const generateCode = (props: Record) => { const { label, description, disabled } = props const disabledProp = disabled ? " disabled" : "" if (!description) { return `import { Switch } from "@/components/ui/switch" import { Label } from "@/components/ui/label" export function SwitchDemo() { return (
) }` } return `import { Switch } from "@/components/ui/switch" import { Label } from "@/components/ui/label" export function SwitchDemo() { return (
${description}
) }` } const renderInteractiveSwitch = (props: Record) => { const { label, description, disabled } = props if (!description) { return (
) } return (
{description}
) } const switchProperties = [ { name: "label", type: "text" as const, defaultValue: "Enable notifications", label: "Label", description: "Text for the label", }, { name: "description", type: "text" as const, defaultValue: "Receive notifications about new updates and features", label: "Description", description: "Description text under the label", }, { name: "disabled", type: "boolean" as const, defaultValue: false, label: "Disabled", description: "Whether the switch is disabled", }, ] return (
}`} >
) }`} >
Receive emails about new products, features, and more.
) }`} >
Receive emails about new products, features, and more.
}`} >
) }