@allons-y/course-kit 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  <script webc:setup>
2
2
  /**
3
- * The home page's opening band: this week's topics, the next class, what
3
+ * The home page's opening band: the next class with a link to its week, what
4
4
  * is due soon (date first) and the week-by-week progress, side by side as space allows. Hidden until its script has judged "today" in the
5
5
  * campus zone. Wording comes from `copy.home` and `copy.schedule`.
6
6
  * @prop {object[]} [weeks] `scheduleWeeks` output; built from the page's lessons, schedule, decks and demos when left out
@@ -20,37 +20,22 @@
20
20
  weekday: meeting.weekday,
21
21
  date: meeting.date,
22
22
  title: firstTopic(meeting),
23
- slides: meeting.slides ?? "",
24
23
  })),
25
24
  );
26
- /** Each week that holds class: its number, its topics as plain text, and its first and last class day. */
27
- const weekSummaries = (weeks) =>
28
- (weeks ?? []).flatMap((week) => {
29
- const held = (week.meetings ?? []).filter((meeting) => !meeting.noClass && meeting.iso);
30
- if (!held.length) return [];
31
- const topics = [...new Set(held.flatMap((meeting) => meeting.topics ?? []).map((topic) => String(topic).replace(/<[^>]+>/g, "").trim()))].filter(Boolean);
32
- return [{ week: week.week, topics, from: held[0].iso, to: held.at(-1).iso, fromDate: held[0].date, toDate: held.at(-1).date }];
33
- });
34
- /** The script's data: meetings, weeks and deadlines, safe inside a <script> element. */
25
+ /** The script's data: meetings and deadlines, safe inside a <script> element. */
35
26
  const nowData = (weeks, schedule, copy) =>
36
- JSON.stringify({ meetings: flatMeetings(weeks), weeks: weekSummaries(weeks), deadlines: courseDeadlines(weeks, schedule, copy) }).replaceAll("<", "\\u003c");
27
+ JSON.stringify({ meetings: flatMeetings(weeks), deadlines: courseDeadlines(weeks, schedule, copy) }).replaceAll("<", "\\u003c");
37
28
  /** Every class date in a week, for the progress track. */
38
29
  const datesOf = (week) => (week?.meetings ?? []).map((meeting) => meeting.iso).filter(Boolean).join(" ");
39
30
  </script>
40
31
  <section webc:root="override" class="course-now screen-only" aria-labelledby="course-now-heading" data-course-now webc:if="(weeks ?? defaultWeeks)?.length" hidden>
41
32
  <h2 id="course-now-heading" class="sr-only" @text="$data.copy.home.heading"></h2>
42
- <div class="this-week" data-this-week hidden>
43
- <h2 data-week-label></h2>
44
- <p class="when" data-week-when></p>
45
- <ul role="list" data-week-topics></ul>
46
- <p><a data-week-link><span @text="$data.copy.home.seeWeek"></span> <span aria-hidden="true">→</span></a></p>
47
- </div>
48
33
  <div class="now-card on-accent" data-now-card hidden>
49
34
  <p class="label" data-now-label></p>
50
35
  <p class="when" data-now-when></p>
51
36
  <p class="topic" data-now-title></p>
52
37
  <p class="actions">
53
- <a class="primary" data-now-slides hidden><span @text="$data.copy.home.openSlides"></span> <span aria-hidden="true">→</span></a>
38
+ <a class="primary" :href="scheduleUrl ?? '/schedule/'" data-now-week><span @text="$data.copy.home.seeWeek"></span> <span aria-hidden="true">→</span></a>
54
39
  </p>
55
40
  </div>
56
41
  <div class="coming-up" data-coming-up>
@@ -90,7 +75,7 @@
90
75
  const campusToday = () => new Date().toLocaleDateString("en-CA", { timeZone: document.documentElement.dataset.timezone });
91
76
  const { t } = window.ckCopy;
92
77
  const today = campusToday();
93
- const { meetings, weeks: weekList, deadlines } = JSON.parse(root.querySelector("[data-course-now-data]").textContent);
78
+ const { meetings, deadlines } = JSON.parse(root.querySelector("[data-course-now-data]").textContent);
94
79
  const DAY_MS = 86_400_000;
95
80
  const day = (iso) => Date.parse(`${iso}T00:00:00Z`);
96
81
  const inDays = (iso) => Math.round((day(iso) - day(today)) / DAY_MS);
@@ -103,33 +88,12 @@
103
88
  root.querySelector("[data-now-label]").textContent = t("home", label);
104
89
  root.querySelector("[data-now-when]").textContent = t("home", "when", { week: next.week, weekday: next.weekday, date: next.date });
105
90
  root.querySelector("[data-now-title]").textContent = next.title;
