import React from "react"; import styled from "styled-components"; import { CommonComponentProps } from "./common"; import Text, { Case, TextType } from "./Text"; export type TabProp = { key: string; title: T; panelComponent: JSX.Element; }; const TabList = styled.div` margin-left: 30px; display: flex; align-items: center; height: 24px; background-color: ${(props) => props.theme.colors.multiSwitch.bg}; width: fit-content; margin-bottom: 12px; padding-left: 1px; `; const TabContent = styled.div` height: calc(100% - 24px); `; const Tab = styled.div<{ selected: boolean }>` display: flex; align-items: center; cursor: pointer; height: 22px; padding: 0 12px; ${(props) => props.selected ? ` background-color: ${props.theme.colors.multiSwitch.selectedBg}; ` : null}; border-right: 1px solid ${(props) => props.theme.colors.multiSwitch.border}; `; type MultiSwitchProps = CommonComponentProps & { tabs: Array>; selected: { title: T; value: string }; onSelect: (title: T) => void; }; export default function MultiSwitch(props: MultiSwitchProps) { const selectedTab = props.tabs.find( (tab) => tab.key === props.selected.value, ); return (
{props.tabs.map((tab) => ( props.onSelect(tab.title)} selected={props.selected.value === tab.key} > {tab.title} ))} {selectedTab && {selectedTab.panelComponent}}
); }