@pocketprep/ui-kit 3.4.9 → 3.4.10

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.
@@ -0,0 +1,333 @@
1
+ <template>
2
+ <div
3
+ v-if="showExplanation && !showPaywall"
4
+ v-breakpoint:questionEl="breakpoints"
5
+ v-dark="isDarkMode"
6
+ class="uikit-question-explanation"
7
+ >
8
+ <div
9
+ ref="explanation"
10
+ v-dark="isDarkMode"
11
+ class="uikit-question-explanation__explanation-title"
12
+ tabindex="-1"
13
+ >
14
+ Explanation Details
15
+ </div>
16
+ <div
17
+ v-dark="isDarkMode"
18
+ v-breakpoint:questionEl="breakpoints"
19
+ class="uikit-question-explanation__explanation-text"
20
+ v-html="question.explanation"
21
+ />
22
+ <img
23
+ v-if="explanationImageUrl"
24
+ v-dark="isDarkMode"
25
+ v-breakpoint:questionEl="breakpoints"
26
+ class="uikit-question-explanation__explanation-image"
27
+ :class="{
28
+ 'uikit-question-explanation__explanation-image--long-alt': explanationImageLongAlt,
29
+ }"
30
+ :src="explanationImageUrl"
31
+ :alt="`${explanationImageAlt}. Extended image description below.`"
32
+ >
33
+ <PocketButton
34
+ v-if="explanationImageLongAlt"
35
+ v-breakpoint:questionEl="breakpoints"
36
+ type="tertiary-small"
37
+ class="uikit-question-explanation__toggle-explanation-img-description"
38
+ :class="{
39
+ 'uikit-question-explanation__toggle-explanation-img-description--open': showExplanationImageLongAlt,
40
+ }"
41
+ :is-dark-mode="isDarkMode"
42
+ :aria-expanded="showExplanationImageLongAlt ? 'true' : 'false'"
43
+ @click.stop="toggleExplanationImageLongAlt"
44
+ @mousedown.prevent
45
+ >
46
+ <span class="uikit-question-explanation__toggle-explanation-img-description-text">Image Description</span>
47
+ <Icon
48
+ class="uikit-question-explanation__toggle-explanation-img-description-icon"
49
+ :class="{
50
+ 'uikit-question-explanation__toggle-explanation-img-description-icon--up':
51
+ showExplanationImageLongAlt,
52
+ }"
53
+ type="accordionArrow"
54
+ />
55
+ </PocketButton>
56
+ <div
57
+ v-if="showExplanationImageLongAlt"
58
+ ref="uikit-question-explanation__explanation-img-description"
59
+ v-dark="isDarkMode"
60
+ class="uikit-question-explanation__explanation-img-description"
61
+ tabindex="-1"
62
+ v-html="explanationImageLongAlt"
63
+ />
64
+ <div
65
+ v-if="reference && !hideReferences"
66
+ v-dark="isDarkMode"
67
+ class="uikit-question-explanation__reference"
68
+ >
69
+ <span class="uikit-question-explanation__reference-label">Reference: </span>
70
+ <div v-html="reference" />
71
+ </div>
72
+ <div
73
+ v-if="!reviewMode"
74
+ v-dark="isDarkMode"
75
+ class="uikit-question-explanation__explanation-close"
76
+ tabindex="0"
77
+ role="button"
78
+ aria-label="Close explanation"
79
+ @keydown.enter.stop="toggleExplanation"
80
+ @click.stop="toggleExplanation"
81
+ @mousedown.prevent
82
+ >
83
+ <Icon type="close" />
84
+ </div>
85
+ </div>
86
+ </template>
87
+
88
+ <script lang="ts">
89
+ import { Component, Emit, Prop, Vue } from 'vue-facing-decorator'
90
+ import type { Study } from '@pocketprep/types'
91
+ import Icon from '../../Icons/Icon.vue'
92
+ import PocketButton from '../../Buttons/Button.vue'
93
+ import { breakpoint, dark } from '../../../directives'
94
+ import type { TBreakPointsObject } from './../question'
95
+
96
+ @Component({
97
+ components: {
98
+ Icon,
99
+ PocketButton,
100
+ },
101
+ directives: {
102
+ dark,
103
+ breakpoint,
104
+ },
105
+ })
106
+ export default class Explanation extends Vue {
107
+ @Prop() question!: Study.Class.QuestionJSON
108
+ @Prop({ default: false }) showExplanation!: boolean
109
+ @Prop({ default: false }) showPaywall!: boolean
110
+ @Prop({ default: false }) showExplanationImageLongAlt!: boolean
111
+ @Prop({ default: null }) explanationImageUrl!: string | null
112
+ @Prop({ default: undefined }) explanationImageAlt!: string | undefined
113
+ @Prop({ default: undefined }) explanationImageLongAlt!: string | undefined
114
+ @Prop({ default: false }) reviewMode!: boolean
115
+ @Prop({ default: undefined }) reference!: string | undefined
116
+ @Prop({ default: false }) hideReferences!: boolean
117
+ @Prop({ default: false }) isDarkMode!: boolean
118
+ @Prop({ default: null }) questionEl!: Element | null
119
+ @Prop({ default: {
120
+ 'mobile': 767,
121
+ 'tablet-portrait': 1023,
122
+ 'tablet-landscape': 1439,
123
+ } }) breakpoints!: TBreakPointsObject
124
+
125
+ @Emit('toggleExplanationImageLongAlt')
126
+ toggleExplanationImageLongAlt () {
127
+ return
128
+ }
129
+
130
+ @Emit('toggleExplanation')
131
+ toggleExplanation () {
132
+ return
133
+ }
134
+ }
135
+ </script>
136
+
137
+ <style lang="scss">
138
+ @import '../../../styles/colors';
139
+ @import '../../../styles/breakpoints';
140
+
141
+ .uikit-question-explanation {
142
+ position: relative;
143
+ background-color: $white;
144
+ border: 1px solid rgba($pewter, 0.85);
145
+ border-bottom: 0;
146
+ border-radius: 6px 6px 0 0;
147
+ padding: 42px 60px 72px;
148
+ box-sizing: border-box;
149
+ max-width: 565px;
150
+ min-height: 100%;
151
+
152
+ &--tablet-landscape {
153
+ max-width: 460px;
154
+ padding: 42px 36px 72px;
155
+ }
156
+
157
+ &--dark {
158
+ border-color: $slate;
159
+ background-color: $mariner;
160
+ }
161
+
162
+ &__explanation-close {
163
+ position: absolute;
164
+ width: 30px;
165
+ height: 30px;
166
+ top: 12px;
167
+ right: 12px;
168
+ color: $brand-blue;
169
+ cursor: pointer;
170
+ outline: none;
171
+
172
+ &:hover {
173
+ color: $brand-black;
174
+ }
175
+
176
+ &:focus::before {
177
+ content: '';
178
+ left: -1px;
179
+ top: -1px;
180
+ width: 100%;
181
+ height: 100%;
182
+ position: absolute;
183
+ border: 1px solid $brand-blue;
184
+ border-radius: 5px;
185
+ }
186
+
187
+ &--dark {
188
+ color: $banana-bread;
189
+
190
+ &:hover {
191
+ color: $butterscotch;
192
+ }
193
+
194
+ &:focus::before {
195
+ border-color: $banana-bread;
196
+ }
197
+ }
198
+
199
+ svg {
200
+ width: 100%;
201
+ height: 100%;
202
+ }
203
+ }
204
+
205
+ &__explanation-title {
206
+ font-weight: 600;
207
+ font-size: 17.5px;
208
+ letter-spacing: -0.1px;
209
+ line-height: 25px;
210
+ outline: none;
211
+
212
+ &--dark {
213
+ color: $fog;
214
+ }
215
+ }
216
+
217
+ &__explanation-text {
218
+ font-weight: 400;
219
+ font-size: 16.5px;
220
+ letter-spacing: -0.1px;
221
+ line-height: 26px;
222
+ margin-bottom: 24px;
223
+ word-break: break-word;
224
+
225
+ &--dark {
226
+ color: $white;
227
+ }
228
+
229
+ &--tablet-landscape {
230
+ margin-bottom: 24px;
231
+ font-size: 16px;
232
+ line-height: 24px;
233
+ }
234
+
235
+ strong,
236
+ b {
237
+ font-weight: 600;
238
+ }
239
+ }
240
+
241
+ &__explanation-image {
242
+ display: block;
243
+ position: relative;
244
+ left: 50%;
245
+ transform: translateX(-50%);
246
+ width: calc(100% + 24px);
247
+ margin-bottom: 24px;
248
+ border: 1px solid $fog;
249
+
250
+ &--long-alt {
251
+ margin-bottom: 0;
252
+ }
253
+
254
+ &--dark {
255
+ border: 1px solid $jet;
256
+ }
257
+
258
+ &--tablet-landscape {
259
+ width: calc(100% + 16px);
260
+ }
261
+ }
262
+
263
+ &__toggle-explanation-img-description {
264
+ margin-top: 24px;
265
+
266
+ &--open {
267
+ margin-bottom: 6px;
268
+ }
269
+
270
+ &--tablet-landscape {
271
+ margin-top: 12px;
272
+ }
273
+ }
274
+
275
+ &__explanation-img-description {
276
+ outline: none;
277
+ color: $ash;
278
+ font-size: 15px;
279
+ font-weight: 500;
280
+ letter-spacing: -0.2px;
281
+ line-height: 22px;
282
+ margin-bottom: 24px;
283
+
284
+ &--dark {
285
+ color: $fog;
286
+ }
287
+
288
+ p {
289
+ margin: 0;
290
+ }
291
+ }
292
+
293
+ &__toggle-explanation-img-description-text {
294
+ outline: none;
295
+ }
296
+
297
+ &__toggle-explanation-img-description-icon {
298
+ margin-left: 8px;
299
+
300
+ &--up {
301
+ transform: rotate(180deg);
302
+ }
303
+ }
304
+
305
+ &__reference {
306
+ padding-top: 24px;
307
+ border-top: 1px solid $fog;
308
+ font-size: 15px;
309
+ letter-spacing: -0.1px;
310
+ line-height: 22px;
311
+ font-weight: 600;
312
+ word-break: break-word;
313
+
314
+ &--dark {
315
+ color: $white;
316
+ border-top-color: rgba($fog, 0.28);
317
+ }
318
+
319
+ p {
320
+ margin: 6px 0 8pt 0;
321
+ font-size: 15px;
322
+ letter-spacing: -0.1px;
323
+ font-weight: 400;
324
+ font-style: italic;
325
+ }
326
+ }
327
+
328
+ &__reference-label {
329
+ font-weight: 600;
330
+ }
331
+
332
+ }
333
+ </style>