ant-design/.dumi/theme/builtins/InstallDependencies/index.tsx

55 lines
1.4 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { ConfigProvider, Tabs } from 'antd';
2023-12-09 19:32:10 +08:00
import SourceCode from 'dumi/theme-default/builtins/SourceCode';
import type { Tab } from 'rc-tabs/lib/interface';
import NpmLogo from './npm';
import PnpmLogo from './pnpm';
import YarnLogo from './yarn';
import BunLogo from './bun';
interface InstallProps {
npm?: string;
yarn?: string;
pnpm?: string;
bun?: string;
}
const InstallDependencies: React.FC<InstallProps> = (props) => {
const { npm, yarn, pnpm, bun } = props;
2023-12-09 19:32:10 +08:00
const items: Tab[] = [
{
key: 'npm',
label: 'npm',
children: npm ? <SourceCode lang="bash">{npm}</SourceCode> : null,
icon: <NpmLogo />,
},
{
key: 'yarn',
label: 'yarn',
children: yarn ? <SourceCode lang="bash">{yarn}</SourceCode> : null,
icon: <YarnLogo />,
},
{
key: 'pnpm',
label: 'pnpm',
children: pnpm ? <SourceCode lang="bash">{pnpm}</SourceCode> : null,
icon: <PnpmLogo />,
},
{
key: 'bun',
label: 'Bun',
children: bun ? <SourceCode lang="bash">{bun}</SourceCode> : null,
icon: <BunLogo />,
},
2023-12-09 19:32:10 +08:00
].filter((item) => item.children);
return (
2023-12-09 19:32:10 +08:00
<ConfigProvider theme={{ components: { Tabs: { horizontalMargin: '0' } } }}>
<Tabs className="markdown" size="small" defaultActiveKey="npm" items={items} />
</ConfigProvider>
);
};
export default InstallDependencies;