import React from 'react' import { cn } from '@nextsparkjs/core/lib/utils' import { buildSectionClasses } from '@nextsparkjs/core/types/blocks' import { sel } from '../../lib/selectors' import type { PostContentBlockProps } from './schema' /** * Post Content Block Component * * Beautiful editorial typography optimized for long-form reading. * Inspired by Medium, The New York Times, and other premium publishers. * * Props from 3-tab structure: * - Content: title, content (rich-text article body), cta * - Design: backgroundColor, drop cap, typography, dividers * - Advanced: className, id * * Features: * - Optimal reading width (680-900px) * - Beautiful line height (1.7-1.8) for readability * - Optional decorative drop cap * - Configurable typography scale * - Section dividers for visual breaks */ export function PostContentBlock({ // Base content props title, content, cta, // Base design props backgroundColor, // Post-content-specific design showDropCap = false, dropCapStyle = 'serif', maxWidth = 'narrow', fontSize = 'medium', lineHeight = 'relaxed', paragraphSpacing = 'normal', showDividers = false, dividerStyle = 'line', // Base advanced props className, id, }: PostContentBlockProps) { // Max width classes for optimal reading const maxWidthClasses: Record = { narrow: 'max-w-[680px]', // Optimal for reading medium: 'max-w-[768px]', wide: 'max-w-[900px]', } // Font size classes const fontSizeClasses: Record = { small: 'text-base', // 16px medium: 'text-lg', // 18px large: 'text-xl', // 20px } // Line height classes const lineHeightClasses: Record = { compact: 'leading-relaxed', // 1.6 normal: 'leading-loose', // 1.7 relaxed: 'leading-[1.8]', // 1.8 } // Paragraph spacing classes const paragraphSpacingClasses: Record = { tight: '[&_p]:mb-4', normal: '[&_p]:mb-6', loose: '[&_p]:mb-8', } // Drop cap style classes const dropCapClasses: Record = { serif: 'font-serif', 'sans-serif': 'font-sans', decorative: 'font-serif italic', } // Build section classes with background const sectionClasses = buildSectionClasses( 'py-16 px-4 @md:py-24', { backgroundColor, className } ) // Drop cap CSS (applied via first-letter pseudo-element) const contentWithDropCap = showDropCap ? `[&>p:first-of-type]:first-letter:float-left [&>p:first-of-type]:first-letter:text-7xl [&>p:first-of-type]:first-letter:font-bold [&>p:first-of-type]:first-letter:mr-3 [&>p:first-of-type]:first-letter:mt-1 [&>p:first-of-type]:first-letter:leading-none [&>p:first-of-type]:first-letter:${dropCapClasses[dropCapStyle]}` : '' // Divider component const Divider = () => { if (!showDividers) return null const dividerContent: Record = { line:
, dots: (
•••
), asterisks: (
* * *
), } return (
{dividerContent[dividerStyle]}
) } return (
{/* Optional Section Title */} {title && (

{title}

)} {/* Rich Text Article Content - Editorial Typography */}
{/* Optional Divider after content */} {showDividers && } {/* Optional CTA */} {cta && ( )}
) }