Skip to content

Commit

Permalink
refactor(face): move STATE_LIST to Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteWither committed Aug 17, 2024
1 parent 9573390 commit add291f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Components/Face/index.sass
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.face
display: flex

button
&__button
width: 30px
height: 30px

Expand Down
24 changes: 7 additions & 17 deletions src/Components/Face/index.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
import { GameStates, STATE_LIST } from "@/Components/Menu"
import "./index.sass"

export type FaceTypes = "lose" | "win" | "game" | "start"

type stateList = {
[key in FaceTypes]: string
}

const STATE_LIST: stateList = {
lose: "πŸ’€",
win: "😎",
game: "πŸ™‚",
start: "πŸ™‚",
}

type faceProps = {
state: FaceTypes
interface FaceProps {
gameState: GameStates
onResetGame: () => void
}

export function Face({ state, onResetGame }: faceProps) {
export function Face({ gameState, onResetGame }: FaceProps) {
const onClick = () => {
onResetGame()
}

return (
<div className="face">
<button onClick={onClick}>{STATE_LIST[state]}</button>
<button onClick={onClick} className="face__button">
{STATE_LIST[gameState]}
</button>
</div>
)
}

0 comments on commit add291f

Please sign in to comment.