Skip to content
Snippets Groups Projects
Commit 674850c4 authored by Kevin Lin's avatar Kevin Lin :sparkles:
Browse files

Represent schedules as collections

parent 4fc646e9
No related branches found
No related tags found
No related merge requests found
...@@ -37,11 +37,17 @@ footer_content: ...@@ -37,11 +37,17 @@ footer_content:
# Collections for website data # Collections for website data
collections: collections:
- modules announcements:
- announcements modules:
- staffers schedules:
staffers:
# Default layouts for each collection type # Default layouts for each collection type
defaults: defaults:
- scope:
path: ''
type: announcements
values:
layout: announcement
- scope: - scope:
path: '' path: ''
type: modules type: modules
...@@ -49,9 +55,9 @@ defaults: ...@@ -49,9 +55,9 @@ defaults:
layout: module layout: module
- scope: - scope:
path: '' path: ''
type: announcements type: schedules
values: values:
layout: announcement layout: schedule
- scope: - scope:
path: '' path: ''
type: staffers type: staffers
......
{% capture schedule_workspace %}
{% comment %}
Return the HTML for the schedule corresponding to the given data.
Parameters:
`data` (site data): site data file containing the requested schedule.
`interval` (integer): time in minutes between each timeline tick.
`row_height` (integer): row height in pixels.
`min_day_width` (integer): minimum width reserved for each day in pixels.
`header_tag` (string): HTML tag for the schedule-header, default: 'h3'.
{% endcomment %}
{% assign header_tag = include.header_tag | default: 'h3' %}
{% assign timeline_first = include.data.timeline | first %}
{% capture offset %}{% include minutes.liquid time=timeline_first %}{% endcapture %}
{% endcapture %}{% assign schedule_workspace = '' %}
<div class="schedule">
<ul class="schedule-timeline" style="margin-top: {{ include.row_height }}px; min-width: {{ include.data.schedule | size | times: include.min_day_width }}px">
{% for time in include.data.timeline %}
<li class="schedule-time" style="height: {{ include.row_height }}px">
{{- time -}}
</li>
{% endfor %}
</ul>
<ul class="schedule-group">
{% for day in include.data.schedule %}
<li class="schedule-day" style="min-width: {{ include.min_day_width }}px">
<{{ header_tag }} class="schedule-header" style="height: {{ include.row_height }}px">{{ day.name }}</{{ header_tag }}>
{% if day.events %}
<ul class="schedule-events" style="height: {{ include.data.timeline | size | times: include.row_height }}px">
{% for event in day.events %}
{%- capture start -%}{% include minutes.liquid time=event.start %}{%- endcapture -%}
{%- capture end -%}{% include minutes.liquid time=event.end %}{%- endcapture -%}
{%- assign top = start | minus: offset | times: include.row_height | divided_by: include.interval -%}
{%- assign height = end | minus: start | times: include.row_height | divided_by: include.interval -%}
<li class="schedule-event {{ event.class }}"
style="top: {{ top }}px; height: {{ height }}px;">
<div class="name">{{ event.name }}</div>
<div class="time">{{ event.start }}–{{ event.end }}</div>
<div class="location">{{ event.location }}</div>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% assign start_time = page.timeline | first %}
{% capture offset %}{% include minutes.liquid time=start_time %}{% endcapture %}
<div class="schedule">
<ul class="schedule-timeline" style="min-width: {{ page.schedule | size | times: 130 }}px">
{% for time in page.timeline %}
<li class="schedule-time">{{ time }} </li>
{% endfor %}
</ul>
<ul class="schedule-group">
{% for day in page.schedule %}
<li class="schedule-day">
<h2 class="schedule-header">{{ day.name }}</h2>
{% if day.events %}
<ul class="schedule-events" style="height: {{ page.timeline | size | times: 40 }}px">
{% for event in day.events %}
{% capture start %}{% include minutes.liquid time=event.start %}{% endcapture %}
{% capture end %}{% include minutes.liquid time=event.end %}{% endcapture %}
{% assign top = start | minus: offset | times: 40 | divided_by: 30 %}
{% assign height = end | minus: start | times: 40 | divided_by: 30 %}
<li class="schedule-event {% if event.class %}{{ event.class }}{% else %}{{ event.name | slugify }}{% endif %}"
style="top: {{ top }}px; height: {{ height }}px;">
<div class="name">{{ event.name }}</div>
<div class="time">{{ event.start }}–{{ event.end }}</div>
<div class="location">{{ event.location }}</div>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
} }
.schedule-timeline { .schedule-timeline {
margin-bottom: 0; margin: 40px auto 0;
position: absolute; position: absolute;
width: 100%; width: 100%;
} }
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
.schedule-time { .schedule-time {
@extend .fs-2; @extend .fs-2;
color: $grey-dk-000; color: $grey-dk-000;
height: 40px;
margin: 0; margin: 0;
padding: $sp-2; padding: $sp-2;
position: relative; position: relative;
...@@ -48,6 +49,7 @@ ...@@ -48,6 +49,7 @@
border-left: $border $border-color; border-left: $border $border-color;
flex: 1 0 0; flex: 1 0 0;
margin: 0; margin: 0;
min-width: 130px;
&:first-of-type { &:first-of-type {
border-left: 0; border-left: 0;
...@@ -58,6 +60,8 @@ ...@@ -58,6 +60,8 @@
@extend .fw-700; @extend .fw-700;
align-items: center; align-items: center;
display: flex; display: flex;
font-size: 18px !important;
height: 40px;
justify-content: center; justify-content: center;
margin: 0; margin: 0;
} }
......
timeline: [ ---
'9:00 AM', '9:30 AM', '10:00 AM', '10:30 AM', '11:00 AM', '11:30 AM', timeline:
'12:00 PM', '12:30 PM', '1:00 PM', '1:30 PM', '2:00 PM', '2:30 PM', - '9:00 AM'
'3:00 PM', '3:30 PM', '4:00 PM', '4:30 PM', '5:00 PM', '5:30 PM', - '9:30 AM'
] - '10:00 AM'
- '10:30 AM'
- '11:00 AM'
- '11:30 AM'
- '12:00 PM'
- '12:30 PM'
- '1:00 PM'
- '1:30 PM'
- '2:00 PM'
- '2:30 PM'
- '3:00 PM'
- '3:30 PM'
- '4:00 PM'
- '4:30 PM'
- '5:00 PM'
- '5:30 PM'
schedule: schedule:
- name: Monday - name: Monday
events: events:
- name: Lecture - name: Lecture
class: lecture
start: 9:30 AM start: 9:30 AM
end: 10:30 AM end: 10:30 AM
location: 150 Wheeler location: 150 Wheeler
- name: Section - name: Section
class: section
start: 11:30 AM start: 11:30 AM
end: 12:30 PM end: 12:30 PM
location: 310 Soda location: 310 Soda
- name: Office Hours - name: Office Hours
class: office-hours
start: 12:30 PM start: 12:30 PM
end: 2:00 PM end: 2:00 PM
location: 271 Soda location: 271 Soda
...@@ -25,17 +37,14 @@ schedule: ...@@ -25,17 +37,14 @@ schedule:
- name: Wednesday - name: Wednesday
events: events:
- name: Lecture - name: Lecture
class: lecture
start: 9:30 AM start: 9:30 AM
end: 10:30 AM end: 10:30 AM
location: 150 Wheeler location: 150 Wheeler
- name: Section - name: Section
class: section
start: 11:30 AM start: 11:30 AM
end: 12:30 PM end: 12:30 PM
location: 310 Soda location: 310 Soda
- name: Office Hours - name: Office Hours
class: office-hours
start: 12:30 PM start: 12:30 PM
end: 2:00 PM end: 2:00 PM
location: 271 Soda location: 271 Soda
...@@ -43,17 +52,15 @@ schedule: ...@@ -43,17 +52,15 @@ schedule:
- name: Friday - name: Friday
events: events:
- name: Lecture - name: Lecture
class: lecture
start: 9:30 AM start: 9:30 AM
end: 10:30 AM end: 10:30 AM
location: 150 Wheeler location: 150 Wheeler
- name: Section - name: Section
class: section
start: 11:30 AM start: 11:30 AM
end: 12:30 PM end: 12:30 PM
location: 310 Soda location: 310 Soda
- name: Office Hours - name: Office Hours
class: office-hours
start: 12:30 PM start: 12:30 PM
end: 2:00 PM end: 2:00 PM
location: 271 Soda location: 271 Soda
---
...@@ -7,4 +7,6 @@ description: The weekly event schedule. ...@@ -7,4 +7,6 @@ description: The weekly event schedule.
# Weekly Schedule # Weekly Schedule
{% include schedule.html data=site.data.schedule.weekly interval=30 row_height=40 min_day_width=130 %} {% for schedule in site.schedules %}
{{ schedule }}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment