@material-ui/lab#SkeletonProps TypeScript Examples
The following examples show how to use
@material-ui/lab#SkeletonProps.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FieldSkeleton.tsx From firetable with Apache License 2.0 | 6 votes |
export default function FieldSkeleton(props: SkeletonProps) {
const theme = useTheme();
return (
<Skeleton
variant="rect"
width="100%"
height={56}
animation="wave"
style={{ borderRadius: theme.shape.borderRadius }}
{...props}
/>
);
}
Example #2
Source File: index.tsx From aqualink-app with MIT License | 5 votes |
LoadingSkeleton: FC<LoadingSkeletonProps> = ({
loading,
children,
variant,
width,
height,
lines,
image,
dark = true,
className,
longText,
textHeight,
}) => {
const classes = useStyles({ image, textHeight });
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("xs"));
const [lineWidths, setLineWidths] = useState<
{ key: number; width: number }[]
>([]);
const rectSkeletonProps: SkeletonProps =
variant === "rect" &&
(typeof width !== "undefined" || typeof height !== "undefined")
? { width, height }
: {};
useEffect(() => {
if (typeof lines === "number") {
setLineWidths(
times(lines, (i) => ({
key: i,
width: random(
longText || isMobile ? 50 : 20,
longText || isMobile ? 100 : 40
),
}))
);
}
}, [isMobile, lines, longText]);
if (!loading) {
return <>{children}</>;
}
if (variant === "text" && typeof lines === "number" && lineWidths.length) {
return (
<>
{lineWidths.map(({ key, width: lineWidth }) => (
<Skeleton
animation="wave"
className={classNames(classes.root, classes.textHeight, className, {
[classes.dark]: dark,
})}
key={key}
variant={variant}
width={width || `${lineWidth}%`}
/>
))}
</>
);
}
return (
<Skeleton
animation="wave"
className={classNames(classes.root, classes.image, className, {
[classes.dark]: dark,
})}
variant={variant}
{...rectSkeletonProps}
/>
);
}