diff options
| author | Brendan F <EpicWolverine@users.noreply.github.com> | 2024-02-19 20:35:50 -0800 |
|---|---|---|
| committer | Brendan F <EpicWolverine@users.noreply.github.com> | 2024-02-19 20:35:50 -0800 |
| commit | 647edc9389b24bda19503514170ed31301ea0a72 (patch) | |
| tree | 2b76df7a0e6ada2ad0042d91b3b7b2a679e2f5e8 /src/components | |
| parent | aa3a3063cbbd449ecd8b0d6092fd83ea4db27984 (diff) | |
Add guess states and exact artist match as a yellow
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Game/index.tsx | 1 | ||||
| -rw-r--r-- | src/components/Guess/index.styled.ts | 10 | ||||
| -rw-r--r-- | src/components/Guess/index.tsx | 11 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/components/Game/index.tsx b/src/components/Game/index.tsx index 6f6b736..2f4a2ec 100644 --- a/src/components/Game/index.tsx +++ b/src/components/Game/index.tsx @@ -43,7 +43,6 @@ export function Game({ <Guess key={index} guess={guess} - isCorrect={guess.isCorrect} active={index === currentTry} /> ))} diff --git a/src/components/Guess/index.styled.ts b/src/components/Guess/index.styled.ts index 5118b70..a235355 100644 --- a/src/components/Guess/index.styled.ts +++ b/src/components/Guess/index.styled.ts @@ -1,8 +1,10 @@ import styled from "styled-components"; +import { GuessState } from "../../types/guess"; + export const Container = styled.div<{ active: boolean; - isCorrect: boolean | undefined; + state: GuessState | undefined; }>` width: 100%; height: 45px; @@ -12,10 +14,12 @@ export const Container = styled.div<{ display: flex; align-items: center; - border-color: ${({ theme, active, isCorrect }) => { + border-color: ${({ theme, active, state }) => { if (active) { return theme.border; - } else if (isCorrect === false) { + } else if (state === GuessState.PartiallyCorrect) { + return theme.yellow; + } else if (state === GuessState.Incorrect) { return theme.red; } else { return theme.border100; diff --git a/src/components/Guess/index.tsx b/src/components/Guess/index.tsx index 2afd35c..ee5b2c2 100644 --- a/src/components/Guess/index.tsx +++ b/src/components/Guess/index.tsx @@ -1,23 +1,22 @@ import React from "react"; -import { GuessType } from "../../types/guess"; +import { GuessType, GuessState } from "../../types/guess"; import * as Styled from "./index.styled"; interface Props { guess: GuessType; - isCorrect: boolean | undefined; active: boolean; } -export function Guess({ guess, isCorrect, active }: Props) { - const { song, skipped } = guess; +export function Guess({ guess, active }: Props) { + const { song, state } = guess; const [text, setText] = React.useState<string>(""); React.useEffect(() => { if (song) { setText(`${song.artist} - ${song.name}`); - } else if (skipped) { + } else if (state === GuessState.Skipped) { setText("Skipped"); } else { setText(""); @@ -25,7 +24,7 @@ export function Guess({ guess, isCorrect, active }: Props) { }, [guess]); return ( - <Styled.Container active={active} isCorrect={isCorrect}> + <Styled.Container active={active} state={state}> <Styled.Text>{text}</Styled.Text> </Styled.Container> ); |
