"use client" import { Alert, AlertIcon, AlertContent, AlertTitle, AlertDescription, AlertActions, } from "@/components/ui/alert-compound" import { Button } from "@/components/ui/button" import { SectionHeading } from "@/components/ui/section-heading" import { ComponentContainer } from "@/components/ui/component-container" import { Info, AlertCircle, AlertTriangle, CheckCircle } from "lucide-react" import { commonProperties, getIconByName, getActualValue } from "@/utils/component-properties" export function AlertsSection() { // Define alert properties const alertProperties = [ { name: "variant", type: "select", options: ["Default", "Destructive", "Warning", "Success", "Info"], defaultValue: "default", label: "Variant", description: "The visual style of the alert", }, { name: "title", type: "text", defaultValue: "Alert Title", label: "Title", description: "The title of the alert", }, { name: "description", type: "textarea", defaultValue: "This is an alert message with additional information.", label: "Description", description: "The description text for the alert", }, commonProperties.icon, { name: "withActions", type: "boolean", defaultValue: false, label: "Include Actions", description: "Whether to include action buttons", }, ] // Map variant to icon if not specified const getDefaultIcon = (variant: string) => { const actualVariant = getActualValue(variant) switch (actualVariant) { case "destructive": return "AlertCircle" case "warning": return "AlertTriangle" case "success": return "CheckCircle" case "info": return "Info" default: return "Info" } } // Render alert based on properties const renderAlert = (props: Record) => { const actualVariant = getActualValue(props.variant) const actualIcon = getActualValue(props.icon) const iconName = actualIcon === "none" ? getDefaultIcon(props.variant) : props.icon const icon = getIconByName(iconName) return ( {props.title} {props.description} {props.withActions && ( )} ) } // Generate alert code const generateAlertCode = (props: Record) => { const actualVariant = getActualValue(props.variant) const actualIcon = getActualValue(props.icon) const iconName = actualIcon === "none" ? getDefaultIcon(props.variant) : props.icon let code = `import {\n Alert,\n AlertIcon,\n AlertContent,\n AlertTitle,\n AlertDescription` if (props.withActions) { code += `,\n AlertActions` } code += `\n} from "@/components/ui/alert-compound"\n` code += `import { ${iconName} } from "lucide-react"\n` if (props.withActions) { code += `import { Button } from "@/components/ui/button"\n` } code += `\n\n` code += ` } />\n` code += ` \n` code += ` ${props.title}\n` code += ` ${props.description}\n` if (props.withActions) { code += ` \n` code += ` \n` code += ` \n` code += ` \n` } code += ` \n` code += `` return code } return (
} /> Alert Title This is an alert message with additional information. } /> Heads up! You can add components to your app using the CLI. `} > } /> Heads up! You can add components to your app using the CLI. } /> Information This action will update your current settings. `} > } /> Information This action will update your current settings. } /> Error Your session has expired. Please log in again. `} > } /> Error Your session has expired. Please log in again. } /> Warning Your storage is almost full. Please free up some space. `} > } /> Warning Your storage is almost full. Please free up some space. } /> Success Your changes have been successfully saved. `} > } /> Success Your changes have been successfully saved. } /> Information A new software update is available. `} > } /> Information A new software update is available. } /> Warning Your account is about to expire. `} > } /> Warning Your account is about to expire. } /> This is a very long alert title that will wrap to multiple lines to demonstrate that the alert height is determined by its content The icon should remain vertically centered with the first line of the title, and the alert should expand to fit all content. `} > } /> This is a very long alert title that will wrap to multiple lines to demonstrate that the alert height is determined by its content The icon should remain vertically centered with the first line of the title, and the alert should expand to fit all content.

Usage

            {`import {
  Alert,
  AlertIcon,
  AlertContent,
  AlertTitle,
  AlertDescription,
  AlertActions,
} from "@/components/ui/alert-compound"`}
          
) }