@@ -17,6 +17,11 @@ import { createGsapLivePreview } from "./gsapLivePreview";
1717import { formatTextFieldPreview , StyleSections } from "./propertyPanelSections" ;
1818import { STUDIO_GSAP_PANEL_ENABLED } from "./manualEditingAvailability" ;
1919import { ColorGradingSection } from "./propertyPanelColorGradingSection" ;
20+ import { useColorGradingController } from "./useColorGradingController" ;
21+ import {
22+ FlatColorGradingAccessory ,
23+ FlatColorGradingSection ,
24+ } from "./propertyPanelFlatColorGradingSection" ;
2025
2126type EditingSections = ReturnType < typeof resolveEditingSections > ;
2227
@@ -225,6 +230,20 @@ export function PropertyPanelFlat({
225230 ) ;
226231 const [ pinnedGroupIds , setPinnedGroupIds ] = useState < string [ ] > ( [ ] ) ;
227232
233+ // Grade group state. Called unconditionally (React rules-of-hooks) even when
234+ // sections.colorGrading is false — unlike the legacy ColorGradingSection,
235+ // which is only mounted when the section is active, PropertyPanelFlat is not
236+ // remounted per-section so the hook must run every render. Shares one state
237+ // object between the group's header accessory (compare/status/reset) and its
238+ // body (the FlatColorGradingSection controls).
239+ const colorGradingController = useColorGradingController ( {
240+ projectId,
241+ element,
242+ previewIframeRef,
243+ onSetAttributeLive,
244+ onApplyScope : onApplyColorGradingScope ,
245+ } ) ;
246+
228247 const isTextEditable = isTextEditableSelection ( element ) ;
229248 const elementKind = sections . media ? "media" : element . textFields . length > 0 ? "text" : "other" ;
230249 const toggleOpen = ( groupId : string ) =>
@@ -415,6 +434,30 @@ export function PropertyPanelFlat({
415434 />
416435 </ FlatGroup >
417436 ) }
437+ { sections . colorGrading && (
438+ < FlatGroup
439+ title = "Grade"
440+ isOpen = { openGroupId === "grade" || pinnedGroupIds . includes ( "grade" ) }
441+ isPinned = { pinnedGroupIds . includes ( "grade" ) }
442+ onToggleOpen = { ( ) => toggleOpen ( "grade" ) }
443+ onTogglePin = { ( ) => togglePin ( "grade" ) }
444+ accessory = { < FlatColorGradingAccessory state = { colorGradingController } /> }
445+ summary = { `${ colorGradingController . grading . preset ?? "neutral" } · ${ Math . round ( colorGradingController . grading . intensity * 100 ) } %` }
446+ >
447+ < FlatColorGradingSection
448+ grading = { colorGradingController . grading }
449+ assets = { assets }
450+ onImportAssets = { onImportAssets }
451+ onCommitColorGrading = { colorGradingController . commitColorGrading }
452+ applyScope = { colorGradingController . applyScope }
453+ applyBusy = { colorGradingController . applyBusy }
454+ onSetApplyScope = { colorGradingController . setApplyScope }
455+ onApplyToScope = { ( ) => void colorGradingController . applyToScope ( ) }
456+ onApplyScopeAvailable = { Boolean ( onApplyColorGradingScope ) }
457+ mediaMetadata = { colorGradingController . mediaMetadata }
458+ />
459+ </ FlatGroup >
460+ ) }
418461 { sections . colorGrading && (
419462 < ColorGradingSection
420463 key = { [
0 commit comments