diff --git a/src/lib/component-code-snippets.ts b/src/lib/component-code-snippets.ts index 4fcb03b..b7bccd5 100644 --- a/src/lib/component-code-snippets.ts +++ b/src/lib/component-code-snippets.ts @@ -1,1006 +1,9 @@ -export const atomsCodeSnippets = { - buttonDefault: `interface ButtonProps { - children?: string - onClick?: () => void -} +/** + * Component code snippets - Main re-export module + * This file maintains backward compatibility while delegating to specialized modules + */ -function DefaultButton({ children = "Default", onClick }: ButtonProps) { - return -}`, - buttonSecondary: `interface ButtonProps { - children?: string - variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" - onClick?: () => void -} - -function CustomButton({ children = "Secondary", variant = "secondary", onClick }: ButtonProps) { - return -}`, - buttonDestructive: `interface DestructiveButtonProps { - children?: string - onClick?: () => void -} - -function DestructiveButton({ children = "Destructive", onClick }: DestructiveButtonProps) { - return -}`, - buttonOutline: `interface OutlineButtonProps { - children?: string - onClick?: () => void -} - -function OutlineButton({ children = "Outline", onClick }: OutlineButtonProps) { - return -}`, - buttonGhost: `interface GhostButtonProps { - children?: string - onClick?: () => void -} - -function GhostButton({ children = "Ghost", onClick }: GhostButtonProps) { - return -}`, - buttonLink: `interface LinkButtonProps { - children?: string - onClick?: () => void -} - -function LinkButton({ children = "Link", onClick }: LinkButtonProps) { - return -}`, - buttonSizes: `interface ButtonSizesProps { - smallText?: string - defaultText?: string - largeText?: string - onSmallClick?: () => void - onDefaultClick?: () => void - onLargeClick?: () => void - onIconClick?: () => void -} - -function ButtonSizes({ - smallText = "Small", - defaultText = "Default", - largeText = "Large", - onSmallClick, - onDefaultClick, - onLargeClick, - onIconClick -}: ButtonSizesProps) { - return ( - <> - - - - - - ) -}`, - buttonWithIcons: `interface IconButtonProps { - primaryText?: string - secondaryText?: string - onPrimaryClick?: () => void - onSecondaryClick?: () => void -} - -function IconButtons({ - primaryText = "Favorite", - secondaryText = "Add Item", - onPrimaryClick, - onSecondaryClick -}: IconButtonProps) { - return ( - <> - - - - ) -}`, - badgeVariants: `interface BadgeVariantsProps { - defaultText?: string - secondaryText?: string - destructiveText?: string - outlineText?: string -} - -function BadgeVariants({ - defaultText = "Default", - secondaryText = "Secondary", - destructiveText = "Destructive", - outlineText = "Outline" -}: BadgeVariantsProps) { - return ( - <> - {defaultText} - {secondaryText} - {destructiveText} - {outlineText} - - ) -}`, - badgeWithIcons: `interface IconBadgeProps { - completedText?: string - failedText?: string -} - -function IconBadges({ - completedText = "Completed", - failedText = "Failed" -}: IconBadgeProps) { - return ( - <> - - - {completedText} - - - - {failedText} - - - ) -}`, - inputBasic: `interface InputProps { - placeholder?: string - value?: string - onChange?: (e: React.ChangeEvent) => void -} - -function BasicInput({ placeholder = "Default input", value, onChange }: InputProps) { - return -}`, - inputWithIcon: `interface SearchInputProps { - placeholder?: string - value?: string - onChange?: (e: React.ChangeEvent) => void -} - -function SearchInput({ placeholder = "Search...", value, onChange }: SearchInputProps) { - return ( -
- - -
- ) -}`, - inputTypes: `interface TypedInputsProps { - textPlaceholder?: string - emailPlaceholder?: string - passwordPlaceholder?: string - numberPlaceholder?: string - onTextChange?: (e: React.ChangeEvent) => void - onEmailChange?: (e: React.ChangeEvent) => void - onPasswordChange?: (e: React.ChangeEvent) => void - onNumberChange?: (e: React.ChangeEvent) => void -} - -function TypedInputs({ - textPlaceholder = "Text input", - emailPlaceholder = "email@example.com", - passwordPlaceholder = "Password", - numberPlaceholder = "123", - onTextChange, - onEmailChange, - onPasswordChange, - onNumberChange -}: TypedInputsProps) { - return ( - <> - - - - - - ) -}`, -} - -export const moleculesCodeSnippets = { - formField: `interface FormFieldProps { - label?: string - placeholder?: string - helperText?: string - id?: string - value?: string - onChange?: (e: React.ChangeEvent) => void -} - -function EmailFormField({ - label = "Email Address", - placeholder = "john@example.com", - helperText = "We'll never share your email with anyone else.", - id = "email", - value, - onChange -}: FormFieldProps) { - return ( -
- -
- - -
-

- {helperText} -

-
- ) -}`, - searchBar: `interface SearchBarProps { - placeholder?: string - value?: string - onChange?: (e: React.ChangeEvent) => void -} - -function SearchBar({ placeholder = "Search...", value, onChange }: SearchBarProps) { - return ( -
- - -
- ) -}`, - searchBarWithButton: `interface SearchBarWithButtonProps { - placeholder?: string - buttonText?: string - value?: string - onChange?: (e: React.ChangeEvent) => void - onSearch?: () => void -} - -function SearchBarWithButton({ - placeholder = "Search...", - buttonText = "Search", - value, - onChange, - onSearch -}: SearchBarWithButtonProps) { - return ( -
-
- - -
- -
- ) -}`, - userCard: `interface UserCardProps { - name?: string - username?: string - bio?: string - avatarUrl?: string - avatarFallback?: string - buttonText?: string - onButtonClick?: () => void -} - -function UserCard({ - name = "Alex Morgan", - username = "@alexmorgan", - bio = "Product designer passionate about creating delightful user experiences.", - avatarUrl = "https://i.pravatar.cc/150?img=1", - avatarFallback = "AM", - buttonText = "Follow", - onButtonClick -}: UserCardProps) { - return ( - -
- - - {avatarFallback} - -
-

{name}

-

{username}

-

- {bio} -

-
- -
-
- ) -}`, - socialActions: `interface SocialActionsProps { - likeText?: string - commentText?: string - shareText?: string - onLike?: () => void - onComment?: () => void - onShare?: () => void -} - -function SocialActions({ - likeText = "Like", - commentText = "Comment", - shareText = "Share", - onLike, - onComment, - onShare -}: SocialActionsProps) { - return ( -
- - - -
- ) -}`, - statusIndicator: `interface StatusIndicatorProps { - statusText?: string - badgeText?: string - isActive?: boolean -} - -function StatusIndicator({ - statusText = "System Online", - badgeText = "Active", - isActive = true -}: StatusIndicatorProps) { - return ( -
-
-
- {statusText} -
- {badgeText} -
- ) -}`, - contentCard: `interface ContentCardProps { - title?: string - description?: string - date?: string - readTime?: string - tags?: string[] -} - -function ContentCard({ - title = "Building Scalable Design Systems", - description = "Learn how to create and maintain design systems that grow with your team.", - date = "Mar 15, 2024", - readTime = "5 min read", - tags = ["Design", "System"] -}: ContentCardProps) { - return ( - -
-
-
-

- {title} -

-

- {description} -

-
-
-
-
- - {date} -
- - {readTime} -
-
- {tags.map((tag) => ( - {tag} - ))} -
-
-
- ) -}`, -} - -export const organismsCodeSnippets = { - navigationBar: `interface NavigationBarProps { - brandName?: string - navItems?: Array<{ label: string; icon: React.ReactNode; onClick?: () => void }> - avatarUrl?: string - avatarFallback?: string - onNotificationClick?: () => void - onSettingsClick?: () => void -} - -function NavigationBar({ - brandName = "BrandName", - navItems = [ - { label: "Home", icon: }, - { label: "Analytics", icon: }, - { label: "Projects", icon: } - ], - avatarUrl = "https://i.pravatar.cc/150?img=3", - avatarFallback = "U", - onNotificationClick, - onSettingsClick -}: NavigationBarProps) { - return ( -
-
-
-

{brandName}

- -
-
- - - - - {avatarFallback} - -
-
-
- ) -}`, - dataTable: `interface Transaction { - id: string - status: string - statusVariant?: "default" | "secondary" | "destructive" | "outline" - description: string - date: string - amount: string - isNegative?: boolean -} - -interface DataTableProps { - title?: string - exportButtonText?: string - transactions?: Transaction[] - onExport?: () => void -} - -function DataTable({ - title = "Recent Transactions", - exportButtonText = "Export", - transactions = [ - { id: "1", status: "Completed", description: "Payment received", date: "Mar 15, 2024", amount: "$250.00" } - ], - onExport -}: DataTableProps) { - return ( - -
-
-

{title}

- -
-
- - - - Status - Transaction - Date - Amount - - - - {transactions.map((transaction) => ( - - - {transaction.status} - - {transaction.description} - {transaction.date} - {transaction.amount} - - ))} - -
-
- ) -}`, - form: `interface CreateAccountFormProps { - title?: string - description?: string - firstNameLabel?: string - lastNameLabel?: string - emailLabel?: string - firstNamePlaceholder?: string - lastNamePlaceholder?: string - emailPlaceholder?: string - cancelButtonText?: string - submitButtonText?: string - onCancel?: () => void - onSubmit?: (data: { firstName: string; lastName: string; email: string }) => void -} - -function CreateAccountForm({ - title = "Create Account", - description = "Fill in your details to get started", - firstNameLabel = "First Name", - lastNameLabel = "Last Name", - emailLabel = "Email", - firstNamePlaceholder = "John", - lastNamePlaceholder = "Doe", - emailPlaceholder = "john@example.com", - cancelButtonText = "Cancel", - submitButtonText = "Create Account", - onCancel, - onSubmit -}: CreateAccountFormProps) { - const [firstName, setFirstName] = useState("") - const [lastName, setLastName] = useState("") - const [email, setEmail] = useState("") - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault() - onSubmit?.({ firstName, lastName, email }) - } - - return ( - -
-
-

{title}

-

- {description} -

-
- -
-
- - setFirstName(e.target.value)} - /> -
-
- - setLastName(e.target.value)} - /> -
-
-
- -
- - setEmail(e.target.value)} - /> -
-
- -
- - -
- -
- ) -}`, - taskList: `interface Task { - id: string - title: string - description: string - status: string - statusColor?: "accent" | "destructive" - badgeText: string - badgeVariant?: "default" | "secondary" | "destructive" | "outline" - icon: React.ReactNode -} - -interface TaskListProps { - title?: string - addButtonText?: string - tasks?: Task[] - onAddTask?: () => void -} - -function TaskList({ - title = "Project Tasks", - addButtonText = "Add Task", - tasks = [ - { - id: "1", - title: "Design system documentation", - description: "Complete the component library documentation", - status: "Completed", - statusColor: "accent" as const, - badgeText: "Design", - badgeVariant: "secondary" as const, - icon: - } - ], - onAddTask -}: TaskListProps) { - return ( - -
-
-

{title}

- -
-
-
- {tasks.map((task) => ( -
-
- {task.icon} -
-

{task.title}

-

- {task.description} -

-
- {task.badgeText} - {task.status} -
-
-
-
- ))} -
-
- ) -}`, - sidebarNavigation: `interface SidebarNavItem { - label: string - icon: React.ReactNode - variant?: "default" | "ghost" - onClick?: () => void -} - -interface SidebarNavigationProps { - title?: string - navItems?: SidebarNavItem[] - contentText?: string -} - -function SidebarNavigation({ - title = "Dashboard", - navItems = [ - { label: "Home", icon: , variant: "ghost" as const }, - { label: "Analytics", icon: , variant: "default" as const }, - { label: "Projects", icon: , variant: "ghost" as const } - ], - contentText = "Main content area" -}: SidebarNavigationProps) { - return ( -
- -
-

- {contentText} -

-
-
- ) -}`, -} - -export const templatesCodeSnippets = { - dashboardLayout: `interface StatCard { - label: string - value: string - trend?: string -} - -interface DashboardLayoutProps { - title?: string - navItems?: Array<{ label: string; icon: React.ReactNode; variant?: "default" | "ghost" }> - avatarUrl?: string - avatarFallback?: string - stats?: StatCard[] - onNotificationClick?: () => void -} - -function DashboardLayout({ - title = "Dashboard", - navItems = [ - { label: "Overview", icon: , variant: "default" as const }, - { label: "Analytics", icon: , variant: "ghost" as const } - ], - avatarUrl, - avatarFallback = "U", - stats = [ - { label: "Total Revenue", value: "$45,231", trend: "+20.1% from last month" } - ], - onNotificationClick -}: DashboardLayoutProps) { - return ( -
-
-
-

{title}

-
- - - {avatarUrl && } - {avatarFallback} - -
-
-
-
- -
-

Overview

-
- {stats.map((stat) => ( - -

{stat.label}

-

{stat.value}

- {stat.trend && ( -

{stat.trend}

- )} -
- ))} -
-
-
-
- ) -}`, - landingPage: `interface LandingPageProps { - brandName?: string - navItems?: string[] - badge?: string - headline?: string - description?: string - primaryCta?: string - secondaryCta?: string - onPrimaryCta?: () => void - onSecondaryCta?: () => void -} - -function LandingPage({ - brandName = "ProductName", - navItems = ["Features", "Sign Up"], - badge = "New Release", - headline = "Build Amazing Products Faster", - description = "The complete toolkit for modern product development.", - primaryCta = "Get Started", - secondaryCta, - onPrimaryCta, - onSecondaryCta -}: LandingPageProps) { - return ( -
-
-
-
-
-

{brandName}

-
-
- {navItems.map((item) => ( - - ))} -
-
-
-
- {badge} -

- {headline} -

-

- {description} -

-
- - {secondaryCta && ( - - )} -
-
-
- ) -}`, - ecommercePage: `interface EcommercePageProps { - storeName?: string - productBadge?: string - productName?: string - productPrice?: string - originalPrice?: string - onAddToCart?: () => void -} - -function EcommercePage({ - storeName = "Store", - productBadge = "New Arrival", - productName = "Premium Product", - productPrice = "$299.00", - originalPrice, - onAddToCart -}: EcommercePageProps) { - return ( -
-
-
-

{storeName}

- -
-
-
-
-
-
- {productBadge} -

{productName}

-
- {productPrice} - {originalPrice && ( - - {originalPrice} - - )} -
- -
-
-
-
- ) -}`, - blogArticle: `interface BlogArticleProps { - blogName?: string - tags?: string[] - title?: string - authorName?: string - authorAvatar?: string - authorFallback?: string - date?: string - readTime?: string - excerpt?: string -} - -function BlogArticle({ - blogName = "Blog", - tags = ["Design", "Tutorial"], - title = "Building a Comprehensive Component Library", - authorName = "Alex Writer", - authorAvatar, - authorFallback = "AW", - date = "March 15, 2024", - readTime = "10 min read", - excerpt = "Design systems have become an essential part of modern product development." -}: BlogArticleProps) { - return ( -
-
-

{blogName}

-
-
-
-
- {tags.map((tag, idx) => ( - - {tag} - - ))} -
-

- {title} -

-
- - {authorAvatar && } - {authorFallback} - -
-

{authorName}

-

- {date} · {readTime} -

-
-
-
-

- {excerpt} -

-
-
-
- ) -}`, -} +export { atomsCodeSnippets } from './snippets/atoms' +export { moleculesCodeSnippets } from './snippets/molecules' +export { organismsCodeSnippets } from './snippets/organisms' +export { templatesCodeSnippets } from './snippets/templates' diff --git a/src/lib/snippets/atoms.ts b/src/lib/snippets/atoms.ts new file mode 100644 index 0000000..3d33b94 --- /dev/null +++ b/src/lib/snippets/atoms.ts @@ -0,0 +1,209 @@ +/** + * Atoms - Basic UI building blocks code snippets + */ + +export const atomsCodeSnippets = { + buttonDefault: `interface ButtonProps { + children?: string + onClick?: () => void +} + +function DefaultButton({ children = "Default", onClick }: ButtonProps) { + return +}`, + buttonSecondary: `interface ButtonProps { + children?: string + variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" + onClick?: () => void +} + +function CustomButton({ children = "Secondary", variant = "secondary", onClick }: ButtonProps) { + return +}`, + buttonDestructive: `interface DestructiveButtonProps { + children?: string + onClick?: () => void +} + +function DestructiveButton({ children = "Destructive", onClick }: DestructiveButtonProps) { + return +}`, + buttonOutline: `interface OutlineButtonProps { + children?: string + onClick?: () => void +} + +function OutlineButton({ children = "Outline", onClick }: OutlineButtonProps) { + return +}`, + buttonGhost: `interface GhostButtonProps { + children?: string + onClick?: () => void +} + +function GhostButton({ children = "Ghost", onClick }: GhostButtonProps) { + return +}`, + buttonLink: `interface LinkButtonProps { + children?: string + onClick?: () => void +} + +function LinkButton({ children = "Link", onClick }: LinkButtonProps) { + return +}`, + buttonSizes: `interface ButtonSizesProps { + smallText?: string + defaultText?: string + largeText?: string + onSmallClick?: () => void + onDefaultClick?: () => void + onLargeClick?: () => void + onIconClick?: () => void +} + +function ButtonSizes({ + smallText = "Small", + defaultText = "Default", + largeText = "Large", + onSmallClick, + onDefaultClick, + onLargeClick, + onIconClick +}: ButtonSizesProps) { + return ( + <> + + + + + + ) +}`, + buttonWithIcons: `interface IconButtonProps { + primaryText?: string + secondaryText?: string + onPrimaryClick?: () => void + onSecondaryClick?: () => void +} + +function IconButtons({ + primaryText = "Favorite", + secondaryText = "Add Item", + onPrimaryClick, + onSecondaryClick +}: IconButtonProps) { + return ( + <> + + + + ) +}`, + badgeVariants: `interface BadgeVariantsProps { + defaultText?: string + secondaryText?: string + destructiveText?: string + outlineText?: string +} + +function BadgeVariants({ + defaultText = "Default", + secondaryText = "Secondary", + destructiveText = "Destructive", + outlineText = "Outline" +}: BadgeVariantsProps) { + return ( + <> + {defaultText} + {secondaryText} + {destructiveText} + {outlineText} + + ) +}`, + badgeWithIcons: `interface IconBadgeProps { + completedText?: string + failedText?: string +} + +function IconBadges({ + completedText = "Completed", + failedText = "Failed" +}: IconBadgeProps) { + return ( + <> + + + {completedText} + + + + {failedText} + + + ) +}`, + inputBasic: `interface InputProps { + placeholder?: string + value?: string + onChange?: (e: React.ChangeEvent) => void +} + +function BasicInput({ placeholder = "Default input", value, onChange }: InputProps) { + return +}`, + inputWithIcon: `interface SearchInputProps { + placeholder?: string + value?: string + onChange?: (e: React.ChangeEvent) => void +} + +function SearchInput({ placeholder = "Search...", value, onChange }: SearchInputProps) { + return ( +
+ + +
+ ) +}`, + inputTypes: `interface TypedInputsProps { + textPlaceholder?: string + emailPlaceholder?: string + passwordPlaceholder?: string + numberPlaceholder?: string + onTextChange?: (e: React.ChangeEvent) => void + onEmailChange?: (e: React.ChangeEvent) => void + onPasswordChange?: (e: React.ChangeEvent) => void + onNumberChange?: (e: React.ChangeEvent) => void +} + +function TypedInputs({ + textPlaceholder = "Text input", + emailPlaceholder = "email@example.com", + passwordPlaceholder = "Password", + numberPlaceholder = "123", + onTextChange, + onEmailChange, + onPasswordChange, + onNumberChange +}: TypedInputsProps) { + return ( + <> + + + + + + ) +}`, +} + diff --git a/src/lib/snippets/index.ts b/src/lib/snippets/index.ts new file mode 100644 index 0000000..e29e75f --- /dev/null +++ b/src/lib/snippets/index.ts @@ -0,0 +1,8 @@ +/** + * Component code snippets - Re-exports from focused modules + */ + +export { atomsCodeSnippets } from './atoms' +export { moleculesCodeSnippets } from './molecules' +export { organismsCodeSnippets } from './organisms' +export { templatesCodeSnippets } from './templates' diff --git a/src/lib/snippets/molecules.ts b/src/lib/snippets/molecules.ts new file mode 100644 index 0000000..d01b800 --- /dev/null +++ b/src/lib/snippets/molecules.ts @@ -0,0 +1,219 @@ +/** + * Molecules - Composite UI components code snippets + */ + +export const moleculesCodeSnippets = { + formField: `interface FormFieldProps { + label?: string + placeholder?: string + helperText?: string + id?: string + value?: string + onChange?: (e: React.ChangeEvent) => void +} + +function EmailFormField({ + label = "Email Address", + placeholder = "john@example.com", + helperText = "We'll never share your email with anyone else.", + id = "email", + value, + onChange +}: FormFieldProps) { + return ( +
+ +
+ + +
+

+ {helperText} +

+
+ ) +}`, + searchBar: `interface SearchBarProps { + placeholder?: string + value?: string + onChange?: (e: React.ChangeEvent) => void +} + +function SearchBar({ placeholder = "Search...", value, onChange }: SearchBarProps) { + return ( +
+ + +
+ ) +}`, + searchBarWithButton: `interface SearchBarWithButtonProps { + placeholder?: string + buttonText?: string + value?: string + onChange?: (e: React.ChangeEvent) => void + onSearch?: () => void +} + +function SearchBarWithButton({ + placeholder = "Search...", + buttonText = "Search", + value, + onChange, + onSearch +}: SearchBarWithButtonProps) { + return ( +
+
+ + +
+ +
+ ) +}`, + userCard: `interface UserCardProps { + name?: string + username?: string + bio?: string + avatarUrl?: string + avatarFallback?: string + buttonText?: string + onButtonClick?: () => void +} + +function UserCard({ + name = "Alex Morgan", + username = "@alexmorgan", + bio = "Product designer passionate about creating delightful user experiences.", + avatarUrl = "https://i.pravatar.cc/150?img=1", + avatarFallback = "AM", + buttonText = "Follow", + onButtonClick +}: UserCardProps) { + return ( + +
+ + + {avatarFallback} + +
+

{name}

+

{username}

+

+ {bio} +

+
+ +
+
+ ) +}`, + socialActions: `interface SocialActionsProps { + likeText?: string + commentText?: string + shareText?: string + onLike?: () => void + onComment?: () => void + onShare?: () => void +} + +function SocialActions({ + likeText = "Like", + commentText = "Comment", + shareText = "Share", + onLike, + onComment, + onShare +}: SocialActionsProps) { + return ( +
+ + + +
+ ) +}`, + statusIndicator: `interface StatusIndicatorProps { + statusText?: string + badgeText?: string + isActive?: boolean +} + +function StatusIndicator({ + statusText = "System Online", + badgeText = "Active", + isActive = true +}: StatusIndicatorProps) { + return ( +
+
+
+ {statusText} +
+ {badgeText} +
+ ) +}`, + contentCard: `interface ContentCardProps { + title?: string + description?: string + date?: string + readTime?: string + tags?: string[] +} + +function ContentCard({ + title = "Building Scalable Design Systems", + description = "Learn how to create and maintain design systems that grow with your team.", + date = "Mar 15, 2024", + readTime = "5 min read", + tags = ["Design", "System"] +}: ContentCardProps) { + return ( + +
+
+
+

+ {title} +

+

+ {description} +

+
+
+
+
+ + {date} +
+ + {readTime} +
+
+ {tags.map((tag) => ( + {tag} + ))} +
+
+
+ ) +}`, +} + diff --git a/src/lib/snippets/organisms.ts b/src/lib/snippets/organisms.ts new file mode 100644 index 0000000..49af3e4 --- /dev/null +++ b/src/lib/snippets/organisms.ts @@ -0,0 +1,338 @@ +/** + * Organisms - Complex UI patterns code snippets + */ + +export const organismsCodeSnippets = { + navigationBar: `interface NavigationBarProps { + brandName?: string + navItems?: Array<{ label: string; icon: React.ReactNode; onClick?: () => void }> + avatarUrl?: string + avatarFallback?: string + onNotificationClick?: () => void + onSettingsClick?: () => void +} + +function NavigationBar({ + brandName = "BrandName", + navItems = [ + { label: "Home", icon: }, + { label: "Analytics", icon: }, + { label: "Projects", icon: } + ], + avatarUrl = "https://i.pravatar.cc/150?img=3", + avatarFallback = "U", + onNotificationClick, + onSettingsClick +}: NavigationBarProps) { + return ( +
+
+
+

{brandName}

+ +
+
+ + + + + {avatarFallback} + +
+
+
+ ) +}`, + dataTable: `interface Transaction { + id: string + status: string + statusVariant?: "default" | "secondary" | "destructive" | "outline" + description: string + date: string + amount: string + isNegative?: boolean +} + +interface DataTableProps { + title?: string + exportButtonText?: string + transactions?: Transaction[] + onExport?: () => void +} + +function DataTable({ + title = "Recent Transactions", + exportButtonText = "Export", + transactions = [ + { id: "1", status: "Completed", description: "Payment received", date: "Mar 15, 2024", amount: "$250.00" } + ], + onExport +}: DataTableProps) { + return ( + +
+
+

{title}

+ +
+
+ + + + Status + Transaction + Date + Amount + + + + {transactions.map((transaction) => ( + + + {transaction.status} + + {transaction.description} + {transaction.date} + {transaction.amount} + + ))} + +
+
+ ) +}`, + form: `interface CreateAccountFormProps { + title?: string + description?: string + firstNameLabel?: string + lastNameLabel?: string + emailLabel?: string + firstNamePlaceholder?: string + lastNamePlaceholder?: string + emailPlaceholder?: string + cancelButtonText?: string + submitButtonText?: string + onCancel?: () => void + onSubmit?: (data: { firstName: string; lastName: string; email: string }) => void +} + +function CreateAccountForm({ + title = "Create Account", + description = "Fill in your details to get started", + firstNameLabel = "First Name", + lastNameLabel = "Last Name", + emailLabel = "Email", + firstNamePlaceholder = "John", + lastNamePlaceholder = "Doe", + emailPlaceholder = "john@example.com", + cancelButtonText = "Cancel", + submitButtonText = "Create Account", + onCancel, + onSubmit +}: CreateAccountFormProps) { + const [firstName, setFirstName] = useState("") + const [lastName, setLastName] = useState("") + const [email, setEmail] = useState("") + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + onSubmit?.({ firstName, lastName, email }) + } + + return ( + +
+
+

{title}

+

+ {description} +

+
+ +
+
+ + setFirstName(e.target.value)} + /> +
+
+ + setLastName(e.target.value)} + /> +
+
+
+ +
+ + setEmail(e.target.value)} + /> +
+
+ +
+ + +
+ +
+ ) +}`, + taskList: `interface Task { + id: string + title: string + description: string + status: string + statusColor?: "accent" | "destructive" + badgeText: string + badgeVariant?: "default" | "secondary" | "destructive" | "outline" + icon: React.ReactNode +} + +interface TaskListProps { + title?: string + addButtonText?: string + tasks?: Task[] + onAddTask?: () => void +} + +function TaskList({ + title = "Project Tasks", + addButtonText = "Add Task", + tasks = [ + { + id: "1", + title: "Design system documentation", + description: "Complete the component library documentation", + status: "Completed", + statusColor: "accent" as const, + badgeText: "Design", + badgeVariant: "secondary" as const, + icon: + } + ], + onAddTask +}: TaskListProps) { + return ( + +
+
+

{title}

+ +
+
+
+ {tasks.map((task) => ( +
+
+ {task.icon} +
+

{task.title}

+

+ {task.description} +

+
+ {task.badgeText} + {task.status} +
+
+
+
+ ))} +
+
+ ) +}`, + sidebarNavigation: `interface SidebarNavItem { + label: string + icon: React.ReactNode + variant?: "default" | "ghost" + onClick?: () => void +} + +interface SidebarNavigationProps { + title?: string + navItems?: SidebarNavItem[] + contentText?: string +} + +function SidebarNavigation({ + title = "Dashboard", + navItems = [ + { label: "Home", icon: , variant: "ghost" as const }, + { label: "Analytics", icon: , variant: "default" as const }, + { label: "Projects", icon: , variant: "ghost" as const } + ], + contentText = "Main content area" +}: SidebarNavigationProps) { + return ( +
+ +
+

+ {contentText} +

+
+
+ ) +}`, +} + diff --git a/src/lib/snippets/templates.ts b/src/lib/snippets/templates.ts new file mode 100644 index 0000000..76ee6ea --- /dev/null +++ b/src/lib/snippets/templates.ts @@ -0,0 +1,256 @@ +/** + * Templates - Complete page layouts code snippets + */ + +export const templatesCodeSnippets = { + dashboardLayout: `interface StatCard { + label: string + value: string + trend?: string +} + +interface DashboardLayoutProps { + title?: string + navItems?: Array<{ label: string; icon: React.ReactNode; variant?: "default" | "ghost" }> + avatarUrl?: string + avatarFallback?: string + stats?: StatCard[] + onNotificationClick?: () => void +} + +function DashboardLayout({ + title = "Dashboard", + navItems = [ + { label: "Overview", icon: , variant: "default" as const }, + { label: "Analytics", icon: , variant: "ghost" as const } + ], + avatarUrl, + avatarFallback = "U", + stats = [ + { label: "Total Revenue", value: "$45,231", trend: "+20.1% from last month" } + ], + onNotificationClick +}: DashboardLayoutProps) { + return ( +
+
+
+

{title}

+
+ + + {avatarUrl && } + {avatarFallback} + +
+
+
+
+ +
+

Overview

+
+ {stats.map((stat) => ( + +

{stat.label}

+

{stat.value}

+ {stat.trend && ( +

{stat.trend}

+ )} +
+ ))} +
+
+
+
+ ) +}`, + landingPage: `interface LandingPageProps { + brandName?: string + navItems?: string[] + badge?: string + headline?: string + description?: string + primaryCta?: string + secondaryCta?: string + onPrimaryCta?: () => void + onSecondaryCta?: () => void +} + +function LandingPage({ + brandName = "ProductName", + navItems = ["Features", "Sign Up"], + badge = "New Release", + headline = "Build Amazing Products Faster", + description = "The complete toolkit for modern product development.", + primaryCta = "Get Started", + secondaryCta, + onPrimaryCta, + onSecondaryCta +}: LandingPageProps) { + return ( +
+
+
+
+
+

{brandName}

+
+
+ {navItems.map((item) => ( + + ))} +
+
+
+
+ {badge} +

+ {headline} +

+

+ {description} +

+
+ + {secondaryCta && ( + + )} +
+
+
+ ) +}`, + ecommercePage: `interface EcommercePageProps { + storeName?: string + productBadge?: string + productName?: string + productPrice?: string + originalPrice?: string + onAddToCart?: () => void +} + +function EcommercePage({ + storeName = "Store", + productBadge = "New Arrival", + productName = "Premium Product", + productPrice = "$299.00", + originalPrice, + onAddToCart +}: EcommercePageProps) { + return ( +
+
+
+

{storeName}

+ +
+
+
+
+
+
+ {productBadge} +

{productName}

+
+ {productPrice} + {originalPrice && ( + + {originalPrice} + + )} +
+ +
+
+
+
+ ) +}`, + blogArticle: `interface BlogArticleProps { + blogName?: string + tags?: string[] + title?: string + authorName?: string + authorAvatar?: string + authorFallback?: string + date?: string + readTime?: string + excerpt?: string +} + +function BlogArticle({ + blogName = "Blog", + tags = ["Design", "Tutorial"], + title = "Building a Comprehensive Component Library", + authorName = "Alex Writer", + authorAvatar, + authorFallback = "AW", + date = "March 15, 2024", + readTime = "10 min read", + excerpt = "Design systems have become an essential part of modern product development." +}: BlogArticleProps) { + return ( +
+
+

{blogName}

+
+
+
+
+ {tags.map((tag, idx) => ( + + {tag} + + ))} +
+

+ {title} +

+
+ + {authorAvatar && } + {authorFallback} + +
+

{authorName}

+

+ {date} · {readTime} +

+
+
+
+

+ {excerpt} +

+
+
+
+ ) +}`, +}