import React from 'react'; import useMediaQuery from 'use-media-antd-query'; import { Skeleton, Card, Space, Divider } from 'antd'; /** 一条分割线 */ export const Line = ({ padding }: { padding?: string | number }) => (
); export const MediaQueryKeyEnum = { xs: 2, sm: 2, md: 4, lg: 4, xl: 6, xxl: 6, }; const StatisticSkeleton: React.FC<{ size?: number; active?: boolean; }> = ({ size, active }) => { const colSize = useMediaQuery(); const arraySize = size === undefined ? MediaQueryKeyEnum[colSize] || 6 : size; const firstWidth = (index: number) => { if (arraySize > 2 && index !== 0) { return 42; } if (index === 0) { return 0; } return 16; }; return (
{new Array(arraySize).fill(null).map((_, index) => (
2 && index === 1 ? '1px solid rgba(0,0,0,0.06)' : undefined, paddingLeft: firstWidth(index), flex: 1, marginRight: index === 0 ? 16 : 0, }} >
))}
); }; /** 列表子项目骨架屏 */ export const ListSkeletonItem: React.FC<{ active: boolean }> = ({ active }) => ( <>
); /** 列表骨架屏 */ export const ListSkeleton: React.FC<{ size: number; active?: boolean; actionButton?: boolean; }> = ({ size, active = true, actionButton }) => ( {new Array(size).fill(null).map((_, index) => ( // eslint-disable-next-line react/no-array-index-key ))} {actionButton !== false && ( )} ); /** * 面包屑的 骨架屏 * * @param param0 */ export const PageHeaderSkeleton = ({ active }: { active: boolean }) => (
); export type ListPageSkeletonProps = { active?: boolean; pageHeader?: false; statistic?: number | false; actionButton?: false; toolbar?: false; list?: number | false; }; /** * 列表操作栏的骨架屏 * * @param param0 */ export const ListToolbarSkeleton = ({ active }: { active: boolean }) => ( ); const ListPageSkeleton: React.FC = ({ active = true, statistic, actionButton, toolbar, pageHeader, list = 5, }) => (
{pageHeader !== false && } {statistic !== false && } {(toolbar !== false || list !== false) && ( {toolbar !== false && } {list !== false && ( )} )}
); export default ListPageSkeleton;