Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#207: Calendars Page #286

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
"clean:client": "rimraf dist",
"clean:server": "rimraf dist-server",
"clean:all": "npm run clean:client && npm run clean:server && rimraf bower_components && rimraf node_modules",
"build:webpack-client": "NODE_ENV=production webpack --config webpack.config.prod.js --bail",
"build:webpack-server": "NODE_ENV=production webpack --config webpack.config.server.prod.js --bail",
"build:webpack-client": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --bail",
"build:webpack-server": "cross-env NODE_ENV=production webpack --config webpack.config.server.prod.js --bail",
"build:client": "npm run clean:client && npm run build:webpack-client",
"build:server": "npm run clean:server && npm run build:webpack-server",
"build": "npm run clean:client && npm run clean:server && concurrently \"npm run build:client\" \"npm run build:server\"",
"start": "NODE_ENV=production NODE_PATH=./src node src/server/index.js",
"dev:server": "NODE_PATH=./src nodemon src/server/index.js",
"build": "npm run clean:client && npm run clean:server && concurrently \"npm run build:webpack-client\" \"npm run build:webpack-server\"",
"start": "cross-env NODE_ENV=production NODE_PATH=./src node src/server/index.js",
"dev:server": "cross-env NODE_PATH=./src nodemon src/server/index.js",
"dev": "node src/server/devServer.js",
"eslint:ci": "eslint src/ --ext .js,.jsx --max-warnings 10",
"eslint": "eslint src/ --ext .js,.jsx || true",
"eslint:fix": "eslint src/ --ext .js,.jsx --fix || true",
"reinstall": "npm run clean:all && bower i && npm i",
"postinstall": "bower install && npm run build",
"ngrok": "ngrok http 8888",
"tape-tests": "NODE_PATH=./src tape -r './src/tests/index.js' 'src/**/tests/**/*.js'",
"tape-tests": "cross-env NODE_PATH=./src tape -r './src/tests/index.js' 'src/**/tests/**/*.js'",
"test": "npm run tape-tests | tap-spec",
"test:dot": "npm run tape-tests | tap-dot || true"
},
Expand Down Expand Up @@ -55,10 +55,11 @@
"babel-preset-es2015-node6": "^0.3.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-2": "^6.17.0",
"bower": "^1.7.9",
"bower": "^1.8.0",
"chalk": "^1.1.3",
"compression": "^1.6.2",
"concurrently": "^2.1.0",
"cross-env": "^5.0.0",
"css-loader": "0.14.5",
"eslint": "~2.11.1",
"eslint-plugin-react": "^5.1.1",
Expand All @@ -80,12 +81,12 @@
"react-transform-hmr": "^1.0.2",
"redbox-react": "^1.3.1",
"redux-logger": "^2.7.0",
"rimraf": "^2.4.4",
"shortid": "^2.2.6",
"rimraf": "^2.6.1",
"sass-loader": "^4.0.2",
"shortid": "^2.2.6",
"style-loader": "^0.13.0",
"tap-dot": "^1.0.5",
"svg-inline-loader": "^0.7.1",
"tap-dot": "^1.0.5",
"tap-spec": "^4.1.1",
"tape": "^4.6.2",
"url-loader": "^0.5.7",
Expand Down
37 changes: 37 additions & 0 deletions src/client/calendar/Calendars.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Component from 'react-pure-render/component'
import './Calendars.scss'
import React from 'react'

class Calendars extends Component {
render() {
const {
calendars
} = this.props

const calendarsComponents = Object.keys(calendars)
.map(key => <li key={key}>
<a href={`calendars/${key.replace('cal-', '')}`}>
{calendars[key].name}
</a>
{calendars[key].description && <p>Description: <b>{calendars[key].description}</b></p>}
</li>)

return (
<div style={{display: 'flex'}}>
<div>Calendars:</div>
<ul className='Calendars'>
{calendarsComponents}
</ul>
</div>
)
}
}

import { connect } from 'react-redux'
import { getAllCalendars } from 'shared/reducers/reducer.js'

