Skip to content

Commit 041a5c2

Browse files
committed
styled the entire app
1 parent 2524f51 commit 041a5c2

File tree

6 files changed

+199
-32
lines changed

6 files changed

+199
-32
lines changed

index.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>React Parcel Micro App</title>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
7+
<link
8+
href="https://fonts.googleapis.com/css?family=Roboto:300,400,700&display=swap"
9+
rel="stylesheet"
10+
/>
11+
<title>Tic Tac Toe</title>
512
</head>
613
<body>
714
<div id="root"></div>

src/App.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,26 @@ const App = () => {
6262

6363
return (
6464
<div className="app">
65-
<h1>TIC TAC TOE</h1>
65+
<h1>
66+
TIC <span className="text-green">TAC</span> TOE
67+
</h1>
6668
<StatusMessage winner={winner} current={current} />
6769
<Board
6870
board={current.board}
6971
handleSquareClick={handleSquareClick}
7072
winningSquares={winningSquares}
7173
/>
72-
<button style={{ fontWeight: 'bold' }} type="button" onClick={onNewGame}>
74+
<button
75+
style={{ fontWeight: 'bold' }}
76+
type="button"
77+
onClick={onNewGame}
78+
className={`btn-reset ${winner ? 'active' : ''}`}
79+
>
7380
New Game
7481
</button>
82+
<h2 style={{ fontWeight: 'normal' }}>Current Game History</h2>
7583
<History history={history} moveTo={moveTo} currentMove={currentMove} />
84+
<div className="bg-balls" />
7685
</div>
7786
);
7887
};

src/components/History.js

+22-19
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@ import React from 'react';
22

33
const History = ({ history, moveTo, currentMove }) => {
44
return (
5-
<ul>
6-
{history.map((_, move) => {
7-
return (
8-
<li key={move}>
9-
<button
10-
style={{
11-
fontWeight: move === currentMove ? 'bold' : 'normal',
12-
}}
13-
type="button"
14-
onClick={() => {
15-
moveTo(move);
16-
}}
17-
>
18-
{move === 0 ? 'Start the Game' : `Go to move #${move}`}
19-
</button>
20-
</li>
21-
);
22-
})}
23-
</ul>
5+
<div className="history-wrapper">
6+
<ul className="history">
7+
{history.map((_, move) => {
8+
return (
9+
<li key={move}>
10+
<button
11+
// style={{
12+
// fontWeight: move === currentMove ? 'bold' : 'normal',
13+
// }}
14+
className={`btn-move ${move == currentMove ? 'active' : ''}`}
15+
type="button"
16+
onClick={() => {
17+
moveTo(move);
18+
}}
19+
>
20+
{move === 0 ? 'Start the Game' : `Go to move #${move}`}
21+
</button>
22+
</li>
23+
);
24+
})}
25+
</ul>
26+
</div>
2427
);
2528
};
2629

