@abreen/tada 1.15.0 → 1.15.1

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.
@@ -28,10 +28,8 @@ Selection sort's strength is its simplicity.
28
28
  - `index_smallest()` always scans from `start` to the end
29
29
  - It requires no additional memory (other than local variables)
30
30
 
31
- However
32
-
33
- - It has no `break` statements & can't return early
34
- - No difference between best, average and worst cases
31
+ However, it has no `break` statements and therefore can't return early if
32
+ the array is already sorted.
35
33
 
36
34
  ---
37
35
 
@@ -48,10 +46,10 @@ However
48
46
  The innermost statement compares `nums[i]` and `nums[curr]`.
49
47
 
50
48
  - when `i` is 0, the comparison is executed $n - 1$ times
51
- - when `i` is 1, the innermost statement is executed $n - 2$ times
49
+ - when `i` is 1, the comparison is executed $n - 2$ times
52
50
  - $\dots$
53
- - when `i` is $n - 3$, the innermost statement is executed two times
54
- - when `i` is $n - 2$, the innermost statement is executed one time
51
+ - when `i` is $n - 3$, the comparison is executed two times
52
+ - when `i` is $n - 2$, the comparison is executed one time
55
53
 
56
54
  Therefore the total number of comparisons is
57
55
 
@@ -59,3 +57,20 @@ $$
59
57
  (n-1) + (n-2) + \dots + 1 = \sum_{i=1}^{n-1}i
60
58
  $$
61
59
 
60
+ ---
61
+
62
+ ## Review
63
+
64
+ ??? question The outer loop of selection sort runs
65
+ - [ ] $n$ times
66
+ - [x] $n - 1$ times
67
+ - [ ] $n^2$ times
68
+ - [ ] $n - 2$ times
69
+ ???
70
+
71
+ ??? question What is selection sort's best case?
72
+ - [ ] An already sorted array
73
+ - [ ] A reverse-sorted array
74
+ - [ ] An array filled with the same element
75
+ - [x] Its best, worst, and average cases are all the same
76
+ ???
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abreen/tada",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "type": "module",
5
5
  "description": "A static site generator",
6
6
  "license": "MIT",
@@ -3,7 +3,7 @@
3
3
  .question {
4
4
  --question-label-width: 1.2em;
5
5
 
6
- margin-bottom: 2rem;
6
+ margin-bottom: 1rem;
7
7
  }
8
8
 
9
9
  .question-q,
@@ -136,13 +136,13 @@
136
136
  .question-multiple-choice-options {
137
137
  display: flex;
138
138
  flex-direction: column;
139
- gap: 0.75em;
139
+ gap: 0.5em;
140
140
  margin-left: calc(var(--question-label-width) + 0.5em);
141
141
  }
142
142
 
143
143
  .question-multiple-choice-option {
144
144
  position: relative;
145
- padding: 0.5em calc(var(--question-result-icon-size) + 1em) 0.5em 0.5em;
145
+ padding: 0.25em calc(var(--question-result-icon-size) + 1em) 0.25em 0.5em;
146
146
  cursor: pointer;
147
147
  border: 0.125em solid var(--bg2-color);
148
148
  border-radius: var(--border-radius);
@@ -156,6 +156,14 @@
156
156
  }
157
157
  }
158
158
 
159
+ .question-multiple-choice-option:has(> code):not(
160
+ :has(> :not(code, .question-multiple-choice-result))
161
+ )
162
+ > code {
163
+ padding: 0;
164
+ background: none;
165
+ }
166
+
159
167
  .question-multiple-choice-option::after {
160
168
  position: absolute;
161
169
  top: 50%;
@@ -224,11 +224,21 @@ export default function mountSlides(window: Window): void | (() => void) {
224
224
  }
225
225
  }
226
226
 
