@doenet/doenetml-iframe 0.7.23-dev.472 → 0.7.23-dev.476

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.
Files changed (4) hide show
  1. package/index.js +134 -24
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
  4. package/style.css +240 -23
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@doenet/doenetml-iframe",
3
3
  "type": "module",
4
4
  "description": "A renderer for DoenetML contained in an iframe",
5
- "version": "0.7.23-dev.472",
5
+ "version": "0.7.23-dev.476",
6
6
  "license": "AGPL-3.0-or-later",
7
7
  "homepage": "https://github.com/Doenet/DoenetML#readme",
8
8
  "repository": {
package/style.css CHANGED
@@ -1,19 +1,52 @@
1
+ .container {
2
+ width: 100%;
3
+ }
4
+ @media (min-width: 640px) {
5
+ .container {
6
+ max-width: 640px;
7
+ }
8
+ }
9
+ @media (min-width: 768px) {
10
+ .container {
11
+ max-width: 768px;
12
+ }
13
+ }
14
+ @media (min-width: 1024px) {
15
+ .container {
16
+ max-width: 1024px;
17
+ }
18
+ }
19
+ @media (min-width: 1280px) {
20
+ .container {
21
+ max-width: 1280px;
22
+ }
23
+ }
24
+ @media (min-width: 1536px) {
25
+ .container {
26
+ max-width: 1536px;
27
+ }
28
+ }
29
+ .fixed {
30
+ position: fixed;
31
+ }
1
32
  .inline {
2
33
  display: inline;
3
34
  }
4
-
5
35
  .overline {
6
36
  text-decoration-line: overline;
7
37
  }
8
-
9
38
  .blur {
10
39
  --tw-blur: blur(8px);
11
40
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
12
41
  }
13
-
14
42
  .filter {
15
43
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
16
44
  }
45
+ .transition {
46
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
47
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
48
+ transition-duration: 150ms;
49
+ }
17
50
 
18
51
  .keyboard-button {
19
52
  display: inline-flex;
@@ -82,8 +115,13 @@
82
115
  }
83
116
 
84
117
  .virtual-keyboard {
118
+ /*
119
+ * How wide the keyboard may spread. A variable because the sub-keyboard
120
+ * has to agree with it, and because the touch-device block below raises
121
+ * it — two literals that must match are two literals that can drift.
122
+ */
123
+ --keyboard-max-width: 42rem;
85
124
  display: flex;
86
- max-width: 42rem;
87
125
  justify-content: center;
88
126
  row-gap: 0.25rem;
89
127
  -moz-column-gap: 0.75rem;
@@ -91,7 +129,6 @@
91
129
  }
92
130
 
93
131
  @media (min-width: 640px) {
94
-
95
132
  .virtual-keyboard {
96
133
  row-gap: 0.5rem;
97
134
  }
@@ -102,12 +139,15 @@
102
139
  }
103
140
 
104
141
  @media (min-width: 640px) {
105
-
106
142
  .virtual-keyboard {
107
143
  flex-wrap: nowrap;
108
144
  }
109
145
  }
110
146
 
147
+ .virtual-keyboard {
148
+ max-width: var(--keyboard-max-width);
149
+ }
150
+
111
151
  .virtual-keyboard .row {
112
152
  display: flex;
113
153
  flex-basis: 100%;
@@ -117,7 +157,6 @@
117
157
  }
118
158
 
119
159
  @media (min-width: 640px) {
120
-
121
160
  .virtual-keyboard .row {
122
161
  -moz-column-gap: 0.5rem;
123
162
  column-gap: 0.5rem;
@@ -133,7 +172,6 @@
133
172
  }
134
173
 
135
174
  @media (min-width: 640px) {
136
-
137
175
  .virtual-keyboard .keyboard-region {
138
176
  -moz-column-gap: 0.5rem;
139
177
  column-gap: 0.5rem;
@@ -147,7 +185,6 @@
147
185
  }
148
186
 
149
187
  @media (min-width: 640px) {
150
-
151
188
  .virtual-keyboard .keyboard-region .key {
152
189
  padding-left: 1rem;
153
190
  padding-right: 1rem;
@@ -156,14 +193,12 @@
156
193
 
157
194
  .virtual-keyboard .sub-keyboard {
158
195
  display: flex;
159
- max-width: 42rem;
160
196
  flex-wrap: wrap;
161
197
  justify-content: center;
162
198
  row-gap: 0.25rem;
163
199
  }
164
200
 
165
201
  @media (min-width: 640px) {
166
-
167
202
  .virtual-keyboard .sub-keyboard {
168
203
  row-gap: 0.5rem;
169
204
  }
@@ -171,6 +206,7 @@
171
206
 
172
207
  .virtual-keyboard .sub-keyboard {
173
208
  height: 100%;
209
+ max-width: var(--keyboard-max-width);
174
210
  }
175
211
 
176
212
  .virtual-keyboard button {
@@ -291,7 +327,6 @@
291
327
  }
292
328
 
293
329
  @media (min-width: 640px) {
294
-
295
330
  .virtual-keyboard-tab-list button {
296
331
  padding: 0.5rem;
297
332
  padding-left: 0.75rem;
@@ -313,10 +348,90 @@
313
348
  --tw-text-opacity: 1;
314
349
  color: rgb(37 99 235 / var(--tw-text-opacity, 1));
315
350
  }
351
+
352
+ /*
353
+ * Touch devices — see the note beside the matching block in
354
+ * `keyboard-tray.css`. A key was 39x40 on a phone and a layout tab 30x25;
355
+ * both are below the 44px a fingertip needs (issue #449).
356
+ *
357
+ * Height is raised outright, since it costs only tray height. Width is left
358
+ * to the flex layout, which already gives each key an equal share of the row:
359
+ * a phone cannot fit twelve 44px-wide keys across, and forcing it would push
360
+ * the row into an overflow or a wrap that helps no one. What helps the other
361
+ * end — a tablet, where the row had room to spare and the keys stayed small
362
+ * in the middle of it — is room for the row to grow, so the even share each
363
+ * key gets is a larger one, and a ceiling raised to match.
364
+ *
365
+ * Both halves are needed. `--keyboard-max-width` alone would hand the extra
366
+ * room to shift, backspace and space, the only keys with no ceiling of their
367
+ * own; the per-key `max-width` alone has nothing extra to hand out. Note that
368
+ * the ceiling is in `em`, and a key is a `button`, which this package's
369
+ * partial copy of Tailwind's preflight leaves at the UA font size of
370
+ * 13.33px — so `4em` is 53px and `4.5em` is 60px, not 64 and 72.
371
+ *
372
+ * Last in the file because every rule here raises one above it and each pair
373
+ * has equal specificity, so source order is all that separates them — a media
374
+ * query adds none. Shift, backspace and space are the exception: their
375
+ * `max-width: none` is set on `.virtual-keyboard .key-*`, two classes, which
376
+ * already outranks the one-class-one-type `button` selector here, so they
377
+ * stay unbounded without being named again. Backspace on the numeric layout
378
+ * is the exception to that exception — a rule above puts its ceiling back at
379
+ * `4em`, and outranks this block for the same reason — so it is the one key
380
+ * that has to be raised by name.
381
+ */
382
+ @media (pointer: coarse) {
383
+ .virtual-keyboard {
384
+ --keyboard-max-width: 48rem;
385
+ }
386
+
387
+ .virtual-keyboard button {
388
+ min-height: 2.75rem;
389
+ max-width: 4.5em;
390
+ }
391
+ .virtual-keyboard.numeric .key-backspace {
392
+ max-width: 4.5em;
393
+ }
394
+ .virtual-keyboard-tab-list button {
395
+ min-height: 2.75rem;
396
+ padding-left: 0.75rem;
397
+ padding-right: 0.75rem;
398
+ }
399
+ }
316
400
  /*
317
401
  Tailwind base is purposely not included because we want all styles to be prefixed. We manually copy in whatever is needed from tailwind preflight.
318
402
  @tailwind base;
319
403
  */
404
+ .container {
405
+ width: 100%;
406
+ }
407
+ @media (min-width: 640px) {
408
+ .container {
409
+ max-width: 640px;
410
+ }
411
+ }
412
+ @media (min-width: 768px) {
413
+ .container {
414
+ max-width: 768px;
415
+ }
416
+ }
417
+ @media (min-width: 1024px) {
418
+ .container {
419
+ max-width: 1024px;
420
+ }
421
+ }
422
+ @media (min-width: 1280px) {
423
+ .container {
424
+ max-width: 1280px;
425
+ }
426
+ }
427
+ @media (min-width: 1536px) {
428
+ .container {
429
+ max-width: 1536px;
430
+ }
431
+ }
432
+ .fixed {
433
+ position: fixed;
434
+ }
320
435
  .inline {
321
436
  display: inline;
322
437
  }
@@ -330,6 +445,11 @@ Tailwind base is purposely not included because we want all styles to be prefixe
330
445
  .filter {
331
446
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
332
447
  }
448
+ .transition {
449
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
450
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
451
+ transition-duration: 150ms;
452
+ }
333
453
 
334
454
  /*
335
455
  * Some styles from tailwind preflight need to be included here
@@ -374,6 +494,15 @@ Tailwind base is purposely not included because we want all styles to be prefixe
374
494
 
375
495
  --keyboard-tray-height: 280px;
376
496
 
497
+ /*
498
+ * The tab that peeks above a closed tray. Its height and the distance it
499
+ * is raised by are the same measurement — it sits exactly its own height
500
+ * above the tray's top edge — so they are one value, not two that have to
501
+ * be kept equal.
502
+ */
503
+ --keyboard-tab-height: 1.5rem;
504
+ --keyboard-tab-width: 3rem;
505
+
377
506
  border-top: 1px solid var(--kb-tray-border-top);
378
507
 
379
508
  position: fixed;
@@ -399,12 +528,67 @@ Tailwind base is purposely not included because we want all styles to be prefixe
399
528
  transition-duration: 300ms;
400
529
 
401
530
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
402
- min-height: var(--keyboard-tray-height);
403
- max-height: calc(100vh - 1.5rem);
531
+ /* A column, so `.keyboard-container` is bound by the height set below. */
532
+ display: flex;
533
+ flex-direction: column;
534
+ /*
535
+ * The tray may never be so tall that it carries its own tab off the top of
536
+ * the screen: the tab hangs exactly `--keyboard-tab-height` above the
537
+ * tray's top edge, so that much has to stay clear. Both bounds are held to
538
+ * it — the floor as well as the ceiling, because a `min-height` outranks a
539
+ * `max-height` and would otherwise reinstate the overshoot on a viewport
540
+ * shorter than the floor. Written against the variable rather than
541
+ * repeating its value: widening the tab for a fingertip is exactly the
542
+ * change that a literal here would have missed.
543
+ */
544
+ --keyboard-tray-max-height: calc(100vh - var(--keyboard-tab-height));
545
+ min-height: min(
546
+ var(--keyboard-tray-height),
547
+ var(--keyboard-tray-max-height)
548
+ );
549
+ max-height: var(--keyboard-tray-max-height);
404
550
  z-index: 10000;
405
551
  background-color: var(--kb-tray-bg);
406
552
  }
407
553
 
554
+ /*
555
+ * The layout tabs and the keyboard under them, and the only part of the
556
+ * tray that scrolls. A viewport too short for the keyboard — a phone held
557
+ * sideways, or any short window — used to cut the bottom rows off, which
558
+ * on the numeric layout is the number pad; taller keys for a fingertip
559
+ * would have cut off more. `min-height: 0` is what lets it shrink: a flex
560
+ * item's automatic minimum is its own content, which would otherwise push
561
+ * the overflow straight back out to the tray.
562
+ *
563
+ * The layout tabs scroll with the keys rather than staying pinned, so a
564
+ * tray reopened at the position it was left at would be missing them.
565
+ * `keyboard-tray.tsx` scrolls this back to the top as the tray opens.
566
+ *
567
+ * A finger can pan it even though the tray cancels the default action of
568
+ * `pointerdown` across its whole subtree (see `keyboard-tray.tsx`): what
569
+ * suppresses a pan is `touch-action` or a cancelled `touchstart` /
570
+ * `touchmove`, and the tray does neither. Confirmed in Chromium with a
571
+ * real coarse pointer, and asserted in
572
+ * `cypress/e2e/accessibility/virtualKeyboardTouchTargets.cy.js`; iOS
573
+ * Safari has not been tried. `overscroll-behavior` keeps a pan that runs
574
+ * off the end of it from scrolling the document behind the tray.
575
+ */
576
+
577
+ #virtual-keyboard-tray .keyboard-container {
578
+ min-height: 0;
579
+ overflow-y: auto;
580
+ overscroll-behavior: contain;
581
+ }
582
+
583
+ /*
584
+ * Outside `.keyboard-container`'s scroll for positioning purposes even
585
+ * though it is inside it in the markup: its containing block is the tray,
586
+ * so it neither scrolls away nor is clipped, and stays in the corner
587
+ * where it can be reached. That holds only while nothing between the two
588
+ * is positioned — give `.keyboard-container` a `position` and the button
589
+ * starts scrolling away with the keys.
590
+ */
591
+
408
592
  #virtual-keyboard-tray .close-keyboard-button {
409
593
  position: absolute;
410
594
  top: 0px;
@@ -434,19 +618,19 @@ Tailwind base is purposely not included because we want all styles to be prefixe
434
618
  }
435
619
 
436
620
  /*
437
- * Inline-end footprint of this button (w-12 + me-4 = 4rem) is mirrored
438
- * by `--keyboard-tab-reserve-width` in
621
+ * Inline-end footprint of this button (`--keyboard-tab-width` + me-4) is
622
+ * mirrored by `--keyboard-tab-reserve-width` in
439
623
  * `packages/doenetml/src/EditorViewer/editor-viewer.css` so the editor
440
624
  * footer can shift its last element inward to clear it. Keep the two
441
- * values in sync — and keep both on the *same* axis. `end-0` here pairs
442
- * with `margin-inline-end` there; making one logical and leaving the
443
- * other physical would send the tab and the space reserved for it to
444
- * opposite edges under `rtl`, which is worse than either alone.
625
+ * values in sync — including the touch-device widening below and keep
626
+ * both on the *same* axis. `end-0` here pairs with `margin-inline-end`
627
+ * there; making one logical and leaving the other physical would send the
628
+ * tab and the space reserved for it to opposite edges under `rtl`, which
629
+ * is worse than either alone.
445
630
  */
446
631
 
447
632
  #virtual-keyboard-tray .open-keyboard-button {
448
633
  position: absolute;
449
- top: -1.5rem;
450
634
  inset-inline-end: 0px;
451
635
  margin-inline-end: 1rem;
452
636
  border-top-left-radius: 0.25rem;
@@ -468,13 +652,14 @@ Tailwind base is purposely not included because we want all styles to be prefixe
468
652
 
469
653
  #virtual-keyboard-tray .open-keyboard-button {
470
654
  display: flex;
471
- height: 1.5rem;
472
- width: 3rem;
473
655
  align-items: center;
474
656
  justify-content: center;
475
657
  border-width: 1px;
476
658
  --tw-bg-opacity: 1;
477
659
  background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
660
+ top: calc(-1 * var(--keyboard-tab-height));
661
+ width: var(--keyboard-tab-width);
662
+ height: var(--keyboard-tab-height);
478
663
  }
479
664
 
480
665
  #virtual-keyboard-tray .virtual-keyboard-tab-list {
@@ -494,6 +679,38 @@ Tailwind base is purposely not included because we want all styles to be prefixe
494
679
  margin-right: auto;
495
680
  }
496
681
 
682
+ /*
683
+ * Touch devices: everything here is tapped with a fingertip rather than
684
+ * pointed at, so every control needs a target a fingertip can land on. 44px is
685
+ * the minimum in Apple's HIG and in WCAG 2.5.5. The tray shipped with a 48x24
686
+ * tab to open it, a 24x24 button to close it, and layout tabs measuring 30x25
687
+ * on a phone — issue #449.
688
+ *
689
+ * Keyed on the reader's primary pointer being coarse rather than on how wide
690
+ * the viewport is: a narrow window on a desktop is still driven by a mouse,
691
+ * and a tablet held in two hands is not, however much room it has. This is the
692
+ * same test the viewer uses to decide whether to suppress the device's own
693
+ * on-screen keyboard, so the two stay consistent about what a touch device is.
694
+ */
695
+ @media (pointer: coarse) {
696
+ #virtual-keyboard-tray {
697
+ --keyboard-tab-height: 2.75rem;
698
+ --keyboard-tab-width: 4rem;
699
+ }
700
+
701
+ #virtual-keyboard-tray .open-keyboard-button {
702
+ /* The icon is drawn at 1em, so it grows with the tab. */
703
+ font-size: 1.25rem;
704
+ line-height: 1.75rem;
705
+ }
706
+
707
+ #virtual-keyboard-tray .close-keyboard-button {
708
+ margin: 0.25rem;
709
+ height: 2.75rem;
710
+ width: 2.75rem;
711
+ }
712
+ }
713
+
497
714
  /* Dark-mode overrides — applied when data-theme="dark" is written to #virtual-keyboard-tray */
498
715
  #virtual-keyboard-tray[data-theme="dark"] {
499
716
  --kb-tray-bg: #1e1e1e;