106
- const slides = root.querySelector("[data-now-slides]");
107
- if (next.slides) {
108
- slides.href = next.slides;
109
- slides.hidden = false;
110
- }
91
+ // The rendered href carries any path prefix; only the week's anchor is added here.
92
+ const week = root.querySelector("[data-now-week]");
93
+ week.href = `${week.getAttribute("href").split("#")[0]}#week-${next.week}`;
111
94
  card.hidden = false;
112
95
  }
113
96
 
114
- // This week: the week whose classes are not over yet. It is "this week" from the
115
- // Monday of its first class, "next week" before that, and the first week before the term.
116
- const current = weekList.find((week) => week.to >= today);
117
- if (current) {
118
- const monday = day(current.from) - ((new Date(day(current.from)).getUTCDay() + 6) % 7) * DAY_MS;
119
- const label = day(today) >= monday ? "weekThis" : weekList[0] === current ? "weekFirst" : "weekNext";
120
- root.querySelector("[data-week-label]").textContent = t("home", label);
121
- root.querySelector("[data-week-when]").textContent =
122
- current.from === current.to ? t("home", "weekWhenDay", { week: current.week, date: current.fromDate }) : t("home", "weekWhen", { week: current.week, from: current.fromDate, to: current.toDate });
123
- const topics = root.querySelector("[data-week-topics]");
124
- for (const topic of current.topics) {
125
- const row = document.createElement("li");
126
- row.textContent = topic;
127
- topics.append(row);
128
- }
129
- root.querySelector("[data-week-link]").href = `/schedule/#week-${current.week}`;
130
- root.querySelector("[data-this-week]").hidden = false;
131
- }
132
-
133
97
  // Coming up: a week ahead, at least three, and always the next test.
134
98
  const up = deadlines.filter((item) => item.iso >= today);
135
99
  let shown = up.filter((item) => inDays(item.iso) <= 7);
@@ -200,9 +164,9 @@
200
164
  display: none;
201
165
  }
202
166
 
203
- /* This week, the next class and what is coming up share a row while they
204
- fit, and wrap one at a time as the page narrows; a panel alone on a
205
- row fills it. The progress track always has a row of its own. */
167
+ /* The next class and what is coming up share a row while they fit, and
168
+ wrap as the page narrows; a panel alone on a row fills it. The progress
169
+ track always has a row of its own. */
206
170
  :host {
207
171
  display: flex;
208
172
  flex-wrap: wrap;
@@ -215,7 +179,6 @@
215
179
  }
216
180
  }
217
181
 
218
- .this-week,
219
182
  .coming-up {
220
183
  flex: 1 1 16rem;
221
184
  }
@@ -224,44 +187,6 @@
224
187
  flex: 1.5 1 20rem;
225
188
  }
226
189
 
227
- .this-week {
228
- display: grid;
229
- gap: calc(var(--gutter) * 3);
230
- align-content: start;
231
- padding: calc(var(--content-space) * 1.4);
232
- border: var(--thin-border-width) solid var(--color-border);
233
- border-radius: calc(var(--standard-border-radius) * 4);
234
-
235
- &[hidden] {
236
- display: none;
237
- }
238
-
239
- p {
240
- margin: 0;
241
- }
242
-
243
- .when {
244
- color: var(--color-text-muted);
245
- font-size: max(var(--base-font-size), 0.875em);
246
- }
247
-
248
- ul {
249
- display: grid;
250
- gap: calc(var(--gutter) * 2);
251
- margin: 0;
252
- padding: 0;
253
- list-style: none;
254
- font-weight: var(--font-weight--semi-bold);
255
- }
256
-
257
- p > a {
258
- display: inline-flex;
259
- align-items: center;
260
- min-block-size: var(--target-min);
261
- font-weight: var(--font-weight--semi-bold);
262
- }
263
- }
264
-
265
190
  .now-card {
266
191
  display: flex;
267
192
  flex-direction: column;
package/lib/copy.js CHANGED
@@ -63,12 +63,6 @@ export const COPY_DEFAULTS = {
63
63
  nextLabel: "Next class",
64
64
  firstLabel: "First class",
65
65
  when: "Week {week} · {weekday}, {date}",
66
- openSlides: "Open the slides",
67
- weekThis: "This week",
68
- weekNext: "Next week",
69
- weekFirst: "First week",
70
- weekWhen: "Week {week} · {from} to {to}",
71
- weekWhenDay: "Week {week} · {date}",
72
66
  seeWeek: "See the week",
73
67
  comingUp: "Coming up",
74
68
  fullSchedule: "Full schedule",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allons-y/course-kit",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Shared layouts, components, styles and build helpers for Eleventy course sites.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "Cassondra Roberts <castastrophe@users.noreply.github.com> (https://allons-y.studio)",