From 9bf7e55a8bfc7a2ec0bb1ae8856c8040020db6bb Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Thu, 18 Dec 2025 09:36:12 -0700 Subject: [PATCH] chore: un-generic panel display components --- package.json | 3 +- src/components/FullPlayground.tsx | 23 ++-- src/components/panels/base/common.tsx | 16 +-- src/components/panels/base/components.tsx | 52 ++++---- src/components/panels/base/coordinator.tsx | 137 +++++++++++---------- src/components/panels/base/reflexed.tsx | 112 ++++++----------- src/components/panels/panels.tsx | 3 - src/components/panels/problems.tsx | 9 +- src/components/panels/terminal.tsx | 3 +- src/components/panels/types.ts | 2 + src/components/panels/validation.tsx | 7 +- src/components/panels/visualizer.tsx | 3 +- src/components/panels/watches.tsx | 22 ++-- yarn.lock | 5 + 14 files changed, 178 insertions(+), 219 deletions(-) delete mode 100644 src/components/panels/panels.tsx create mode 100644 src/components/panels/types.ts diff --git a/package.json b/package.json index 8c6dc63..8289c16 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,8 @@ "use-deep-compare-effect": "^1.8.1", "use-keyboard-shortcuts": "^2.2.2", "visjs-network": "^4.24.11", - "yaml": "^2.0.1" + "yaml": "^2.0.1", + "zod": "^4.2.1" }, "devDependencies": { "@eslint/js": "^9.18.0", diff --git a/src/components/FullPlayground.tsx b/src/components/FullPlayground.tsx index 20b333d..d1bcc17 100644 --- a/src/components/FullPlayground.tsx +++ b/src/components/FullPlayground.tsx @@ -77,7 +77,6 @@ import { ShareLoader } from "./ShareLoader"; import { ValidateButton } from "./ValidationButton"; import { Panel, useSummaryStyles } from "./panels/base/common"; import { ReflexedPanelDisplay } from "./panels/base/reflexed"; -import { PlaygroundPanelLocation } from "./panels/panels"; import { ProblemsPanel, ProblemsSummary } from "./panels/problems"; import { TerminalPanel, TerminalSummary } from "./panels/terminal"; import { ValidationPanel, ValidationSummary } from "./panels/validation"; @@ -1104,31 +1103,31 @@ const TabLabelWithCount = (props: { ); }; -const panels: Panel[] = [ +const panels: Panel[] = [ { id: "problems", - summary: ProblemsSummary, - content: ProblemsPanel, + Summary: ProblemsSummary, + Content: ProblemsPanel, }, { id: "watches", - summary: WatchesSummary, - content: WatchesPanel, + Summary: WatchesSummary, + Content: WatchesPanel, }, { id: "visualizer", - summary: VisualizerSummary, - content: VisualizerPanel, + Summary: VisualizerSummary, + Content: VisualizerPanel, }, { id: "validation", - summary: ValidationSummary, - content: ValidationPanel, + Summary: ValidationSummary, + Content: ValidationPanel, }, { id: "terminal", - summary: TerminalSummary, - content: TerminalPanel, + Summary: TerminalSummary, + Content: TerminalPanel, }, ]; diff --git a/src/components/panels/base/common.tsx b/src/components/panels/base/common.tsx index 33a257a..294a6e4 100644 --- a/src/components/panels/base/common.tsx +++ b/src/components/panels/base/common.tsx @@ -1,12 +1,14 @@ +import { type ReactNode } from "react"; import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"; import "react-reflex/styles.css"; import { DataStore } from "../../../services/datastore"; import { Services } from "../../../services/services"; +import { ReflexedPanelLocation } from "../types"; /** * Panel defines a single panel found in the panel display component. */ -export interface Panel { +export interface Panel { /** * id is the unique ID for the panel. Must be stable across loads. */ @@ -15,29 +17,29 @@ export interface Panel { /** * summary is the React tag to render for displaying the summary of the panel. */ - summary: (props: PanelSummaryProps) => JSX.Element; + Summary: (props: PanelSummaryProps) => ReactNode; /** * content is the React tag to render for displaying the contents of the panel. */ - content: (props: PanelProps) => JSX.Element; + Content: (props: PanelProps) => ReactNode; } /** * PanelProps are the props passed to all panels content tags. */ -export interface PanelProps { +export interface PanelProps { datastore: DataStore; services: Services; - location: L; + location: ReflexedPanelLocation; } /** * PanelSummaryProps are the props passed to all panel summary tags. */ -export interface PanelSummaryProps { +export interface PanelSummaryProps { services: Services; - location: L; + location: ReflexedPanelLocation; } /** diff --git a/src/components/panels/base/components.tsx b/src/components/panels/base/components.tsx index d8ad7b3..6e7a861 100644 --- a/src/components/panels/base/components.tsx +++ b/src/components/panels/base/components.tsx @@ -13,15 +13,16 @@ import { DataStore } from "../../../services/datastore"; import { Services } from "../../../services/services"; import { Panel, useSummaryStyles } from "./common"; import { LocationData, PanelsCoordinator } from "./coordinator"; +import { ReflexedPanelLocation } from "../types"; export const SUMMARY_BAR_HEIGHT = 48; // Pixels /** * PanelSummaryBar is the summary bar displayed when a panel display is closed. */ -export function PanelSummaryBar(props: { - location: L; - coordinator: PanelsCoordinator; +export function PanelSummaryBar(props: { + location: ReflexedPanelLocation; + coordinator: PanelsCoordinator; services: Services; disabled?: boolean | undefined; overrideSummaryDisplay?: ReactNode; @@ -45,10 +46,10 @@ export function PanelSummaryBar(props: { > {props.overrideSummaryDisplay !== undefined && props.overrideSummaryDisplay} - {panels.map((panel: Panel) => { + {panels.map((panel: Panel) => { // NOTE: Using this as a tag here is important for React's state system. Otherwise, // it'll run hooks outside of the normal flow, which breaks things. - const Summary = panel.summary; + const Summary = panel.Summary; return (