Skip to content

Commit f9d030c

Browse files
committed
added: added some types for TypeScript migration, Animations on board using ReactSpring, Tutorial UI, MenuCard UI
1 parent 82576bb commit f9d030c

20 files changed

+935
-173
lines changed

package-lock.json

+119
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@react-spring/web": "^9.7.3",
7+
"@stitches/react": "^1.2.8",
68
"@testing-library/jest-dom": "^5.16.4",
79
"@testing-library/react": "^13.3.0",
810
"@testing-library/user-event": "^13.5.0",

public/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
content="Web site created using create-react-app"
1111
/>
1212
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
14+
1315
<!--
1416
manifest.json provides metadata used when your web app is installed on a
1517
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/

src/App.css

+7-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:root {
22
/* ------------------------------GENERAL -------------------------------- */
3-
--gap: 12px;
3+
--gap: 20px;
44
/* ----------------------------- GRID-CELL ------------------------------ */
55
--cell-size: 80px;
66
/* --cell-shadow-color: #000000ee; */
@@ -9,23 +9,28 @@
99
--imcomplete-bg: #ffffff;
1010
--imcomplete-shadow: #9ebff1;
1111
--imcorrect-bg: #ccc;
12-
--imcorrect-shadow: #aaa;
12+
--imcorrect-shadow: #545454;
1313
--correct-bg: #b1fe0e;
1414
--correct-shadow: #36b101;
1515
--wrong-positon-bg: #fef572;
1616
--wrong-positon-shadow: #ff6100;
17+
--gray:#727272;
1718

1819
/* -- */
1920
}
2021

2122
.App {
23+
z-index: 2;
24+
position: relative;
2225
height: 100%;
2326
width: 100%;
2427
display: flex;
2528

2629
align-items: center;
2730
/* justify-content: center; */
2831
flex-direction: column;
32+
/* background: rgb(143,75,222); */
33+
background: linear-gradient(180deg, rgba(143,75,222,1) 0%, rgba(225,171,203,1) 50%, rgba(137,163,237,1) 100%);
2934
}
3035

3136
header {
@@ -45,35 +50,3 @@ footer {
4550
justify-content: center;
4651
}
4752

48-
.submit-btn {
49-
padding: 10px 20px;
50-
/* margin: 40px 20px; */
51-
border: none;
52-
border-bottom: 8px solid var(--correct-shadow);
53-
background-color: var(--correct-bg);
54-
box-shadow: var(--cell-shadow);
55-
border-radius: 20px;
56-
font-size: 2rem;
57-
font-weight: 800;
58-
color: transparent;
59-
-webkit-text-stroke: 2px #555;
60-
transition: 100ms all ease-in;
61-
cursor: pointer;
62-
}
63-
64-
.submit-btn:hover {
65-
border-bottom-width: 10px;
66-
/* box-shadow: var(--cell-shadow-hover); */
67-
}
68-
69-
.submit-btn:active {
70-
border-bottom-width: 5px;
71-
/* box-shadow: var(--cell-shadow-hover); */
72-
}
73-
74-
.submit-btn:disabled {
75-
filter: grayscale(1);
76-
opacity: 0.6;
77-
cursor: not-allowed;
78-
border-bottom-width: 2px;
79-
}

src/App.tsx

+30-21
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,58 @@ import React from "react";
33
import "./App.css";
44
import GridRow from "./components/GridRow/GridRow";
55
import useWorddle from "./hooks/useWorddle";
6+
import Home from "./components/Home/Home";
7+
import Button from "./ui/Button/Button";
8+
import MenuCard from "ui/MenuCard/MenuCard";
9+
import Tutorial from "staticUI/Tutorial/Tutorial";
610

7-
const COREECT_WORD = "MIKASA"; // :)
11+
const CORRECT_WORD = "MIKASA"; // :)
812

913
function App() {
1014
const {
15+
level,
16+
setLevel,
1117
gameState,
1218
currentPosition,
1319
handleEnter: guessTheWord,
1420
isWon,
15-
} = useWorddle({ correctWord: COREECT_WORD });
21+
canEnter,
22+
} = useWorddle({ correctWord: CORRECT_WORD });
23+
1624
return (
1725
<div className="App">
18-
{/* <header>
19-
<div>Worddle Game</div>
20-
<div>Guess the anime character :)</div>
21-
</header> */}
22-
<div className="main-container">
23-
{Array(6)
26+
<Tutorial />
27+
{/* {
28+
// !isStarted ?<Home setIsStarted={setIsStarted} />:
29+
!gameState ?<Home setLevel={setLevel} />:
30+
<>
31+
<div className="main-container">
32+
{Array(6)
2433
.fill("")
2534
.map((_, index) => (
2635
<GridRow
2736
key={index}
28-
data={gameState[index].data}
29-
isFixed={gameState[index].fixed}
30-
wordToGuess={COREECT_WORD}
37+
data={gameState?.[index].data}
38+
isFixed={gameState?.[index].isFixed}
39+
wordToGuess={CORRECT_WORD}
40+
level={level}
3141
/>
3242
))}
33-
{/* <GridRow data={gameState[0]} />
34-
<GridRow />
35-
<GridRow />
36-
<GridRow />
37-
<GridRow />
38-
<GridRow /> */}
43+
44+
3945
</div>
4046
<footer>
41-
<button
42-
disabled={currentPosition !== 6}
47+
<Button
48+
disabled={!canEnter}
4349
onClick={guessTheWord}
44-
className="submit-btn"
50+
btnType="try"
4551
>
4652
TRY IT
47-
</button>
53+
</Button>
4854
</footer>
55+
56+
</>
57+
} */}
4958
</div>
5059
);
5160
}

src/components/GridRow/GridRow.jsx renamed to src/components/GridRow/GridRow.tsx

+28-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1-
import React from "react";
1+
import React, { FC } from "react";
22
import GridRowCell from "./GridRowCell/GridRowCell";
33
import "./GridRow.css";
4+
import { IWordState } from "../../hooks/useWorddle";
5+
import { animated, useSpring } from '@react-spring/web';
46

5-
const GridRow = ({ data, wordToGuess, isFixed }) => {
7+
interface GridRowProps extends IWordState{
8+
9+
wordToGuess: string;
10+
level:number
11+
}
12+
13+
const GridRow:FC<GridRowProps> = ({ data, wordToGuess, isFixed,level }) => {
14+
15+
const [styles] =useSpring(()=>({
16+
from:{
17+
scale:0.8
18+
},
19+
to:{
20+
scale:1
21+
},
22+
config:{
23+
tension:150,
24+
friction:10
25+
}
26+
}))
627
return (
7-
<div className={"grid-row"}>
8-
{Array(6)
28+
<animated.div className={"grid-row"} style={{...styles}}>
29+
{Array(level)
930
.fill("")
1031
.map((_, index) => (
1132
<GridRowCell
@@ -18,18 +39,14 @@ const GridRow = ({ data, wordToGuess, isFixed }) => {
1839
: data[index] !== "" && wordToGuess.includes(data[index])
1940
? "wrong-position"
2041
: data[5] !== ""
21-
? "imcorrect"
42+
? "incorrect"
2243
: ""
2344
: ""
2445
}
2546
/>
2647
))}
27-
{/* <GridRowCell value="A" status={"correct"} />
28-
<GridRowCell value="D" status={"wrong-position"} />
29-
<GridRowCell />
30-
<GridRowCell />
31-
<GridRowCell /> */}
32-
</div>
48+
49+
</animated.div>
3350
);
3451
};
3552

0 commit comments

Comments
 (0)