Skip to content

Commit 7eaa99c

Browse files
committed
events: theme the embed to match the site (font, colors, dark mode)
- Render the calendar + popover in the site font (Atkinson Hyperlegible); aggregate-events.js vendors the woff2s to /fonts/ since MyST hashes static/ - Move every calendar + popover color onto :root variables (event tiles included) so the palette lives in one place - Add prefers-color-scheme dark mode mirroring the site's dark palette - Drop the stray internal scrollbar (overflow: hidden); the iframe is auto-sized to its content, so it never needs one
1 parent d31eb17 commit 7eaa99c

2 files changed

Lines changed: 73 additions & 18 deletions

File tree

scripts/aggregate-events.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ try {
8484
path.join(buildRoot, "purify.min.js"),
8585
);
8686
console.log("Copied purify.min.js to build root");
87+
88+
// Vendor the site's Atkinson Hyperlegible font next to the embed so the iframe
89+
// (a separate document that can't inherit the page's @font-face) renders in the
90+
// site font. Served at /fonts/; keep the weights in sync with the @font-face in
91+
// embed.html and static/css/custom.css.
92+
const fontsDir = path.join(buildRoot, "fonts");
93+
fs.mkdirSync(fontsDir, { recursive: true });
94+
for (const weight of ["400", "700"]) {
95+
const file = `atkinson-hyperlegible-latin-${weight}-normal.woff2`;
96+
fs.copyFileSync(path.join(__dirname, "..", "static", "fonts", file), path.join(fontsDir, file));
97+
}
98+
console.log("Copied Atkinson Hyperlegible fonts to build root /fonts");
8799
} catch (err) {
88100
console.error(`\nFailed to write build outputs: ${err.message}`);
89101
process.exit(1);

scripts/events/embed.html

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,60 @@
1717
<title>UC OSPO Network events</title>
1818
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.15/index.global.min.css" rel="stylesheet" />
1919
<style>
20+
/* Site font (Atkinson Hyperlegible), mirrored from static/css/custom.css.
21+
The iframe is a separate document, so the @font-face must be redeclared
22+
here. MyST hashes files under static/, so the build (aggregate-events.js)
23+
vendors these woff2s to /fonts/ next to the embed, same as purify.min.js. */
24+
@font-face {
25+
font-family: "Atkinson Hyperlegible";
26+
font-style: normal;
27+
font-weight: 400;
28+
src: url("/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
29+
}
30+
@font-face {
31+
font-family: "Atkinson Hyperlegible";
32+
font-style: normal;
33+
font-weight: 700;
34+
src: url("/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
35+
}
2036
:root {
21-
/* Mirror the site brand palette (static/css/custom.css) so the popover
22-
matches the rest of the page. This iframe is a separate document and
23-
does NOT inherit the parent's --pst-* variables, so they're restated
24-
here; keep in sync with custom.css if the brand colors change. */
25-
--uco-primary: #003cb3; /* --pst-color-primary / --pst-color-link */
37+
/* Mirror the site brand palette + font (static/css/custom.css) so the
38+
embed matches the rest of the page. This iframe is a separate document
39+
and does NOT inherit the parent's --pst-* variables, so they're
40+
restated here. Change them in one place; keep in sync with custom.css. */
41+
--uco-font: "Atkinson Hyperlegible", sans-serif;
42+
--uco-primary: #003cb3; /* links, event tiles, button (--pst-color-link) */
2643
--uco-link-hover: #ff9100; /* --pst-color-link-hover */
27-
--uco-text: #222832; /* --tw-prose-body */
44+
--uco-text: #222832; /* body / popover text (--tw-prose-body) */
45+
--uco-surface: #fff; /* popover card + button background */
46+
--uco-border: #e0e0e0; /* popover card border */
47+
--uco-muted: #767676; /* source label, close button */
48+
--uco-daynum: #1a1a1a; /* current-month day number */
49+
--uco-daynum-muted: #6b6b6b; /* other-month day number */
50+
--uco-event-text: #fff; /* text on event tiles + button hover */
51+
}
52+
/* Dark mode follows the OS (prefers-color-scheme), which is how the site's
53+
book-theme resolves its default/"system" appearance. Values mirror the
54+
site's dark palette (#7ab3ff accent, light text on dark surfaces). */
55+
@media (prefers-color-scheme: dark) {
56+
:root {
57+
--uco-primary: #7ab3ff; /* .dark .article a in custom.css */
58+
--uco-text: #e3e3e8;
59+
--uco-surface: #1f1f1f;
60+
--uco-border: #3a3a3a;
61+
--uco-muted: #9aa0a6;
62+
--uco-daynum: #e3e3e8;
63+
--uco-daynum-muted: #8a8a8a;
64+
--uco-event-text: #10243f; /* dark text on the lighter dark-mode tiles */
65+
}
2866
}
2967
body {
3068
margin: 0;
31-
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
69+
font-family: var(--uco-font);
3270
color: var(--uco-text);
71+
/* The parent page sizes this iframe to fit its content, so an internal
72+
scrollbar is never needed; hide the sub-pixel-overflow one. */
73+
overflow: hidden;
3374
}
3475
#calendar {
3576
max-width: 100%;
@@ -39,24 +80,25 @@
3980
.fc .fc-scrollgrid {
4081
border: 0;
4182
}
42-
/* Brand-blue event tiles. FullCalendar's default event color renders white
43-
text at ~3.7:1 (fails WCAG AA); #00609c gives ~6.6:1. */
83+
/* Brand-blue event tiles (site --uco-primary). FullCalendar's default event
84+
color renders white text at ~3.7:1 (fails WCAG AA); #003cb3 gives ~9:1. */
4485
.fc {
45-
--fc-event-bg-color: #00609c;
46-
--fc-event-border-color: #00609c;
86+
--fc-event-bg-color: var(--uco-primary);
87+
--fc-event-border-color: var(--uco-primary);
88+
--fc-event-text-color: var(--uco-event-text);
4789
}
4890
/* FullCalendar's default day numbers are low-contrast: current-month ones
4991
are a light gray, and other-month ones are faded with opacity (which
5092
tanks contrast regardless of color). Darken current-month, and replace
5193
the other-month opacity with a muted-but-AA-passing gray. */
5294
.fc .fc-daygrid-day-number {
53-
color: #1a1a1a;
95+
color: var(--uco-daynum);
5496
}
5597
.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-top {
5698
opacity: 1;
5799
}
58100
.fc .fc-day-other .fc-daygrid-day-number {
59-
color: #6b6b6b;
101+
color: var(--uco-daynum-muted);
60102
}
61103
a {
62104
color: var(--uco-primary);
@@ -79,7 +121,8 @@
79121
}
80122
.evt-card {
81123
position: relative;
82-
background: #fff;
124+
background: var(--uco-surface);
125+
border: 1px solid var(--uco-border);
83126
width: 100%;
84127
max-width: 420px;
85128
max-height: 90%;
@@ -96,14 +139,14 @@
96139
background: none;
97140
font-size: 22px;
98141
line-height: 1;
99-
color: #666;
142+
color: var(--uco-muted);
100143
cursor: pointer;
101144
}
102145
.evt-source {
103146
font-size: 0.8em;
104147
text-transform: uppercase;
105148
letter-spacing: 0.03em;
106-
color: #767676;
149+
color: var(--uco-muted);
107150
}
108151
.evt-card .evt-title {
109152
margin: 4px 24px 8px 0;
@@ -134,7 +177,7 @@
134177
}
135178
.evt-ics {
136179
border: 1px solid var(--uco-primary);
137-
background: #fff;
180+
background: var(--uco-surface);
138181
color: var(--uco-primary);
139182
border-radius: 6px;
140183
padding: 7px 12px;
@@ -144,7 +187,7 @@
144187
}
145188
.evt-ics:hover {
146189
background: var(--uco-primary);
147-
color: #fff;
190+
color: var(--uco-event-text);
148191
}
149192
</style>
150193
</head>

0 commit comments

Comments
 (0)