Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 4x 7x 7x 7x 7x 26x 26x 8x | import { Card, EmptyCard } from 'components';
import { Entity } from 'types';
import * as S from './styles';
type Item = Entity & {
empty?: boolean;
};
export type CardListProps = {
items?: Item[];
};
const CardList = ({ items = [] }: CardListProps) => {
const minCountToFill = 4;
const lackForFill = items.length - minCountToFill;
const needFill = lackForFill < 0;
return (
<S.Container>
{items.map(item => {
const Item = item.empty ? EmptyCard : Card;
return <Item key={item.id} {...item} />;
})}
{needFill &&
Array(Math.abs(lackForFill))
.fill('')
.map((_, index) => <S.Fill key={index} />)}
</S.Container>
);
};
export { CardList };
|