import type { TooltipProps } from 'antd'; import { Tooltip } from 'antd'; import clsx from 'clsx'; import { themeLayoutModeRecord } from '@/constants/app'; import { setLayoutMode } from '@/features/theme'; import { getIsMobile } from '@/layouts/appStore'; type LayoutConfig = Record< UnionKey.ThemeLayoutMode, { headerClass: string; mainClass: string; menuClass: string; placement: TooltipProps['placement']; } >; const LAYOUT_CONFIG: LayoutConfig = { horizontal: { headerClass: '', mainClass: 'w-full h-3/4', menuClass: 'w-full h-1/4', placement: 'bottom' }, 'horizontal-mix': { headerClass: '', mainClass: 'w-2/3 h-3/4', menuClass: 'w-full h-1/4', placement: 'bottom' }, vertical: { headerClass: '', mainClass: 'w-2/3 h-3/4', menuClass: 'w-1/3 h-full', placement: 'bottom' }, 'vertical-mix': { headerClass: '', mainClass: 'w-2/3 h-3/4', menuClass: 'w-1/4 h-full', placement: 'bottom' } }; interface Props extends Record { mode: UnionKey.ThemeLayoutMode; } const LayoutModeCard: FC = ({ mode, ...rest }: Props) => { const isMobile = useAppSelector(getIsMobile); const dispatch = useAppDispatch(); const { t } = useTranslation(); function handleChangeMode(modeType: UnionKey.ThemeLayoutMode) { if (isMobile) return; dispatch(setLayoutMode(modeType)); } return (
{Object.entries(LAYOUT_CONFIG).map(([key, item]) => (
handleChangeMode(key as UnionKey.ThemeLayoutMode)} >
{rest[key as UnionKey.ThemeLayoutMode]}
))}
); }; export default LayoutModeCard;