Skip to main content

max / makenotwork

3.1 KB · 56 lines History Blame Raw
1 //! The two design-system sheets the public embeds inline.
2 //!
3 //! What used to be here as well were five Askama templates, one per embed, each
4 //! carrying a hand-written `<style>` block. They are gone: `54d7f8cf`, and the
5 //! screens they drew are described in `crate::quasi::embeds` now. What survives
6 //! is the pair of generated sheets, because the reason an embed inlines its
7 //! design system did not change with how the embed is drawn.
8
9 /// The spacing layer the embeds inline, written by `build.rs` from
10 /// makeover-geometry at Pointer density.
11 ///
12 /// An embed cannot link a stylesheet: it renders inside an iframe on somebody
13 /// else's page, so its whole design system has to arrive in the document. That
14 /// is why these five templates carry a `<style>` block when nothing else in the
15 /// tree does. What it must not mean is that the values were copied by hand,
16 /// which is what it meant until this existed.
17 pub const EMBED_GEOMETRY_CSS: &str = include_str!("../../static/embed-geometry.css");
18
19 /// The typography layer, inlined for the same reason as the spacing one.
20 ///
21 /// Its own file, like geometry's, and for a reason of the same shape: geometry
22 /// differs because an embed runs at Pointer density with no `@media` block,
23 /// and typography differs because **an embed carries the house slots and not
24 /// MNW's brand override**. Young Serif reaches the site through layer 0, but an
25 /// embed leaves `--font-display` undefined so the
26 /// `var(--font-display, Georgia, serif)` fallback in each template renders.
27 /// That is the older decision unchanged, now stated as a second `Typography`
28 /// rather than as a token nobody defined; both files come out of one
29 /// vocabulary in build.rs, so they cannot drift on the slots they share.
30 ///
31 /// The `@font-face` URLs are absolute (`/static/fonts/...`) and the iframe's
32 /// document is served from this origin, so they resolve here rather than
33 /// against the host page.
34 ///
35 /// **This makes an embed fetch 81 KB of font on somebody else's page**, which
36 /// is a cost the host author did not choose, so it is worth saying why it is
37 /// the right call. The five templates named `Lato` and `IBM Plex Mono` as
38 /// literals and neither face was ever declared in an embed document, so every
39 /// one of them has been rendering in `-apple-system` and the host's default
40 /// monospace since they were written: the literals described an intention
41 /// nothing implemented. The choice is therefore between an embed that looks
42 /// like our product and one that looks like whatever the visitor's browser
43 /// prefers, and it is not close. `font-display: swap` keeps the card readable
44 /// while the faces arrive.
45 pub const EMBED_TYPOGRAPHY_CSS: &str = include_str!("../../static/embed-typography.css");
46
47 /// The colour layer for an embed: the platform default theme, resolved through
48 /// makeover the same way every page's is.
49 ///
50 /// Always the default. Serving a creator's chosen theme into a third-party page
51 /// is a separate product question, and this is not the place to answer it by
52 /// accident.
53 pub fn embed_theme_css() -> &'static str {
54 crate::theming::theme_css(None)
55 }
56