Skip to content

Commit

Permalink
feat(status-display): added status display
Browse files Browse the repository at this point in the history
  • Loading branch information
jnmorse committed May 17, 2019
1 parent b7f13c2 commit b2e532c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { Provider } from 'react-redux'
import store from '../../store'

import Layout from '../Layout'
import StatusDisplay from '../StatusDisplay'

const App = () => (
<Provider store={store}>
<Layout title="Connect Four" subtitle={() => <p>Under Construction</p>}>
<Layout title="Connect Four">
<StatusDisplay />
<p>This is where my board will go eventually</p>
</Layout>
</Provider>
Expand Down
4 changes: 4 additions & 0 deletions src/components/StatusDisplay/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { connect } from 'react-redux'
import StatusDisplay from './status-display'

export default connect(({ status }) => ({ status }))(StatusDisplay)
18 changes: 18 additions & 0 deletions src/components/StatusDisplay/status-display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import PropTypes from 'prop-types'

import { root } from './status-display.module.css'

const StatusDisplay = ({ status }) => {
if (status) {
return <div className={root}>{status}</div>
}

return null
}

StatusDisplay.propTypes = {
status: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]).isRequired
}

export default StatusDisplay
6 changes: 6 additions & 0 deletions src/components/StatusDisplay/status-display.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.root {
font-size: 1.2em;
line-height: 2em;
background-color: green;
text-align: center;
}
1 change: 0 additions & 1 deletion src/reducers/game-reducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { GAME_WON } = require('../actions/types')

export const defaultState = {
status: false,
board: Array(7).fill(Array(6).fill(0))
}

Expand Down
2 changes: 2 additions & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { combineReducers } from 'redux'

import gameReducer from './game-reducer'
import statusReducer from './status-reducer'

export default combineReducers({
status: statusReducer,
game: gameReducer
})
7 changes: 7 additions & 0 deletions src/reducers/status-reducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function statusReducer(state = false, action) {
switch (action.type) {
default: {
return state
}
}
}

0 comments on commit b2e532c

Please sign in to comment.