@abreen/tada 1.16.2 → 1.16.3

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.
@@ -119,7 +119,8 @@ const HEADING_SIZES = Object.freeze({
119
119
  });
120
120
 
121
121
  function formatCssNumber(value: number): string {
122
- return Number(value.toFixed(4)).toString();
122
+ const rounded = Number(value.toFixed(4));
123
+ return (rounded === 0 && value !== 0 ? value : rounded).toString();
123
124
  }
124
125
 
125
126
  export function renderCustomFontTuningScss(
@@ -130,6 +131,18 @@ export function renderCustomFontTuningScss(
130
131
  const monoTuning = fontOverrides?.serifMono?.tuning;
131
132
  const rootSelector = ":root[data-font-preference='serif']";
132
133
 
134
+ if (serifTuning?.fontSizeAdjust !== undefined) {
135
+ rules.push(
136
+ ` ${rootSelector} {\n --font-size-adjust: cap-height ${formatCssNumber(serifTuning.fontSizeAdjust)};\n }`,
137
+ );
138
+ }
139
+
140
+ if (monoTuning?.fontSizeAdjust !== undefined) {
141
+ rules.push(
142
+ ` ${rootSelector} {\n --mono-font-size-adjust: cap-height ${formatCssNumber(monoTuning.fontSizeAdjust)};\n }`,
143
+ );
144
+ }
145
+
133
146
  if (serifTuning?.scale !== undefined) {
134
147
  rules.push(
135
148
  ` ${rootSelector} {\n --font-size: ${formatCssNumber(serifTuning.scale)}rem;\n }`,
package/build/types.d.ts CHANGED
@@ -8,11 +8,13 @@ export interface SerifFontTuning {
8
8
  lineHeight?: number;
9
9
  headingScale?: number;
10
10
  headingWeight?: 400 | 700;
11
+ fontSizeAdjust?: number;
11
12
  }
12
13
 
13
14
  export interface SerifMonoFontTuning {
14
15
  scale?: number;
15
16
  lineHeight?: number;
17
+ fontSizeAdjust?: number;
16
18
  }
17
19
 
18
20
  export interface FontFamilyOverride<Tuning = unknown> {
@@ -414,7 +414,8 @@ Here's a time range:
414
414
  <time datetime="12:45">12:45</time>--<time datetime="13:45">1:45 pm</time>
415
415
 
416
416
  - When a `<time>` element is adjusted,
417
- * the appearance of the element changes slightly to indicate it was updated,
417
+ * the selected time zone abbreviation is shown after its AM/PM period (or
418
+ after the final endpoint of a time range),
418
419
  * hovering over the text produces a tooltip telling the user the original time
419
420
  and time zone, and
420
421
  * if the time adjustment crosses a day boundary, *(next day)* or *(prev. day)*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abreen/tada",
3
- "version": "1.16.2",
3
+ "version": "1.16.3",
4
4
  "type": "module",
5
5
  "description": "A static site generator",
6
6
  "license": "MIT",
@@ -77,7 +77,7 @@
77
77
  "png-to-ico": "^3.0.1",
78
78
  "quote-quote": "^1.2.0",
79
79
  "sass": "^1.99.0",
80
- "sharp": "^0.34.5",
80
+ "sharp": "^0.35.3",
81
81
  "shiki": "^4.0.2",
82
82
  "string-strip-html": "^8.5.0"
83
83
  },
@@ -93,7 +93,8 @@
93
93
  "scale": { "$ref": "#/$defs/fontScale" },
94
94
  "lineHeight": { "$ref": "#/$defs/fontLineHeight" },
95
95
  "headingScale": { "$ref": "#/$defs/fontScale" },
96
- "headingWeight": { "type": "integer", "enum": [400, 700] }
96
+ "headingWeight": { "type": "integer", "enum": [400, 700] },
97
+ "fontSizeAdjust": { "$ref": "#/$defs/fontSizeAdjust" }
97
98
  },
98
99
  "additionalProperties": false
99
100
  }
@@ -117,7 +118,8 @@
117
118
  "type": "object",
118
119
  "properties": {
119
120
  "scale": { "$ref": "#/$defs/fontScale" },
120
- "lineHeight": { "$ref": "#/$defs/fontLineHeight" }
121
+ "lineHeight": { "$ref": "#/$defs/fontLineHeight" },
122
+ "fontSizeAdjust": { "$ref": "#/$defs/fontSizeAdjust" }
121
123
  },
122
124
  "additionalProperties": false
123
125
  }
@@ -126,6 +128,7 @@
126
128
  },
