@allons-y/course-kit 0.1.0 → 0.3.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,8 +1,11 @@
1
1
  <script webc:setup>
2
2
  /**
3
- * The schedule page's header: the meeting line, the key dates, and a row
4
- * of jump links (Today, then one per month). Props are read in the
5
- * template, since a setup script cannot see them.
3
+ * The schedule page's header: the meeting line, the key dates, and a sticky
4
+ * row of one jump link per month, with the Hide past weeks toggle at its
5
+ * end. The month on screen is marked as the page scrolls. The row is
6
+ * sticky from 40em wide and static below it, where it would take too much
7
+ * of a phone's height. Props are read in the template, since a setup script
8
+ * cannot see them.
6
9
  * @prop {{ title: string, items: object[] }[]} [groups] `scheduleKeyDates`
7
10
  * output; built from the page's lessons, project and exam slot when left out
8
11
  * @prop {object[]} [weeks] `scheduleWeeks` output, for the month links;
@@ -13,10 +16,6 @@
13
16
  </script>
14
17
  <header webc:root="override" class="schedule-overview">
15
18
  <today-marker></today-marker>
16
- <eyebrow class="separators">
17
- <span @text="$data.term.label"></span>
18
- <span @text="$data.course.code"></span>
19
- </eyebrow>
20
19
  <h1 @text="$data.copy.scheduleOverview.schedule"></h1>
21
20
  <p class="meets" webc:if="$data.schedule?.meetings?.days?.length">
22
21
  <span @text="$data.schedule.meetings.days.length > 1 ? `${$data.schedule.meetings.days.slice(0, -1).join(', ')} & ${$data.schedule.meetings.days.at(-1)}` : $data.schedule.meetings.days[0]"></span>
@@ -38,13 +37,18 @@
38
37
  </div>
39
38
  </section>
40
39
 
41
- <nav class="schedule-jump" :aria-label="$data.copy.scheduleOverview.jumpTo" webc:if="scheduleMonths(weeks ?? defaultWeeks).length">
42
- <h2 @text="$data.copy.scheduleOverview.jumpTo"></h2>
43
- <ul role="list">
44
- <li><today-link :@label="$data.copy.schedule.today"></today-link></li>
45
- <li webc:for="entry of scheduleMonths(weeks ?? defaultWeeks)"><a :href="`#week-${entry.week}`" @text="entry.name"></a></li>
46
- </ul>
47
- </nav>
40
+ <div class="schedule-bar" data-schedule-bar webc:if="scheduleMonths(weeks ?? defaultWeeks).length">
41
+ <nav class="schedule-jump" :aria-label="$data.copy.scheduleOverview.jumpTo">
42
+ <h2 @text="$data.copy.scheduleOverview.jumpTo"></h2>
43
+ <ul role="list">
44
+ <li webc:for="entry of scheduleMonths(weeks ?? defaultWeeks)"><a :href="`#week-${entry.week}`" :data-first-week="entry.week" :data-last-week="entry.last" @text="entry.name"></a></li>
45
+ </ul>
46
+ </nav>
47
+ <div class="schedule-toggle" data-schedule-tools hidden>
48
+ <p class="schedule-status" data-schedule-status role="status"></p>
49
+ <button type="button" class="hide-past" data-hide-past aria-pressed="false" @text="$data.copy.schedule.hidePast"></button>
50
+ </div>
51
+ </div>
48
52
  </header>
49
53
 
50
54
  <style webc:scoped>
@@ -108,7 +112,56 @@
108
112
  }
109
113
  }
110
114
 
115
+ /* The row of month links and the toggle. From 40em it is sticky, pinned to the top of the page through the weeks: the header's own box is
116
+ dropped (`display: contents`) so the row's containing block is the whole page column, and the page's scroll-padding follows the row's height
117
+ (set by the script) so an anchor or a focused control is never under it. Below 40em it is a plain row, because on a phone it would take a
118
+ quarter of the screen. */
119
+ .schedule-bar {
120
+ display: flex;
121
+ flex-wrap: wrap;
122
+ align-items: center;
123
+ justify-content: space-between;
124
+ gap: 0.25rem var(--content-space);
125
+ margin-block: var(--content-space);
126
+
127
+ @media screen and (width >= 40em) {
128
+ position: sticky;
129
+ inset-block-start: 0;
130
+ z-index: 10;
131
+ margin-block: 0;
132
+ padding-block: 0.4rem;
133
+ background-color: var(--color-page);
134
+ border-block-end: var(--thin-border-width) solid var(--color-border-strong);
135
+ }
136
+ }
137
+
138
+ @media screen and (width >= 40em) {
139
+ :host {
140
+ display: contents;
141
+ }
142
+
143
+ :host > .schedule-bar + * {
144
+ margin-block-start: var(--content-space);
145
+ }
146
+ }
147
+
111
148
  .schedule-jump {
149
+ display: flex;
150
+ flex-wrap: wrap;
151
+ align-items: center;
152
+ gap: 0 var(--content-space);
153
+ min-inline-size: 0;
154
+
155
+ h2 {
156
+ margin: 0;
157
+ font-family: var(--sans-font);
158
+ font-size: var(--font-size-6);
159
+ font-weight: var(--font-weight--semi-bold);
160
+ letter-spacing: 0.08em;
161
+ text-transform: uppercase;
162
+ color: var(--color-text-muted);
163
+ }
164
+
112
165
  ul {
113
166
  display: flex;
114
167
  flex-wrap: wrap;
@@ -134,12 +187,140 @@
134
187
  background-color: var(--color-surface);
135
188
  border-color: var(--color-accent);
136
189
  }
190
+
191
+ /* The month on screen, set by the script as the page scrolls: a thick underline in the location accent. A shape, not a color alone, and
192
+ it changes no size, so nothing moves when the mark does. */
193
+ &[aria-current] {
194
+ text-decoration: underline;
195
+ text-decoration-color: var(--color-accent-secondary);
196
+ text-decoration-thickness: 0.2em;
197
+ text-underline-offset: 0.3em;
198
+ }
199
+ }
200
+ }
201
+
202
+ .schedule-toggle {
203
+ display: flex;
204
+ flex-wrap: wrap;
205
+ align-items: center;
206
+ gap: 0.25rem var(--content-space);
207
+
208
+ &[hidden] {
209
+ display: none;
210
+ }
211
+ }
212
+
213
+ /* The count beside the button when there is room; below 48em it is hidden from sight and still announced (role="status"). */
214
+ .schedule-status {
215
+ margin: 0;
216
+ color: var(--color-text-muted);
217
+
218
+ @media screen and (width < 48em) {
219
+ position: absolute;
220
+ inline-size: 1px;
221
+ block-size: 1px;
222
+ overflow: hidden;
223
+ clip-path: inset(50%);
224
+ white-space: nowrap;
225
+ }
226
+ }
227
+
228
+ .hide-past {
229
+ min-block-size: var(--target-min);
230
+ min-inline-size: var(--target-min);
231
+ padding-inline: 1.1em;
232
+ border: var(--thin-border-width) solid var(--color-border-strong);
233
+ border-radius: var(--radius-pill);
234
+ background: transparent;
235
+ color: var(--color-text);
236
+ font: inherit;
237
+ font-weight: var(--font-weight--semi-bold);
238
+ cursor: pointer;
239
+
240
+ &[aria-pressed="true"] {
241
+ border-color: var(--color-accent-secondary);
242
+ background-color: var(--color-accent-secondary);
243
+ color: var(--color-on-accent-secondary);
244
+ --color-focus-ring: var(--color-on-accent-secondary);
245
+ }
246
+ }
247
+
248
+ @media (forced-colors: active) {
249
+ .schedule-bar {
250
+ border-block-end-color: CanvasText;
251
+ }
252
+
253
+ .schedule-jump a[aria-current] {
254
+ text-decoration-color: Highlight;
255
+ }
256
+
257
+ .hide-past[aria-pressed="true"] {
258
+ forced-color-adjust: none;
259
+ background: SelectedItem;
260
+ border-color: SelectedItem;
261
+ color: SelectedItemText;
137
262
  }
138
263
  }
