From edece6473321f5510e22d7375a6679701acc240f Mon Sep 17 00:00:00 2001 From: Zac Wood Date: Sat, 11 May 2019 17:02:56 -0400 Subject: [PATCH] Polishing Calendar features --- .prettierrc | 8 +++ schedules/app/javascript/src/Calendar.jsx | 4 ++ .../app/javascript/src/InstructorCard.jsx | 15 +++++ .../app/javascript/src/InstructorList.jsx | 8 +++ schedules/app/javascript/src/SearchList.jsx | 14 +++++ schedules/app/javascript/src/Toolbar.jsx | 61 +++++++++++++++++++ schedules/app/views/about/index.html.erb | 21 +++++++ schedules/db/seeds.rb | 1 + schedules/package.json | 1 + schedules/yarn.lock | 15 ++++- 10 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 .prettierrc create mode 100644 schedules/app/javascript/src/InstructorCard.jsx create mode 100644 schedules/app/javascript/src/InstructorList.jsx create mode 100644 schedules/app/javascript/src/SearchList.jsx create mode 100644 schedules/app/javascript/src/Toolbar.jsx create mode 100644 schedules/app/views/about/index.html.erb diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..79dfc32 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "printWidth": 120, + "tabWidth": 4, + "singleQuote": true, + "useTabs": false, + "jsxBracketSameLine": true, + "trailingComma": "es5" +} diff --git a/schedules/app/javascript/src/Calendar.jsx b/schedules/app/javascript/src/Calendar.jsx index 4bb2531..551d837 100644 --- a/schedules/app/javascript/src/Calendar.jsx +++ b/schedules/app/javascript/src/Calendar.jsx @@ -1,7 +1,9 @@ import React from 'react'; import BigCalendar from 'react-big-calendar'; +import Toolbar from 'src/Toolbar'; import moment from 'moment'; import '!style-loader!css-loader!react-big-calendar/lib/css/react-big-calendar.css'; +import withSizes from 'react-sizes'; const localizer = BigCalendar.momentLocalizer(moment); @@ -11,6 +13,7 @@ const Calendar = props => ( localizer={localizer} events={props.events} title="" + components={{ toolbar: Toolbar }} defaultView="week" views={['week', 'day']} startAccessor="start" @@ -18,6 +21,7 @@ const Calendar = props => ( defaultDate={moment('2019-01-14').toDate()} formats={{ dayFormat: (date, culture, localizer) => localizer.format(date, 'ddd', culture), + dayHeaderFormat: (date, culture, localizer) => localizer.format(date, 'ddd', culture), dayRangeHeaderFormat: () => '', }} style={{ height: '75vh' }} diff --git a/schedules/app/javascript/src/InstructorCard.jsx b/schedules/app/javascript/src/InstructorCard.jsx new file mode 100644 index 0000000..6b16441 --- /dev/null +++ b/schedules/app/javascript/src/InstructorCard.jsx @@ -0,0 +1,15 @@ +import React from 'react'; + +export default class InstructorCard extends React.Component { + render() { + const inst = this.props.instructor; + return ( +
+ + + {this.props.instructor.name} + +
+ ); + } +} diff --git a/schedules/app/javascript/src/InstructorList.jsx b/schedules/app/javascript/src/InstructorList.jsx new file mode 100644 index 0000000..2845e45 --- /dev/null +++ b/schedules/app/javascript/src/InstructorList.jsx @@ -0,0 +1,8 @@ +import React from 'react'; +import InstructorCard from 'src/InstructorCard'; + +export default class InstructorList extends React.Component { + render() { + return
{this.props.instructors && this.props.instructors.map(i => )}
; + } +} diff --git a/schedules/app/javascript/src/SearchList.jsx b/schedules/app/javascript/src/SearchList.jsx new file mode 100644 index 0000000..a0471fc --- /dev/null +++ b/schedules/app/javascript/src/SearchList.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import CourseList from 'src/CourseList'; +import InstructorList from 'src/InstructorList'; + +export default class SearchList extends React.Component { + render() { + return ( +
+ + +
+ ); + } +} diff --git a/schedules/app/javascript/src/Toolbar.jsx b/schedules/app/javascript/src/Toolbar.jsx new file mode 100644 index 0000000..597fc16 --- /dev/null +++ b/schedules/app/javascript/src/Toolbar.jsx @@ -0,0 +1,61 @@ +import React from 'react'; +import BigCalendar from 'react-big-calendar'; +import Toolbar from 'react-big-calendar/lib/Toolbar'; +import '!style-loader!css-loader!react-big-calendar/lib/css/react-big-calendar.css'; +import withSizes from 'react-sizes'; + +class CustomToolbar extends Toolbar { + render() { + const { label, isMobile } = this.props; + if (isMobile && label === '') { + this.view('day'); + } + return ( +
+ {!isMobile && ( + + + + + )} + + {this.props.label} + + {this.props.view === 'day' && ( + + {this.props.label !== 'Sun' && ( + + )} + {this.props.label !== 'Sat' && ( + + )} + + )} +
+ ); + } + + navigate = action => { + console.log(action); + + this.props.onNavigate(action); + }; + + view = action => { + this.props.onView(action); + }; +} + +const mapSizesToProps = ({ width }) => ({ + isMobile: width < 1000, +}); + +export default withSizes(mapSizesToProps)(CustomToolbar); diff --git a/schedules/app/views/about/index.html.erb b/schedules/app/views/about/index.html.erb new file mode 100644 index 0000000..ca3222e --- /dev/null +++ b/schedules/app/views/about/index.html.erb @@ -0,0 +1,21 @@ +
+

 SRCT Schedules

+

Version 3.0

+
+ Last updated: 2:00am, 4/14/19 +
+ +

Thank you to our contributors who make Schedules possible!

+ +Zac Wood, David Haynes, Zach Perkins, Gilberto Barrientos, Michael Bailey, Nic Anderson + +

+ +

Questions?

+All data in Schedules is sourced from data made publicly avaiable by GMU. + + +Please contact SRCT at srct@gmu.edu with any other questions. diff --git a/schedules/db/seeds.rb b/schedules/db/seeds.rb index ec09a4c..9459b58 100644 --- a/schedules/db/seeds.rb +++ b/schedules/db/seeds.rb @@ -8,6 +8,7 @@ require 'httparty' require 'nokogiri' require 'json' require 'set' +require 'yaml/store' def parse_courses(subjects) courses = [] diff --git a/schedules/package.json b/schedules/package.json index b91a36e..cb5673c 100644 --- a/schedules/package.json +++ b/schedules/package.json @@ -14,6 +14,7 @@ "react": "^16.8.6", "react-big-calendar": "^0.20.4", "react-dom": "^16.8.6", + "react-sizes": "^2.0.0", "url-polyfill": "^1.1.3" }, "devDependencies": { diff --git a/schedules/yarn.lock b/schedules/yarn.lock index c793da8..735ca70 100644 --- a/schedules/yarn.lock +++ b/schedules/yarn.lock @@ -3276,6 +3276,11 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" +lodash.throttle@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" + integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ= + lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" @@ -4615,7 +4620,7 @@ prop-types-extra@^1.0.1, prop-types-extra@^1.1.0: react-is "^16.3.2" warning "^3.0.0" -prop-types@^15.5.10, prop-types@^15.6.2, prop-types@^15.7.2: +prop-types@^15.5.10, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -4801,6 +4806,14 @@ react-overlays@^0.8.3: react-transition-group "^2.2.0" warning "^3.0.0" +react-sizes@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/react-sizes/-/react-sizes-2.0.0.tgz#c2100daf3bf74077fb410f09204340c1af5c1d4f" + integrity sha512-YNGPQGJTxNMD4wdFRmVmqlLZlwhETVW06H7dVbOjj+OV1ckz/gkH3/5MfRuSO8t99nMOmi+Uj14jkvG+zlP57w== + dependencies: + lodash.throttle "^4.1.1" + prop-types "^15.6.0" + react-transition-group@^2.2.0: version "2.8.0" resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-2.8.0.tgz#d6d8f635d81a0955b67348be5d017cff77d6c75f" -- GitLab