Skip to content

Commit

Permalink
UI enhancements on buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
daithihearn committed Jul 9, 2023
1 parent d993554 commit f71d5cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
25 changes: 13 additions & 12 deletions src/components/Game/Actions/PlayCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const PlayCard = () => {
)

const AutoPlayDropdown = () => (
<FormControl variant="filled" sx={{ m: 1, minWidth: 120 }}>
<FormControl variant="filled" sx={{ minWidth: 90 }}>
<InputLabel id="autoplay-select-label">Autoplay</InputLabel>
<Select
labelId="autoplay-select-label"
Expand All @@ -68,16 +68,6 @@ const PlayCard = () => {
</FormControl>
)

const PlayCardButton = () => (
<Button
id="playCardButton"
type="button"
onClick={selectCardToPlay}
color="warning">
<b>Play</b>
</Button>
)

const playButtonEnabled = useMemo(
() =>
isMyGo &&
Expand All @@ -90,6 +80,17 @@ const PlayCard = () => {
[isMyGo, round, myCards],
)

const PlayCardButton = () => (
<Button
id="playCardButton"
type="button"
disabled={!playButtonEnabled}
onClick={selectCardToPlay}
color="warning">
<b>Play Card</b>
</Button>
)

const playCard = useCallback(
(card: string) =>
dispatch(GameService.playCard(gameId!, card)).catch(e => {
Expand Down Expand Up @@ -121,7 +122,7 @@ const PlayCard = () => {

return (
<ButtonGroup disableElevation variant="contained" size="large">
{playButtonEnabled && <PlayCardButton />}
<PlayCardButton />
<AutoPlayDropdown />
</ButtonGroup>
)
Expand Down
4 changes: 0 additions & 4 deletions src/pages/Game/_game.scss
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@
padding-left: 5px;
}

#playCardButton:disabled {
display: none;
}

@media (min-width: 576px) {

.modal-dialog {
Expand Down

0 comments on commit f71d5cf

Please sign in to comment.