/** * Renders one typography role's field group (Body Text, Headings, Links, * Buttons, Misc) inside a TypographyCard, plus the Headings-only scale * preview. Which fields appear is driven by `section.key` — see the schema * shape in ../../types (TypographySectionSchema). */ import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Button } from '@wordpress/components'; import { ChevronDown, ChevronUp } from 'lucide-react'; import TypographyCard from '../../controls/typography-card'; import UnitField from '../../controls/unit-field'; import ColorField from '../../controls/color-field'; import SelectField from '../../controls/select-field'; import HeadingPreview from './heading-preview'; import { HEADING_LEVELS, LENGTH_UNITS, LINE_HEIGHT_UNITS } from './constants'; import type { TypographySectionSchema, TypographyFieldValues, SetPath, } from '../../types'; interface Option { label: string; value: string; } interface SectionFieldsProps { section: TypographySectionSchema; values: TypographyFieldValues; familyValue: string; familyOptions: Option[]; pairingFamilyOptions: Option[]; weightOptions: Option[]; transformOptions: Option[]; decorationOptions: Option[]; scaleOptions: Option[]; activePairingFontLabel: ( role: 'heading' | 'body' ) => string; headingFamilyCss: string; isDefault: boolean; onReset: () => void; onChangeFamily: ( value: string ) => void; setPath: SetPath; onManagePairings: () => void; showHeadingPreview: boolean; } export default function SectionFields( { section, values, familyValue, familyOptions, pairingFamilyOptions, weightOptions, transformOptions, decorationOptions, scaleOptions, activePairingFontLabel, headingFamilyCss, isDefault, onReset, onChangeFamily, setPath, onManagePairings, showHeadingPreview, }: SectionFieldsProps ) { const [ showCustomSizes, setShowCustomSizes ] = useState( false ); const familyIsPairingDriven = 'heading' === section.family_role || 'body' === section.family_role; const familyIsExtended = 'link' === section.family_role || 'button' === section.family_role || 'misc' === section.family_role; const fieldPath = ( key: string ) => `${ section.path }.${ key }`; return ( <> { familyIsPairingDriven ? (

{ __( 'Managed by the active Font Pairing.', 'aureon' ) }{ ' ' } { activePairingFontLabel( section.family_role as 'heading' | 'body' ) }

) : ( ) } { ( 'body' === section.key || 'misc' === section.key ) && ( setPath( fieldPath( 'size' ), value ) } /> ) } { 'headings' === section.key && ( <> setPath( fieldPath( 'scale' ), value ) } /> setPath( fieldPath( 'base_size' ), value ) } />
{ showCustomSizes && (
{ HEADING_LEVELS.map( ( level ) => ( setPath( fieldPath( `overrides.${ level.key }` ), value ) } /> ) ) }
) }
) } { ( 'body' === section.key || 'headings' === section.key || 'misc' === section.key ) && ( setPath( fieldPath( 'line_height' ), value ) } /> ) } setPath( fieldPath( 'weight' ), value ) } /> { ( 'body' === section.key || 'links' === section.key || 'buttons' === section.key ) && ( setPath( fieldPath( 'transform' ), value ) } /> ) } { 'links' === section.key && ( setPath( fieldPath( 'decoration' ), value ) } /> ) } { ( 'body' === section.key || 'headings' === section.key || 'links' === section.key || 'buttons' === section.key ) && ( setPath( fieldPath( 'letter_spacing' ), value ) } /> ) } { 'misc' === section.key && ( setPath( fieldPath( 'color' ), value ) } /> ) }
{ showHeadingPreview && ( ) } ); }