Skip to content

Commit

Permalink
fix: news detail page (#520)
Browse files Browse the repository at this point in the history
* fixing BlockImageCarousel bug, adding fallback image source for fancybox

* fixing inline hero image on edu news detail pages

* fixing alignment of BlockInlineImage

* fixing publication date on edu news template

* modifying DetailHeadline component to handle single and multiple authors

* fixing some bugs when there is no author data

* fixing accessibility issue -- temp workaround

* bumping explorer-1/vue version
  • Loading branch information
stephiescastle committed Jul 29, 2024
1 parent 21ba7aa commit eaa9657
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 76 deletions.
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@explorer-1/vue",
"version": "0.1.8",
"version": "0.1.9",
"private": false,
"publishConfig": {
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default defineComponent({
<div class="max-w-screen-3xl mx-auto">
<MixinFancybox
v-if="theData.src"
:src="theData.original"
:src="theData.original || theData.src?.url"
:caption="theData.caption"
:credit="theData.credit"
:detail-url="theData.detailUrl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default defineComponent({
<div v-if="theData">
<MixinFancybox
v-if="theData.src"
:src="theData.original"
:src="theData.original || theData.src?.url"
:caption="theData.caption"
:credit="theData.credit"
:detail-url="theData.detailUrl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const BlockImageCarouselData = [

// stories
export const BaseStory = {
name: 'BlockImageCarousel',
name: 'CarouselBlock',
args: {
blockId: 'ev106po56n',
showTitle: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default defineComponent({
return false
},
itemsMobileNav(): Partial<ImageObject>[] | undefined {
const navArray = this.items
const navArray = this.items ? this.items.map((item) => item) : undefined
if (navArray && this.hasCover) {
navArray.push({ cover: 'hasCover' })
return navArray
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div v-if="theImageData">
<MixinFancybox
:src="theImageData.original"
:src="theImageData.original || theImageData.src?.url"
:caption="theImageData.caption"
:credit="theImageData.credit"
:detail-url="theImageData.detailUrl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<template #firstSlide>
<MixinFancybox
v-if="cover"
:src="cover.original"
:src="cover.original || cover.src?.url"
:caption="description"
:credit="cover.credit"
:detail-url="cover.detailUrl"
Expand Down
80 changes: 41 additions & 39 deletions packages/vue/src/components/BlockInlineImage/BlockInlineImage.vue
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
<template>
<div
v-if="data"
class="BlockInlineImage lg:BaseGrid container mx-auto"
class="BlockInlineImage container mx-auto"
>
<!-- the image -->
<div
v-if="theImageData"
class="lg:mb-0 lg:w-full sm:w-xl lg:mt-0 lg:pr-4 2xl:pr-0 col-span-5 mx-auto mt-8 mb-8"
:class="data.alignTo === 'right' ? 'col-start-8 lg:order-2' : 'col-start-1 lg:order-1'"
>
<!-- should accommodate any size/shape image without cropping -->
<MixinFancybox
<div class="lg:BaseGrid lg:px-0 px-4">
<!-- the image -->
<div
v-if="theImageData"
:src="theImageData.original"
:caption="theImageData.caption"
:credit="theImageData.credit"
:detail-url="theImageData.detailUrl"
class="lg:mb-0 lg:w-full sm:w-xl lg:mt-0 lg:pr-4 2xl:pr-0 col-span-5 mx-auto mt-8 mb-8"
:class="data.alignTo === 'right' ? 'col-start-8 lg:order-2' : 'col-start-1 lg:order-1'"
>
<BaseImagePlaceholder aspect-ratio="none">
<BaseImage
v-if="theImageData && theImageData.src"
:src="theImageData.src.url"
:srcset="theSrcSet"
:width="theImageData.src.width"
:height="theImageData.src.height"
image-class="w-full h-auto"
:alt="theImageData.alt"
loading="lazy"
/>
</BaseImagePlaceholder>
</MixinFancybox>
<BaseImageCaption
v-if="hasCaptionArea"
class="lg:mt-3 mt-2"
:data="theImageData"
/>
</div>
<!-- should accommodate any size/shape image without cropping -->
<MixinFancybox
v-if="theImageData"
:src="theImageData.original || theImageData.src?.url"
:caption="theImageData.caption"
:credit="theImageData.credit"
:detail-url="theImageData.detailUrl"
>
<BaseImagePlaceholder aspect-ratio="none">
<BaseImage
v-if="theImageData && theImageData.src"
:src="theImageData.src.url"
:srcset="theSrcSet"
:width="theImageData.src.width"
:height="theImageData.src.height"
image-class="w-full h-auto"
:alt="theImageData.alt"
loading="lazy"
/>
</BaseImagePlaceholder>
</MixinFancybox>
<BaseImageCaption
v-if="hasCaptionArea"
class="lg:mt-3 mt-2"
:data="theImageData"
/>
</div>

<!-- the text -->
<div
v-if="data.text"
class="flex col-span-5"
:class="data.alignTo === 'right' ? 'col-start-3 lg:order-1' : 'col-start-6 lg:order-2'"
>
<BlockText :text="data.text" />
<!-- the text -->
<div
v-if="data.text"
class="flex col-span-5"
:class="data.alignTo === 'right' ? 'col-start-3 lg:order-1' : 'col-start-6 lg:order-2'"
>
<BlockText :text="data.text" />
</div>
</div>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<BlockInlineImage
v-else-if="block.blockType == 'InlineImageBlock'"
:key="`inlineImageBlock${index}`"
class="lg:px-0 px-4"
:class="seamlessText(index) ? 'lg:mb-8 mb-5' : 'lg:mb-18 mb-10'"
:data="block"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ export const BaseStory = {
args: DetailHeadlineData
}

export const MultipleAuthors = {
args: {
...DetailHeadlineData,
author: [
{
author: {
name: 'Author Name',
organization: 'Organization'
}
},
{
author: {
name: 'Another Author',
organization: 'Organization'
}
}
]
}
}

export const NoAuthor = {
args: {
title: "NASA's Ingenuity Mars Helicopter Recharges Its Batteries in Flight",
Expand Down
57 changes: 45 additions & 12 deletions packages/vue/src/components/DetailHeadline/DetailHeadline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,30 @@
>{{ title }}
</BaseHeading>
<div
v-if="author || publicationDate"
v-if="authors?.length || publicationDate"
class="lg:text-base text-gray-mid-dark divide-gray-mid-dark px-3 mt-5 -ml-3 text-sm leading-normal"
>
<span
v-if="author"
v-if="authors?.length"
:itemprop="schema ? 'author' : undefined"
itemscope
itemtype="https://schema.org/Person"
class="pr-3 border-r mr-2"
>
Written by
<span :itemprop="schema ? 'name' : undefined">{{ author.name }}</span>
<template
v-for="(a, index) of authors"
:key="index"
>
<span
class="inline-block"
:itemprop="schema ? 'name' : undefined"
>{{ a.name }}</span
>
<template v-if="index !== authors.length - 1"
><span class="inline-block pr-1">,</span></template
>
</template>
</span>
<span
v-else
Expand Down Expand Up @@ -87,7 +99,7 @@
import { defineComponent, type PropType } from 'vue'
import { mapStores } from 'pinia'
import { useThemeStore } from '../../store/theme'
import type { Topic } from './../../interfaces'
import type { Topic, AuthorObject } from './../../interfaces'
import BaseLink from './../BaseLink/BaseLink.vue'
import BaseHeading from './../BaseHeading/BaseHeading.vue'
Expand All @@ -100,32 +112,39 @@ export default defineComponent({
props: {
title: {
type: String,
required: false
required: false,
default: undefined
},
author: {
type: Object,
required: false
type: Object as PropType<AuthorObject | AuthorObject[]>,
required: false,
default: undefined
},
publicationDate: {
type: String,
required: false
required: false,
default: undefined
},
publicationTime: {
type: String,
required: false
required: false,
default: undefined
},
topics: {
type: Array as PropType<Topic[]>,
required: false
required: false,
default: undefined
},
// if topics array isn't available
label: {
type: String,
required: false
required: false,
default: undefined
},
labelLink: {
type: String,
required: false
required: false,
default: undefined
},
schema: {
type: Boolean,
Expand All @@ -138,6 +157,20 @@ export default defineComponent({
const currentTime = this.publicationTime || '00:00:00'
const returnDate = new Date(this.publicationDate + ' ' + currentTime)
return returnDate.toISOString()
},
authors(): { name: string; organization: string }[] | undefined {
let authors: AuthorObject[] | undefined = undefined
if (this.author && this.author.constructor === Array) {
authors = []
// @ts-expect-error we know it's an array at this point
this.author.forEach((author: { author: AuthorObject }) => {
// @ts-expect-error authors array is defined above
authors.push(author.author)
})
} else if (this.author) {
authors = [this.author] as AuthorObject[]
}
return authors
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const ImageDetailPageData = {
}
],
keepExploringInstrument: BlockLinkTileCarouselData,
keepExploringMission: BlockLinkTileCarouselData,
keepExploringMission: [
BlockLinkTileCarouselData[0],
BlockLinkTileCarouselData[1],
BlockLinkTileCarouselData[2]
],
keepExploringTarget: BlockLinkTileCarouselData,
label: 'Image',
piaNumber: 'PIA23356',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/>
<MixinFancybox
v-if="data.image"
:src="data.image.original"
:src="data.image.original || data.image.src?.url"
:caption="data.image.caption"
:credit="data.image.credit"
:title="data.title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ export const BaseStory = {
slug: 'nasas-ingenuity-mars-helicopter-recharges-its-batteries-in-flight',
url: '/news/nasas-ingenuity-mars-helicopter-recharges-its-batteries-in-flight',
title: "NASA's Ingenuity Mars Helicopter Recharges Its Batteries in Flight",
firstPublishedAt: '2024-06-20T20:36:49.657301+00:00',
publicationDate: '2024-06-20 20:36:49.657301+00:00',
authors: [
{
author: {
name: 'Author Name',
organization: 'Organization Name'
}
}
],
getTopicsForDisplay: [
{
title: 'Mars',
Expand Down
Loading

0 comments on commit eaa9657

Please sign in to comment.