/** * Component Template * * Usage: Copy this file to create new components * 1. Replace TEMPLATE_NAME with your component name * 2. Define the props interface * 3. Implement your component logic */ 'use client' import { useState } from 'react' import { cn } from '@/lib/utils' // Component props interface interface TemplateComponentProps { // Define your props here className?: string children?: React.ReactNode // Add other props as needed title?: string description?: string variant?: 'default' | 'secondary' | 'outline' size?: 'sm' | 'md' | 'lg' disabled?: boolean onClick?: () => void } /** * TEMPLATE_NAME Component * * @param props - Component properties * @returns JSX element */ export function TemplateComponent({ className, children, title, description, variant = 'default', size = 'md', disabled = false, onClick, ...props }: TemplateComponentProps) { // State management const [isLoading, setIsLoading] = useState(false) // Event handlers const handleClick = async () => { if (disabled || isLoading) return setIsLoading(true) try { await onClick?.() } finally { setIsLoading(false) } } // CSS class variations const variants = { default: 'bg-primary text-primary-foreground hover:bg-primary/90', secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80', outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground', } const sizes = { sm: 'h-8 px-3 text-sm', md: 'h-10 px-4 py-2', lg: 'h-12 px-8 text-lg', } return (
{/* Loading spinner */} {isLoading && ( )} {/* Content */}
{title &&

{title}

} {description &&

{description}

} {children}
) } /** * Alternative component patterns: * * 1. Server Component (remove 'use client' and useState) * 2. Compound Components: * * export function TemplateComponent({ children }: { children: React.ReactNode }) { * return
{children}
; * } * * TemplateComponent.Header = function Header({ children }: { children: React.ReactNode }) { * return
{children}
; * }; * * TemplateComponent.Body = function Body({ children }: { children: React.ReactNode }) { * return
{children}
; * }; * * 3. Forward Ref: * * export const TemplateComponent = forwardRef( * ({ className, ...props }, ref) => { * return
; * } * ); * TemplateComponent.displayName = "TemplateComponent"; */