Generated by Spark: Load more of UI from JSON declarations and break up large components into atomic and create hooks as needed

This commit is contained in:
2026-01-17 12:35:17 +00:00
committed by GitHub
parent 55114937a7
commit 9fde2a100c
9 changed files with 689 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { ReactNode } from 'react'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { IconRenderer } from './IconRenderer'
interface DataCardProps {
title: string
description?: string
icon?: string
gradient?: string
children: ReactNode
className?: string
}
export function DataCard({ title, description, icon, gradient, children, className }: DataCardProps) {
return (
<Card className={`${gradient ? `bg-gradient-to-br ${gradient} border-primary/20` : ''} ${className || ''}`}>
<CardHeader>
<CardTitle className="flex items-center gap-2">
{icon && (
<span className="text-primary">
<IconRenderer name={icon} />
</span>
)}
{title}
</CardTitle>
{description && <CardDescription>{description}</CardDescription>}
</CardHeader>
<CardContent>
{children}
</CardContent>
</Card>
)
}

View File

@@ -0,0 +1,21 @@
import { ReactNode } from 'react'
import { ComponentSchema } from '@/types/json-ui'
import * as Icons from '@phosphor-icons/react'
import { cn } from '@/lib/utils'
interface IconRendererProps {
name: string
size?: number
weight?: 'thin' | 'light' | 'regular' | 'bold' | 'fill' | 'duotone'
className?: string
}
export function IconRenderer({ name, size = 24, weight = 'duotone', className }: IconRendererProps) {
const IconComponent = (Icons as any)[name]
if (!IconComponent) {
return null
}
return <IconComponent size={size} weight={weight} className={className} />
}

View File

@@ -0,0 +1,2 @@
export { IconRenderer } from './IconRenderer'
export { DataCard } from './DataCard'