227
+ function scrollToSlide(index: number): void {
228
+ const slide = slides[index];
229
+ if (!slide || typeof slide.scrollIntoView !== 'function') {
230
+ return;
231
+ }
232
+
233
+ slide.scrollIntoView({ block: 'start', inline: 'nearest' });
234
+ }
235
+
227
236
  function exitPresentation(): void {
228
237
  if (!isPresenting) {
229
238
  return;
230
239
  }
231
240
 
241
+ const exitingActiveIndex = activeIndex;
232
242
  const shouldExitFullscreen =
233
243
  presentationMode === 'fullscreen' &&
234
244
  domDocument.fullscreenElement != null &&
@@ -245,8 +255,16 @@ export default function mountSlides(window: Window): void | (() => void) {
245
255
  setTraceToolbarVisibility(false);
246
256
 
247
257
  if (shouldExitFullscreen) {
248
- void domDocument.exitFullscreen?.();
258
+ void domDocument
259
+ .exitFullscreen()
260
+ .finally(() => scrollToSlide(exitingActiveIndex))
261
+ .catch(() => {
262
+ // ignored
263
+ });
264
+ return;
249
265
  }
266
+
267
+ scrollToSlide(exitingActiveIndex);
250
268
  }
251
269
 
252
270
  function resetReadyTraces(scope: HTMLElement = slidesRoot): void {
@@ -440,15 +458,7 @@ export default function mountSlides(window: Window): void | (() => void) {
440
458
  return;
441
459
  }
442
460
 
443
- const activeSlide = slides[activeIndex];
444
- if (!activeSlide) {
445
- return;
446
- }
447
-
448
- if (
449
- !(event.target instanceof domView.Node) ||
450
- !activeSlide.contains(event.target)
451
- ) {
461
+ if (!(event.target instanceof domView.Node)) {
452
462
  return;
453
463
  }
454
464
 
@@ -6,7 +6,7 @@
6
6
  }
7
7
 
8
8
  body.is-presenting {
9
- --slides-scale: clamp(150%, 3.6vmin, 250%);
9
+ --slides-scale: clamp(150%, 2.6vmin, 200%);
10
10
 
11
11
  overflow: hidden;
12
12
  }
@@ -55,20 +55,20 @@ body.is-presenting .slide {
55
55
  @include user-select(none);
56
56
 
57
57
  position: fixed;
58
- top: 50%;
58
+ top: 0;
59
59
  left: 50%;
60
60
  z-index: 1000;
61
61
  box-sizing: border-box;
62
62
  display: none;
63
- width: min(100vw, calc(100vh * 4 / 3));
64
- height: min(100vh, calc(100vw * 3 / 4));
63
+ width: min(calc(100vw - var(--gap) - var(--gap)), 70rem);
64
+ height: 100vh;
65
65
  padding: calc(3 * var(--gap));
66
66
  overflow: auto;
67
67
  font-size: var(--slides-scale);
68
68
  letter-spacing: 0.2px;
69
69
  outline: none;
70
70
  background: var(--bg-color);
71
- transform: translate(-50%, -50%);
71
+ transform: translateX(-50%);
72
72
 
73
73
  > :first-child {
74
74
  margin-top: 0;
@@ -57,8 +57,8 @@
57
57
  // Mask icons (color-agnostic, painted via background-color: currentColor)
58
58
  --icon-external-link: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path d='M6 18 L20 4 M10 4 H20 V14' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
59
59
  --icon-anchor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 28'><path d='M11 4 L8 20 M17 4 L14 20 M5 9 H21 M3 15 H19' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
60
- --icon-warning: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><polygon points='12,2 22,20 2,20' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='black' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='16' x2='12' y2='16' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
61
- --icon-note: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='black' stroke-width='1.5'/><line x1='12' y1='10' x2='12' y2='16' stroke='black' stroke-width='2' stroke-linecap='round'/><line x1='12' y1='7' x2='12' y2='7' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
60
+ --icon-warning: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M10.8 4.2 Q12 2 13.2 4.2 L20.8 17.9 Q22 20 19.6 20 H4.4 Q2 20 3.2 17.9 Z' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/><line x1='12' y1='9' x2='12' y2='13' stroke='black' stroke-width='2' stroke-linecap='square'/><line x1='12' y1='16' x2='12' y2='16' stroke='black' stroke-width='2' stroke-linecap='square'/></svg>");
61
+ --icon-note: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='9.5' fill='none' stroke='black' stroke-width='1.5'/><line x1='12' y1='10' x2='12' y2='16' stroke='black' stroke-width='2' stroke-linecap='square'/><line x1='12' y1='7' x2='12' y2='7' stroke='black' stroke-width='2' stroke-linecap='square'/></svg>");
62
62
  --icon-check: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path d='M5 12.5 10 17 19 7' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
63
63
  --icon-search: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><circle cx='11' cy='11' r='7' stroke='<%= iconColor %>' stroke-width='2' fill='none'/><line x1='16.5' y1='16.5' x2='22' y2='22' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/></svg>");
64
64
  --icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><polyline points='9 18 15 12 9 6' stroke='<%= iconColor %>' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");