Skip to content

Commit 06f3093

Browse files
committed
make endscreen and temporarily mount in GameScreen
1 parent 9cca064 commit 06f3093

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

code/src/components/EndScreen.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react'
2+
import styled from 'styled-components'
3+
import { useSelector} from 'react-redux'
4+
import "nes.css/css/nes.min.css"
5+
6+
const EndScreen = () => {
7+
const lastDescription = useSelector((store) => store.games.gameStatus)
8+
9+
return (
10+
<EndContainer>
11+
<div class="nes-container is-rounded is-dark">
12+
<Header>{lastDescription.description}</Header>
13+
<CssCredit>CSS from <a href="https://nostalgic-css.github.io/NES.css/">Ness.css</a>
14+
</CssCredit>
15+
</div>
16+
</EndContainer>
17+
)
18+
}
19+
20+
const EndContainer = styled.section `
21+
display: flex;
22+
flex-direction: column;
23+
align-items: center;
24+
justify-content: center;
25+
border-style: inset;
26+
margin: 0 auto;
27+
`
28+
const Header = styled.h1`
29+
font-size: 18px;
30+
letter-spacing: 1px;
31+
`
32+
const CssCredit = styled.p`
33+
margin-top: 50px;
34+
`
35+
export default EndScreen

code/src/components/GameScreen.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import styled from 'styled-components/macro'
44

55
import { games, CarryOnGame } from '../reducers/games'
66
import { Container } from '../styling/GlobalStyling'
7+
import EndScreen from './EndScreen'
78

89
const GameScreen = () => {
910
const userName = useSelector(store => store.games.username)
1011
const actions = useSelector(store => store.games.gameStatus.actions)
1112
const history = useSelector(store => store.games.history)
12-
// console.log(history) // history is object
1313

1414
const dispatch = useDispatch()
1515

@@ -20,7 +20,11 @@ const GameScreen = () => {
2020
//enables you to read the value of a property located deep within
2121
//a chain of connected objects without having to check that each reference
2222
//in the chain is valid.
23-
23+
/* if (actions.length === 0) {
24+
return (
25+
<EndScreen />
26+
)
27+
} */
2428
return (
2529
<Container>
2630
<h3>{userName.description}</h3>
@@ -42,6 +46,7 @@ const GameScreen = () => {
4246
>
4347
Go back
4448
</button>
49+
<EndScreen />
4550
</Container>
4651
)
4752
}

0 commit comments

Comments
 (0)