card.tsx 966 B

12345678910111213141516171819202122232425
  1. 'use client';
  2. import { type ComponentRenderProps } from '@json-render/react';
  3. export function Card({ element, children }: ComponentRenderProps) {
  4. const { title, description, padding } = element.props as {
  5. title?: string | null;
  6. description?: string | null;
  7. padding?: string | null;
  8. };
  9. const paddings: Record<string, string> = { none: '0', sm: '12px', lg: '24px' };
  10. return (
  11. <div style={{ background: 'var(--card)', border: '1px solid var(--border)', borderRadius: 'var(--radius)' }}>
  12. {(title || description) && (
  13. <div style={{ padding: '16px 20px', borderBottom: '1px solid var(--border)' }}>
  14. {title && <h3 style={{ margin: 0, fontSize: 16, fontWeight: 600 }}>{title}</h3>}
  15. {description && <p style={{ margin: '4px 0 0', fontSize: 14, color: 'var(--muted)' }}>{description}</p>}
  16. </div>
  17. )}
  18. <div style={{ padding: paddings[padding || ''] || '16px' }}>{children}</div>
  19. </div>
  20. );
  21. }