export default connect(
(state, ownProps) => ({
calendars: getAllCalendars(state)
})
)(Calendars)
22 changes: 22 additions & 0 deletions src/client/calendar/Calendars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.Calendars {
list-style-type: none;

li {
height: 8rem;
width: 20rem;
float: left;
text-align: center;
margin-right: 1rem;
border: 0.1rem solid #aaa;
padding: 0 1rem;
}

li a {
text-decoration: none;
text-transform: uppercase;
}

li a:hover {
font-weight: bold;
}
}
2 changes: 2 additions & 0 deletions src/client/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Dev from 'Dev'
import MtbCalendar from 'calendar/MtbCalendar'
import NcncaCalendar from 'calendar/NcncaCalendar'
import NcncaDraftCalendar from 'calendar/NcncaDraftCalendar'
import Calendars from 'calendar/Calendars.jsx'
import EventDetails from 'calendar/events/event-details/EventDetails.jsx'
import AdminIndex from 'admin/index'
import CreateEventId from 'admin/events/CreateEventId.jsx'
Expand All @@ -14,6 +15,7 @@ const routes = (
<Route path="/" component={App}>
<IndexRoute component={Home} />
<Route path="/dev" component={Dev} />
<Route path="/calendars" component={Calendars} />
<Route path="/calendars/norcal-mtb" component={MtbCalendar} />
<Route path="/calendars/ncnca-2017-draft" component={NcncaDraftCalendar} />
<Route path="/calendars/:calendarId" component={NcncaCalendar} />
Expand Down
4 changes: 3 additions & 1 deletion src/shared/reducers/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,11 @@ const eventsByDate = (events) => {
const getEvent = (state, id) => state.events[id]

const getCalendar = (state, props) => state.calendars[props.calendarId]
const getAllCalendars = (state) => state.calendars

const getAllEvents = state => state.events
const getEventIdsForCalendar = (state, props) => getCalendar(state, props).eventsIds


const getEventsForCalendar = createSelector(
getEventIdsForCalendar,
getAllEvents,
Expand All @@ -244,6 +245,7 @@ export {
getCalendar,
getEventsForCalendar,
getEventsByDateForCalendar,
getAllCalendars
}

export default rootReducer
33 changes: 32 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,13 @@ core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"

cross-env@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.0.0.tgz#565ccae4d09676441a5087f406fe7661a29c931b"
dependencies:
cross-spawn "^5.1.0"
is-windows "^1.0.0"

cross-spawn@^0.2.9:
version "0.2.9"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-0.2.9.tgz#bd67f96c07efb6303b7fe94c1e979f88478e0a39"
Expand All @@ -1286,6 +1293,14 @@ cross-spawn@^3.0.0:
lru-cache "^4.0.1"
which "^1.2.9"

cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
dependencies:
lru-cache "^4.0.1"
shebang-command "^1.2.0"
which "^1.2.9"

[email protected]:
version "2.0.5"
resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8"
Expand Down Expand Up @@ -2464,6 +2479,10 @@ is-utf8@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"

is-windows@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.1.tgz#310db70f742d259a16a369202b51af84233310d9"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
Expand Down Expand Up @@ -3665,12 +3684,18 @@ right-align@^0.1.1:
dependencies:
align-text "^0.1.1"

rimraf@2, rimraf@^2.2.8, rimraf@^2.4.4, rimraf@~2.5.0, rimraf@~2.5.1:
rimraf@2, rimraf@^2.2.8, rimraf@~2.5.0, rimraf@~2.5.1:
version "2.5.4"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
dependencies:
glob "^7.0.5"

rimraf@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d"
dependencies:
glob "^7.0.5"

[email protected]:
version "0.2.0"
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-0.2.0.tgz#2bf198bde167cacfa51c0a928e84b68bbe171fce"
Expand Down Expand Up @@ -3759,6 +3784,12 @@ [email protected]:
version "2.2.6"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.2.6.tgz#17ddeddc5f722fb66501658895461977867315ba"

shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
dependencies:
shebang-regex "^1.0.0"

shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
Expand Down