heading.tsx 616 B

1234567891011121314151617181920212223242526272829
  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 {
  6. text: string;
  7. level?: string | null;
  8. };
  9. const Tag = (level || "h2") as keyof React.JSX.IntrinsicElements;
  10. const sizes: Record<string, string> = {
  11. h1: "28px",
  12. h2: "24px",
  13. h3: "20px",
  14. h4: "16px",
  15. };
  16. return (
  17. <Tag
  18. style={{
  19. margin: "0 0 16px",
  20. fontSize: sizes[level || "h2"],
  21. fontWeight: 600,
  22. }}
  23. >
  24. {text}
  25. </Tag>
  26. );
  27. }