mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
---
|
|
import type { BundledLanguage } from 'shiki';
|
|
|
|
import ServerCode from '@/components/Code/ServerCode.astro';
|
|
import { Tab, TabsList, TabsPanel, TabsRoot } from '@/components/Tabs';
|
|
|
|
interface FileTab {
|
|
title: string;
|
|
code: string;
|
|
lang: BundledLanguage;
|
|
}
|
|
|
|
interface Props {
|
|
files: FileTab[];
|
|
}
|
|
|
|
const { files } = Astro.props;
|
|
---
|
|
|
|
<div class="my-6 w-full max-w-3xl mx-auto flex flex-col rounded-lg overflow-hidden border border-light-40 dark:border-dark-80">
|
|
<div class="relative z-20 bg-light-80 dark:bg-dark-100">
|
|
<slot />
|
|
</div>
|
|
<TabsRoot client:idle maxWidth={false} className="my-0 rounded-none border-0 border-t border-light-40 dark:border-dark-80">
|
|
<TabsList client:idle label="Demo source code">
|
|
{files.map((file, i) => (
|
|
<Tab client:idle value={file.title} initial={i === 0}>
|
|
{file.title}
|
|
</Tab>
|
|
))}
|
|
</TabsList>
|
|
{files.map((file, i) => (
|
|
<TabsPanel client:idle value={file.title} initial={i === 0}>
|
|
<ServerCode code={file.code} lang={file.lang} />
|
|
</TabsPanel>
|
|
))}
|
|
</TabsRoot>
|
|
</div>
|