Refactor and update news teasers on start page

This commit is contained in:
Ramon Wenger 2020-06-30 18:05:45 +02:00
parent a2bbb6b26a
commit f4f9b7c1a1
10 changed files with 224 additions and 160 deletions

View File

@ -1,103 +0,0 @@
<template>
<div class="news-teasers">
<div
:key="teaser.id"
class="news-teasers__teaser teaser"
v-for="teaser in newsTeasers">
<a :href="teaser.newsArticleUrl">
<img
:src="teaser.imageUrl"
class="teaser__image">
<p class="teaser__image-source">
<a
:href="teaser.imageSource"
class="tiny-text">Quelle {{ teaser.imageSource }}</a></p>
<h4 class="teaser__title">{{ teaser.title }}</h4>
<p class="teaser__description">{{ teaser.description }}</p>
<p class="teaser__date">{{ teaser.displayDate }}</p>
</a>
</div>
</div>
</template>
<script>
import NEWS_TEASER_QUERY from '@/graphql/gql/newsTeasersQuery.gql';
export default {
components: {},
data() {
return {
newsTeasers: []
};
},
apollo: {
$client: 'publicClient',
newsTeasers: {
query: NEWS_TEASER_QUERY,
update(data) {
return this.$getRidOfEdges(data).newsTeasers;
}
}
}
};
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_functions.scss";
@import "@/styles/_mixins.scss";
$news_width: 550px;
$image_height: 254px;
.teasers {
display: block;
@include desktop {
@supports (display: grid) {
display: grid;
display: -ms-grid;
}
grid-template-columns: repeat(auto-fit, minmax(320px, $news_width));
grid-gap: 40px;
grid-auto-rows: minmax(400px, auto);
grid-template-rows: auto auto;
-ms-grid-columns: $news_width $news_width;
}
}
.teaser {
margin-bottom: $large-spacing;
position: relative;
&__image {
display: block;
max-width: 100%;
height: auto;
@include desktop {
max-width: $news_width;
}
}
&__image-source {
line-height: 25px;
}
&__description {
margin-bottom: $large-spacing;
}
&__date {
font-family: $sans-serif-font-family;
font-weight: $font-weight-regular;
color: $color-silver-dark;
position: absolute;
bottom: 0;
left: 0;
}
}
</style>

View File

@ -0,0 +1,67 @@
<template>
<div class="news-teaser">
<a :href="teaser.newsArticleUrl">
<img
:src="teaser.imageUrl"
class="news-news-teaser__image">
<p class="news-teaser__image-source">
<a
:href="teaser.imageSource"
class="tiny-text">Quelle {{ teaser.imageSource }}</a></p>
<h4 class="news-teaser__title">{{ teaser.title }}</h4>
<p class="news-teaser__description">{{ teaser.description }}</p>
<p class="news-teaser__date">{{ teaser.displayDate }}</p>
</a>
</div>
</template>
<script>
export default {
props: {
teaser: {
type: Object,
default: () => {
return {}
}
}
}
}
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_functions.scss";
@import "@/styles/_mixins.scss";
.news-teaser {
position: relative;
padding-bottom: $large-spacing;
&__image {
display: block;
max-width: 100%;
height: auto;
@include desktop {
max-width: $news_width;
}
}
&__image-source {
line-height: 25px;
}
&__description {
margin-bottom: $large-spacing;
}
&__date {
font-family: $sans-serif-font-family;
font-weight: $font-weight-regular;
color: $color-silver-dark;
position: absolute;
bottom: 0;
left: 0;
}
}
</style>

View File

@ -0,0 +1,48 @@
<template>
<div class="news-teasers">
<news-teaser
:key="teaser.id"
:teaser="teaser"
class="news-teasers__teaser teaser"
v-for="teaser in newsTeasers"/>
</div>
</template>
<script>
import NewsTeaser from '@/components/news/NewsTeaser';
import news from '@/mixins/news'
export default {
mixins: [news],
components: {
NewsTeaser
},
};
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_functions.scss";
@import "@/styles/_mixins.scss";
$image_height: 254px;
.news-teasers {
display: -ms-grid;
@supports (display: grid) {
display: grid;
}
margin-bottom: $large-spacing;
grid-gap: 40px;
@include desktop {
grid-column-gap: 40px;
grid-template-columns: repeat(auto-fit, minmax(320px, $news_width));
grid-auto-rows: minmax(400px, auto);
grid-template-rows: auto auto;
-ms-grid-columns: $news_width $news_width;
}
}
</style>

