import type { JSX } from "solid-js"; import { For, createSignal } from "solid-js"; import { Highlight } from "./Highlight"; import clsx from "clsx"; function TrafficLightsIcon(props: JSX.IntrinsicElements["svg"]) { return ( ); } type SnippetTab = { name: string; codeLanguage: string; code: string; }; type SnippetProps = { children?: JSX.Element; class?: string; snippets: SnippetTab[]; dark?: boolean; }; export function Snippet(props: SnippetProps) { const [selectedTab, setSelectedTab] = createSignal( props.snippets[0], ); const isActive = (tab: SnippetTab) => selectedTab()?.name === tab.name; const selectTab = (name: string) => { const tab = props.snippets.find((tab) => tab.name === name); if (tab) setSelectedTab(tab); }; return ( {(tab) => ( selectTab(tab.name)} > {tab.name} )} {selectedTab() && ( {selectedTab().code} )} ); }