src/components/Square.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const Square = ({ value, onClick, isWinningSquare }) => {
44
return (
55
<button
66
type="button"
7-
className="square"
87
onClick={onClick}
8+
className={`square ${isWinningSquare ? 'winning' : ''} ${
9+
value === 'X' ? 'text-green' : 'text-orange'
10+
}`}
911
style={{ fontWeight: isWinningSquare ? 'bold' : 'normal' }}
1012
>
1113
{' '}

src/components/StatusMessage.js

+24-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,30 @@ const StatusMessage = ({ winner, current }) => {
88
const noMovesLeft = current.board.every(el => el !== null);
99

1010
return (
11-
<h2>
12-
{winner && `Winner is ${winner}`}
13-
{!winner &&
14-
!noMovesLeft &&
15-
`Next player is ${current.isXNext ? 'X' : 'O'}`}
16-
{!winner && noMovesLeft && 'X and O Tied '}
17-
</h2>
11+
<div className="status-message">
12+
{winner && (
13+
<>
14+
Winner is{' '}
15+
<span className={winner === 'X' ? 'text-orange' : 'text-green'}>
16+
{winner}
17+
</span>
18+
</>
19+
)}
20+
{!winner && !noMovesLeft && (
21+
<>
22+
Next player is{' '}
23+
<span className={current.isXNext ? 'text-green' : 'text-orange'}>
24+
{current.isXNext ? 'X' : 'O'}{' '}
25+
</span>
26+
</>
27+
)}
28+
{!winner && noMovesLeft && (
29+
<>
30+
<span className="text-green">X</span> and{' '}
31+
<span className="text-orange">O</span> Tied
32+
</>
33+
)}
34+
</div>
1835
);
1936
};
2037

src/styles/root.scss

+131-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
$green: #12e177;
2+
$orange: #ffc72a;
3+
$blue: #4c43d4;
4+
15
body {
6+
font-family: 'Roboto', sans-serif;
7+
background-color: $blue;
8+
color: #fff;
29
padding: 0;
310
margin: 0;
411
}
@@ -19,25 +26,147 @@ button {
1926
align-items: center;
2027
}
2128

29+
.text-green {
30+
color: $green;
31+
}
32+
33+
.text-orange {
34+
color: $orange;
35+
}
36+
37+
.history-wrapper {
38+
width: 300px;
39+
text-align: center;
40+
margin-bottom: 20px;
41+
.history {
42+
display: inline-block;
43+
padding: 0;
44+
margin: 0;
45+
li {
46+
list-style: none;
47+
text-align: left;
48+
&:before {
49+
content: '';
50+
border-radius: 50%;
51+
display: inline-block;
52+
height: 5px;
53+
width: 5px;
54+
background-color: $green;
55+
margin-right: 4px;
56+
margin-bottom: 1px;
57+
}
58+
59+
.btn-move {
60+
color: #fff;
61+
&.active {
62+
font-weight: bold;
63+
color: $green;
64+
}
65+
}
66+
}
67+
}
68+
}
69+
70+
.status-message {
71+
margin-bottom: 30px;
72+
font-size: 1.2rem;
73+
font-weight: lighter;
74+
span {
75+
font-weight: normal;
76+
}
77+
}
78+
79+
.btn-reset {
80+
font-size: 0.8rem;
81+
color: #fff;
82+
border-radius: 15px;
83+
padding: 12px 18px;
84+
margin-top: 25px;
85+
transition: all 0.2s;
86+
background-color: $blue;
87+
box-shadow: 0px 0px 0px 1px $orange;
88+
&.active {
89+
background-color: $orange;
90+
box-shadow: none;
91+
}
92+
}
93+
2294
.board {
2395
.board-row {
2496
display: flex;
2597
flex-direction: row;
26-
border-bottom: 2px solid #000;
98+
border-bottom: 2px solid #fff;
2799
&:last-child {
28100
border-bottom: none;
29101
}
30102
.square {
31103
width: 80px;
32104
height: 80px;
33-
border-right: 2px solid #000;
105+
border-right: 2px solid #fff;
34106
font-size: 2.5rem;
35107
padding: 0;
36108
overflow: hidden;
37109
transition: all 0.2s;
38110
&:last-child {
39111
border-right: none;
40112
}
113+
&.winning {
114+
animation: scaleText 1.2s infinite;
115+
@keyframes scaleText {
116+
0% {
117+
transform: 2.5rem;
118+
}
119+
50% {
120+
font-size: 3.5rem;
121+
}
122+
100% {
123+
font-size: 2.5rem;
124+
}
125+
}
126+
}
127+
}
128+
}
129+
}
130+
131+
.bg-balls {
132+
position: fixed;
133+
top: 0;
134+
left: 0;
135+
right: 0;
136+
bottom: 0;
137+
min-width: 100%;
138+
z-index: -1;
139+
140+
&:before,
141+
&:after {
142+
content: '';
143+
position: absolute;
144+
width: 150px;
145+
height: 150px;
146+
border-radius: 50%;
147+
}
148+
149+
&:before {
150+
background-color: $orange;
151+
right: -75px;
152+
bottom: -75px;
153+
@media screen and (min-width: 476px) {
154+
width: 220px;
155+
height: 220px;
156+
right: -110px;
157+
bottom: -110px;
158+
}
159+
}
160+
161+
&:after {
162+
background-color: $green;
163+
top: -75px;
164+
left: -75px;
165+
@media screen and (min-width: 476px) {
166+
width: 220px;
167+
height: 220px;
168+
top: -110px;
169+
left: -110px;
41170
}
42171
}
43172
}

0 commit comments

Comments
 (0)