18
client/src/mixins/news.js Normal file
View File

@ -0,0 +1,18 @@
import NEWS_TEASER_QUERY from '@/graphql/gql/newsTeasersQuery.gql';
export default {
data() {
return {
newsTeasers: []
};
},
apollo: {
newsTeasers: {
query: NEWS_TEASER_QUERY,
update(data) {
return this.$getRidOfEdges(data).newsTeasers;
},
client: 'publicClient',
}
}
}

View File

@ -1,13 +1,13 @@
<template> <template>
<div class="news"> <div class="news">
<h1 class="news__heading">News</h1> <h1 class="news__heading">News</h1>
<NewsTeasers /> <news-teasers />
</div> </div>
</template> </template>
<script> <script>
import NewsTeasers from '@/components/NewsTeasers'; import NewsTeasers from '@/components/news/NewsTeasers';
export default { export default {
components: {NewsTeasers}, components: {NewsTeasers},

View File

@ -56,7 +56,7 @@
</template> </template>
<script> <script>
import SectionBlock from '@/components/SectionBlock.vue'; import SectionBlock from '@/components/SectionBlock.vue';
import NewsTeaser from '@/components/NewsTeaser.vue'; import NewsTeaser from '@/components/news/NewsTeaserOld.vue';
import HeaderBar from '@/components/HeaderBar'; import HeaderBar from '@/components/HeaderBar';
import ContentsIllustration from '@/components/illustrations/ContentsIllustration'; import ContentsIllustration from '@/components/illustrations/ContentsIllustration';

View File

@ -1,40 +1,49 @@
<template> <template>
<div class="start-page"> <div class="start-page">
<header-bar class="start-page__header"/> <div class="start-page__content">
<div
class="start-page__modules start-sections"
data-cy="start-modules-list">
<h2 class="start-page__heading">Letzte Module</h2>
<div class="start-page__modules-list">
<module-teaser
:key="index"
:meta-title="module.metaTitle"
:title="module.title"
:hero-image="module.heroImage"
:slug="module.slug"
data-cy="start-module-teaser"
v-for="(module, index) in me.recentModules"/>
<div </div>
class="start-page__modules start-sections" <router-link
data-cy="start-modules-list"> :to="topicRoute"
<module-teaser tag="div"
:key="index" class="button">Alle Module anzeigen
:meta-title="module.metaTitle" </router-link>
:title="module.title" </div>
:hero-image="module.heroImage" <div class="start-page__news news">
:slug="module.slug" <h2 class="start-page__heading">News</h2>
data-cy="start-module-teaser" <div class="news__list">
v-for="(module, index) in me.recentModules"/> <news-teaser
</div> :teaser="teaser"
<div class="start-page__news news"> :key="teaser.id"
<h2 class="news__title">News</h2> v-for="teaser in teasers"/>
<news-teaser </div>
date="27. Mai 2020"
title="Lockdown" <router-link
url="https://myskillbox-abu-news.webflow.io/lockdown"/> :to="{name: 'news'}"
<news-teaser class="button">Alle News anzeigen
date="11. März 2020" </router-link>
title="Brexit" </div>
url="https://myskillbox-abu-news.webflow.io/brexit"/>
<news-teaser
date="20. Dezember 2019"
title="Blockchain"
url="https://myskillbox-abu-news.webflow.io/blockchain"/>
<div class="news__more">Mehr...</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import SectionBlock from '@/components/SectionBlock.vue'; import SectionBlock from '@/components/SectionBlock.vue';
import NewsTeaser from '@/components/NewsTeaser.vue'; import NewsTeaser from '@/components/news/NewsTeaser.vue';
import NewsTeasers from '@/components/news/NewsTeasers.vue';
import HeaderBar from '@/components/HeaderBar'; import HeaderBar from '@/components/HeaderBar';
import ModuleTeaser from '@/components/modules/ModuleTeaser'; import ModuleTeaser from '@/components/modules/ModuleTeaser';
@ -44,16 +53,19 @@
import MobileHeader from '@/components/MobileHeader'; import MobileHeader from '@/components/MobileHeader';
import meMixin from '@/mixins/me'; import meQuery from '@/mixins/me';
import news from '@/mixins/news';
export default { export default {
mixins: [meMixin], mixins: [meQuery, news],
components: { components: {
MobileHeader, MobileHeader,
HeaderBar, HeaderBar,
SectionBlock, SectionBlock,
NewsTeaser, NewsTeaser,
NewsTeasers,
ContentsIllustration, ContentsIllustration,
PortfolioIllustration, PortfolioIllustration,
RoomsIllustration, RoomsIllustration,
@ -72,6 +84,9 @@
return 'Aktuelles Modul anzeigen'; return 'Aktuelles Modul anzeigen';
} }
return 'Alle Inhalte anzeigen' return 'Alle Inhalte anzeigen'
},
teasers() {
return this.newsTeasers.slice(0, 2);
} }
}, },
@ -96,10 +111,6 @@
width: 100vw; width: 100vw;
box-sizing: border-box; box-sizing: border-box;
&__header {
}
&__title { &__title {
color: $color-brand; color: $color-brand;
text-align: center; text-align: center;
@ -121,25 +132,45 @@
1px 1px 0 $color-brand;*/ 1px 1px 0 $color-brand;*/
} }
&__heading {
width: 100%;
@include meta-title;
}
&__content {
padding-top: 2*$large-spacing;
box-sizing: border-box;
max-width: 100%;
@include desktop {
max-width: 1200px;
margin: 0 auto;
}
}
&__modules { &__modules {
margin: 0 30px; margin-bottom: $large-spacing;
}
&__modules-list {
/*margin: 0 30px;*/
display: -ms-grid; display: -ms-grid;
-ms-grid-column-align: center; -ms-grid-column-align: center;
-ms-grid-columns: 1fr 1fr 1fr; -ms-grid-columns: 1fr 1fr 1fr;
margin-bottom: 90px; width: 100%;
margin-bottom: $large-spacing;
@supports (display: grid) { @supports (display: grid) {
display: grid; display: grid;
} }
@include desktop { @include desktop {
padding-left: 120px;
padding-right: 120px;
grid-template-columns: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: max-content;
} }
grid-row-gap: 15px; grid-row-gap: 15px;
grid-column-gap: 50px; grid-column-gap: 50px;
justify-items: start; justify-items: start;
align-items: center; align-items: center;
/* /*
* For IE10+ * For IE10+
@ -162,22 +193,24 @@
} }
.news { .news {
background-color: $color-charcoal-dark;
color: $color-white;
padding-top: $large-spacing;
padding-bottom: $large-spacing; padding-bottom: $large-spacing;
display: flex;
justify-content: space-around;
-ms-grid-columns: 1fr 1fr 1fr;
@supports (display: grid) {
display: grid;
grid-template-columns: 1fr;
}
grid-row-gap: $large-spacing; & &__list {
display: flex;
@include desktop { grid-row-gap: $large-spacing;
grid-template-columns: repeat(5, 1fr); grid-column-gap: $large-spacing;
margin-bottom: $large-spacing;
@supports (display: grid) {
display: grid;
grid-template-columns: 1fr;
}
@include desktop {
grid-template-columns: repeat(2, 1fr);
}
} }
/* /*

View File

@ -47,7 +47,7 @@ const routes = [
path: '/', path: '/',
name: 'home', name: 'home',
component: start, component: start,
meta: {layout: 'blank'} // meta: {layout: 'blank'}
}, },
{ {
path: '/login', path: '/login',

View File

@ -77,3 +77,4 @@ $default-heading-line-height: 1.2;
$popover-default-bottom: -110px; $popover-default-bottom: -110px;
$footer-width: 800px; $footer-width: 800px;
$news_width: 550px;