Skip to content

Commit

Permalink
Bono/goth 324 (#218)
Browse files Browse the repository at this point in the history
* good start

* first draft complete

* added logic for when only 1 article

* clean up

* design feedback done

* qa bug fixed
  • Loading branch information
bonomite authored Dec 16, 2022
1 parent f82fc7f commit f606230
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 25 deletions.
8 changes: 5 additions & 3 deletions components/Byline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const commentCount = computed(() => {
<div class="byline">
<!-- sponsored -->
<div v-if="isSponsored" class="sponsored flex align-items-center">
<div class="author-image">
<div class="author-image flex-none">
<v-flexible-link :to="sponsor?.link" raw>
<v-simple-responsive-image
v-if="sponsor?.logo"
Expand All @@ -67,7 +67,8 @@ const commentCount = computed(() => {
to="#comments"
class="type-textlink2"
>
{{ String(Number(commentCount)) }} {{commentCount === 1 ? 'comment' : 'comments'}}
{{ String(Number(commentCount)) }}
{{ commentCount === 1 ? 'comment' : 'comments' }}
</v-flexible-link>
</div>
</div>
Expand Down Expand Up @@ -101,7 +102,8 @@ const commentCount = computed(() => {
to="#comments"
class="type-textlink2"
>
{{ String(Number(commentCount)) }} {{commentCount === 1 ? 'comment' : 'comments'}}
{{ String(Number(commentCount)) }}
{{ commentCount === 1 ? 'comment' : 'comments' }}
</v-flexible-link>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/CenterFeature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const articlesSm = ref([
<template>
<div v-if="articleLg && articleMd && articlesSm" class="center-feature">
<template v-if="collection.label">
<hr class="mb-2 black" />
<div class="type-label3 mb-5">{{ collection.label }}</div>
<hr class="black" />
<div class="type-label3 mt-2 mb-4">{{ collection.label }}</div>
</template>
<div class="grid gutter-x-30">
<div class="col-fixed flex-order-2 lg:flex-order-1">
Expand Down
201 changes: 201 additions & 0 deletions components/SkylineFeature.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<script setup>
import VCard from '@nypublicradio/nypr-design-system-vue3/v2/src/components/VCard.vue'
import { useBreakpoints } from '@vueuse/core'
import breakpoint from '@nypublicradio/nypr-design-system-vue3/src/assets/library/breakpoints.module.scss'
import { ref } from 'vue'
const props = defineProps({
collection: {
type: Object,
default: {},
required: true,
},
})
const breakpoints = useBreakpoints({
md: Number(breakpoint.md),
})
const smallerThanMd = ref(breakpoints.smaller('md'))
// Note: the skyline feature should display the first 3 stories in the content collection
const articleLg = ref(
props.collection.data[0]
? normalizeArticlePage(props.collection.data[0])
: null
)
const articleMd = ref(
props.collection.data[1]
? normalizeArticlePage(props.collection.data[1])
: null
)
const articleSm = ref(
props.collection.data[2]
? normalizeArticlePage(props.collection.data[2])
: null
)
const featureLabel = ref(props.collection.label)
const isOneOnly = !articleMd.value && !articleSm.value
</script>

<template>
<div v-if="articleLg">
<div class="skyline-feature">
<template v-if="featureLabel">
<hr class="black" />
<p role="heading" aria-level="2" class="type-label3 mt-2 mb-4">
{{ featureLabel }}
</p>
</template>
<div class="grid gutter-x-30 justify-content-center">
<div
class="col-12 lg:col-12 flex-order-0 xl:flex-order-3"
:class="isOneOnly ? 'xl:col-12' : 'xl:col-6'"
>
<v-card
class="primary article-lg mod-vertical mod-featured2 mod-large mb-4"
:image="useImageUrl(articleLg?.listingImage)"
:sizes="[1]"
:ratio="isOneOnly ? [6, 2] : [3, 2]"
:width="isOneOnly ? 1360 : 665"
:height="isOneOnly ? 453 : 443"
:title="articleLg?.listingTitle"
:titleLink="articleLg?.link"
:maxWidth="articleLg?.listingImage?.width"
:maxHeight="articleLg?.listingImage?.height"
:tags="[
{
name: articleLg?.section.name,
slug: `/${articleLg?.section.slug}`,
},
]"
loading="eager"
>
<v-card-metadata
class="mt-0 md:mt-2"
altDesign
:article="articleLg"
/>
</v-card>
<!-- <hr class="block xl:hidden mb-3" /> -->
</div>
<!-- need to wrap in ClientOnly for breakpoint to initially work -->
<ClientOnly>
<div
v-if="articleMd"
class="col-12 md:col-6 xl:col-3 flex-order-1 lg:flex-order-0"
>
<!-- md article desktop -->
<v-card
class="secondary article-md mb-5 tag-small"
:class="
smallerThanMd
? 'mod-horizontal mod-left'
: 'mod-vertical mod-large'
"
:image="useImageUrl(articleMd?.listingImage)"
:title="articleMd?.listingTitle"
:titleLink="articleMd?.link"
:ratio="[1, 1]"
:width="318"
:height="318"
:sizes="[1]"
:maxWidth="articleMd?.listingImage?.width"
:maxHeight="articleMd?.listingImage?.height"
:tags="[
{
name: articleMd?.section.name,
slug: `/${articleMd?.section.slug}`,
},
]"
loading="eager"
>
<p>
{{ articleMd?.description }}
</p>
<v-card-metadata stack :article="articleMd" />
</v-card>
</div>
<div
v-if="articleSm"
class="col-12 md:col-6 xl:col-3 flex-order-2 lg:flex-order-1"
>
<!-- sm article desktop -->
<v-card
class="secondary article-sm mb-5 tag-small secondary"
:class="
smallerThanMd
? 'mod-horizontal mod-left'
: 'mod-vertical mod-large'
"
:image="useImageUrl(articleSm?.listingImage)"
:title="articleSm?.listingTitle"
:titleLink="articleSm?.link"
:ratio="[3, 2]"
:width="318"
:height="212"
:sizes="[1]"
:maxWidth="articleSm?.listingImage?.width"
:maxHeight="articleSm?.listingImage?.height"
:tags="[
{
name: articleSm?.section.name,
slug: `/${articleSm?.section.slug}`,
},
]"
loading="eager"
>
<p>
{{ articleSm?.description }}
</p>
<v-card-metadata stack :article="articleSm" />
</v-card>
</div>
</ClientOnly>
</div>
</div>
</div>
</template>
<style lang="scss">
.skyline-feature {
.v-card {
&.primary.mod-featured2 {
.card-details {
.card-title {
.v-tag {
margin-top: 0;
// line-height: var(--font-size-2);
@include media('<lg') {
margin-top: 11px;
}
@include media('<md') {
margin-top: 0;
}
}
.h2 {
@include font-config($type-header3);
}
}
}
}
&.secondary {
.card-details {
.card-title {
.v-tag {
margin-top: 0;
line-height: var(--font-size-2);
@include media('<md') {
line-height: inherit;
}
}
.h2 {
font-size: var(--font-size-7);
line-height: 21px;
}
}
}
}
}
}
</style>
17 changes: 12 additions & 5 deletions components/VCardMetadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ const commentCount = computed(() => {
:authors="props.article.authors || props.article.relatedAuthors"
/>
</span>
<span class="comments" v-if="!props.article.comments && showComments && commentCount">
<NuxtLink :to="{ path: props.article.link, hash: '#comments' }">{{ String(Number(commentCount)) }} {{commentCount === 1 ? 'comment' : 'comments'}}</NuxtLink>
<span
class="comments"
v-if="!props.article.comments && showComments && commentCount"
>
<NuxtLink :to="{ path: props.article.link, hash: '#comments' }"
>{{ String(Number(commentCount)) }}
{{ commentCount === 1 ? 'comment' : 'comments' }}</NuxtLink
>
</span>
</template>

Expand All @@ -69,9 +75,10 @@ const commentCount = computed(() => {
class="col-12 comments"
v-if="!props.article.comments && showComments && commentCount"
>
<NuxtLink :to="{ path: props.article.link, hash: '#comments' }">
{{ String(Number(commentCount)) }} {{commentCount === 1 ? 'comment' : 'comments'}}
</NuxtLink>
<NuxtLink :to="{ path: props.article.link, hash: '#comments' }">
{{ String(Number(commentCount)) }}
{{ commentCount === 1 ? 'comment' : 'comments' }}
</NuxtLink>
</span>
</div>
</template>
Expand Down
37 changes: 22 additions & 15 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import { onMounted } from 'vue'
import VCard from '@nypublicradio/nypr-design-system-vue3/v2/src/components/VCard.vue'
import { useUpdateCommentCounts } from '~~/composables/comments'
import useImageUrl from '~~/composables/useImageUrl'
import { ArticlePage } from '~~/composables/types/Page';
import { ArticlePage } from '~~/composables/types/Page'
import { computed, ref } from 'vue'
const riverStoryCount = ref(6)
const riverAdOffset = ref(2)
const riverAdRepeatRate = ref(6)
const articlesPromise = findArticlePages({limit: riverStoryCount.value}).then(({ data }) =>
normalizeFindArticlePagesResponse(data)
const articlesPromise = findArticlePages({ limit: riverStoryCount.value }).then(
({ data }) => normalizeFindArticlePagesResponse(data)
)
const homePageCollectionsPromise = findPage('/').then(({ data }) => {
return data.value.pageCollectionRelationship.map((collection) => {
return {
Expand All @@ -30,7 +29,6 @@ const [articles, homePageCollections] = await Promise.all([
articlesPromise,
homePageCollectionsPromise,
])
// the latest articles
const latestArticles = ref([...articles])
Expand All @@ -49,7 +47,7 @@ const riverSegments = computed(() => {
const loadMoreArticles = async () => {
const newArticles = await useLoadMoreArticles({
limit: riverStoryCount.value,
offset: latestArticles.value.length
offset: latestArticles.value.length,
})
latestArticles.value.push(...newArticles)
}
Expand Down Expand Up @@ -85,7 +83,6 @@ const nativoSectionLoaded = (name) => {
PostRelease.Start()
}
}
</script>

<template>
Expand All @@ -98,7 +95,7 @@ const nativoSectionLoaded = (name) => {
@vue:mounted="nativoSectionLoaded('ntv-latest-1')"
/>
<!-- newsletter -->
<div class="my-8">
<div class="mt-8">
<hr class="black mb-4" />
<newsletter-home source="gothamist_home" @submit="newsletterSubmitEvent" />
</div>
Expand All @@ -118,6 +115,11 @@ const nativoSectionLoaded = (name) => {
v-if="collection.layout === 'center-feature'"
:collection="collection"
/>
<skyline-feature
class="content"
v-if="collection.layout === 'skyline'"
:collection="collection"
/>
<div v-if="index === 0" id="ntv-stream-2"></div>
</template>
</template>
Expand All @@ -132,13 +134,18 @@ const nativoSectionLoaded = (name) => {
<div id="latest">
<div
v-for="(riverSegment, segmentIndex) in riverSegments"
:key="riverSegment.map(article => article.uuid).join('-')"
:key="riverSegment.map((article) => article.uuid).join('-')"
class="grid gutter-x-xl"
>
<div class="col-12 xxl:col-1 type-label3">{{segmentIndex === 0 ? "LATEST" : ""}}</div>
<div class="col-12 xxl:col-1 type-label3">
{{ segmentIndex === 0 ? 'LATEST' : '' }}
</div>
<div class="col">
<div
v-for="(article, itemIndex) in riverSegment.slice(0, riverStoryCount)"
v-for="(article, itemIndex) in riverSegment.slice(
0,
riverStoryCount
)"
:key="article.uuid"
>
<v-card
Expand Down Expand Up @@ -189,10 +196,10 @@ const nativoSectionLoaded = (name) => {
<div class="col-12 xxl:col-1"></div>
<div class="col">
<Button
class="p-button-rounded"
label="Load More"
@click="loadMoreArticles"
>
class="p-button-rounded"
label="Load More"
@click="loadMoreArticles"
>
</Button>
</div>
</div>
Expand Down

0 comments on commit f606230

Please sign in to comment.