-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from TNG/random-card
New page to draw random cards
- Loading branch information
Showing
33 changed files
with
236 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.logo { | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/client/src/components/randomcarddisplay/randomCardDisplay.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.card-deck-selector-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: start; | ||
} | ||
.card-deck-selection { | ||
width: 15rem; | ||
cursor: pointer; | ||
} | ||
|
||
.card-container { | ||
display: flex; | ||
position: inherit; | ||
justify-content: center; | ||
height: 600px; | ||
} |
64 changes: 64 additions & 0 deletions
64
apps/client/src/components/randomcarddisplay/randomCardDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import { CARD_DECKS, GameMode, SUITS } from '@eop/shared'; | ||
import { FC, useState } from 'react'; | ||
import DealtCard from '../dealtcard/dealtcard'; | ||
import classes from './randomCardDisplay.module.css'; | ||
import { Button, FormGroup, Input, Label } from 'reactstrap'; | ||
|
||
const allDecks = Object.keys(CARD_DECKS) as GameMode[]; | ||
const RandomCardDisplay: FC = () => { | ||
const [selectedDecks, setSelectedDecks] = useState<GameMode[]>(allDecks); | ||
const selectableCards = selectedDecks.flatMap((deck) => | ||
SUITS.flatMap((suit) => | ||
CARD_DECKS[deck][suit].cards.map((card) => ({ | ||
card, | ||
gameMode: deck, | ||
})), | ||
), | ||
); | ||
const getRandomSelectableCard = () => | ||
selectableCards[Math.floor(Math.random() * selectableCards.length)]; | ||
const [selectedCard, setSelectedCard] = useState(getRandomSelectableCard()); | ||
const selectCard = () => setSelectedCard(getRandomSelectableCard()); | ||
const toggleCardDeck = (deck: GameMode) => | ||
setSelectedDecks((selectedDecks) => | ||
selectedDecks.includes(deck) | ||
? selectedDecks.filter((selectedDeck) => selectedDeck !== deck) | ||
: [...selectedDecks, deck], | ||
); | ||
|
||
return ( | ||
<> | ||
<FormGroup check className={classes['card-deck-selector-container']}> | ||
{allDecks.map((deck) => ( | ||
<Label | ||
check | ||
className={classes['card-deck-selection']} | ||
key={`card-deck-selector-${deck}`} | ||
> | ||
<Input | ||
id="radio-button-default-model" | ||
type="checkbox" | ||
onChange={() => toggleCardDeck(deck)} | ||
checked={selectedDecks.includes(deck)} | ||
/> | ||
{deck} | ||
</Label> | ||
))} | ||
</FormGroup> | ||
{selectedCard && ( | ||
<div className={classes['card-container']}> | ||
<DealtCard | ||
gameMode={selectedCard.gameMode} | ||
card={selectedCard.card} | ||
/> | ||
</div> | ||
)} | ||
<Button block size="lg" color="primary" onClick={selectCard}> | ||
New Card | ||
</Button> | ||
</> | ||
); | ||
}; | ||
|
||
export default RandomCardDisplay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { FC } from 'react'; | ||
import { Card, CardBody, CardHeader, Col, Container, Row } from 'reactstrap'; | ||
import Banner from '../components/banner/banner'; | ||
|
||
import Footer from '../components/footer/footer'; | ||
import Logo from '../components/logo/logo'; | ||
import RandomCardDisplay from '../components/randomcarddisplay/randomCardDisplay'; | ||
|
||
const RandomCard: FC = () => { | ||
return ( | ||
<div> | ||
<Banner /> | ||
<Container className="about" fluid> | ||
<Row style={{ paddingTop: '20px' }}> | ||
<Col sm="12" md={{ size: 6, offset: 3 }}> | ||
<div className="text-center"> | ||
<Logo /> | ||
</div> | ||
<Card> | ||
<CardHeader className="text-center">Threat Modeling</CardHeader> | ||
<CardBody> | ||
<h1>Random Card</h1> | ||
<RandomCardDisplay /> | ||
</CardBody> | ||
</Card> | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col sm="12" md={{ size: 6, offset: 3 }} className="text-center"> | ||
<Footer /> | ||
</Col> | ||
</Row> | ||
</Container> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RandomCard; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.