role | Description |
---|---|
Complete Data Visualization | Present detailed views of domain entities |
Page-Level Components | Serve as primary content for application pages |
Server-Side Optimization | Leverage Next.js server components for performance |
Component Integration | Integrate with Zones (layout) and Units (list items) |
Present detailed views of domain entities
Serve as primary content for application pages
Leverage Next.js server components for performance
Integrate with Zones (layout) and Units (list items)
// File structure example
export interface ProductViewProps {
product: cnst.Product;
className?: string;
}
// General view (standard)
export const General = ({ product, className }: ProductViewProps) => (
<div className={clsx("space-y-6", className)}>
<h1 className="text-2xl font-bold">{product.name}</h1>
{/* Product details */}
</div>
);
// Dashboard view (condensed)
export const Dashboard = ({ product }: ProductViewProps) => (
<div className="bg-base-100 p-4 rounded-lg">
<h2 className="text-lg font-bold">{product.name}</h2>
{/* Key metrics */}
</div>
);
// Timeline view (specialized)
export const Timeline = ({ project }: ProjectViewProps) => (
<div className="project-timeline">
{/* Timeline visualization */}
</div>
);
Option | Type | Default | Description | Example |
---|---|---|---|---|
pages | Page Components | - | Used as primary content in page routes |
|
utils | Util Components | - | Wrapped in client components for interactivity |
|
zones | Zone Components | - | Embedded in layout containers for complex UIs |
|
Used as primary content in page routes
app/products/[id]/page.tsx
Wrapped in client components for interactivity
Product.Util.tsx
Embedded in layout containers for complex UIs
Dashboard.Zone.tsx
// Consistent layout structure
export const OrderView = ({ order }: OrderViewProps) => (
<div className="space-y-6">
{/* Header section */}
<div className="flex items-center justify-between">
<h1 className="text-2xl font-bold">Order #{order.number}</h1>
<span className="badge badge-lg">{order.status}</span>
</div>
{/* Responsive design */}
<div className="flex flex-col gap-6 lg:flex-row">
<div className="w-full lg:w-2/3">
{/* Order items table */}
</div>
<div className="w-full lg:w-1/3">
{/* Order summary card */}
</div>
</div>
{/* Conditional rendering */}
{order.status === 'delivered' && (
<div className="bg-success text-success-content p-4 rounded-lg">
<h2 className="text-lg font-medium">Delivery Information</h2>
{/* Delivery details */}
</div>
)}
</div>
);
// Status-based visualization
export const ProjectStatusView = ({ project }: { project: cnst.Project }) => {
const statusColors = {
planning: 'bg-info text-info-content',
active: 'bg-success text-success-content',
onHold: 'bg-warning text-warning-content',
completed: 'bg-accent text-accent-content',
cancelled: 'bg-error text-error-content',
};
return (
<div className="flex items-center gap-2">
<span className={`badge ${statusColors[project.status] || 'bg-neutral'}`}>
{project.status}
</span>
<progress
className="progress progress-primary w-64"
value={project.progress}
max="100"
/>
<span>{project.progress}%</span>
</div>
);
};
// Component composition
const OrderHeader = ({ order }: { order: cnst.Order }) => (
<div className="flex justify-between items-center p-4 bg-base-200 rounded-t-lg">
<h1 className="text-xl font-bold">Order #{order.number}</h1>
<StatusBadge status={order.status} />
</div>
);
const OrderItems = ({ items }: { items: cnst.OrderItem[] }) => (
<div className="p-4">
{/* Render order items */}
</div>
);
const OrderSummary = ({ totals }: { totals: any }) => (
<div className="p-4 bg-base-100">
{/* Render order summary */}
</div>
);
export const OrderView = ({ order }: { order: cnst.Order }) => (
<div className="border rounded-lg overflow-hidden">
<OrderHeader order={order} />
<OrderItems items={order.items} />
<OrderSummary totals={order.totals} />
</div>
);
issue | Description | Example |
---|---|---|
Client Hooks Error | Cannot use useState/useEffect in server components |
|
Missing Data | Undefined properties causing runtime errors |
|
Layout Shifts | Content jumps when conditional elements render |
|
Cannot use useState/useEffect in server components
Move interactivity to Util components
Undefined properties causing runtime errors
Add null checks: {data ? ( ... ) : ( ... )}
Content jumps when conditional elements render
Use fixed-height containers or skeletons