@explorer-1/vue 0.2.43 → 0.2.45
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.
- package/dist/explorer-1-vue.js +146 -141
- package/dist/explorer-1-vue.umd.cjs +1 -1
- package/package.json +1 -2
- package/src/components/BlockImageComparison/BlockImageComparison.vue +10 -8
- package/src/templates/edu/PageEduLesson/PageEduLesson.stories.js +1 -1
- package/src/templates/edu/PageEduLesson/PageEduLesson.vue +36 -32
- package/src/templates/edu/PageEduLesson/PageEduLessonSection.vue +5 -10
- package/src/utils/generateHash.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@explorer-1/vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.45",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"twitter-widgets": "^2.0.0",
|
|
29
29
|
"vue": "^3.4.21",
|
|
30
30
|
"vue-bind-once": "^0.2.1",
|
|
31
|
-
"vue-observe-visibility": "^1.0.0",
|
|
32
31
|
"vue3-compare-image": "^1.2.5",
|
|
33
32
|
"vue3-observe-visibility": "^1.0.1",
|
|
34
33
|
"@explorer-1/common": "1.1.12"
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-if="data">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
<ClientOnly>
|
|
4
|
+
<VueCompareImage
|
|
5
|
+
v-if="theBeforeImageSrc && theAfterImageSrc"
|
|
6
|
+
class="h-full animate-fadeIn"
|
|
7
|
+
:left-image="theBeforeImageSrc.url"
|
|
8
|
+
left-image-alt="Left image"
|
|
9
|
+
:right-image="theAfterImageSrc.url"
|
|
10
|
+
right-image-alt="Right image"
|
|
11
|
+
/>
|
|
12
|
+
</ClientOnly>
|
|
11
13
|
<div
|
|
12
14
|
v-if="data.caption || customDetailUrl"
|
|
13
15
|
class="lg:px-0 p-4 pb-0 print:pl-0"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, reactive, ref } from 'vue'
|
|
3
3
|
import type {
|
|
4
|
-
BlockData,
|
|
5
4
|
ImageObject,
|
|
6
5
|
PageEduResourcesObject,
|
|
7
6
|
StreamfieldBlockData
|
|
@@ -24,13 +23,15 @@ import AboutTheAuthor from './../../../components/AboutTheAuthor/AboutTheAuthor.
|
|
|
24
23
|
import { HeadingLevel } from '../../../components/BaseHeading/BaseHeading.vue'
|
|
25
24
|
|
|
26
25
|
interface EduLessonSectionObject extends PageEduLessonSectionProps {
|
|
27
|
-
type?:
|
|
26
|
+
type?: string
|
|
28
27
|
}
|
|
29
28
|
interface EduLessonProcedureBlocks {
|
|
30
29
|
blocks: StreamfieldBlockData[]
|
|
31
30
|
}
|
|
32
|
-
interface EduLessonProcedure {
|
|
33
|
-
|
|
31
|
+
export interface EduLessonProcedure {
|
|
32
|
+
sectionHeading?: string
|
|
33
|
+
steps?: EduLessonProcedureBlocks[]
|
|
34
|
+
stepsNumbering?: boolean
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
interface PageEduLessonObject extends PageEduResourcesObject {
|
|
@@ -129,13 +130,16 @@ const sectionOrder = [
|
|
|
129
130
|
const staticSectionHeadings = computed((): { [key: string]: BlockHeadingObject } | undefined => {
|
|
130
131
|
if (data) {
|
|
131
132
|
const result = sectionOrder.reduce<Record<string, BlockHeadingObject>>((acc, section) => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
// only include the heading if the section has content
|
|
134
|
+
if (data[section]?.length) {
|
|
135
|
+
const headingText =
|
|
136
|
+
section === 'techAddons'
|
|
137
|
+
? 'Tech Add-ons'
|
|
138
|
+
: section.charAt(0).toUpperCase() + section.slice(1)
|
|
139
|
+
acc[section] = stringAsHeadingBlockData(
|
|
140
|
+
(data[`${section}Heading`] as HeadingLevel) || headingText
|
|
141
|
+
)
|
|
142
|
+
}
|
|
139
143
|
return acc
|
|
140
144
|
}, {})
|
|
141
145
|
return result
|
|
@@ -193,8 +197,8 @@ const consolidatedBlocks = computed(() => {
|
|
|
193
197
|
} else if (section === 'procedures' && data.procedures?.length) {
|
|
194
198
|
// get blocks in nested procedures
|
|
195
199
|
data.procedures.forEach((item) => {
|
|
196
|
-
if (item.
|
|
197
|
-
blocks.push(...item.
|
|
200
|
+
if (item.steps?.length) {
|
|
201
|
+
blocks.push(...item.steps)
|
|
198
202
|
}
|
|
199
203
|
})
|
|
200
204
|
}
|
|
@@ -218,7 +222,7 @@ const consolidatedBlocks = computed(() => {
|
|
|
218
222
|
|
|
219
223
|
// organize data to render with PageEduLessonSection component
|
|
220
224
|
const consolidatedSections = computed((): EduLessonSectionObject[] => {
|
|
221
|
-
const sections = []
|
|
225
|
+
const sections: EduLessonSectionObject[] = []
|
|
222
226
|
// include custom top section
|
|
223
227
|
if (keyedCustomSections.value && keyedCustomSections.value['top']) {
|
|
224
228
|
sections.push({ type: 'streamfield', blocks: keyedCustomSections.value['top'] })
|
|
@@ -226,9 +230,7 @@ const consolidatedSections = computed((): EduLessonSectionObject[] => {
|
|
|
226
230
|
sectionOrder.forEach((section) => {
|
|
227
231
|
if (data && data[section]) {
|
|
228
232
|
sections.push({
|
|
229
|
-
heading: staticSectionHeadings.value
|
|
230
|
-
? (staticSectionHeadings.value[section] as BlockData)
|
|
231
|
-
: undefined,
|
|
233
|
+
heading: staticSectionHeadings.value ? staticSectionHeadings.value[section] : undefined,
|
|
232
234
|
blocks: section !== 'materials' && section !== 'procedures' ? data[section] : undefined,
|
|
233
235
|
text: section === 'materials' ? data[section] : undefined,
|
|
234
236
|
procedures: section === 'procedures' ? data[section] : undefined
|
|
@@ -243,7 +245,11 @@ const consolidatedSections = computed((): EduLessonSectionObject[] => {
|
|
|
243
245
|
if (keyedCustomSections.value && keyedCustomSections.value['bottom']) {
|
|
244
246
|
sections.push({ type: 'streamfield', blocks: keyedCustomSections.value['bottom'] })
|
|
245
247
|
}
|
|
246
|
-
|
|
248
|
+
const filteredSections = sections.filter(
|
|
249
|
+
(item) => item.text || item.blocks?.length || item.procedures?.length
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
return filteredSections
|
|
247
253
|
})
|
|
248
254
|
</script>
|
|
249
255
|
<template>
|
|
@@ -332,20 +338,18 @@ const consolidatedSections = computed((): EduLessonSectionObject[] => {
|
|
|
332
338
|
v-for="(value, _key) in consolidatedSections"
|
|
333
339
|
:key="_key"
|
|
334
340
|
>
|
|
335
|
-
<
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
/>
|
|
348
|
-
</template>
|
|
341
|
+
<BlockStreamfield
|
|
342
|
+
v-if="value.type === 'streamfield'"
|
|
343
|
+
:data="value.blocks"
|
|
344
|
+
/>
|
|
345
|
+
<PageEduLessonSection
|
|
346
|
+
v-else
|
|
347
|
+
:heading="value.heading"
|
|
348
|
+
:blocks="value.blocks"
|
|
349
|
+
:procedures="value.procedures"
|
|
350
|
+
:text="value.text"
|
|
351
|
+
:image="value.image"
|
|
352
|
+
/>
|
|
349
353
|
</template>
|
|
350
354
|
|
|
351
355
|
<!-- streamfield blocks -->
|
|
@@ -5,6 +5,7 @@ import type { ImageObject, StreamfieldBlockData } from './../../../interfaces'
|
|
|
5
5
|
import BlockHeading, {
|
|
6
6
|
type BlockHeadingObject
|
|
7
7
|
} from './../../../components/BlockHeading/BlockHeading.vue'
|
|
8
|
+
import type { EduLessonProcedure } from './PageEduLesson.vue'
|
|
8
9
|
import BaseHeading from './../../../components/BaseHeading/BaseHeading.vue'
|
|
9
10
|
import BlockText from './../../../components/BlockText/BlockText.vue'
|
|
10
11
|
import LayoutHelper from './../../../components/LayoutHelper/LayoutHelper.vue'
|
|
@@ -12,15 +13,9 @@ import BlockImageStandard from './../../../components/BlockImage/BlockImageStand
|
|
|
12
13
|
import BlockStreamfield from './../../../components/BlockStreamfield/BlockStreamfield.vue'
|
|
13
14
|
|
|
14
15
|
export interface PageEduLessonSectionProps {
|
|
15
|
-
heading
|
|
16
|
+
heading?: BlockHeadingObject
|
|
16
17
|
blocks?: StreamfieldBlockData[]
|
|
17
|
-
procedures?:
|
|
18
|
-
sectionHeading: string
|
|
19
|
-
stepsNumbering: boolean
|
|
20
|
-
steps: {
|
|
21
|
-
blocks: StreamfieldBlockData[]
|
|
22
|
-
}[]
|
|
23
|
-
}[]
|
|
18
|
+
procedures?: EduLessonProcedure[]
|
|
24
19
|
text?: string
|
|
25
20
|
image?: ImageObject
|
|
26
21
|
}
|
|
@@ -36,14 +31,14 @@ const props = withDefaults(defineProps<PageEduLessonSectionProps>(), {
|
|
|
36
31
|
const { heading, blocks, image } = reactive(props)
|
|
37
32
|
|
|
38
33
|
const anchorId = computed(() => {
|
|
39
|
-
return 'lesson_' + camelCase(heading
|
|
34
|
+
return 'lesson_' + camelCase(heading?.heading)
|
|
40
35
|
})
|
|
41
36
|
</script>
|
|
42
37
|
<template>
|
|
43
38
|
<section
|
|
44
39
|
:id="anchorId"
|
|
45
40
|
class="PageEduLessonSection"
|
|
46
|
-
:aria-label="heading
|
|
41
|
+
:aria-label="heading?.heading"
|
|
47
42
|
>
|
|
48
43
|
<LayoutHelper
|
|
49
44
|
indent="col-3"
|