Skip to content

Commit a9409d1

Browse files
vanceingallsclaude
andcommitted
feat(studio): wire the flat Grade group into the one-open accordion
Co-Authored-By: Claude Sonnet 5 <[email protected]>
1 parent 4e81bd7 commit a9409d1

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎packages/studio/src/components/editor/PropertyPanel.test.tsx‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,26 @@ function flatGroupTitles(host: HTMLElement): string[] {
668668
return [...open, ...collapsed];
669669
}
670670

671+
describe("PropertyPanel — Grade group (flag on)", () => {
672+
it(
673+
"renders the Grade group with its accessory for a grade-editable (video) element",
674+
async () => {
675+
const { host, root } = await renderPanel(true, {
676+
...baseElement(),
677+
tagName: "video",
678+
textFields: [],
679+
});
680+
const gradeCollapsedOrOpen =
681+
host.querySelector('[data-flat-group-collapsed="true"]') ||
682+
host.querySelector('[data-flat-group-open="true"]');
683+
expect(host.textContent).toContain("Grade");
684+
expect(gradeCollapsedOrOpen).not.toBeNull();
685+
act(() => root.unmount());
686+
},
687+
RENDER_TIMEOUT_MS,
688+
);
689+
});
690+
671691
describe("PropertyPanel — Media group (Plan 4)", () => {
672692
it(
673693
"renders the flat Media group and not the legacy MediaSection, for a video element",

‎packages/studio/src/components/editor/PropertyPanelFlat.tsx‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ import { createGsapLivePreview } from "./gsapLivePreview";
1717
import { formatTextFieldPreview, StyleSections } from "./propertyPanelSections";
1818
import { STUDIO_GSAP_PANEL_ENABLED } from "./manualEditingAvailability";
1919
import { ColorGradingSection } from "./propertyPanelColorGradingSection";
20+
import { useColorGradingController } from "./useColorGradingController";
21+
import {
22+
FlatColorGradingAccessory,
23+
FlatColorGradingSection,
24+
} from "./propertyPanelFlatColorGradingSection";
2025

2126
type 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

Comments
 (0)