mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added placeholders
This commit is contained in:
parent
44ab426915
commit
b4b138e90f
16 changed files with 239 additions and 117 deletions
35
src/components/placeholders/Paragraph/index.tsx
Normal file
35
src/components/placeholders/Paragraph/index.tsx
Normal file
|
@ -0,0 +1,35 @@
|
|||
import React, { FC, useMemo } from 'react';
|
||||
import { Placeholder, PlaceholderProps } from '~/components/placeholders/Placeholder';
|
||||
import styles from './styles.module.scss';
|
||||
import { Group } from '~/components/containers/Group';
|
||||
|
||||
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]
|
||||
);
|
||||
|
||||
console.log({ iters });
|
||||
|
||||
return (
|
||||
<Group>
|
||||
{iters.map(words => (
|
||||
<div className={styles.para}>
|
||||
{words.map(word => (
|
||||
<Placeholder key={word} width={`${Math.round(Math.random() * 120) + 60}px`} active />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</Group>
|
||||
);
|
||||
};
|
||||
|
||||
export { Paragraph };
|
Loading…
Add table
Add a link
Reference in a new issue