@pocketprep/ui-kit 3.4.5 → 3.4.6

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.
@@ -84,11 +84,12 @@
84
84
  :is-dark-mode="isDarkMode"
85
85
  :review-mode="reviewMode"
86
86
  :image-url-prefix="imageUrlPrefix"
87
+ :show-passage-image-long-alt="showPassageImageLongAlt"
87
88
  :passage-image-url="passageImageUrl"
88
89
  :passage-image-long-alt="passageImageLongAlt"
89
90
  :passage-image-alt="passageImageAlt"
90
91
  :passage-and-image-title="passageAndImageTitle"
91
- @emitTogglePassageImageLongAlt="togglePassageImageLongAlt"
92
+ @togglePassageImageLongAltDropdown="togglePassageImageLongAlt"
92
93
  />
93
94
  <Paywall
94
95
  v-if="showPaywall"
@@ -300,7 +301,6 @@
300
301
  :global-metrics="globalMetrics"
301
302
  :show-answers="showAnswers"
302
303
  :is-MCR="isMCR"
303
- :show-explanation="showExplanation"
304
304
  :show-explanation-image-long-alt="showExplanationImageLongAlt"
305
305
  :explanation-image-url="explanationImageUrl"
306
306
  :explanation-image-alt="explanationImageAlt"
@@ -310,7 +310,7 @@
310
310
  :is-dark-mode="isDarkMode"
311
311
  :question-el="questionEl"
312
312
  :breakpoints="breakpoints"
313
- @emitToggleExplanationImageLongAlt="toggleExplanationImageLongAlt"
313
+ @toggleDropdownExplanationImageLongAlt="toggleExplanationImageLongAlt"
314
314
  />
315
315
  </div>
316
316
  <template v-if="!globalMetrics">
@@ -416,115 +416,27 @@
416
416
  </div>
417
417
  <slot name="unansweredFlaggedNamesTable" />
418
418
  </div>
419
- <div
419
+ <Summary
420
420
  v-if="isMCR && showAnswers && !showPaywall"
421
- v-dark="isDarkMode"
422
- v-breakpoint:questionEl="breakpoints"
421
+ ref="uikit-question__summary"
423
422
  class="uikit-question__summary"
