Skip to content

Commit

Permalink
Merge pull request #82 from daithihearn/bugfix11
Browse files Browse the repository at this point in the history
Fixing default sorting on tables
  • Loading branch information
daithihearn authored Jan 15, 2023
2 parents fc94083 + effc04e commit ceba122
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 48 deletions.
6 changes: 2 additions & 4 deletions src/components/Game/GameOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import Leaderboard from "../Leaderboard/Leaderboard"
const GameOver = () => {
return (
<CardGroup>
<Card color="secondary" className="p-6">
<Card className="p-6 data-card">
<CardHeader className="cardAreaHeaderContainer" tag="h2">
Game Over
</CardHeader>
<CardBody>
<Container>
<Leaderboard />
</Container>
<Leaderboard />
</CardBody>
</Card>
</CardGroup>
Expand Down
5 changes: 1 addition & 4 deletions src/components/Game/GameWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ const GameWrapper = () => {
<WebsocketManager />
<AutoActionManager />

<Card
className="p-6 tableCloth"
inverse
style={{ backgroundColor: "#333", borderColor: "#333" }}>
<Card className="p-6" inverse>
<PlayersAndCards />

{!iamSpectator ? <MyCards /> : null}
Expand Down
7 changes: 1 addition & 6 deletions src/components/Game/ThrowCardsWarningModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ const ThrowCardsWarningModal: React.FC<ModalOpts> = ({
</ModalHeader>
<ModalBody className="called-modal">
<CardGroup className="gameModalCardGroup">
<CardComponent
className="p-6 tableCloth"
style={{
backgroundColor: "#333",
borderColor: "#333",
}}>
<CardComponent className="p-6">
<CardBody className="cardArea">
{cards.map(card => (
<img
Expand Down
2 changes: 1 addition & 1 deletion src/components/GameStats/GameStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const GameStats = () => {

return (
<CardGroup>
<Card color="secondary" className="p-6">
<Card className="p-6 data-card">
<CardHeader tag="h2">My Stats </CardHeader>
<CardBody>
{!!stats && stats.length > 0 ? (
Expand Down
5 changes: 4 additions & 1 deletion src/components/Leaderboard/DoublesLeaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getPlayerProfiles } from "../../caches/PlayerProfilesSlice"
import { GameStatus } from "../../model/Game"
import { compareScore, compareTeamIds } from "../../utils/PlayerUtils"
import { Player, Team } from "../../model/Player"
import { customStyles } from "../Tables/CustomStyles"

const DoublesLeaderboard = () => {
const game = useAppSelector(getGame)
Expand Down Expand Up @@ -196,7 +197,9 @@ const DoublesLeaderboard = () => {
data={teams}
columns={columns}
highlightOnHover
defaultSortFieldId="score"
customStyles={customStyles}
defaultSortFieldId={3}
defaultSortAsc={false}
/>
</React.Fragment>
)
Expand Down
19 changes: 17 additions & 2 deletions src/components/Leaderboard/LeaderboardModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { useCallback, useState } from "react"

import { Modal, ModalBody, Button } from "reactstrap"
import {
Modal,
ModalBody,
Button,
CardGroup,
Card,
CardHeader,
CardBody,
} from "reactstrap"

import Leaderboard from "../Leaderboard/Leaderboard"

Expand Down Expand Up @@ -31,7 +39,14 @@ const LeaderboardModal = () => {
toggle={toggleLeaderboardModal}
isOpen={modalLeaderboard}>
<ModalBody className="gameModalBody">
<Leaderboard />
<CardGroup>
<Card className="data-card">
<CardHeader tag="h2">Leaderboard</CardHeader>
<CardBody>
<Leaderboard />
</CardBody>
</Card>
</CardGroup>
</ModalBody>
</Modal>
</>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Leaderboard/SinglesLeaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useAppSelector } from "../../caches/hooks"
import { getPlayerProfiles } from "../../caches/PlayerProfilesSlice"
import { GameStatus } from "../../model/Game"
import { Player } from "../../model/Player"
import { customStyles } from "../Tables/CustomStyles"

interface LeaderboardItem {
previousCard?: string
Expand Down Expand Up @@ -129,7 +130,9 @@ const SinglesLeaderboard = () => {
data={leaderboardData}
columns={columns}
highlightOnHover
defaultSortFieldId="score"
customStyles={customStyles}
defaultSortFieldId={3}
defaultSortAsc={false}
/>
</React.Fragment>
)
Expand Down
6 changes: 4 additions & 2 deletions src/components/MyGames/MyGames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { getMyGames } from "../../caches/MyGamesSlice"
import { getMyProfile } from "../../caches/MyProfileSlice"
import { useSnackbar } from "notistack"
import { Game, GameStatus } from "../../model/Game"
import { customStyles } from "../Tables/CustomStyles"

const MyGames = () => {
const dispatch = useAppDispatch()
Expand Down Expand Up @@ -143,7 +144,7 @@ const MyGames = () => {

return (
<CardGroup>
<Card color="secondary" className="p-6">
<Card className="p-6 data-card">
<CardHeader tag="h2">Games</CardHeader>
<CardBody>
<DataTable
Expand All @@ -152,7 +153,8 @@ const MyGames = () => {
theme="solarized"
data={myGames}
columns={columns}
defaultSortFieldId="timestamp"
customStyles={customStyles}
defaultSortFieldId={3}
defaultSortAsc={false}
highlightOnHover
/>
Expand Down
11 changes: 5 additions & 6 deletions src/components/StartNewGame/StartNewGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import {
Card,
CardBody,
CardGroup,
CardHeader,
} from "reactstrap"

import { useAppDispatch, useAppSelector } from "../../caches/hooks"
import { PlayerProfile } from "../../model/Player"
import { useSnackbar } from "notistack"
import { customStyles } from "../Tables/CustomStyles"

const StartNewGame = () => {
const dispatch = useAppDispatch()
Expand Down Expand Up @@ -96,14 +98,10 @@ const StartNewGame = () => {

return (
<CardGroup>
<Card color="secondary">
<CardBody>
<h1>Start a new game</h1>
</CardBody>
<Card className="data-card">
<CardHeader tag="h2">Start a new game</CardHeader>
<CardBody>
<FormGroup>
<h3>Players</h3>

<DataTable
noHeader
pagination
Expand All @@ -112,6 +110,7 @@ const StartNewGame = () => {
columns={columns}
highlightOnHover
selectableRows
customStyles={customStyles}
onSelectedRowsChange={togglePlayer}
/>

Expand Down
26 changes: 26 additions & 0 deletions src/components/Tables/CustomStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const customStyles = {
headRow: {
style: {
border: "none",
},
},
headCells: {
style: {
color: "#202124",
fontSize: "14px",
},
},
rows: {
highlightOnHoverStyle: {
backgroundColor: "rgb(230, 244, 244)",
borderBottomColor: "#FFFFFF",
borderRadius: "25px",
outline: "1px solid #FFFFFF",
},
},
pagination: {
style: {
border: "none",
},
},
}
9 changes: 4 additions & 5 deletions src/pages/Game/_game.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
font-family: $fontFamily;
}

.card {
--cui-card-bg: ;
}

.cardNotSelected {
opacity: 0.9;
filter: brightness(70%);
Expand All @@ -11,11 +15,6 @@
filter: drop-shadow(16px 16px 20px red);
}

.tableCloth {
background-image: url("/assets/img/cloth.jpg");
min-height: 350px;
}

// .carpet {
// background-image: url("/assets/img/carpet2.jpg");
// }
Expand Down
21 changes: 12 additions & 9 deletions src/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect } from "react"
import React, { useEffect } from "react"

import { Card, CardGroup, CardHeader } from "reactstrap"

Expand All @@ -14,6 +14,7 @@ import GameService from "../../services/GameService"
import { useSnackbar } from "notistack"
import StatsService from "../../services/StatsService"
import Loading from "../../components/icons/Loading"
import { Divider } from "@mui/material"

const Home = () => {
const dispatch = useAppDispatch()
Expand Down Expand Up @@ -44,7 +45,7 @@ const Home = () => {
<div className="game_container">
{!myProfile.isPlayer && !myProfile.isAdmin ? (
<CardGroup>
<Card color="secondary" className="p-6">
<Card className="p-6">
<CardHeader tag="h2">
You are successfully logged in but don't
yet have any access permissions. Please
Expand All @@ -55,16 +56,18 @@ const Home = () => {
) : (
<div>
{myProfile.isPlayer ? (
<div>
<>
<MyGames />
<Divider />
<Divider />
<Divider />
<GameStats />
</div>
) : null}
{myProfile.isAdmin ? (
<div>
<StartNewGame />
</div>
<Divider />
<Divider />
<Divider />
</>
) : null}
{myProfile.isAdmin ? <StartNewGame /> : null}
</div>
)}
</div>
Expand Down
10 changes: 4 additions & 6 deletions src/pages/Home/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
font-family: $fontFamily;
}
.app_body {
background-color: $white;
width: auto;
flex: 1;
position: relative;
font-family: $fontFamily;
}

.card-group {
padding-top: 10px;
padding-bottom: 10px;
.data-card {
background-color: $white;
opacity: 0.95;
}


.game_wrap {
min-width: 650px;
overflow: overlay;
margin-left: auto;
margin-right: auto;
text-align: center;
background-color: $white;
}

.game_container {
Expand Down Expand Up @@ -545,6 +544,5 @@
@media (max-width: 277px) {
.app {
position: absolute;
background: $white;
}
}
3 changes: 2 additions & 1 deletion src/scss/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ body {

// Here you can add other styles
.main_content {
background-color: $white;
background-image: url("/assets/img/cloth.jpg");
min-height: 800px;
position: fixed;
width: 100%;
height: 100vh;
Expand Down

0 comments on commit ceba122

Please sign in to comment.