heading.tsx 522 B

1234567891011
  1. 'use client';
  2. import React from 'react';
  3. import { type ComponentRenderProps } from '@json-render/react';
  4. export function Heading({ element }: ComponentRenderProps) {
  5. const { text, level } = element.props as { text: string; level?: string | null };
  6. const Tag = (level || 'h2') as keyof React.JSX.IntrinsicElements;
  7. const sizes: Record<string, string> = { h1: '28px', h2: '24px', h3: '20px', h4: '16px' };
  8. return <Tag style={{ margin: '0 0 16px', fontSize: sizes[level || 'h2'], fontWeight: 600 }}>{text}</Tag>;
  9. }