139
264
 
140
265
  @media print {
141
- .schedule-jump {
266
+ .schedule-bar {
142
267
  display: none;
143
268
  }
144
269
  }
145
270
  </style>
271
+
272
+ <style>
273
+ /* The page scrolls under the sticky row: anchors and focused controls stop below it (WCAG 2.4.11, 2.4.12). The script sets the height. */
274
+ html:has(.schedule-bar) {
275
+ scroll-padding-block-start: calc(var(--schedule-bar-height, 0px) + 1rem);
276
+ }
277
+ </style>
278
+
279
+ <script>
280
+ /**
281
+ * Marks the month on screen in the row with `aria-current="location"`: the month of the week block that crosses a line just below the
282
+ * row (or, in the gap between two weeks, the next one); before the first week reaches it the first month, after the last week the last month. Sets `--schedule-bar-height`
283
+ * for the page's scroll-padding while the row is sticky. It changes no size and runs no animation.
284
+ */
285
+ (() => {
286
+ const bar = document.querySelector("[data-schedule-bar]");
287
+ if (!bar || !bar.getClientRects().length) return;
288
+ const links = [...bar.querySelectorAll("a[data-first-week]")];
289
+ const weeks = [...document.querySelectorAll(".schedule-weeks .week[id^='week-']")];
290
+ if (!links.length || !weeks.length) return;
291
+ const range = links.map((link) => ({ link, first: Number(link.dataset.firstWeek), last: Number(link.dataset.lastWeek) }));
292
+ /** The month of a week: the latest month whose range holds it, so a week spanning two months reads as the second, where its link points. */
293
+ const monthOf = (number) => range.findLast(({ first, last }) => number >= first && number <= last) ?? range.at(-1);
294
+ const mark = () => {
295
+ const line = Math.max(0, bar.getBoundingClientRect().bottom) + 8;
296
+ const shown = weeks.filter((week) => !week.hidden);
297
+ if (!shown.length) return;
298
+ // The first week that is not wholly above the line: the one crossing it, or the next one when the line is in the gap between two,
299
+ // and the first week while the header is still on screen. After the last week, the last month.
300
+ const week = shown.find((candidate) => candidate.getBoundingClientRect().bottom > line);
301
+ // A page scrolled to its foot can leave the last week below the line: then the last month is the one on screen.
302
+ const bottomed = window.scrollY > 0 && window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2;
303
+ const current = week && !bottomed ? monthOf(Number(week.id.slice(5))) : range.at(-1);
304
+ for (const { link } of range) {
305
+ if (link === current.link) link.setAttribute("aria-current", "location");
306
+ else link.removeAttribute("aria-current");
307
+ }
308
+ };
309
+ const measure = () => document.documentElement.style.setProperty("--schedule-bar-height", getComputedStyle(bar).position === "sticky" ? `${Math.ceil(bar.getBoundingClientRect().height)}px` : "0px");
310
+ let queued = false;
311
+ addEventListener("scroll", () => {
312
+ if (queued) return;
313
+ queued = true;
314
+ requestAnimationFrame(() => {
315
+ queued = false;
316
+ mark();
317
+ });
318
+ }, { passive: true });
319
+ new ResizeObserver(() => {
320
+ measure();
321
+ mark();
322
+ }).observe(bar);
323
+ measure();
324
+ mark();
325
+ })();
326
+ </script>
@@ -2,8 +2,9 @@
2
2
  /**
3
3
  * Every week of the term as a bordered block: one row per class meeting
4
4
  * (when, topics, and what that class needs: reading, due items, materials)
5
- * and a footer for the week's own resources. A "This week" card, the
6
- * hide-past toggle and the Now and Done flags are added by the script.
5
+ * and a footer for the week's own resources. A "This week" card and the
6
+ * Now and Done flags are added by the script, which also works the
7
+ * hide-past toggle that <schedule-overview> puts in its sticky row.
7
8
  * Deadlines carry a chip for their `kind`; the key above the weeks lists
8
9
  * the kinds in use. Wording comes from `copy.schedule`.
9
10
  * @prop {object[]} [weeks] `scheduleWeeks` output; built from the page's
@@ -18,10 +19,6 @@
18
19
  </script>
19
20
  <div webc:root="override" class="schedule-weeks" data-today-host="meetings" webc:if="(weeks ?? defaultWeeks)?.length">
20
21
  <today-marker></today-marker>
21
- <div class="schedule-tools screen-only" data-schedule-tools hidden>
22
- <p class="schedule-status" data-schedule-status role="status"></p>
23
- <button type="button" class="hide-past" data-hide-past aria-pressed="false" @text="copy.hidePast"></button>
24
- </div>
25
22
  <section class="this-week screen-only" data-this-week aria-labelledby="this-week-heading" hidden>
26
23
  <header class="this-head">
27
24
  <p class="label" data-this-label @text="copy.thisWeek"></p>
@@ -40,7 +37,7 @@
40
37
  </div>
41
38
  </section>
42
39
  <ul class="due-key" :aria-label="copy.dueKeyLabel" role="list" webc:if="dueKeyItems(weeks ?? defaultWeeks, $data.copy).length">
43
- <li webc:for="entry of dueKeyItems(weeks ?? defaultWeeks, $data.copy)"><span class="due-chip" :data-kind="entry.kind" @text="entry.label"></span> <span @text="entry.graded"></span></li>
40
+ <li webc:for="entry of dueKeyItems(weeks ?? defaultWeeks, $data.copy)"><span class="due-chip" :data-kind="entry.kind" @text="entry.label"></span><template webc:nokeep webc:if="entry.note"> <span @text="entry.note"></span></template></li>
44
41
  </ul>
45
42
  <section class="week" webc:for="week of (weeks ?? defaultWeeks)" :id="`week-${week.week}`" :aria-labelledby="`week-${week.week}-heading`" :data-week-dates="weekDates(week)">
46
43
  <header class="week-head">
@@ -128,8 +125,9 @@
128
125
  const campusToday = () => new Date().toLocaleDateString("en-CA", { timeZone: document.documentElement.dataset.timezone });
129
126
  const { t } = window.ckCopy;
130
127
  const root = document.querySelector(".schedule-weeks");
131
- const tools = root?.querySelector("[data-schedule-tools]");
132
- if (!root || !tools) return;
128
+ if (!root) return;
129
+ // The hide-past toggle is in <schedule-overview>'s row, above the weeks; with no overview there is no toggle.
130
+ const tools = document.querySelector("[data-schedule-tools]");
133
131
  const today = campusToday();
134
132
  const weeks = [...root.querySelectorAll(".week[data-week-dates]")]
135
133
  .map((el) => ({ el, dates: el.dataset.weekDates.split(/\s+/).filter(Boolean).sort() }))
@@ -208,15 +206,15 @@
208
206
  }
209
207
 
210
208
  // One label, "Hide past weeks"; the state is aria-pressed. Not saved: every visit starts with all weeks shown.
211
- const button = tools.querySelector("[data-hide-past]");
212
- const status = tools.querySelector("[data-schedule-status]");
209
+ const button = tools?.querySelector("[data-hide-past]");
210
+ const status = tools?.querySelector("[data-schedule-status]");
213
211
  const past = weeks.filter(({ el }) => el.hasAttribute("data-past"));
214
212
  const apply = (hide) => {
215
213
  button.setAttribute("aria-pressed", String(hide));
216
214
  for (const { el } of past) el.hidden = hide;
217
215
  status.textContent = hide ? t("schedule", "pastHidden", { count: past.length }) : t("schedule", "weeksDone", { done: past.length, total: weeks.length });
218
216
  };
219
- if (past.length) {
217
+ if (button && status && past.length) {
220
218
  apply(false);
221
219
  button.addEventListener("click", () => apply(button.getAttribute("aria-pressed") !== "true"));
222
220
  tools.hidden = false;
@@ -424,44 +422,6 @@
424
422
  }
425
423
  }
426
424
 
427
- /* The toolbar over the weeks: the count and the hide-past toggle. */
428
- .schedule-tools {
429
- display: flex;
430
- flex-wrap: wrap;
431
- align-items: center;
432
- justify-content: space-between;
433
- gap: calc(var(--gutter) * 2) var(--content-space);
434
-
435
- &[hidden] {
436
- display: none;
437
- }
438
- }
439
-
440
- .schedule-status {
441
- margin: 0;
442
- color: var(--color-text-muted);
443
- }
444
-
445
- .hide-past {
446
- min-block-size: var(--target-min);
447
- min-inline-size: var(--target-min);
448
- padding-inline: 1.1em;
449
- border: var(--thin-border-width) solid var(--color-border-strong);
450
- border-radius: var(--radius-pill);
451
- background: transparent;
452
- color: var(--color-text);
453
- font: inherit;
454
- font-weight: var(--font-weight--semi-bold);
455
- cursor: pointer;
456
-
457
- &[aria-pressed="true"] {
458
- border-color: var(--color-accent-secondary);
459
- background-color: var(--color-accent-secondary);
460
- color: var(--color-on-accent-secondary);
461
- --color-focus-ring: var(--color-on-accent-secondary);
462
- }
463
- }
464
-
465
425
  /* "This week": the current week's classes side by side, then what to
466
426
  read and what is due. Filled and revealed by the script. */
467
427
  .this-week {
@@ -488,6 +448,13 @@
488
448
  .week-of {
489
449
  font-weight: var(--font-weight);
490
450
  }
451
+
452
+ /* The week's own link is an operable target: 44px tall (WCAG 2.5.5). */
453
+ h3 a {
454
+ display: inline-flex;
455
+ align-items: center;
456
+ min-block-size: var(--target-min);
457
+ }
491
458
  }
492
459
 
493
460
  .this-days {
@@ -551,6 +518,13 @@
551
518
  li + li {
552
519
  margin-block-start: 0.4em;
553
520
  }
521
+
522
+ /* A link that heads its item is a 44px target; the chip and the check line sit beside it. */
523
+ li > a {
524
+ display: inline-flex;
525
+ align-items: center;
526
+ min-block-size: var(--target-min);
527
+ }
554
528
  }
555
529
 
556
530
  .week[data-current] {
@@ -581,7 +555,6 @@
581
555
  /* Print: the weeks as a plain list, without the card, tools or heads. */
582
556
  @media print {
583
557
  .this-week,
584
- .schedule-tools,
585
558
  .week-cols {
586
559
  display: none;
587
560
  }
@@ -1,6 +1,6 @@
1
1
  <script webc:setup>
2
2
  /**
3
- * The page footer: course, institution, term, copyright and the links. Reads `course`, `site` and `term`.
3
+ * The page footer: course, institution, term, copyright and the links. Reads `course`, `site` and `term`. With `institution.sourceUrl` set it also links to the course's source.
4
4
  */
5
5
  </script>
6
6
  <div webc:root="override">
@@ -11,6 +11,7 @@
11
11
  <span @text="$data.term.label"></span>
12
12
  </p>
13
13
  <copyright></copyright>
14
+ <p class="source" webc:if="$data.site.sourceUrl"><a :href="$data.site.sourceUrl" rel="noopener" @text="$data.copy.nav.openSource"></a></p>
14
15
  </div>
15
16
  <div class="group">
16
17
  <p class="label" id="footer-pages" @text="$data.copy.siteFooter.pages"></p>
@@ -102,8 +103,21 @@
102
103
  font-size: 1em;
103
104
  }
104
105
 
105
- nav.group a,
106
+ .source {
107
+ margin: 0;
108
+ max-inline-size: none;
109
+ }
110
+
111
+ /* The course name is one run of text, "CS101: Introduction…": inline-flex would make each span a flex item and drop the spaces between them. */
106
112
  .course a {
113
+ display: inline-block;
114
+ /* 44px tall (WCAG 2.5.5) with the text centered, however many lines it wraps to. */
115
+ padding-block: max(0px, calc((var(--target-min) - 1lh) / 2));
116
+ font-size: max(var(--base-font-size), 1em);
117
+ }
118
+
119
+ nav.group a,
120
+ .source a {
107
121
  display: inline-flex;
108
122
  align-items: center;
109
123
  min-block-size: var(--target-min);
@@ -1,13 +1,29 @@
1
1
  <script webc:setup>
2
2
  /**
3
- * The syllabus: outcomes, text, technology, coursework and grading. Reads
4
- * the `course`, `grading`, `scale`, `schedule` and `project` data; it takes
5
- * no props.
3
+ * The syllabus: outcomes, text, technology, coursework and grading, with a
4
+ * contents list of its parts: a row of links above the document on a narrow
5
+ * screen and, from 1100px, a sticky column beside it that marks the part on
6
+ * screen. Reads the `course`, `grading`, `scale`, `schedule` and `project`
7
+ * data. The list is built from the parts that render, so a part the course
8
+ * leaves out is not listed.
9
+ * @prop {'false'} [contents] `false` leaves the contents list out; shown otherwise. `"syllabusContents": false` in `course.json` does the same for every syllabus, and this prop wins over it
6
10
  */
7
- const course = $data.course ?? {};
8
11
  const copy = $data.copy.syllabus;
9
12
  /** The project's due date and time: "Thursday, December 3, 2026, 11:59PM". */
10
13
  const projectWhen = (project) => (project.dueTime ? fill(copy.projectDue, { date: fullDate(project.due), time: timeOfDay(project.dueTime) }) : fullDate(project.due));
14
+ /** The parts that render, in page order, for the contents list: the same conditions as the articles below. Takes the page's data, which a setup script's own `$data` is not. */
15
+ const partsOf = (data) =>
16
+ [
17
+ { id: "outcomes", label: copy.learningOutcomes },
18
+ data.course?.additionalOutcomes?.length && { id: "additional-outcomes", label: copy.additionalOutcomes },
19
+ { id: "text", label: copy.text },
20
+ { id: "technology", label: copy.technology },
21
+ data.grading && { id: "coursework", label: copy.coursework },
22
+ data.grading && { id: "grading", label: copy.grading },
23
+ data.term?.keyDates?.length && { id: "key-dates", label: copy.keyDates },
24
+ ].filter(Boolean);
25
+ /** The prop wins over the course's `syllabusContents`; anything but `false` shows the list. */
26
+ const showContents = (data, prop) => (prop === undefined ? data.course?.syllabusContents !== false : prop !== false && prop !== "false");
11
27
  const escape = (text) => String(text).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
12
28
  /** "Full requirements, milestone dates, and the grading rubric are on the project page." with the link in place. */
13
29
  const projectPage = (project) => fill(copy.projectPage, { link: `<a href="${escape(project?.url ?? "/projects/final/")}">${escape(copy.projectPageLink)}</a>` });
@@ -15,33 +31,40 @@
15
31
  <section id="syllabus" aria-labelledby="syllabus-heading" webc:root="override">
16
32
  <h2 id="syllabus-heading" @text="copy.syllabus"></h2>
17
33
 
34
+ <nav class="syllabus-contents screen-only" aria-labelledby="syllabus-contents-label" :style="`--parts: ${partsOf($data).length}`" webc:if="showContents($data, typeof contents === 'undefined' ? undefined : contents)">
35
+ <p class="rail-label" id="syllabus-contents-label" @text="$data.copy.document.contents"></p>
36
+ <ol role="list">
37
+ <li webc:for="part of partsOf($data)"><a :href="`#${part.id}`" @text="part.label"></a></li>
38
+ </ol>
39
+ </nav>
40
+
18
41
  <article>
19
- <h3 @text="copy.learningOutcomes"></h3>
42
+ <h3 id="outcomes" @text="copy.learningOutcomes"></h3>
20
43
  <p @text="copy.uponCompletingThisCourse"></p>
21
44
  <ul>
22
- <li webc:for="outcome of course.outcomes" @text="outcome"></li>
45
+ <li webc:for="outcome of $data.course?.outcomes" @text="outcome"></li>
23
46
  </ul>
24
47
  </article>
25
48
 
26
- <article webc:if="course.additionalOutcomes?.length">
49
+ <article webc:if="$data.course?.additionalOutcomes?.length">
27
50
  <h3 id="additional-outcomes" @text="copy.additionalOutcomesInThis"></h3>
28
51
  <ul>
29
- <li webc:for="outcome of course.additionalOutcomes" @text="outcome"></li>
52
+ <li webc:for="outcome of $data.course?.additionalOutcomes" @text="outcome"></li>
30
53
  </ul>
31
54
  </article>
32
55
 
33
56
  <article>
34
- <h3 @text="copy.text"></h3>
35
- <p webc:if="!course.textbook?.required" @text="copy.noTextIsRequired"></p>
36
- <p webc:if="course.textbook?.required"><strong @text="copy.required"></strong> <span @text="course.textbook.required"></span></p>
37
- <ol webc:if="course.textbook?.access?.length">
38
- <li webc:for="step of course.textbook.access" @raw="step"></li>
57
+ <h3 id="text" @text="copy.text"></h3>
58
+ <p webc:if="!$data.course?.textbook?.required" @text="copy.noTextIsRequired"></p>
59
+ <p webc:if="$data.course?.textbook?.required"><strong @text="copy.required"></strong> <span @text="$data.course?.textbook.required"></span></p>
60
+ <ol webc:if="$data.course?.textbook?.access?.length">
61
+ <li webc:for="step of $data.course?.textbook.access" @raw="step"></li>
39
62
  </ol>
40
63
  </article>
41
64
 
42
65
  <article>
43
- <h3 @text="copy.technology"></h3>
44
- <p><span @text="fill(copy.bringALaptopMeeting, { institution: $data.site.institution || copy.theCollege })"></span> <span webc:for="req of course.requirements ?? []" @text="req"></span> <span webc:if="$data.grading?.homework" @text="fill(copy.accessIsRequired, { lms: $data.site.lms })"></span></p>
66
+ <h3 id="technology" @text="copy.technology"></h3>
67
+ <p><span @text="fill(copy.bringALaptopMeeting, { institution: $data.site.institution || copy.theCollege })"></span> <span webc:for="req of $data.course?.requirements ?? []" @text="req"></span> <span webc:if="$data.grading?.homework" @text="fill(copy.accessIsRequired, { lms: $data.site.lms })"></span></p>
45
68
  </article>
46
69
 
47
70
  <article webc:if="$data.grading">
@@ -192,6 +215,96 @@
192
215
  letter-spacing: 0.03em;
193
216
  }
194
217
 
218
+ /* The contents list: the document layout's rail (`.rail-label`, and
219
+ base.css's `.syllabus-contents` rules for the line, the links and
220
+ the current part) as a row of links above the syllabus on a narrow
221
+ screen, and a sticky column beside it from 1100px. The current part
222
+ changes color and the edge beside it, never the type's weight or
223
+ size, so the list does not move when the script marks a part. */
224
+ #syllabus > .syllabus-contents {
225
+ padding: 0;
226
+ font-size: max(var(--base-font-size), 0.95em);
227
+
228
+ > .rail-label {
229
+ margin-block-end: 0.25em;
230
+ }
231
+
232
+ > ol {
233
+ display: flex;
234
+ flex-wrap: wrap;
235
+ gap: 0 1.25em;
236
+ border-inline-start: 0;
237
+
238
+ li a[href] {
239
+ display: flex;
240
+ align-items: center;
241
+ box-sizing: border-box;
242
+ /* An operable target: 44px each way (WCAG 2.5.5). */
243
+ min-block-size: var(--target-min);
244
+ min-inline-size: var(--target-min);
245
+ margin-inline-start: 0;
246
+ padding: 0;
247
+ border-inline-start: 0;
248
+ border-block-end: var(--border-width) solid transparent;
249
+
250
+ &[aria-current] {
251
+ border-block-end-color: var(--color-accent-secondary);
252
+ font-weight: inherit;
253
+ }
254
+ }
255
+ }
256
+ }
257
+
258
+ @media (width > 1100px) {
259
+ #syllabus:has(> .syllabus-contents) {
260
+ display: grid;
261
+ grid-template-columns: 13rem minmax(0, 1fr);
262
+ column-gap: calc(var(--section-space) * 1.5);
263
+ clear: both;
264
+ }
265
+
266
+ #syllabus:has(> .syllabus-contents) > h2 {
267
+ grid-column: 1 / -1;
268
+ }
269
+
270
+ #syllabus:has(> .syllabus-contents) > article {
271
+ grid-column: 2;
272
+ }
273
+
274
+ #syllabus > .syllabus-contents {
275
+ grid-column: 1;
276
+ /* One row per part, so the column spans the document and sticks beside it. */
277
+ grid-row: 2 / span var(--parts);
278
+ align-self: start;
279
+ position: sticky;
280
+ inset-block-start: var(--content-space);
281
+ max-block-size: calc(100vb - var(--content-space) * 2);
282
+ overflow-y: auto;
283
+
284
+ > ol {
285
+ flex-direction: column;
286
+ border-inline-start: var(--border-width) solid var(--color-border);
287
+
288
+ li a[href] {
289
+ margin-inline-start: calc(var(--border-width) * -1);
290
+ padding-inline: 0.9em;
291
+ border-inline-start: var(--border-width) solid transparent;
292
+ border-block-end: 0;
293
+
294
+ &[aria-current] {
295
+ border-inline-start-color: var(--color-accent-secondary);
296
+ }
297
+ }
298
+ }
299
+ }
300
+ }
301
+
302
+ @media (forced-colors: active) {
303
+ #syllabus > .syllabus-contents > ol li a[href][aria-current] {
304
+ border-color: Highlight;
305
+ }
306
+ }
307
+
195
308
  #key-dates + ul {
