/* Copyright 2024 New Vector Ltd. SPDX-License-Identifier: AGPL-3.0-only Please see LICENSE in the repository root for full details. */ import { Key, ReactNode, useId } from "react"; import { NavBar, NavItem } from "@vector-im/compound-web"; import styles from "./Tabs.module.css"; export interface Tab { key: K; name: string; content: ReactNode; } interface Props { label: string; tab: K; onTabChange: (key: K) => void; tabs: Tab[]; } export function TabContainer({ label, tab, onTabChange, tabs, }: Props): ReactNode { const idPrefix = useId(); return (
{tabs.map(({ key, name }) => ( onTabChange(key)} active={key === tab} > {name} ))} {tabs.map(({ key, content }) => (
{content}
))}
); }