@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorer-1/vue",
3
- "version": "0.2.43",
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
- <VueCompareImage
4
- v-if="theBeforeImageSrc && theAfterImageSrc"
5
- class="h-full animate-fadeIn"
6
- :left-image="theBeforeImageSrc.url"
7
- left-image-alt="Left image"
8
- :right-image="theAfterImageSrc.url"
9
- right-image-alt="Right image"
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"
@@ -152,7 +152,7 @@ export const BaseStory = {
152
152
  }
153
153
  ],
154
154
 
155
- overview: BlockStreamfieldMinimalData.body,
155
+ overview: [],
156
156
  overviewHeading: 'Custom Overview heading',
157
157
  overviewImage: BlockImageData.image,
158
158
 
@@ -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?: 'streamfield'
26
+ type?: string
28
27
  }
29
28
  interface EduLessonProcedureBlocks {
30
29
  blocks: StreamfieldBlockData[]
31
30
  }
32
- interface EduLessonProcedure {
33
- procedure: EduLessonProcedureBlocks
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
- const headingText =
133
- section === 'techAddons'
134
- ? 'Tech Add-ons'
135
- : section.charAt(0).toUpperCase() + section.slice(1)
136
- acc[section] = stringAsHeadingBlockData(
137
- (data[`${section}Heading`] as HeadingLevel) || headingText
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.procedure?.blocks?.length) {
197
- blocks.push(...item.procedure.blocks)
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
- return sections as EduLessonSectionObject[]
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
- <template v-if="value.blocks?.length || value.procedures?.length">
336
- <BlockStreamfield
337
- v-if="value.type === 'streamfield'"
338
- :data="value.blocks"
339
- />
340
- <PageEduLessonSection
341
- v-else
342
- :heading="value.heading"
343
- :blocks="value.blocks"
344
- :procedures="value.procedures"
345
- :text="value.text"
346
- :image="value.image"
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: BlockHeadingObject
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.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.heading"
41
+ :aria-label="heading?.heading"
47
42
  >
48
43
  <LayoutHelper
49
44
  indent="col-3"
@@ -0,0 +1,9 @@
1
+ export function generateHash(str: string): number {
2
+ let hash = 0
3
+ for (let i = 0, len = str.length; i < len; i++) {
4
+ let chr = str.charCodeAt(i)
5
+ hash = (hash << 5) - hash + chr
6
+ hash |= 0 // Convert to 32bit integer
7
+ }
8
+ return hash
9
+ }