import React from 'react'; import { FloatButton } from 'antd'; import { FormattedMessage, Link, useLocation } from 'dumi'; import { DarkTheme, CompactTheme } from 'antd-token-previewer/es/icons'; import { BgColorsOutlined } from '@ant-design/icons'; import useSiteToken from '../../../hooks/useSiteToken'; import { getLocalizedPathname, isZhCN } from '../../utils'; import ThemeIcon from './ThemeIcon'; export type ThemeName = 'light' | 'dark' | 'compact'; export type ThemeSwitchProps = { value?: ThemeName[]; onChange: (value: ThemeName[]) => void; }; const ThemeSwitch: React.FC = (props: ThemeSwitchProps) => { const { value = ['light'], onChange } = props; const { token } = useSiteToken(); const { pathname, search } = useLocation(); return ( }> } tooltip={} /> } type={value.includes('dark') ? 'primary' : 'default'} onClick={() => { if (value.includes('dark')) { onChange(value.filter((theme) => theme !== 'dark')); } else { onChange([...value, 'dark']); } }} tooltip={} /> } type={value.includes('compact') ? 'primary' : 'default'} onClick={() => { if (value.includes('compact')) { onChange(value.filter((theme) => theme !== 'compact')); } else { onChange([...value, 'compact']); } }} tooltip={} /> ); }; export default ThemeSwitch;