127
129
  "fontScale": { "type": "number", "minimum": 0.75, "maximum": 1.5 },
128
130
  "fontLineHeight": { "type": "number", "minimum": 1, "maximum": 2.5 },
131
+ "fontSizeAdjust": { "type": "number", "exclusiveMinimum": 0 },
129
132
  "publicWoff2Path": {
130
133
  "type": "string",
131
134
  "minLength": 6,
package/src/_base.scss CHANGED
@@ -32,6 +32,7 @@ h1 {
32
32
  body {
33
33
  font-family: var(--font);
34
34
  font-size: var(--font-size);
35
+ font-size-adjust: var(--font-size-adjust);
35
36
  font-weight: var(--font-weight);
36
37
  font-feature-settings: var(--font-feature-settings);
37
38
  line-height: var(--line-height);
@@ -83,9 +84,18 @@ pre,
83
84
  tt,
84
85
  code {
85
86
  font-family: var(--mono-font);
87
+ font-size-adjust: var(--mono-font-size-adjust);
86
88
  font-feature-settings: var(--mono-font-feature-settings);
87
89
  }
88
90
 
91
+ [font-family='var(--mono-font)'] {
92
+ font-size-adjust: var(--mono-font-size-adjust);
93
+ }
94
+
95
+ .katex {
96
+ font-size-adjust: none;
97
+ }
98
+
89
99
  tt,
90
100
  code {
91
101
  padding: var(--mono-padding);
@@ -78,6 +78,7 @@
78
78
  font-family:
79
79
  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
80
80
  sans-serif;
81
+ font-size-adjust: none;
81
82
  font-feature-settings: normal;
82
83
  }
83
84
 
@@ -85,6 +86,7 @@
85
86
  // Avoid requesting the bundled serif face just to render the inactive
86
87
  // preview on a default sans page.
87
88
  font-family: var(--serif-preview-font);
89
+ font-size-adjust: none;
88
90
  font-feature-settings: var(--serif-font-feature-settings);
89
91
  }
90
92
 
@@ -95,6 +97,7 @@
95
97
 
96
98
  :root[data-font-preference='serif'] .font-picker-option-serif {
97
99
  font-family: var(--serif-font);
100
+ font-size-adjust: var(--font-size-adjust);
98
101
  }
99
102
 
100
103
  .preference-picker-option[aria-pressed='true'] {
package/src/code.scss CHANGED
@@ -35,6 +35,7 @@ body.code {
35
35
  padding: 0 0.75em;
36
36
  margin-right: var(--gap);
37
37
  font-family: var(--mono-font);
38
+ font-size-adjust: var(--mono-font-size-adjust);
38
39
  font-feature-settings: var(--mono-font-feature-settings);
39
40
  color: var(--fg2-color);
40
41
  text-align: right;
package/src/style.scss CHANGED
@@ -391,9 +391,11 @@ h6.has-subtitle {
391
391
  }
392
392
 
393
393
  .small-caps {
394
- font-size: 0.9em;
395
- font-weight: 600;
394
+ margin-right: -0.05em;
395
+ font-variant-caps: all-small-caps;
396
+ font-synthesis-small-caps: none;
396
397
  text-transform: uppercase;
398
+ letter-spacing: 0.05em;
397
399
  }
398
400
 
399
401
  dl {
@@ -3,6 +3,7 @@ import {
3
3
  detectPeriodStyle,
4
4
  normalizeHM,
5
5
  to12Hour,
6
+ to12HourMarkup,
6
7
  type PeriodStyle,
7
8
  } from './time-format';
8
9
 
@@ -22,6 +23,23 @@ function parseHHMM(hhmm: string) {
22
23
  return Number(h) * 60 + Number(m);
23
24
  }
24
25
 
26
+ function getRangeEnd(el: HTMLTimeElement): HTMLTimeElement | null {
27
+ const separator = el.nextSibling;
28
+ const candidate = separator?.nextSibling;
29
+ if (
30
+ separator?.nodeType !== 3 ||
31
+ !/^\s*(?:--|–|—)\s*$/.test(separator.textContent ?? '') ||
32
+ candidate?.nodeType !== 1
33
+ ) {
34
+ return null;
35
+ }
36
+
37
+ const end = candidate as HTMLElement;
38
+ return end.tagName === 'TIME' && end.hasAttribute('datetime')
39
+ ? (end as HTMLTimeElement)
40
+ : null;
41
+ }
42
+
25
43
  // Compute UTC offset (in minutes) for a time zone at given date (DST-aware)
26
44
  function getOffsetMinutes(tz: string, date: Date): number {
27
45
  const dtf = new Intl.DateTimeFormat('en-US', {
@@ -172,11 +190,33 @@ export default (window: Window) => {
172
190
  const originalStyle = periodStyles.get(el) ?? null;
173
191
  const originalIsPm = Math.floor(baseMinutes / 60) >= 12;
174
192
  const periodChanged = originalIsPm !== h >= 12 || dayShift !== 0;
175
- const style =
193
+ let style =
176
194
  originalStyle === null && periodChanged
177
195
  ? pagePeriodStyle
178
196
  : originalStyle;
179
- el.innerHTML = to12Hour(h, m, style) + suffix;
197
+
198
+ const rangeEnd = getRangeEnd(el);
199
+ const rangeEndDatetime = rangeEnd?.getAttribute('datetime');
200
+ const rangeEndMinutes = rangeEndDatetime
201
+ ? parseHHMM(rangeEndDatetime)
202
+ : NaN;
203
+ if (
204
+ originalStyle === null &&
205
+ rangeEnd !== null &&
206
+ !isNaN(rangeEndMinutes)
207
+ ) {
208
+ const [rangeEndHour] = normalizeHM(rangeEndMinutes + deltaMinutes);
209
+ style =
210
+ h >= 12 === rangeEndHour >= 12
211
+ ? null
212
+ : (periodStyles.get(rangeEnd) ?? pagePeriodStyle);
213
+ }
214
+
215
+ const timeZone =
216
+ isDefault || style === null || rangeEnd !== null
217
+ ? ''
218
+ : ` <span class="small-caps">${target.abbreviation}</span>`;
219
+ el.innerHTML = to12HourMarkup(h, m, style) + timeZone + suffix;
180
220
 
181
221
  if (isDefault) {
182
222
  el.classList.remove('is-modified');
@@ -1,9 +1,3 @@
1
- time[datetime] {
2
- &.is-modified {
3
- text-decoration: var(--fg2-color) underline dotted;
4
- }
5
- }
6
-
7
1
  span.next-prev-day {
8
2
  font-style: italic;
9
3
  color: var(--fg2-color);
@@ -35,6 +35,19 @@ export function to12Hour(
35
35
  return `${hour12}:${pad(m)} ${period}`;
36
36
  }
37
37
 
38
+ export function to12HourMarkup(
39
+ h: number,
40
+ m: number,
41
+ style: PeriodStyle | null = DEFAULT_PERIOD_STYLE,
42
+ ) {
43
+ const hour12 = ((h + 11) % 12) + 1;
44
+ if (!style) {
45
+ return `${hour12}:${pad(m)}`;
46
+ }
47
+ const period = h >= 12 ? style[1] : style[0];
48
+ return `${hour12}:${pad(m)} <span class="small-caps">${period}</span>`;
49
+ }
50
+
38
51
  export function normalizeHM(totalMinutes: number) {
39
52
  const mins = ((totalMinutes % 1440) + 1440) % 1440;
40
53
  const h = Math.floor(mins / 60);
@@ -17,6 +17,7 @@
17
17
  body.code .toc ol li:has(a) {
18
18
  font-family: var(--mono-font);
19
19
  font-size: var(--mono-font-size);
20
+ font-size-adjust: var(--mono-font-size-adjust);
20
21
  font-feature-settings: var(--mono-font-feature-settings);
21
22
  }
22
23
 
@@ -30,6 +31,7 @@ body.code .toc ol a {
30
31
  display: block;
31
32
  font-family: var(--mono-font);
32
33
  font-size: var(--font-size-small);
34
+ font-size-adjust: var(--mono-font-size-adjust);
33
35
  font-style: italic;
34
36
  font-feature-settings: var(--mono-font-feature-settings);
35
37
  text-align: center;
@@ -186,6 +186,7 @@
186
186
  height: auto;
187
187
  font-family: var(--mono-font, monospace);
188
188
  font-size: 15px;
189
+ font-size-adjust: var(--mono-font-size-adjust, none);
189
190
  font-feature-settings: var(--mono-font-feature-settings, normal);
190
191
 
191
192
  .trace-separator {
@@ -65,6 +65,8 @@
65
65
  --mono-font: var(--sans-mono-font);
66
66
  --font-feature-settings: var(--sans-font-feature-settings);
67
67
  --mono-font-feature-settings: var(--sans-mono-font-feature-settings);
68
+ --font-size-adjust: none;
69
+ --mono-font-size-adjust: none;
68
70
  --font-size: 1rem;
69
71
  --font-size-smaller: 0.9375em;
70
72
  --font-size-small: 0.8125em;