diff --git a/packages/ui/src/components/Section.tsx b/packages/ui/src/components/Section.tsx index a5dc482..1ccb5eb 100644 --- a/packages/ui/src/components/Section.tsx +++ b/packages/ui/src/components/Section.tsx @@ -1,58 +1,68 @@ -import { ReactNode } from "react"; +import { createContext, ReactNode, useContext, useState } from "react"; import { Badge, - Button, Card, CardBody, CardHeader, CardTitle, Split, SplitItem, + Switch, } from "@patternfly/react-core"; -import { PencilAltIcon } from "@patternfly/react-icons"; + +const SectionContext = createContext<{ + view: "viewer" | "designer"; + toggleView: () => void; +}>({ + view: "viewer", + toggleView: () => {}, +}); + +export function useSection() { + return useContext(SectionContext).view; +} export function Section({ title, count, id, children, - onEdit, }: { title: ReactNode; count?: number; id: string; children: ReactNode; - onEdit?: () => void; }) { + const [view, setView] = useState<"viewer" | "designer">("viewer"); + const toggleView = () => + setView((v) => (v === "viewer" ? "designer" : "viewer")); return ( - - - {onEdit && ( -