Skip to content

Commit

Permalink
Bono/goth 322 (#101)
Browse files Browse the repository at this point in the history
* starting center feature, first I made the horx drag a component to pass in v-cards in the slot

* fixed inbetween spacing with empty div

* good point, just need to figure out how to populate the articles with the correct collection

* updated the GothamistHomepageTopper with the HorizontalDrag component

* clean up

* finishing up Bono's work on this; moved single story feature to it's own component and cleaned up index page

* deepsource

* deepsource

* get rid of extra API call for featured articles

Co-authored-by: Thomas Bono <thomasbono.com@gmail.com>
  • Loading branch information
kimlarocca and bonomite authored Aug 29, 2022
1 parent 160ee20 commit a226239
Show file tree
Hide file tree
Showing 8 changed files with 556 additions and 234 deletions.
24 changes: 19 additions & 5 deletions assets/scss/extensions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,11 @@ $img-height-mobile: 106px;
gap: 1rem !important;
}
}
.v-card:not([data-style-mode='dark']),
.v-card:not([data-style-mode='dark']) .v-tag .flexible-link .p-button {
background: transparent;
}
// this was messing up the hover of the tags
// .v-card:not([data-style-mode='dark']),
// .v-card:not([data-style-mode='dark']) .v-tag .flexible-link .p-button {
// background: transparent;
// }
.v-card.mod-left .card-image-wrapper {
display: contents;
}
Expand Down Expand Up @@ -426,7 +427,20 @@ $img-height-mobile: 106px;
//line-height: var(--font-size-8);
// fixes safari render issue
line-height: 21px;
font-weight: 400;
font-weight: 500;
}
}
.v-card.mod-mobile {
.image-with-caption {
width: $img-width-mobile !important;
}
.card-details .card-title,
.card-details .card-title .h2 {
font-size: var(--font-size-6);
//line-height: var(--font-size-8);
// fixes safari render issue
line-height: 21px;
font-weight: 500;
}
}
.v-card.mod-small.mod-left {
Expand Down
128 changes: 13 additions & 115 deletions components/ArticleRecirculation.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<script setup lang="ts">
import VCard from '@nypublicradio/nypr-design-system-vue3/v2/src/components/VCard.vue'
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { gsap } from 'gsap'
import { Draggable } from '~/assets/gsap/Draggable.js'
import { InertiaPlugin } from '~/assets/gsap/InertiaPlugin.js'
// this component is used in the articleSlug at the bottom of the article page, and also as the topper in the section index page
Expand All @@ -19,7 +16,6 @@ const props = defineProps({
},
})
const route = useRoute()
const routeSectionSlug = ref(props.slug)
const { title: sectionTitle, id: sectionId } = await findPage(
routeSectionSlug.value as string
Expand All @@ -42,30 +38,6 @@ const articlesSm = ref([
articlesFiltered[3],
articlesFiltered[4],
])
const isMobile = ref(false)
onMounted(() => {
// draggable setup
if (window.innerWidth < 768 && articles) {
isMobile.value = true
setTimeout(() => {
gsap.registerPlugin(InertiaPlugin)
gsap.registerPlugin(Draggable)
Draggable.create('.horz-scroll-content', {
type: 'x',
edgeResistance: 0.45,
bounds: '.horz-scroll',
inertia: true,
})
}, 1000)
}
})
onBeforeUnmount(() => {
// kill draggable
if (isMobile.value) {
Draggable.get('.horz-scroll-content').kill()
}
})
</script>

<template>
Expand Down Expand Up @@ -131,43 +103,19 @@ onBeforeUnmount(() => {
</p>
<v-card-metadata :article="articleMd" />
</v-card>
<hr
class="my-5"
:class="isMobile ? 'block xl:hidden' : 'hidden sm:block xl:hidden'"
/>
<div class="horz-scroll-holder" :class="[{ mobile: isMobile }]">
<div class="horz-scroll">
<div class="grid gutter-x-xl keep-gutter horz-scroll-content">
<div
v-for="articleSm in articlesSm"
:key="articleSm?.id"
class="v-hr flex"
:class="
isMobile
? ' col-4 xl:col-12 xl:flex-column'
: 'col-12 sm:col-4 xl:col-12 flex-column sm:flex-row xl:flex-column'
"
>
<hr
class="w-full mb-3"
:class="
isMobile ? 'hidden xl:block' : 'block sm:hidden xl:block'
"
/>
<v-card
class="article-sm mod-horizontal mod-small mb-3 tag-small"
:title="articleSm?.listingTitle"
:titleLink="articleSm?.link"
>
<v-card-metadata
:article="articleSm"
:showComments="false"
/>
</v-card>
</div>
</div>
</div>
</div>
<hr class="my-3" />
<horizontal-drag :articles="articlesSm" v-slot="slotProps">
<v-card
class="article-sm mod-horizontal mod-small mb-3 tag-small"
:title="slotProps.article.listingTitle"
:titleLink="slotProps.article.link"
>
<v-card-metadata
:article="slotProps.article"
:showComments="false"
/>
</v-card>
</horizontal-drag>
</div>
</div>
</div>
Expand Down Expand Up @@ -195,55 +143,5 @@ onBeforeUnmount(() => {
border-right: 1px solid #ebebeb !important;
}
}
.horz-scroll-holder.mobile {
position: relative;
@include media('<md') {
margin-left: -1.5rem;
margin-right: -1.5rem;
&:after {
content: '';
z-index: 1;
pointer-events: none;
position: absolute;
top: 0;
right: 0;
display: block;
height: 100%;
width: 100%;
background: -moz-linear-gradient(
left,
rgba(255, 255, 255, 1) 0%,
rgba(255, 255, 255, 0) 10%,
rgba(255, 255, 255, 0) 65%,
rgba(255, 255, 255, 1) 100%
);
background: -webkit-linear-gradient(
left,
rgba(255, 255, 255, 1) 0%,
rgba(255, 255, 255, 0) 10%,
rgba(255, 255, 255, 0) 65%,
rgba(255, 255, 255, 1) 100%
);
background: linear-gradient(
to right,
rgba(255, 255, 255, 1) 0%,
rgba(255, 255, 255, 0) 10%,
rgba(255, 255, 255, 0) 65%,
rgba(255, 255, 255, 1) 100%
);
}
}
.horz-scroll {
overflow-x: hidden;
@include media('<md') {
//overflow-x: scroll;
.horz-scroll-content {
padding: 0 24px;
width: 733px;
}
}
}
}
}
</style>
197 changes: 197 additions & 0 deletions components/CenterFeature.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
<script setup lang="ts">
import VCard from '@nypublicradio/nypr-design-system-vue3/v2/src/components/VCard.vue'
import { ref } from 'vue'
const props = defineProps({
collection: {
type: Object,
default: {},
required: true,
},
})
// Note: the center feature should display the first 6 stories in the content collection
const articleLg = ref(normalizeArticlePage(props.collection.data[0]))
const articleMd = ref(normalizeArticlePage(props.collection.data[1]))
const articlesSm = ref([
normalizeArticlePage(props.collection.data[2]),
normalizeArticlePage(props.collection.data[3]),
normalizeArticlePage(props.collection.data[4]),
normalizeArticlePage(props.collection.data[5]),
])
</script>

<template>
<div v-if="articleLg && articleMd && articlesSm" class="center-feature">
<div class="grid gutter-x-30">
<div class="col-fixed flex-order-2 lg:flex-order-1">
<!-- md article desktop -->
<v-card
class="hidden lg:flex article-md mod-vertical mod-large mb-5 tag-small"
:image="useImageUrl(articleMd.listingImage)"
:title="articleMd.listingTitle"
:titleLink="articleMd.link"
:ratio="[3, 2]"
:width="433"
:height="289"
:sizes="[1]"
:maxWidth="articleMd.listingImage?.width"
:maxHeight="articleMd.listingImage?.height"
loading="eager"
:tags="[
{
name: articleMd.section.name,
slug: `/${articleMd.section.slug}`,
},
]"
>
<p>
{{ articleMd.description }}
</p>
<v-card-metadata stack :article="articleMd" />
</v-card>
<!-- md article mobile -->
<v-card
class="flex lg:hidden article-md mod-horizontal mod-left tag-small"
:image="useImageUrl(articleMd.listingImage)"
:title="articleMd.listingTitle"
:titleLink="articleMd.link"
:width="318"
:height="212"
:sizes="[1]"
:maxWidth="articleMd.listingImage?.width"
:maxHeight="articleMd.listingImage?.height"
loading="eager"
:tags="[
{
name: articleMd.section.name,
slug: `/${articleMd.section.slug}`,
},
]"
>
<p>
{{ articleMd.description }}
</p>
<v-card-metadata :article="articleMd" />
</v-card>
<img
class="hidden lg:block mb-4 xl:mb-7"
src="https://fakeimg.pl/300x250/?text=AD Here"
width="300"
height="250"
alt="advertisement"
/>
</div>
<div class="col flex-order-1 lg:flex-order-2">
<v-card
class="article-lg mod-vertical mod-large mb-4"
:image="useImageUrl(articleLg.listingImage)"
:sizes="[1]"
:width="897"
:height="598"
:title="articleLg.listingTitle"
:titleLink="articleLg.link"
:maxWidth="articleLg.listingImage?.width"
:maxHeight="articleLg.listingImage?.height"
loading="eager"
:tags="[
{
name: articleLg.section.name,
slug: `/${articleLg.section.slug}`,
},
]"
>
<v-card-metadata
class="mt-0 md:mt-2"
altDesign
:article="articleLg"
/>
</v-card>
<hr class="block lg:hidden mb-3" />
</div>
<div class="col-3 flex-order-3">
<hr class="my-3 block xl:hidden" />
<horizontal-drag :articles="articlesSm" v-slot="slotProps">
<v-card
class="mod-horizontal mod-left mod-small mb-0"
:image="useImageUrl(slotProps.article.listingImage)"
:width="106"
:height="106"
:ratio="[1, 1]"
:sizes="[2]"
:title="slotProps.article.listingTitle || slotProps.article.title"
:titleLink="slotProps.article.link"
:maxWidth="slotProps.article.listingImage?.width"
:maxHeight="slotProps.article.listingImage?.height"
:quality="80"
>
<div></div>
<v-card-metadata
:article="slotProps.article"
:showComments="false"
/>
</v-card>
</horizontal-drag>
<img
class="block lg:hidden mb-4 xl:mb-7 m-auto mt-6"
src="https://fakeimg.pl/300x250/?text=AD Here"
width="300"
height="250"
alt="advertisement"
/>
</div>
</div>
</div>
</template>
<style lang="scss">
.center-feature {
.col-fixed {
width: $col-fixed-width-330;
@include media('<lg') {
width: 100%;
}
}
.col {
@include media('<xl') {
width: auto;
}
@include media('<lg') {
width: 100%;
}
}
.col-3 {
width: $col-fixed-width-330;
@include media('<xl') {
width: 100%;
}
}
.v-card {
background: transparent;
&.article-sm {
.card-title-link .h2 {
font-weight: 600 !important;
}
.card-slot {
justify-content: end;
}
}
&.article-md {
gap: 1rem !important;
// custom size of title and v-tag placement
@include media('>=lg') {
.card-details .card-title {
.flexible-link {
.h2 {
@include font-config($type-header5);
}
}
.v-tag {
margin-top: -4px;
}
}
}
}
}
}
</style>
Loading

0 comments on commit a226239

Please sign in to comment.