Skip to content

Commit 9eca4f2

Browse files
committed
Allow for decks of fewer than 3 cards
1 parent 2e02498 commit 9eca4f2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/app/components/content/IsaacCardDeck.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ import {Col, Container, Row} from "reactstrap";
55
import classNames from "classnames";
66
import {isAda, isPhy} from "../../services";
77

8+
9+
const MAX_CARDS_IN_CONTENT_DEFINED_DECK = 3;
810
interface IsaacCardDeckProps {
911
doc: IsaacCardDeckDTO,
1012
className?: string
1113
containerClassName?: string
1214
}
13-
1415
export const IsaacCardDeck = ({doc, className, containerClassName}: IsaacCardDeckProps) => {
16+
const noCards = Math.min(doc?.cards?.length || MAX_CARDS_IN_CONTENT_DEFINED_DECK, MAX_CARDS_IN_CONTENT_DEFINED_DECK);
1517
return <Container className={classNames("px-0", containerClassName)}>
1618
{doc.title && <Row className="my-4">
1719
<Col>
1820
<h3 className={classNames("h-title", {"text-center": isPhy})}>{doc.title}</h3>
1921
</Col>
2022
</Row>}
21-
<Row xs={12} className={classNames("d-flex flex-row card-deck row-cols-1 row-cols-sm-2 row-cols-xl-3 justify-content-between", {"my-3" : isAda}, {"isaac-cards-body" : isPhy}, className)}>
23+
<Row xs={12} className={classNames(`d-flex flex-row card-deck row-cols-1 row-cols-sm-2 row-cols-xl-${noCards} justify-content-between`, {"my-3" : isAda}, {"isaac-cards-body" : isPhy}, className)}>
2224
{doc?.cards?.map((props, i) => <Container key={i} className="card-container p-3">
2325
<IsaacCard doc={props} imageClassName={props.imageClassName}/>
2426
</Container>)}

0 commit comments

Comments
 (0)