rename PostCard to PostTeaser

This commit is contained in:
Alina Beck 2020-02-11 10:07:16 +01:00
parent 6671d893e6
commit 09dee69ee0
10 changed files with 99 additions and 86 deletions

View File

@ -316,7 +316,7 @@ $z-index-page-submenu: 2500;
$z-index-page-header: 2000; $z-index-page-header: 2000;
$z-index-page-sidebar: 1500; $z-index-page-sidebar: 1500;
$z-index-sticky: 100; $z-index-sticky: 100;
$z-index-post-card-link: 5; $z-index-post-teaser-link: 5;
/** /**
* @tokens Media Query * @tokens Media Query

View File

@ -3,7 +3,7 @@ import { withA11y } from '@storybook/addon-a11y'
import { action } from '@storybook/addon-actions' import { action } from '@storybook/addon-actions'
import NotificationsTable from '~/components/NotificationsTable/NotificationsTable' import NotificationsTable from '~/components/NotificationsTable/NotificationsTable'
import helpers from '~/storybook/helpers' import helpers from '~/storybook/helpers'
import { post } from '~/components/PostCard/PostCard.story.js' import { post } from '~/components/PostTeaser/PostTeaser.story.js'
import { user } from '~/components/UserTeaser/UserTeaser.story.js' import { user } from '~/components/UserTeaser/UserTeaser.story.js'
helpers.init() helpers.init()

View File

@ -2,14 +2,14 @@ import { config, shallowMount, mount, RouterLinkStub } from '@vue/test-utils'
import Vuex from 'vuex' import Vuex from 'vuex'
import PostCard from './PostCard.vue' import PostTeaser from './PostTeaser.vue'
const localVue = global.localVue const localVue = global.localVue
config.stubs['client-only'] = '<span><slot /></span>' config.stubs['client-only'] = '<span><slot /></span>'
config.stubs['v-popover'] = '<span><slot /></span>' config.stubs['v-popover'] = '<span><slot /></span>'
describe('PostCard', () => { describe('PostTeaser', () => {
let store let store
let stubs let stubs
let mocks let mocks
@ -55,7 +55,7 @@ describe('PostCard', () => {
describe('shallowMount', () => { describe('shallowMount', () => {
Wrapper = () => { Wrapper = () => {
store = new Vuex.Store({ getters }) store = new Vuex.Store({ getters })
return shallowMount(PostCard, { return shallowMount(PostTeaser, {
store, store,
propsData, propsData,
mocks, mocks,
@ -99,7 +99,7 @@ describe('PostCard', () => {
const store = new Vuex.Store({ const store = new Vuex.Store({
getters, getters,
}) })
return mount(PostCard, { return mount(PostTeaser, {
stubs, stubs,
mocks, mocks,
propsData, propsData,

View File

@ -1,6 +1,6 @@
import { storiesOf } from '@storybook/vue' import { storiesOf } from '@storybook/vue'
import { withA11y } from '@storybook/addon-a11y' import { withA11y } from '@storybook/addon-a11y'
import HcPostCard from './PostCard.vue' import PostTeaser from './PostTeaser.vue'
import helpers from '~/storybook/helpers' import helpers from '~/storybook/helpers'
helpers.init() helpers.init()
@ -48,20 +48,20 @@ storiesOf('Post Card', module)
.addDecorator(withA11y) .addDecorator(withA11y)
.addDecorator(helpers.layout) .addDecorator(helpers.layout)
.add('without image', () => ({ .add('without image', () => ({
components: { HcPostCard }, components: { PostTeaser },
store: helpers.store, store: helpers.store,
data: () => ({ data: () => ({
post, post,
}), }),
template: ` template: `
<hc-post-card <post-teaser
:post="post" :post="post"
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }" :width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
/> />
`, `,
})) }))
.add('with image', () => ({ .add('with image', () => ({
components: { HcPostCard }, components: { PostTeaser },
store: helpers.store, store: helpers.store,
data: () => ({ data: () => ({
post: { post: {
@ -70,14 +70,14 @@ storiesOf('Post Card', module)
}, },
}), }),
template: ` template: `
<hc-post-card <post-teaser
:post="post" :post="post"
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }" :width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
/> />
`, `,
})) }))
.add('pinned by admin', () => ({ .add('pinned by admin', () => ({
components: { HcPostCard }, components: { PostTeaser },
store: helpers.store, store: helpers.store,
data: () => ({ data: () => ({
post: { post: {
@ -90,7 +90,7 @@ storiesOf('Post Card', module)
}, },
}), }),
template: ` template: `
<hc-post-card <post-teaser
:post="post" :post="post"
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }" :width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
/> />

View File

@ -6,19 +6,18 @@
<base-card <base-card
:lang="post.language" :lang="post.language"
:class="{ :class="{
'post-card': true,
'disabled-content': post.disabled, 'disabled-content': post.disabled,
'--pinned': isPinned, '--highlight': isPinned,
'--blur-image': post.imageBlurred, '--blur-image': post.imageBlurred,
}" }"
> >
<div class="card-image"> <div v-if="post.image" class="card-image">
<img :src="post.image | proxyApiUrl" class="image" /> <img :src="post.image | proxyApiUrl" class="image" />
</div> </div>
<client-only> <client-only>
<user-teaser :user="post.author" :date-time="post.createdAt" /> <user-teaser :user="post.author" :date-time="post.createdAt" />
</client-only> </client-only>
<h2 class="card-heading hyphentate-text">{{ post.title }}</h2> <h2 class="card-heading hyphenate-text">{{ post.title }}</h2>
<!-- TODO: replace editor content with tiptap render view --> <!-- TODO: replace editor content with tiptap render view -->
<!-- eslint-disable vue/no-v-html --> <!-- eslint-disable vue/no-v-html -->
<div class="content hyphenate-text" v-html="excerpt" /> <div class="content hyphenate-text" v-html="excerpt" />
@ -67,7 +66,7 @@ import { mapGetters } from 'vuex'
import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers' import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers'
export default { export default {
name: 'HcPostCard', name: 'PostTeaser',
components: { components: {
UserTeaser, UserTeaser,
HcCategory, HcCategory,
@ -146,67 +145,67 @@ export default {
height: 100%; height: 100%;
color: $text-color-base; color: $text-color-base;
.user-teaser {
margin-bottom: $space-small;
}
> .base-card {
display: flex;
flex-direction: column;
height: 100%;
&.--pinned {
border: 1px solid $color-warning;
}
&.--blur-image > .card-image > .image {
filter: blur(22px);
}
> .card-image {
overflow: hidden;
> .image {
width: 100%;
object-fit: contain;
}
}
> .content {
flex-grow: 1;
margin-bottom: $space-small;
}
> .footer {
display: flex;
justify-content: space-between;
align-items: center;
> .categories {
flex-grow: 1;
}
> .counter-icon {
display: block;
margin-right: $space-small;
opacity: 0.5;
}
> .content-menu {
position: relative;
z-index: $z-index-post-card-link;
}
.ds-tag {
margin: 0;
}
}
}
> .ribbon { > .ribbon {
position: absolute; position: absolute;
top: 50%; top: 50%;
right: -7px; right: -7px;
} }
} }
.post-teaser > .base-card {
display: flex;
flex-direction: column;
height: 100%;
&.--pinned {
border: 1px solid $color-warning;
}
&.--blur-image > .card-image > .image {
filter: blur(22px);
}
> .card-image {
overflow: hidden;
> .image {
width: 100%;
object-fit: contain;
}
}
> .content {
flex-grow: 1;
margin-bottom: $space-small;
}
> .footer {
display: flex;
justify-content: space-between;
align-items: center;
> .categories {
flex-grow: 1;
}
> .counter-icon {
display: block;
margin-right: $space-small;
opacity: 0.5;
}
> .content-menu {
position: relative;
z-index: $z-index-post-teaser-link;
}
.ds-tag {
margin: 0;
}
}
.user-teaser {
margin-bottom: $space-small;
}
}
</style> </style>

View File

@ -16,6 +16,20 @@ export default {}
background-color: $color-neutral-100; background-color: $color-neutral-100;
box-shadow: $box-shadow-base; box-shadow: $box-shadow-base;
&.--highlight {
border: $border-size-base solid $color-primary;
}
&.--wide-content {
padding: $space-small;
> .card-image {
width: calc(100% + (2 * #{$space-small}));
margin: -$space-small;
margin-bottom: $space-base;
}
}
> .card-image { > .card-image {
width: calc(100% + (2 * #{$space-base})); width: calc(100% + (2 * #{$space-base}));
margin: -$space-base; margin: -$space-base;

View File

@ -1,7 +1,7 @@
import { storiesOf } from '@storybook/vue' import { storiesOf } from '@storybook/vue'
import { withA11y } from '@storybook/addon-a11y' import { withA11y } from '@storybook/addon-a11y'
import { action } from '@storybook/addon-actions' import { action } from '@storybook/addon-actions'
import { post } from '~/components/PostCard/PostCard.story.js' import { post } from '~/components/PostTeaser/PostTeaser.story.js'
import { user } from '~/components/UserTeaser/UserTeaser.story.js' import { user } from '~/components/UserTeaser/UserTeaser.story.js'
import helpers from '~/storybook/helpers' import helpers from '~/storybook/helpers'
import ReportList from './ReportList' import ReportList from './ReportList'

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<masonry-grid> <masonry-grid>
<ds-grid-item v-show="hashtag" :row-span="2" column-span="fullWidth"> <ds-grid-item v-if="hashtag" :row-span="2" column-span="fullWidth">
<filter-menu :hashtag="hashtag" @clearSearch="clearSearch" /> <filter-menu :hashtag="hashtag" @clearSearch="clearSearch" />
</ds-grid-item> </ds-grid-item>
<ds-grid-item :row-span="2" column-span="fullWidth" class="top-info-bar"> <ds-grid-item :row-span="2" column-span="fullWidth" class="top-info-bar">
@ -26,7 +26,7 @@
:key="post.id" :key="post.id"
:imageAspectRatio="post.imageAspectRatio" :imageAspectRatio="post.imageAspectRatio"
> >
<hc-post-card <post-teaser
:post="post" :post="post"
@removePostFromList="deletePost" @removePostFromList="deletePost"
@pinPost="pinPost" @pinPost="pinPost"
@ -67,7 +67,7 @@
// import DonationInfo from '~/components/DonationInfo/DonationInfo.vue' // import DonationInfo from '~/components/DonationInfo/DonationInfo.vue'
import FilterMenu from '~/components/FilterMenu/FilterMenu.vue' import FilterMenu from '~/components/FilterMenu/FilterMenu.vue'
import HcEmpty from '~/components/Empty/Empty' import HcEmpty from '~/components/Empty/Empty'
import HcPostCard from '~/components/PostCard/PostCard.vue' import PostTeaser from '~/components/PostTeaser/PostTeaser.vue'
import MasonryGrid from '~/components/MasonryGrid/MasonryGrid.vue' import MasonryGrid from '~/components/MasonryGrid/MasonryGrid.vue'
import MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem.vue' import MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem.vue'
import { mapGetters, mapMutations } from 'vuex' import { mapGetters, mapMutations } from 'vuex'
@ -79,7 +79,7 @@ export default {
components: { components: {
// DonationInfo, // DonationInfo,
FilterMenu, FilterMenu,
HcPostCard, PostTeaser,
HcEmpty, HcEmpty,
MasonryGrid, MasonryGrid,
MasonryGridItem, MasonryGridItem,

View File

@ -24,7 +24,7 @@
:key="relatedPost.id" :key="relatedPost.id"
:imageAspectRatio="relatedPost.imageAspectRatio" :imageAspectRatio="relatedPost.imageAspectRatio"
> >
<hc-post-card <post-teaser
:post="relatedPost" :post="relatedPost"
:width="{ base: '100%', lg: 1 }" :width="{ base: '100%', lg: 1 }"
@removePostFromList="removePostFromList" @removePostFromList="removePostFromList"
@ -38,7 +38,7 @@
<script> <script>
import HcEmpty from '~/components/Empty/Empty' import HcEmpty from '~/components/Empty/Empty'
import HcPostCard from '~/components/PostCard/PostCard.vue' import PostTeaser from '~/components/PostTeaser/PostTeaser.vue'
import HcCategory from '~/components/Category' import HcCategory from '~/components/Category'
import HcHashtag from '~/components/Hashtag/Hashtag' import HcHashtag from '~/components/Hashtag/Hashtag'
import { relatedContributions } from '~/graphql/PostQuery' import { relatedContributions } from '~/graphql/PostQuery'
@ -51,7 +51,7 @@ export default {
mode: 'out-in', mode: 'out-in',
}, },
components: { components: {
HcPostCard, PostTeaser,
HcCategory, HcCategory,
HcHashtag, HcHashtag,
HcEmpty, HcEmpty,

View File

@ -242,7 +242,7 @@
:key="post.id" :key="post.id"
:imageAspectRatio="post.imageAspectRatio" :imageAspectRatio="post.imageAspectRatio"
> >
<hc-post-card <post-teaser
:post="post" :post="post"
:width="{ base: '100%', md: '100%', xl: '50%' }" :width="{ base: '100%', md: '100%', xl: '50%' }"
@removePostFromList="removePostFromList" @removePostFromList="removePostFromList"
@ -275,7 +275,7 @@
<script> <script>
import uniqBy from 'lodash/uniqBy' import uniqBy from 'lodash/uniqBy'
import UserTeaser from '~/components/UserTeaser/UserTeaser' import UserTeaser from '~/components/UserTeaser/UserTeaser'
import HcPostCard from '~/components/PostCard/PostCard.vue' import PostTeaser from '~/components/PostTeaser/PostTeaser.vue'
import HcFollowButton from '~/components/FollowButton.vue' import HcFollowButton from '~/components/FollowButton.vue'
import HcCountTo from '~/components/CountTo.vue' import HcCountTo from '~/components/CountTo.vue'
import HcBadges from '~/components/Badges.vue' import HcBadges from '~/components/Badges.vue'
@ -303,7 +303,7 @@ const tabToFilterMapping = ({ tab, id }) => {
export default { export default {
components: { components: {
UserTeaser, UserTeaser,
HcPostCard, PostTeaser,
HcFollowButton, HcFollowButton,
HcCountTo, HcCountTo,
HcBadges, HcBadges,