references/patterns.md · 24000
ease: 'easeOut' }, }, };
export const fadeInScale = { hidden: { opacity: 0, scale: 0.95 }, visible: { opacity: 1, scale: 1, transition: { duration: 0.2, ease: 'easeOut' }, }, };
export const slideInFromRight = { hidden: { opacity: 0, x: 20 }, visible: { opacity: 1, x: 0, transition: { duration: 0.3, ease: 'easeOut' }, }, };
export const slideInFromLeft = { hidden: { opacity: 0, x: -20 }, visible: { opacity: 1, x: 0, transition: { duration: 0.3, ease: 'easeOut' }, }, };
### Using Stagger Animations
```tsx
import { motion } from 'framer-motion';
import { staggerContainer, staggerItem } from './variants';
function ItemList({ items }) {
return (
<motion.ul
variants={staggerContainer}
initial="hidden"
animate="visible"
className="space-y-2"
>
{items.map((item) => (
<motion.li key={item.id} variants={staggerItem}>
{item.name}
</motion.li>
))}
</motion.ul>
);
}
Glass Panel Layouts
Two-Column Layout with Glass Panels
export function TwoColumnLayout() {
return (
<div className="flex gap-6 p-8">
{/* Main content */}
<div className="flex-1">
<Card variant="glass">
<h2 className="text-lg font-semibold text-text-primary mb-4">
Main Content
</h2>
{/* Content */}
</Card>
</div>
{/* Sidebar */}
<aside className="w-80">
<Card variant="glass" className="sticky top-8">
<h3 className="text-sm font-medium text-text-muted uppercase tracking-wide mb-4">
Quick Actions
</h3>
{/* Sidebar content */}
</Card>
</aside>
</div>
);
}
Grid of Glass Cards
export function CardGrid({ items }) {
return (
<motion.div
variants={staggerContainer}
initial="hidden"
animate="visible"
className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"
>
{items.map((item) => (
<motion.div key={item.id} variants={staggerItem}>
<Card variant="glass" interactive>
<h3 className="text-base font-medium text-text-primary">
{item.title}
</h3>
<p className="text-sm text-text-secondary mt-2">
{item.description}
</p>
</Card>
</motion.div>
))}
</motion.div>
);
}
Form Patterns
Settings Form
import { Button, Input, Select, Checkbox, Card } from '../components/ui';
export function SettingsForm() {
return (
<Card>
<h2 className="text-lg font-semibold text-text-primary mb-6">
Account Settings
</h2>
<form className="space-y-6">
{/* Two-column grid for larger screens */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<Input
label="First Name"
placeholder="Enter your first name"
/>
<Input
label="Last Name"
placeholder="Enter your last name"
/>
</div>
<Input
label="Email Address"
type="email"
placeholder="[email protected]"
/>
<Select
label="Timezone"
placeholder="Select timezone"
options={[
{ value: 'utc', label: 'UTC' },
{ value: 'pst', label: 'Pacific Time (PST)' },
{ value: 'est', label: 'Eastern Time (EST)' },
]}
/>
<div className="border-t border-border pt-6">
<h3 className="text-sm font-medium text-text-primary mb-4">
Notification Preferences
</h3>
<div className="space-y-3">
<Checkbox label="Email notifications" defaultChecked />
<Checkbox label="Push notifications" />
<Checkbox label="Weekly digest" defaultChecked />
</div>
</div>
<div className="flex justify-end gap-3 pt-4">
<Button variant="secondary">Cancel</Button>
<Button>Save Changes</Button>
</div>
</form>
</Card>
);
}
Empty States
import { motion } from 'framer-motion';
import { FolderIcon } from '@heroicons/react/24/outline';
import { Button } from '../components/ui';
interface EmptyStateProps {
icon?: typeof FolderIcon;
title: string;
description: string;
action?: {
label: string;
onClick: () => void;
};
}
export function EmptyState({ icon: Icon = FolderIcon, title, description, action }: EmptyStateProps) {
return (
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="flex flex-col items-center justify-center py-16 px-4"
>
<div className="w-16 h-16 rounded-full bg-neutral-bg3 flex items-center justify-center mb-4">
<Icon className="w-8 h-8 text-text-muted" />
</div>
<h3 className="text-lg font-medium text-text-primary mb-2">{title}</h3>
<p className="text-sm text-text-secondary text-center max-w-sm mb-6">
{description}
</p>
{action && (
<Button onClick={action.onClick}>{action.label}</Button>
)}
</motion.div>
);
}
Usage
<EmptyState
title="No projects yet"
description="Get started by creating your first project."
action={{
label: 'Create Project',
onClick: () => setShowCreateModal(true),
}}
/>
Loading States
Skeleton Loader
import { clsx } from 'clsx';
interface SkeletonProps {
className?: string;
}
export function Skeleton({ className }: SkeletonProps) {
return (
<div
className={clsx(
'animate-pulse bg-neutral-bg4 rounded',
className
)}
/>
);
}
// Usage
<Skeleton className="h-4 w-32" />
<Skeleton className="h-10 w-full" />
<Skeleton className="h-40 w-full rounded-xl" />
Card Skeleton
export function CardSkeleton() {
return (
<Card>
<div className="space-y-4">
<Skeleton className="h-5 w-1/3" />
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-2/3" />
</div>
</Card>
);
}
Table Skeleton
export function TableSkeleton({ rows = 5 }: { rows?: number }) {
return (
<Card padding="none">
<div className="divide-y divide-border">
{Array.from({ length: rows }).map((_, i) => (
<div key={i} className="flex items-center gap-4 p-4">
<Skeleton className="h-8 w-8 rounded-full" />
<Skeleton className="h-4 flex-1" />
<Skeleton className="h-4 w-20" />
<Skeleton className="h-4 w-24" />
</div>
))}
</div>
</Card>
);
}