196
309
  list-style: none;
197
310
  margin: 0;
@@ -215,3 +328,43 @@
215
328
  }
216
329
  }
217
330
  </style>
331
+
332
+ <script>
333
+ /**
334
+ * Marks the syllabus part on screen in the contents list with
335
+ * `aria-current="location"` as the page scrolls. The list is built when the
336
+ * page renders; this only moves the mark, so nothing shifts. With no list,
337
+ * or with it hidden, it does nothing.
338
+ */
339
+ (() => {
340
+ const rail = document.querySelector("#syllabus > .syllabus-contents");
341
+ if (!rail || !rail.getClientRects().length) return;
342
+ const links = [...rail.querySelectorAll("a[href^='#']")];
343
+ const parts = links.map((link) => document.getElementById(link.hash.slice(1)));
344
+ if (parts.some((part) => !part)) return;
345
+ const section = rail.closest("#syllabus");
346
+ const mark = () => {
347
+ const line = window.innerHeight * 0.3;
348
+ const end = section.getBoundingClientRect().bottom;
349
+ // A page scrolled to its foot can leave the last part below the line: then it is the one on screen.
350
+ const bottomed = window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2 && end <= window.innerHeight + 2;
351
+ // Nothing is marked before the first part reaches the line, or once the syllabus has scrolled past it.
352
+ const inside = (parts[0].getBoundingClientRect().top <= line || bottomed) && end > line;
353
+ const current = !inside ? null : bottomed ? parts.at(-1) : parts.filter((part) => part.getBoundingClientRect().top <= line).at(-1);
354
+ for (const [index, link] of links.entries()) {
355
+ if (parts[index] === current) link.setAttribute("aria-current", "location");
356
+ else link.removeAttribute("aria-current");
357
+ }
358
+ };
359
+ let queued = false;
360
+ addEventListener("scroll", () => {
361
+ if (queued) return;
362
+ queued = true;
363
+ requestAnimationFrame(() => {
364
+ queued = false;
365
+ mark();
366
+ });
367
+ }, { passive: true });
368
+ mark();
369
+ })();
370
+ </script>
@@ -32,13 +32,10 @@
32
32
  </div>
33
33
 
34
34
  <script webc:keep>
35
- /* Set the editor theme before ei.js builds the iframe. */
35
+ /* Set the editor theme before ei.js builds the iframe: it follows the system. */
36
36
  (function () {
37
37
  try {
38
- var forced = document.documentElement.dataset.theme;
39
- var dark =
40
- forced === "dark" ||
41
- (forced !== "light" && matchMedia("(prefers-color-scheme: dark)").matches);
38
+ var dark = matchMedia("(prefers-color-scheme: dark)").matches;
42
39
  document.querySelectorAll(".codepen[data-prefill]").forEach(function (embed) {
43
40
  embed.dataset.themeId = dark ? "dark" : "light";
44
41
  });