Files
bigcapital/packages/webapp/src/components/Skeleton/Skeleton.tsx
2023-02-03 01:02:31 +02:00

28 lines
504 B
TypeScript

// @ts-nocheck
import React, { useMemo } from 'react';
import '@/style/components/Skeleton.scss';
import { randomNumber } from '@/utils';
/**
* Skeleton component.
*/
export function Skeleton({
Tag = 'span',
minWidth = 40,
maxWidth = 100,
children,
}) {
const randomWidth = useMemo(
() => randomNumber(minWidth, maxWidth),
[minWidth, maxWidth],
);
return (
<Tag
className={'skeleton'}
style={{ width: `${randomWidth}%` }}
children={children}
/>
);
}