import { Box, Grid, GridItem, type SystemStyleObject } from "@chakra-ui/react";
import React, { useState } from "react";
import { api } from "~/utils/api";
import NewScenarioButton from "./NewScenarioButton";
import NewVariantButton from "./NewVariantButton";
import OutputCell from "./OutputCell";
import ScenarioEditor from "./ScenarioEditor";
import VariantConfigEditor from "./VariantConfigEditor";
import VariantHeader from "./VariantHeader";
import type { Scenario, PromptVariant } from "./types";
import ScenarioHeader from "~/server/ScenarioHeader";
import { cellPadding } from "../constants";
const stickyHeaderStyle: SystemStyleObject = {
position: "sticky",
top: 0,
backgroundColor: "#fff",
zIndex: 1,
};
const ScenarioRow = (props: { scenario: Scenario; variants: PromptVariant[] }) => {
const [isHovered, setIsHovered] = useState(false);
const highlightStyle = {
backgroundColor: "gray.50", // or any color you prefer
};
return (
setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
sx={isHovered ? highlightStyle : undefined}
borderLeftWidth={1}
>
{props.variants.map((variant) => (
setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
sx={isHovered ? highlightStyle : undefined}
>
))}
);
};
export default function OutputsTable({ experimentId }: { experimentId: string | undefined }) {
const variants = api.promptVariants.list.useQuery(
{ experimentId: experimentId as string },
{ enabled: !!experimentId }
);
const scenarios = api.scenarios.list.useQuery(
{ experimentId: experimentId as string },
{ enabled: !!experimentId }
);
if (!variants.data || !scenarios.data) return null;
return (
*": {
borderColor: "gray.300",
borderBottomWidth: 1,
borderRightWidth: 1,
},
"> *:last-child": {
borderRightWidth: 0,
},
}}
>
{variants.data.map((variant) => (
))}
*" selector on Grid
style={{ borderRightWidth: 0, borderBottomWidth: 0 }}
sx={stickyHeaderStyle}
>
{variants.data.map((variant) => (
))}
{scenarios.data.map((scenario) => (
))}
);
}