424
- >
425
- <div class="uikit-question__summary-title">
426
- {{ isCorrect ? 'Correct': isUnanswered ? 'Unanswered' : 'Incorrect' }}
427
- </div>
428
- <PocketButton
429
- v-breakpoint:questionEl="breakpoints"
430
- type="tertiary-small"
431
- class="uikit-question__summary-toggle-explanation"
432
- :class="{ 'uikit-question__summary-toggle-explanation': reviewMode }"
433
- :is-dark-mode="isDarkMode"
434
- :aria-expanded="showExplanation ? 'true' : 'false'"
435
- @click="toggleExplanation"
436
- @mousedown.prevent
437
- >
438
- <span
439
- ref="uikit-question__summary-toggle-explanation-text"
440
- class="uikit-question__summary-toggle-explanation-text"
441
- tabindex="-1"
442
- >{{ showExplanation ? 'Hide' : 'Show' }} Explanation</span>
443
- <Icon
444
- v-breakpoint:questionEl="breakpoints"
445
- type="accordionArrow"
446
- class="uikit-question__summary-toggle-explanation-icon"
447
- :class="{
448
- 'uikit-question__summary-toggle-explanation-icon--up': showExplanation,
449
- }"
450
- />
451
- </PocketButton>
452
- <div
453
- v-if="showExplanation"
454
- v-breakpoint:questionEl="breakpoints"
455
- class="uikit-question__summary-dropdown-explanation"
456
- >
457
- <div
458
- v-dark="isDarkMode"
459
- class="uikit-question__summary-dropdown-explanation-text"
460
- v-html="question.explanation"
461
- />
462
- <img
463
- v-if="explanationImageUrl"
464
- v-dark="isDarkMode"
465
- class="uikit-question__summary-dropdown-explanation-image"
466
- :src="explanationImageUrl"
467
- :alt="`${explanationImageAlt}. Extended image description below.`"
468
- >
469
- <PocketButton
470
- v-if="explanationImageLongAlt"
471
- v-breakpoint:questionEl="breakpoints"
472
- type="tertiary-small"
473
- class="uikit-question__toggle-summary-dropdown-explanation-img-description"
474
- :class="{
475
- 'uikit-question__toggle-summary-dropdown-explanation-img-description--open':
476
- showExplanationImageLongAlt,
477
- 'uikit-question__toggle-summary-dropdown-explanation-img-description--no-reference':
478
- !reference || hideReferences,
479
- }"
480
- :is-dark-mode="isDarkMode"
481
- :aria-expanded="showExplanationImageLongAlt ? 'true' : 'false'"
482
- @click.stop="toggleExplanationImageLongAlt"
483
- @mousedown.prevent
484
- >
485
- <span class="uikit-question__toggle-summary-dropdown-explanation-img-description-text">
486
- Image Description
487
- </span>
488
- <Icon
489
- class="uikit-question__toggle-summary-dropdown-explanation-img-description-icon"
490
- :class="{
491
- 'uikit-question__toggle-summary-dropdown-explanation-img-description-icon--up':
492
- showExplanationImageLongAlt,
493
- }"
494
- type="accordionArrow"
495
- />
496
- </PocketButton>
497
- <div
498
- v-if="showExplanationImageLongAlt"
499
- ref="uikit-question__summary-dropdown-explanation-img-description"
500
- v-dark="isDarkMode"
501
- v-breakpoint:questionEl="breakpoints"
502
- class="uikit-question__summary-dropdown-explanation-img-description"
503
- tabindex="-1"
504
- v-html="explanationImageLongAlt"
505
- />
506
- <div
507
- v-if="reference && !hideReferences"
508
- v-dark="isDarkMode"
509
- class="uikit-question__summary-dropdown-reference"
510
- >
511
- <span class="uikit-question__summary-dropdown-reference-label">Reference: </span>
512
- <div v-html="reference" />
513
- </div>
514
- </div>
515
- <Icon
516
- v-if="isCorrect"
517
- v-dark="isDarkMode"
518
- type="correct"
519
- class="uikit-question__summary-correct-icon"
520
- />
521
- <Icon
522
- v-else
523
- v-dark="isDarkMode"
524
- type="incorrect"
525
- class="uikit-question__summary-incorrect-icon"
526
- />
527
- </div>
423
+ :question="question"
424
+ :show-explanation="showExplanation"
425
+ :show-explanation-image-long-alt="showExplanationImageLongAlt"
426
+ :explanation-image-url="explanationImageUrl"
427
+ :explanation-image-alt="explanationImageAlt"
428
+ :explanation-image-long-alt="explanationImageLongAlt"
429
+ :reference="reference"
430
+ :hide-references="hideReferences"
431
+ :is-correct="isCorrect"
432
+ :is-unanswered="isUnanswered"
433
+ :review-mode="reviewMode"
434
+ :is-dark-mode="isDarkMode"
435
+ :question-el="questionEl"
436
+ :breakpoints="breakpoints"
437
+ @toggleSummaryExplanation="toggleExplanation"
438
+ @toggleSummaryExplanationImageLongAlt="toggleExplanationImageLongAlt"
439
+ />
528
440
  <slot name="metricsTiles">
529
441
  <div
530
442
  v-if="globalMetrics"
@@ -775,6 +687,7 @@ import QuestionContext from '../Quiz/Question/QuestionContext.vue'
775
687
  import PassageAndImageDropdown from '../Quiz/Question/PassageAndImageDropdown.vue'
776
688
  import DropdownExplanation from '../Quiz/Question/DropdownExplanation.vue'
777
689
  import Paywall from '../Quiz/Question/Paywall.vue'
690
+ import Summary from '../Quiz/Question/Summary.vue'
778
691
  import type { Study } from '@pocketprep/types'
779
692
  import { breakpoint, dark } from '../../directives'
780
693
  import { studyModes } from '../../utils'
@@ -790,6 +703,7 @@ import type { Ref, TQuizMode, TChoiceKey, TChoice, TChoiceScores, TNamesRow, TVi
790
703
  PassageAndImageDropdown,
791
704
  Paywall,
792
705
  DropdownExplanation,
706
+ Summary,
793
707
  },
