1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-26 05:16:41 +07:00
vault-frontend/src/components/placeholders/Paragraph/index.tsx
2022-01-19 12:30:04 +07:00

35 lines
893 B
TypeScript

import React, { FC, useMemo } from 'react';
import { Group } from '~/components/containers/Group';
import { Placeholder, PlaceholderProps } from '~/components/placeholders/Placeholder';
import styles from './styles.module.scss';
type Props = PlaceholderProps & {
lines?: number;
wordsLimit?: number;
};
const Paragraph: FC<Props> = ({ lines = 3, wordsLimit = 12, ...props }) => {
const iters = useMemo(
() =>
[...new Array(lines)].map(() =>
[...new Array(Math.ceil(Math.random() * wordsLimit))].map((_, i) => i)
),
[lines, wordsLimit]
);
return (
<Group>
{iters.map((words, i) => (
<div className={styles.para} key={i}>
{words.map(word => (
<Placeholder key={word} width={`${Math.round(Math.random() * 120) + 60}px`} active />
))}
</div>
))}
</Group>
);
};
export { Paragraph };