Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: listing metadata for EDU News and External Links #635

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions packages/vue/src/components/BlockLinkCard/BlockLinkCard.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export const LargeEduExplainerArticle = {
}
}
}

export const EduCollection = {
decorators: [
() => ({
Expand Down Expand Up @@ -325,3 +326,50 @@ export const EduCollectionLarge = {
}
}
}

export const EduNewsItem = {
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3"><story/></div>`
})
],
args: {
...BlockLinkCardData,
data: {
page: {
...BlockLinkCardData.data,
__typename: 'EDUNewsPage'
}
},
headingLevel: 'h2',
size: 'sm'
}
}

export const ExternalLink = {
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3"><story/></div>`
})
],
args: {
data: {
__typename: 'ExternalLinkCardWithDescription',
externalLink: 'https://nasa.gov',
title: 'External Link',
label: 'Dolor Sit',
summary:
'Cras rhoncus lorem condimentum tellus rhoncus dictum. Maecenas finibus nibh lorem, quis ornare est vulputate et. Nulla imperdiet ultrices est, ac mattis justo consequat sit amet.',
thumbnailImage: {
__typename: 'CustomImage',
src: {
__typename: 'CustomRendition',
url: 'https://picsum.photos/512/288',
width: '512',
height: '288'
}
}
},
headingLevel: 'h2'
}
}
15 changes: 15 additions & 0 deletions packages/vue/src/components/BlockLinkCard/BlockLinkCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@
:content-type="metadataType"
:text="(theItem as EventCardObject).eventType"
/>
<template v-if="metadataType === 'EDUNewsPage' && theItem.label">
<!-- include the topic label for EDU News -->
<span class="text-subtitle text-gray-mid-dark uppercase ThemeVariantLight pl-3">
{{ theItem.label }}
</span>
</template>
</template>
<template
v-else-if="themeStore.isEdu && theItem.parent?.title && theItem.parent?.title !== 'EDU'"
>
<!-- use parent page's title as the label for EDU Content cards, unless the EDU homepage is the parent -->
<div class="flex flex-wrap">
<p
class="text-subtitle"
Expand Down Expand Up @@ -98,6 +105,12 @@
</span>
<span class="sr-only">.</span>
</p>
<template v-if="theItem.externalLink">
<IconExternal
class="text-primary ml-2"
:class="{ 'text-sm mt-1px': small, '-mt-1px': medium, '-mt-.5': large }"
/>
</template>
</div>
</template>

Expand Down Expand Up @@ -177,6 +190,7 @@ import { useThemeStore } from '../../store/theme'
import { mixinFormatEventDates } from './../../utils/mixins'
import type { HeadingLevel } from './../BaseHeading/BaseHeading.vue'
import IconArrow from './../Icons/IconArrow.vue'
import IconExternal from './../Icons/IconExternal.vue'
import BaseLink from './../BaseLink/BaseLink.vue'
import BaseImage from './../BaseImage/BaseImage.vue'
import BaseImagePlaceholder from './../BaseImagePlaceholder/BaseImagePlaceholder.vue'
Expand All @@ -191,6 +205,7 @@ export default defineComponent({
name: 'BlockLinkCard',
components: {
IconArrow,
IconExternal,
BaseLink,
BaseImage,
BaseImagePlaceholder,
Expand Down
6 changes: 6 additions & 0 deletions packages/vue/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type { PillDictionaryInterface } from './interfaces'

export const eduMetadataDictionary: PillDictionaryInterface = {
EDUNewsPage: {
label: 'News',
variant: 'primary',
icons: 'primary',
type: undefined
},
EDUEventPage: {
label: 'Event',
variant: 'primary',
Expand Down