/** * Content Templates workspace. * * A single section covering every content view — the post feed, an individual * post, a standalone page, and search results. Each view is presented as a * stack of labelled cards (Banner, Layout, Reading) in one scroll, with * "Inherit" meaning the site-wide default flows through. * * Writes go to the same sparse trees as before — layout.contexts..*, * title_area..*, blog..* — so nothing about the data model or the * frontend changes; this is presentation only. * * On the Customizer host each view (Post Feed / Article / Page / Search) is a * real `WP_Customize_Section` of its own — see Customizer:: * TEMPLATES_SUBSECTIONS — reached via `onNavigateTab`, mirroring Typography's * hub/tab-section split. On the standalone admin page (no `onNavigateTab`, * no real `wp.customize`) every view still renders inline, unchanged. */ import { __ } from '@wordpress/i18n'; import { LayoutGrid } from '../../icons'; import Tabs from '../../controls/tabs'; import type { BlogSchema } from '../../controls/blog-controls'; import type { WorkingSettings, SetPath } from '../../types'; import useUrlState from '../../use-url-state'; import { VIEWS } from './constants'; import ContextFields from './fields'; import SectionIntro from '../../controls/section-intro'; const ID_PREFIX = 'aureon-templates'; interface TemplatesSectionProps { layoutSchema?: Record< string, unknown >; titleAreaSchema?: Record< string, unknown >; blogSchema?: BlogSchema; working: WorkingSettings; setPath: SetPath; /** Notify the shell which view is active, so the preview can follow. */ onViewChange?: ( context: string ) => void; /** * Customizer host only: focus the given view's own real section instead of * rendering it inline. See Customizer::TEMPLATES_SUBSECTIONS. */ onNavigateTab?: ( key: string ) => void; } export default function TemplatesSection( { layoutSchema, titleAreaSchema, blogSchema, working, setPath, onViewChange, onNavigateTab, }: TemplatesSectionProps ) { // The open view rides the URL (`?view=`), so a reload keeps the workspace on // the template being worked on rather than resetting to the first chip. // Empty until a view is picked: the section's landing screen is the list of // views itself (see `SubNav`). Customizer host only — see `onNavigateTab`. const [ context, setContext ] = useUrlState< string >( 'view', '', VIEWS.map( ( item ) => item.context ) ); const pick = ( next: string ) => { if ( onNavigateTab ) { onNavigateTab( next ); onViewChange?.( next ); return; } setContext( next ); onViewChange?.( next ); }; return (

{ __( 'Content Templates', 'aureon' ) }

{ __( 'Shape each kind of view. Pick one below — anything left on “Inherit” follows your global Layout.', 'aureon' ) }

( { key: item.context, label: item.label, icon: item.icon, description: item.summary, } ) ) } active={ onNavigateTab ? '' : context } onChange={ pick } idPrefix={ ID_PREFIX } variant="subnav" subnavStyle="cards" backLabel={ __( 'Content Templates', 'aureon' ) } /> { ! onNavigateTab && !! context && ( ) }
); }