-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(face): move STATE_LIST to Menu
- Loading branch information
1 parent
9573390
commit add291f
Showing
2 changed files
with
8 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
.face | ||
display: flex | ||
|
||
button | ||
&__button | ||
width: 30px | ||
height: 30px | ||
|
||
|
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 |
---|---|---|
@@ -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> | ||
) | ||
} |