794
708
  directives: {
795
709
  breakpoint,
@@ -827,7 +741,6 @@ export default class Question extends Vue {
827
741
  selectedChoices: TChoiceKey[] = []
828
742
  showAnswers = false
829
743
  showExplanation = false
830
- showPassageImageDropdown = false
831
744
  showPassageImageLongAlt = false
832
745
  showExplanationImageDropdown = false
833
746
  showExplanationImageLongAlt = false
@@ -1309,26 +1222,33 @@ export default class Question extends Vue {
1309
1222
 
1310
1223
  toggleExplanationImageLongAlt () {
1311
1224
  this.showExplanationImageLongAlt = !this.showExplanationImageLongAlt
1312
-
1313
1225
  if (this.showExplanationImageLongAlt) {
1314
1226
  setTimeout(() => {
1315
- const mcrLongAlt = this.$refs['uikit-question__summary-dropdown-explanation-img-description'] as Ref
1227
+ // checks for mobile / tablet portrait uikit-question-summary
1228
+ const mcrLongAltComp = this.$refs['uikit-question__summary'] as ComponentPublicInstance | undefined
1229
+ const mcrLongAlt =
1230
+ // eslint-disable-next-line max-len
1231
+ mcrLongAltComp?.$refs['uikit-question-summary__summary-dropdown-explanation-img-description'] as HTMLElement | undefined
1316
1232
 
1317
1233
  const mobileDropdownExplanation =
1318
1234
  this.$refs['uikit-question__dropdown-explanation'] as Ref[]
1319
- const mobileDropdownExplanationComp =
1235
+ if (mobileDropdownExplanation) {
1236
+ const mobileDropdownExplanationComp =
1320
1237
  mobileDropdownExplanation[0] as ComponentPublicInstance | undefined
1321
- const mobileImgDropdownImgDescription =
1238
+ const mobileImgDropdownImgDescription =
1322
1239
  // eslint-disable-next-line max-len
1323
1240
  mobileDropdownExplanationComp?.$refs['uikit-question-dropdown-explanation__dropdown-explanation-img-description'] as HTMLElement | undefined
1324
1241
 
1242
+ if (mobileImgDropdownImgDescription?.offsetParent) {
1243
+ mobileImgDropdownImgDescription.focus()
1244
+ }
1245
+ }
1246
+
1325
1247
  const longAlt = this.$refs['uikit-question__explanation-img-description'] as Ref
1326
1248
 
1327
1249
  // Checking offsetParent tells us which element is visible
1328
1250
  if (mcrLongAlt?.offsetParent) {
1329
1251
  mcrLongAlt.focus()
1330
- } else if (mobileImgDropdownImgDescription?.offsetParent) {
1331
- mobileImgDropdownImgDescription.focus()
1332
1252
  } else if (longAlt?.offsetParent) {
1333
1253
  longAlt.focus()
1334
1254
  }
@@ -1340,16 +1260,26 @@ export default class Question extends Vue {
1340
1260
  this.showExplanation = !this.showExplanation
1341
1261
  if (!this.showExplanation) {
1342
1262
  setTimeout(() => {
1263
+ const summaryMCRComp =
1264
+ this.$refs['uikit-question__summary'] as ComponentPublicInstance | undefined
1265
+ const summaryMCRExplanation =
1266
+ // eslint-disable-next-line max-len
1267
+ summaryMCRComp?.$refs['uikit-question-summary__summary-toggle-explanation-text'] as HTMLElement | undefined
1268
+
1343
1269
  const showExplanationRef = (
1344
1270
  this.$refs['uikit-question__toggle-explanation-text']
1345
- || this.$refs['uikit-question__summary-toggle-explanation-text']
1346
1271
  ) as Element[] | Element | undefined
1347
- const showExplanationEl = (
1348
- showExplanationRef instanceof Array
1349
- ? showExplanationRef[0]
1350
- : showExplanationRef
1351
- ) as HTMLElement | undefined
1352
- showExplanationEl?.focus()
1272
+
1273
+ if (summaryMCRExplanation) {
1274
+ summaryMCRExplanation?.focus()
1275
+ } else {
1276
+ const showExplanationEl = (
1277
+ showExplanationRef instanceof Array
1278
+ ? showExplanationRef[0]
1279
+ : showExplanationRef
1280
+ ) as HTMLElement | undefined
1281
+ showExplanationEl?.focus()
1282
+ }
1353
1283
  }, 0)
1354
1284
  } else {
1355
1285
  setTimeout(() => {
@@ -1368,16 +1298,26 @@ export default class Question extends Vue {
1368
1298
  questionSerial: this.question.serial,
1369
1299
  })
1370
1300
  setTimeout(() => {
1301
+ const summaryMCRComp =
1302
+ this.$refs['uikit-question__summary'] as ComponentPublicInstance | undefined
1303
+ const summaryMCRExplanation =
1304
+ // eslint-disable-next-line max-len
1305
+ summaryMCRComp?.$refs['uikit-question-summary__summary-toggle-explanation-text'] as HTMLElement | undefined
1306
+
1371
1307
  const showExplanationRef = (
1372
1308
  this.$refs['uikit-question__toggle-explanation-text']
1373
- || this.$refs['uikit-question__summary-toggle-explanation-text']
1374
1309
  ) as Element[] | Element | undefined
1375
- const showExplanationEl = (
1376
- showExplanationRef instanceof Array
1377
- ? showExplanationRef[0]
1378
- : showExplanationRef
1379
- ) as HTMLElement | undefined
1380
- showExplanationEl?.focus()
1310
+
1311
+ if (summaryMCRExplanation) {
1312
+ summaryMCRExplanation?.focus()
1313
+ } else {
1314
+ const showExplanationEl = (
1315
+ showExplanationRef instanceof Array
1316
+ ? showExplanationRef[0]
1317
+ : showExplanationRef
1318
+ ) as HTMLElement | undefined
1319
+ showExplanationEl?.focus()
1320
+ }
1381
1321
  }, 500)
1382
1322
  }
1383
1323
  }
@@ -1666,15 +1606,12 @@ export default class Question extends Vue {
1666
1606
  }
1667
1607
 
1668
1608
  &__toggle-passage-image-description-text,
1669
- &__toggle-explanation-img-description-text,
1670
- &__toggle-summary-dropdown-explanation-img-description-text {
1609
+ &__toggle-explanation-img-description-text {
1671
1610
  outline: none;
1672
1611
  }
1673
1612
 
1674
1613
  &__toggle-passage-image-description-icon,
1675
- &__toggle-explanation-img-description-icon,
1676
-
1677
- &__toggle-summary-dropdown-explanation-img-description-icon {
1614
+ &__toggle-explanation-img-description-icon {
1678
1615
  margin-left: 8px;
1679
1616
 
1680
1617
  &--up {
@@ -1884,8 +1821,7 @@ export default class Question extends Vue {
1884
1821
  }
1885
1822
  }
1886
1823
 
1887
- &__reference-label,
1888
- &__summary-dropdown-reference-label {
1824
+ &__reference-label {
1889
1825
  font-weight: 600;
1890
1826
  }
1891
1827
 
@@ -2441,13 +2377,11 @@ export default class Question extends Vue {
2441
2377
  }
2442
2378
  }
2443
2379
 
2444
- &__toggle-explanation-text,
2445
- &__summary-toggle-explanation-text {
2380
+ &__toggle-explanation-text {
2446
2381
  outline: none;
2447
2382
  }
2448
2383
 
2449
- &__toggle-explanation-icon,
2450
- &__summary-toggle-explanation-icon {
2384
+ &__toggle-explanation-icon {
2451
2385
  margin-left: 5px;
2452
2386
  display: none;
2453
2387
 
@@ -2460,113 +2394,6 @@ export default class Question extends Vue {
2460
2394
  }
2461
2395
  }
2462
2396
 
2463
- &__summary-dropdown-explanation {
2464
- display: none;
2465
-
2466
- &--tablet-portrait {
2467
- display: block;
2468
- }
2469
- }
2470
-
2471
- &__summary-dropdown-explanation-text {
2472
- font-size: 16px;
2473
- letter-spacing: -0.1px;
2474
- line-height: 24px;
2475
- font-weight: 400;
2476
- padding-bottom: 6px;
2477
-
2478
- p {
2479
- margin: 10px 0;
2480
-
2481
- &:first-child {
2482
- margin: 0;
2483
- }
2484
- }
2485
- }
2486
-
2487
- &__summary-dropdown-explanation-image {
2488
- display: block;
2489
- box-sizing: border-box;
2490
- width: 100%;
2491
- border: 1px solid $fog;
2492
-
2493
- &--dark {
2494
- border: 1px solid $jet;
2495
- }
2496
- }
2497
-
2498
- &__toggle-summary-dropdown-explanation-img-description {
2499
- margin-top: 12px;
2500
- margin-bottom: 20px;
2501
-
2502
- &--open {
2503
- margin-bottom: 6px;
2504
- }
2505
-
2506
- &--tablet-portrait {
2507
- &.uikit-question__toggle-summary-dropdown-explanation-img-description--no-reference {
2508
- margin-bottom: 4px;
2509
- }
2510
-
2511
- &.uikit-question__toggle-summary-dropdown-explanation-img-description--open {
2512
- margin-bottom: 6px;
2513
- }
2514
- }
2515
-
2516
- &--mobile {
2517
- margin-top: 16px;
2518
- margin-bottom: 16px;
2519
-
2520
- &.uikit-question__toggle-summary-dropdown-explanation-img-description--no-reference {
2521
- margin-bottom: 7px;
2522
- }
2523
-
2524
- &.uikit-question__toggle-summary-dropdown-explanation-img-description--open {
2525
- margin-bottom: 4px;
2526
- }
2527
- }
2528
- }
2529
-
2530
- &__summary-dropdown-explanation-img-description {
2531
- outline: none;
2532
- color: $ash;
2533
- font-size: 15px;
2534
- line-height: 22px;
2535
- margin-bottom: 20px;
2536
-
2537
- &--dark {
2538
- color: $fog;
2539
- }
2540
-
2541
- &--mobile {
2542
- margin-bottom: 16px;
2543
- }
2544
-
2545
- p {
2546
- margin: 0;
2547
- }
2548
- }
2549
-
2550
- &__summary-dropdown-reference {
2551
- padding-top: 24px;
2552
- border-top: 1px solid $fog;
2553
- font-size: 15px;
2554
- letter-spacing: -0.1px;
2555
- line-height: 22px;
2556
- font-weight: 400;
2557
- word-break: break-word;
2558
- margin-bottom: -7px;
2559
-
2560
- &--dark {
2561
- color: $white;
2562
- border-top-color: rgba($fog, 0.28);
2563
- }
2564
-
2565
- p {
2566
- margin: 6px 0 8pt 0;
2567
- }
2568
- }
2569
-
2570
2397
  &__strikethrough {
2571
2398
  display: flex;
2572
2399
  align-items: center;
@@ -2806,74 +2633,6 @@ export default class Question extends Vue {
2806
2633
  }
2807
2634
  }
2808
2635
 
2809
- &__summary {
2810
- position: relative;
2811
- background-color: $white;
2812
- width: 100%;
2813
- max-width: 492px;
2814
- margin-top: 24px;
2815
- padding: 11px 46px 11px 15px;
2816
- box-sizing: border-box;
2817
- border-radius: 5px;
2818
- box-shadow: 0 1px 6px 0 rgba($fog, 0.6);
2819
-
2820
- &--dark {
2821
- background: $brand-black;
2822
- border: 1px solid $slate;
2823
- box-shadow: 0 1px 4px 0 rgba($jet, 0.3);
2824
- }
2825
-
2826
- &--tablet-portrait {
2827
- display: inline-block;
2828
- }
2829
- }
2830
-
2831
- &__summary-title {
2832
- font-weight: 600;
2833
- font-size: 15.5px;
2834
- line-height: 22px;
2835
- }
2836
-
2837
- &__summary-toggle-explanation {
2838
- margin-top: 8px;
2839
- margin-bottom: 8px;
2840
- padding: 0;
2841
-
2842
- &--review-mode {
2843
- display: none;
2844
-
2845
- &.uikit-question__summary-toggle-explanation--tablet-portrait {
2846
- display: block;
2847
- }
2848
- }
2849
- }
2850
-
2851
- &__summary-correct-icon {
2852
- position: absolute;
2853
- top: 12px;
2854
- right: 10px;
2855
- width: 22px;
2856
- height: 22px;
2857
- color: $cadaverous;
2858
-
2859
- &--dark {
2860
- color: $jungle-green;
2861
- }
2862
- }
2863
-
2864
- &__summary-incorrect-icon {
2865
- position: absolute;
2866
- top: 12px;
2867
- right: 10px;
2868
- width: 22px;
2869
- height: 22px;
2870
- color: $pepper;
2871
-
2872
- &--dark {
2873
- color: $rosa;
2874
- }
2875
- }
2876
-
2877
2636
  &__stats-summary {
2878
2637
  margin-top: 24px;
2879
2638
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocketprep/ui-kit",
3
- "version": "3.4.5",
3
+ "version": "3.4.6",
4
4
  "description": "Pocket Prep UI Kit",
5
5
  "author": "pocketprep",
6
6
  "scripts": {