|
| 1 | +// Shared pkgdown theme for Camille Ross's R packages. |
| 2 | +// |
| 3 | +// These sites are served from camilleross.org/<package>/, because GitHub |
| 4 | +// applies the user site's custom domain to every project page on the account. |
| 5 | +// A visitor therefore crosses from the main site into these without changing |
| 6 | +// hostname, and stock Bootstrap makes that crossing look like a mistake. The |
| 7 | +// tokens below are lifted from chross22.github.io/_sass/site/_tokens.scss so |
| 8 | +// the two read as one property. |
| 9 | +// |
| 10 | +// Everything is expressed as Bootstrap 5.3 CSS custom properties rather than |
| 11 | +// Sass variables, for one reason: pkgdown's light switch flips |
| 12 | +// data-bs-theme at runtime, and only the CSS-variable layer can follow it. |
| 13 | +// Setting $body-bg at compile time would give one fixed palette. |
| 14 | +// |
| 15 | +// ACCESSIBILITY CONTRACT, inherited from the main site — do not break it: |
| 16 | +// * Every text colour clears 4.5:1 on both surfaces in both themes. |
| 17 | +// * --accent and --link are near-identical in luminance, so neither may be |
| 18 | +// the only thing distinguishing two meanings. Links stay underlined. |
| 19 | +// System font stacks only: no network requests, no FOUT, nothing to self-host. |
| 20 | + |
| 21 | +:root { |
| 22 | + --site-paper: #fbfbf9; |
| 23 | + --site-paper-2: #f2f3f1; |
| 24 | + --site-abyss: #1d2528; |
| 25 | + --site-abyss-2: #263033; |
| 26 | + --site-ink: #26302f; |
| 27 | + --site-ink-2: #5c6765; |
| 28 | + --site-bone: #e3e8e6; |
| 29 | + --site-bone-2: #a7b3b4; |
| 30 | + --site-sea: #276270; |
| 31 | + --site-sea-deep: #1d5364; |
| 32 | + --site-sea-light: #7fc4d9; |
| 33 | + --site-sea-pale: #a6dbea; |
| 34 | + --site-copper: #8b4920; |
| 35 | + --site-copper-lt: #e09a62; |
| 36 | + --site-rule: #e3e5e0; |
| 37 | + --site-rule-dk: #35403f; |
| 38 | + |
| 39 | + --site-font-display: Charter, "Bitstream Charter", "Iowan Old Style", |
| 40 | + "Source Serif 4", Georgia, "Times New Roman", serif; |
| 41 | + --site-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, |
| 42 | + "Helvetica Neue", Arial, sans-serif; |
| 43 | + --site-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; |
| 44 | +} |
| 45 | + |
| 46 | +// ---- light --------------------------------------------------------------- |
| 47 | +:root, |
| 48 | +[data-bs-theme="light"] { |
| 49 | + --bs-body-bg: var(--site-paper); |
| 50 | + --bs-body-color: var(--site-ink); |
| 51 | + --bs-secondary-color: var(--site-ink-2); |
| 52 | + --bs-emphasis-color: var(--site-ink); |
| 53 | + --bs-border-color: var(--site-rule); |
| 54 | + --bs-link-color: var(--site-sea); |
| 55 | + --bs-link-hover-color: var(--site-sea-deep); |
| 56 | + // Bootstrap 5.3 resolves anchors through the -rgb pair, not the colour |
| 57 | + // itself: a { color: rgba(var(--bs-link-color-rgb), var(--bs-link-opacity)) }. |
| 58 | + // Setting only --bs-link-color leaves every link Bootstrap blue. |
| 59 | + --bs-link-color-rgb: 39, 98, 112; |
| 60 | + --bs-link-hover-color-rgb: 29, 83, 100; |
| 61 | + --bs-code-color: var(--site-copper); |
| 62 | + --bs-secondary-bg: var(--site-paper-2); |
| 63 | + --bs-tertiary-bg: var(--site-paper-2); |
| 64 | + --site-accent: var(--site-copper); |
| 65 | +} |
| 66 | + |
| 67 | +// ---- dark ---------------------------------------------------------------- |
| 68 | +// Bootstrap's own dark mode lands near black, which is not this palette. |
| 69 | +[data-bs-theme="dark"] { |
| 70 | + --bs-body-bg: var(--site-abyss); |
| 71 | + --bs-body-color: var(--site-bone); |
| 72 | + --bs-secondary-color: var(--site-bone-2); |
| 73 | + --bs-emphasis-color: var(--site-bone); |
| 74 | + --bs-border-color: var(--site-rule-dk); |
| 75 | + --bs-link-color: var(--site-sea-light); |
| 76 | + --bs-link-hover-color: var(--site-sea-pale); |
| 77 | + --bs-link-color-rgb: 127, 196, 217; |
| 78 | + --bs-link-hover-color-rgb: 166, 219, 234; |
| 79 | + --bs-code-color: var(--site-copper-lt); |
| 80 | + --bs-secondary-bg: var(--site-abyss-2); |
| 81 | + --bs-tertiary-bg: var(--site-abyss-2); |
| 82 | + --site-accent: var(--site-copper-lt); |
| 83 | +} |
| 84 | + |
| 85 | +// ---- type ---------------------------------------------------------------- |
| 86 | +body { |
| 87 | + font-family: var(--site-font-body); |
| 88 | + font-size: 1.0625rem; |
| 89 | + line-height: 1.65; |
| 90 | +} |
| 91 | + |
| 92 | +h1, h2, h3, h4, h5, h6, |
| 93 | +.navbar-brand { |
| 94 | + font-family: var(--site-font-display); |
| 95 | + font-weight: 600; |
| 96 | + line-height: 1.25; |
| 97 | + letter-spacing: -0.005em; |
| 98 | + text-wrap: balance; |
| 99 | +} |
| 100 | + |
| 101 | +// unquote(): Sass would otherwise try to add rem to vw at compile time. |
| 102 | +h1 { font-size: clamp(1.875rem, unquote("1.4rem + 1.8vw"), 2.375rem); } |
| 103 | +h2 { font-size: 1.5625rem; } |
| 104 | +h3 { font-size: 1.4375rem; } |
| 105 | + |
| 106 | +code, pre, kbd, samp { font-family: var(--site-font-mono); } |
| 107 | + |
| 108 | +// Colour is decoration, never the only cue: under protanopia in dark mode the |
| 109 | +// link and body colours sit at about 1.5:1. |
| 110 | +main a:not(.btn):not(.anchor):not(.nav-link) { text-decoration: underline; } |
| 111 | + |
| 112 | +// ---- chrome -------------------------------------------------------------- |
| 113 | +.navbar { |
| 114 | + background-color: var(--bs-body-bg) !important; |
| 115 | + border-bottom: 1px solid var(--bs-border-color); |
| 116 | +} |
| 117 | + |
| 118 | +.navbar-brand { |
| 119 | + font-size: 1.1875rem; |
| 120 | + letter-spacing: 0.01em; |
| 121 | +} |
| 122 | + |
| 123 | +.navbar .nav-link { color: var(--bs-secondary-color) !important; } |
| 124 | +.navbar .nav-link:hover, |
| 125 | +.navbar .nav-link.active { color: var(--bs-emphasis-color) !important; } |
| 126 | + |
| 127 | +// The active page gets a copper rule, matching the main site's header. |
| 128 | +.navbar .nav-link.active { |
| 129 | + box-shadow: inset 0 -2px 0 var(--site-accent); |
| 130 | +} |
| 131 | + |
| 132 | +.template-home h1 { margin-bottom: 1.5rem; } |
| 133 | + |
| 134 | +pre, .sourceCode { |
| 135 | + background-color: var(--bs-secondary-bg) !important; |
| 136 | + border: 1px solid var(--bs-border-color); |
| 137 | + border-radius: 5px; |
| 138 | +} |
| 139 | + |
| 140 | +table { font-size: 0.9375rem; } |
| 141 | +thead th { border-bottom: 1px solid var(--bs-border-color); } |
| 142 | + |
| 143 | +.sidebar { |
| 144 | + font-size: 0.9375rem; |
| 145 | + h2, h3 { font-size: 1.1875rem; } |
| 146 | +} |
| 147 | + |
| 148 | +footer { |
| 149 | + border-top: 1px solid var(--bs-border-color); |
| 150 | + color: var(--bs-secondary-color); |
| 151 | + font-size: 0.8125rem; |
| 152 | +} |
| 153 | + |
| 154 | +// Focus ring carries the sea colour rather than Bootstrap's default blue. |
| 155 | +:focus-visible { |
| 156 | + outline: 2px solid var(--bs-link-color); |
| 157 | + outline-offset: 2px; |
| 158 | +} |
0 commit comments