/** * Performance section — baseline output optimizations exposed as toggles. * Each writes a boolean into the `performance` settings tree; the Performance * core layer (includes/Core/Performance.php) gates the matching behaviour. * All default to on, so turning one off is an opt-out of a baseline tweak. * * On the Customizer host each tab (Requests / Caching / Uploads) is a real * `WP_Customize_Section` of its own — see Customizer::PERFORMANCE_SUBSECTIONS * — reached via `onNavigateTab`, mirroring Typography's hub/tab-section * split. On the standalone admin page (no `onNavigateTab`) every tab still * renders inline, unchanged. */ import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Gauge, Zap, HardDrive, Upload } from 'lucide-react'; import Tabs, { TabPanel } from '../../controls/tabs'; import { RequestsFields, CachingFields, UploadsFields, type PerformanceSchema, } from './fields'; import type { WorkingSettings, SetPath, SectionExtra } from '../../types'; import SectionIntro from '../../controls/section-intro'; const ID_PREFIX = 'aureon-performance'; interface PerformanceSectionProps { schema?: PerformanceSchema; working: WorkingSettings; setPath: SetPath; // Fields a plugin has targeted at this section (e.g. Aureon Nexus's SVG // uploads toggle, which moved out of the theme for WordPress.org review // but still belongs under "Uploads" here). See SECTION_EXTRAS in app.tsx. extras?: SectionExtra[]; onNavigateTab?: ( key: string ) => void; } export default function PerformanceSection( { schema, working, setPath, extras, onNavigateTab, }: PerformanceSectionProps ) { const [ activeTab, setActiveTab ] = useState( '' ); if ( ! schema ) { return null; } const performance = ( working?.performance ?? {} ) as Record< string, unknown >; const hasUploads = !! extras && extras.length > 0; // Caching's only control needs the companion plugin's file writer. const hasCaching = !! schema.cssFileCacheEnabled; const tabs = [ { key: 'requests', label: __( 'Requests', 'aureon' ), icon: Zap }, ...( hasCaching ? [ { key: 'caching', label: __( 'Caching', 'aureon' ), icon: HardDrive, }, ] : [] ), ...( hasUploads ? [ { key: 'uploads', label: __( 'Uploads', 'aureon' ), icon: Upload, }, ] : [] ), ]; const openTab = ( key: string ) => { if ( onNavigateTab ) { onNavigateTab( key ); return; } setActiveTab( key ); }; return (

{ schema.label }

{ __( 'Trim what WordPress loads on the front end. Turn an option off if a plugin or workflow needs what it removes.', 'aureon' ) }

{ ! onNavigateTab && ( <> { hasUploads && ( ) } ) }
); }