@allons-y/course-kit 0.1.0 → 0.2.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.
- package/README.md +2 -2
- package/assets/scripts/email.js +5 -3
- package/assets/styles/base.css +5 -4
- package/components/site/instructor.webc +171 -8
- package/components/site/syllabus.webc +168 -15
- package/lib/copy.js +3 -0
- package/lib/data/index.js +1 -1
- package/lib/data/read.js +16 -1
- package/lib/plugin.js +4 -1
- package/package.json +3 -2
- package/schemas/course.schema.json +5 -0
- package/schemas/instructor.schema.json +8 -0
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ You get:
|
|
|
15
15
|
|
|
16
16
|
## Start here
|
|
17
17
|
|
|
18
|
-
You need [Node.js](https://nodejs.org)
|
|
18
|
+
You need [Node.js](https://nodejs.org) 24 or newer, and a terminal.
|
|
19
19
|
|
|
20
20
|
1. Copy the [`examples/starter`](examples/starter) folder to a new folder for your course.
|
|
21
21
|
2. In that folder, add a `package.json`:
|
|
@@ -31,7 +31,7 @@ You need [Node.js](https://nodejs.org) 22 or newer, and a terminal.
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@11ty/eleventy": "^3.1.0",
|
|
34
|
-
"@allons-y/course-kit": "
|
|
34
|
+
"@allons-y/course-kit": "~0.1.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
```
|
package/assets/scripts/email.js
CHANGED
|
@@ -4,11 +4,13 @@ for (const anchor of document.querySelectorAll("a[data-email]")) {
|
|
|
4
4
|
try {
|
|
5
5
|
const address = atob(anchor.dataset.email);
|
|
6
6
|
anchor.href = `mailto:${address}`;
|
|
7
|
-
|
|
7
|
+
// An icon link keeps its svg and writes the address into its own text slot.
|
|
8
|
+
const target = anchor.querySelector("[data-email-text]") ?? anchor;
|
|
9
|
+
if (!target.textContent.trim()) {
|
|
8
10
|
// Break opportunities before "@" and after each ".": a narrow screen wraps the address there, not mid-word.
|
|
9
11
|
address.split(/(?=@)|(?<=\.)/).forEach((part, index) => {
|
|
10
|
-
if (index)
|
|
11
|
-
|
|
12
|
+
if (index) target.append(document.createElement("wbr"));
|
|
13
|
+
target.append(part);
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
} catch {
|
package/assets/styles/base.css
CHANGED
|
@@ -982,9 +982,10 @@ eyebrow + :where(h1, h2, h3, h4, h5, h6) {
|
|
|
982
982
|
}
|
|
983
983
|
|
|
984
984
|
/* ---- Side columns ----
|
|
985
|
-
A contents column beside a document
|
|
986
|
-
|
|
987
|
-
|
|
985
|
+
A contents column beside a document (and beside the syllabus, whose own
|
|
986
|
+
component sets where it sits), and an outline and a tools rail beside
|
|
987
|
+
a lesson plan. Only the syllabus's list is sticky, and each falls to one
|
|
988
|
+
column on a narrow screen, the side columns first. */
|
|
988
989
|
.rail-label {
|
|
989
990
|
margin: 0 0 0.5em;
|
|
990
991
|
color: var(--color-text-muted);
|
|
@@ -1049,7 +1050,7 @@ body:has(.doc-layout[data-contents="true"], .lesson-layout) {
|
|
|
1049
1050
|
}
|
|
1050
1051
|
}
|
|
1051
1052
|
|
|
1052
|
-
:is(.doc-contents nav, .lesson-outline, .lesson-rail nav) > :is(ol, ul) {
|
|
1053
|
+
:is(.doc-contents nav, .lesson-outline, .lesson-rail nav, .syllabus-contents) > :is(ol, ul) {
|
|
1053
1054
|
margin: 0;
|
|
1054
1055
|
padding: 0;
|
|
1055
1056
|
list-style: none;
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* The instructor's details: photo, office, contact and hours. Reads `instructor`.
|
|
4
4
|
* @prop {'card'} [variant] a compact card instead of the full section
|
|
5
|
+
* @prop {'icons'} [contactLinks] show the email, the message link and the blog as icon links in the corner of the panel instead of rows in the fact list; the same as `contactLinks: "icons"` in `instructor.json`, and wins over it
|
|
5
6
|
*/
|
|
7
|
+
/** The prop wins over the data; either one set to "icons" turns the icon links on. */
|
|
8
|
+
const iconsOn = (data, prop) => (prop ?? data.instructor?.contactLinks) === "icons";
|
|
9
|
+
const host = (url) => url.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
6
10
|
</script>
|
|
7
11
|
<section id="instructor" aria-labelledby="instructor-heading" webc:root="override" webc:if="$data.instructor">
|
|
8
|
-
<template webc:nokeep webc:if="variant !== 'card'">
|
|
12
|
+
<template webc:nokeep webc:for="icons of [iconsOn($data, typeof contactLinks === 'undefined' ? undefined : contactLinks)]" webc:if="variant !== 'card'">
|
|
9
13
|
<div class="who">
|
|
10
14
|
<img class="photo screen-only" webc:if="$data.instructor.photo" :src="$data.instructor.photo" :alt="$data.instructor.name" width="160" height="160">
|
|
11
15
|
<div class="facts-column">
|
|
@@ -28,20 +32,36 @@
|
|
|
28
32
|
</ul>
|
|
29
33
|
</dd>
|
|
30
34
|
</div>
|
|
31
|
-
<div webc:if="$data.instructor.email" :class="$data.instructor.contact ? 'print-only' : ''">
|
|
35
|
+
<div webc:if="!icons && $data.instructor.email" :class="$data.instructor.contact ? 'print-only' : ''">
|
|
32
36
|
<dt @text="$data.copy.instructor.email"></dt>
|
|
33
37
|
<dd><a :data-email="encodeEmail($data.instructor.email)"></a></dd>
|
|
34
38
|
</div>
|
|
35
|
-
<div webc:if="$data.instructor.contact" :class="$data.instructor.email ? 'screen-only' : ''">
|
|
39
|
+
<div webc:if="!icons && $data.instructor.contact" :class="$data.instructor.email ? 'screen-only' : ''">
|
|
36
40
|
<dt @text="$data.copy.instructor.message"></dt>
|
|
37
41
|
<dd><a :href="$data.instructor.contact" @text="$data.copy.instructor.sendMeAMessage"></a></dd>
|
|
38
42
|
</div>
|
|
39
|
-
<div webc:if="$data.instructor.blog">
|
|
43
|
+
<div webc:if="!icons && $data.instructor.blog">
|
|
40
44
|
<dt @text="$data.copy.instructor.blog"></dt>
|
|
41
45
|
<dd><a :href="$data.instructor.blog" @text="$data.instructor.blog.replace(/^https?:\/\//, '').replace(/\/$/, '')"></a></dd>
|
|
42
46
|
</div>
|
|
43
47
|
</dl>
|
|
44
|
-
<p class="muted note" webc:if="$data.instructor.note" @text="$data.instructor.note"></p>
|
|
48
|
+
<p class="muted note" webc:if="$data.instructor.note" @text="$data.instructor.note"></p><ul class="links" role="list" :aria-label="$data.copy.instructor.contact" webc:if="icons && ($data.instructor.email || $data.instructor.contact || $data.instructor.blog)">
|
|
49
|
+
<li webc:if="$data.instructor.email">
|
|
50
|
+
<a class="icon-link" :data-email="encodeEmail($data.instructor.email)" :aria-label="$data.copy.instructor.email" :title="$data.copy.instructor.email"><svg
|
|
51
|
+
aria-hidden="true" focusable="false" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="2"></rect><path d="m3 7 9 6 9-6"></path></svg><span
|
|
52
|
+
class="link-text" data-email-text></span></a>
|
|
53
|
+
</li>
|
|
54
|
+
<li webc:if="$data.instructor.contact" :class="$data.instructor.email ? 'screen-only' : ''">
|
|
55
|
+
<a class="icon-link" :href="$data.instructor.contact" :aria-label="$data.copy.instructor.sendMeAMessage" :title="$data.copy.instructor.sendMeAMessage"><svg
|
|
56
|
+
aria-hidden="true" focusable="false" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"></path></svg><span
|
|
57
|
+
class="link-text" @text="$data.copy.instructor.sendMeAMessage"></span></a>
|
|
58
|
+
</li>
|
|
59
|
+
<li webc:if="$data.instructor.blog">
|
|
60
|
+
<a class="icon-link" :href="$data.instructor.blog" :aria-label="$data.copy.instructor.blog" :title="fill($data.copy.instructor.blogUrl, { url: host($data.instructor.blog) })"><svg
|
|
61
|
+
aria-hidden="true" focusable="false" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"></circle><path d="M3 12h18"></path><path d="M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18"></path></svg><span
|
|
62
|
+
class="link-text" @text="host($data.instructor.blog)"></span></a>
|
|
63
|
+
</li>
|
|
64
|
+
</ul>
|
|
45
65
|
</div>
|
|
46
66
|
</div>
|
|
47
67
|
</template>
|
|
@@ -255,15 +275,158 @@
|
|
|
255
275
|
}
|
|
256
276
|
</style>
|
|
257
277
|
|
|
278
|
+
<style>
|
|
279
|
+
/* Icon links (`contactLinks: "icons"`): the email, the message link and the
|
|
280
|
+
blog as 44px circles beside the "Your instructor" heading, at the top
|
|
281
|
+
right of the panel. They follow the facts in the source, so print, which
|
|
282
|
+
drops the photo and runs the facts into one line, reads facts first and
|
|
283
|
+
then the address and the host in place of the icons. Plain selectors,
|
|
284
|
+
not the scoped block above: that block is what every other site renders. */
|
|
285
|
+
/* The heading and the icons share the first line; when the column is too
|
|
286
|
+
narrow for both, the icons wrap onto a line of their own, still at the
|
|
287
|
+
right. The facts and the note take full lines. `order` puts the icons
|
|
288
|
+
after the heading on screen while they follow the facts in the source. */
|
|
289
|
+
#instructor .facts-column:has(> .links) {
|
|
290
|
+
display: flex;
|
|
291
|
+
flex-wrap: wrap;
|
|
292
|
+
align-items: center;
|
|
293
|
+
column-gap: var(--content-space);
|
|
294
|
+
|
|
295
|
+
@media print {
|
|
296
|
+
display: block;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
#instructor .facts-column:has(> .links) > h2 {
|
|
301
|
+
flex: 1 1 auto;
|
|
302
|
+
margin-block: 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
#instructor .facts-column:has(> .links) > .facts {
|
|
306
|
+
flex: 1 1 100%;
|
|
307
|
+
order: 2;
|
|
308
|
+
margin-block-start: 0.35em;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
#instructor .facts-column:has(> .links) > .note {
|
|
312
|
+
flex: 1 1 100%;
|
|
313
|
+
order: 3;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
#instructor .links {
|
|
317
|
+
flex: none;
|
|
318
|
+
order: 1;
|
|
319
|
+
margin: 0 0 0 auto;
|
|
320
|
+
padding: 0;
|
|
321
|
+
display: flex;
|
|
322
|
+
gap: 0.5em;
|
|
323
|
+
list-style: none;
|
|
324
|
+
|
|
325
|
+
@media print {
|
|
326
|
+
display: inline;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
#instructor .links > li {
|
|
331
|
+
margin: 0;
|
|
332
|
+
padding: 0;
|
|
333
|
+
|
|
334
|
+
@media print {
|
|
335
|
+
display: inline;
|
|
336
|
+
|
|
337
|
+
&::before {
|
|
338
|
+
content: " · ";
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* The message link stands in for the address on screen only. */
|
|
342
|
+
&.screen-only {
|
|
343
|
+
display: none;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
#instructor .icon-link {
|
|
349
|
+
position: relative;
|
|
350
|
+
display: inline-flex;
|
|
351
|
+
align-items: center;
|
|
352
|
+
justify-content: center;
|
|
353
|
+
box-sizing: border-box;
|
|
354
|
+
/* An operable target: 44px each way (WCAG 2.5.5), the icon 24px inside it. */
|
|
355
|
+
inline-size: var(--target-min);
|
|
356
|
+
block-size: var(--target-min);
|
|
357
|
+
aspect-ratio: auto;
|
|
358
|
+
border: var(--thin-border-width) solid var(--color-border-strong);
|
|
359
|
+
border-radius: var(--circle-border-radius);
|
|
360
|
+
color: var(--color-link);
|
|
361
|
+
text-decoration: none;
|
|
362
|
+
|
|
363
|
+
&:is(:hover, :focus-visible) {
|
|
364
|
+
border-color: var(--color-link);
|
|
365
|
+
background-color: var(--color-surface-accent);
|
|
366
|
+
text-decoration: none;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* base.css gives an svg without a size a full-width, 2.5em-tall box and a currentColor fill. These carry a width, a height and fill="none"; say so
|
|
370
|
+
again for any rule that is looser. */
|
|
371
|
+
svg {
|
|
372
|
+
flex: none;
|
|
373
|
+
inline-size: 24px;
|
|
374
|
+
block-size: 24px;
|
|
375
|
+
min-block-size: 0;
|
|
376
|
+
fill: none;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
@media print {
|
|
380
|
+
display: inline;
|
|
381
|
+
inline-size: auto;
|
|
382
|
+
block-size: auto;
|
|
383
|
+
border: none;
|
|
384
|
+
border-radius: 0;
|
|
385
|
+
color: inherit;
|
|
386
|
+
text-decoration: underline;
|
|
387
|
+
|
|
388
|
+
svg {
|
|
389
|
+
display: none;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/* The address, the message label or the host behind each icon: clipped on
|
|
395
|
+
screen, where the aria-label names the link, and printed in place of
|
|
396
|
+
the icon. It stays in the text, so find-in-page and copy reach it. */
|
|
397
|
+
@media screen {
|
|
398
|
+
#instructor .link-text {
|
|
399
|
+
position: absolute;
|
|
400
|
+
inline-size: 1px;
|
|
401
|
+
block-size: 1px;
|
|
402
|
+
overflow: hidden;
|
|
403
|
+
clip-path: inset(50%);
|
|
404
|
+
white-space: nowrap;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
@media (forced-colors: active) {
|
|
409
|
+
#instructor .icon-link {
|
|
410
|
+
border-color: LinkText;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
#instructor .icon-link:is(:hover, :focus-visible) {
|
|
414
|
+
border-color: Highlight;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
</style>
|
|
418
|
+
|
|
258
419
|
<script>
|
|
259
420
|
for (const link of document.querySelectorAll("a[data-email]")) {
|
|
260
421
|
const email = atob(link.dataset.email);
|
|
261
422
|
link.href = `mailto:${email}`;
|
|
423
|
+
// An icon link keeps its svg and writes the address into its own text slot.
|
|
424
|
+
const target = link.querySelector("[data-email-text]") ?? link;
|
|
425
|
+
if (target.textContent.trim()) continue;
|
|
262
426
|
// Break opportunities before "@" and after each ".": a narrow screen wraps the address there, not mid-word.
|
|
263
|
-
link.textContent = "";
|
|
264
427
|
email.split(/(?=@)|(?<=\.)/).forEach((part, index) => {
|
|
265
|
-
if (index)
|
|
266
|
-
|
|
428
|
+
if (index) target.append(document.createElement("wbr"));
|
|
429
|
+
target.append(part);
|
|
267
430
|
});
|
|
268
431
|
}
|
|
269
432
|
</script>
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
<script webc:setup>
|
|
2
2
|
/**
|
|
3
|
-
* The syllabus: outcomes, text, technology, coursework and grading
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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, "&").replace(/</g, "<").replace(/"/g, """);
|
|
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
|
|
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
|
|
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
|
|
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="
|
|
36
|
-
<p webc:if="course
|
|
37
|
-
<ol webc:if="course
|
|
38
|
-
<li webc:for="step of course
|
|
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
|
|
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>
|
package/lib/copy.js
CHANGED
|
@@ -185,6 +185,7 @@ export const COPY_DEFAULTS = {
|
|
|
185
185
|
learningOutcomes: "Learning outcomes",
|
|
186
186
|
uponCompletingThisCourse: "Upon completing this course students will be able to:",
|
|
187
187
|
additionalOutcomesInThis: "Additional outcomes in this section",
|
|
188
|
+
additionalOutcomes: "Additional outcomes",
|
|
188
189
|
text: "Text",
|
|
189
190
|
noTextIsRequired: "No text is required.",
|
|
190
191
|
required: "Required:",
|
|
@@ -333,6 +334,8 @@ export const COPY_DEFAULTS = {
|
|
|
333
334
|
sendMeAMessage: "Send me a message",
|
|
334
335
|
blog: "Blog",
|
|
335
336
|
instructor: "Instructor",
|
|
337
|
+
contact: "Contact",
|
|
338
|
+
blogUrl: "Blog: {url}",
|
|
336
339
|
},
|
|
337
340
|
codepenEmbed: {
|
|
338
341
|
theCode: "The code",
|
package/lib/data/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { courseDefines, readCourseData, readPackage } from "./read.js";
|
|
1
|
+
export { courseDefines, readCourseData, readPackage, withoutSchema } from "./read.js";
|
|
2
2
|
export { resolveTerm } from "./term.js";
|
|
3
3
|
export { buildGlossary } from "./glossary.js";
|
|
4
4
|
export { buildLessons, DEFAULT_DAYS, SEGMENTS } from "./lessons.js";
|
package/lib/data/read.js
CHANGED
|
@@ -7,7 +7,7 @@ import { join } from "node:path";
|
|
|
7
7
|
*/
|
|
8
8
|
const readJson = (file) => {
|
|
9
9
|
try {
|
|
10
|
-
return JSON.parse(readFileSync(file, "utf8"));
|
|
10
|
+
return withoutSchema(JSON.parse(readFileSync(file, "utf8")));
|
|
11
11
|
} catch (error) {
|
|
12
12
|
if (error.code === "ENOENT") return {};
|
|
13
13
|
if (error instanceof SyntaxError) throw new Error(`${file} could not be read as JSON. Check for a missing or extra comma, quote or bracket. (${error.message.replace(/\s+/g, " ")})`, { cause: error });
|
|
@@ -15,6 +15,21 @@ const readJson = (file) => {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A parsed data file without its top-level `$schema`: the key is for the editor that validates the file, and a template that loops over a data
|
|
20
|
+
* object (`scale`, `policies`) would otherwise print it as an entry.
|
|
21
|
+
* @param {unknown} data
|
|
22
|
+
* @returns {unknown}
|
|
23
|
+
*/
|
|
24
|
+
export const withoutSchema = (data) => {
|
|
25
|
+
if (data && typeof data === "object" && !Array.isArray(data) && "$schema" in data) {
|
|
26
|
+
const rest = { ...data };
|
|
27
|
+
delete rest.$schema;
|
|
28
|
+
return rest;
|
|
29
|
+
}
|
|
30
|
+
return data;
|
|
31
|
+
};
|
|
32
|
+
|
|
18
33
|
/**
|
|
19
34
|
* The course's authored data files.
|
|
20
35
|
* @param {string} [dataDir]
|
package/lib/plugin.js
CHANGED
|
@@ -7,7 +7,7 @@ import dashly from "@allons-y/dashly";
|
|
|
7
7
|
import { registerAssets } from "./assets.js";
|
|
8
8
|
import registerBundles from "./bundles.js";
|
|
9
9
|
import { checkOptions, courseWarnings } from "./check.js";
|
|
10
|
-
import { buildGlossary, buildLessons, courseDefines, inlineFontFaces, readCourseData, readPackage, resolveAudience, resolvePdf, resolveSite, resolveTerm } from "./data/index.js";
|
|
10
|
+
import { buildGlossary, buildLessons, courseDefines, inlineFontFaces, readCourseData, readPackage, resolveAudience, resolvePdf, resolveSite, resolveTerm, withoutSchema } from "./data/index.js";
|
|
11
11
|
import { copyJson, copyReader, fill, plural, resolveCopy } from "./copy.js";
|
|
12
12
|
import registerExtensions from "./extensions.js";
|
|
13
13
|
import registerFilters from "./filters.js";
|
|
@@ -112,6 +112,9 @@ export default function courseKit(config, options = {}) {
|
|
|
112
112
|
config.addLayoutAlias("notes", "notes.webc");
|
|
113
113
|
config.addLayoutAlias("worksheet", "worksheet.webc");
|
|
114
114
|
|
|
115
|
+
// A data file's `$schema` is for the editor; a template that loops over `scale` or `policies` must not see it.
|
|
116
|
+
config.addDataExtension("json", { parser: (text) => withoutSchema(JSON.parse(text)) });
|
|
117
|
+
|
|
115
118
|
registerPlugins(config, { components });
|
|
116
119
|
registerBundles(config, { inputDir });
|
|
117
120
|
registerFilters(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allons-y/course-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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)",
|
|
@@ -115,6 +115,7 @@
|
|
|
115
115
|
"flavor": "landing"
|
|
116
116
|
},
|
|
117
117
|
"publishConfig": {
|
|
118
|
-
"access": "public"
|
|
118
|
+
"access": "public",
|
|
119
|
+
"provenance": true
|
|
119
120
|
}
|
|
120
121
|
}
|
|
@@ -84,6 +84,11 @@
|
|
|
84
84
|
},
|
|
85
85
|
"description": "Section-specific outcomes layered on top of the committed catalog set."
|
|
86
86
|
},
|
|
87
|
+
"syllabusContents": {
|
|
88
|
+
"type": "boolean",
|
|
89
|
+
"default": true,
|
|
90
|
+
"description": "Whether the `<syllabus>` shows its contents list (a row of links above the syllabus, and from 1100px a sticky column beside it). `false` leaves it out. The tag's `contents=\"false\"` attribute does the same for one place and wins over this."
|
|
91
|
+
},
|
|
87
92
|
"textbook": {
|
|
88
93
|
"type": "object",
|
|
89
94
|
"description": "Required text and how to get it — the textbook/materials element Meredith requires. Omit the whole key ONLY when the course has no text: the `<syllabus>` component then renders \"No text is required.\", which is still an explicit materials statement. Never leave the key present but empty.",
|
|
@@ -43,6 +43,14 @@
|
|
|
43
43
|
"format": "uri",
|
|
44
44
|
"description": "Optional personal site or blog, shown as its own row in the instructor panel."
|
|
45
45
|
},
|
|
46
|
+
"contactLinks": {
|
|
47
|
+
"enum": [
|
|
48
|
+
"rows",
|
|
49
|
+
"icons"
|
|
50
|
+
],
|
|
51
|
+
"default": "rows",
|
|
52
|
+
"description": "How the email, the message link and the blog are shown in the instructor panel: `rows` (the default) lists them in the fact list; `icons` shows each as an icon link in the top right of the panel, with the address or host printed in its place. The `<instructor>` tag's `contact-links` attribute overrides it."
|
|
53
|
+
},
|
|
46
54
|
"photo": {
|
|
47
55
|
"type": "string",
|
|
48
56
|
"pattern": "^/images/",
|