added shout button

This commit is contained in:
Grzegorz Leoniec 2018-10-17 23:17:53 +02:00
parent a4272d8805
commit fa009151cd
4 changed files with 98 additions and 11 deletions

View File

@ -0,0 +1,63 @@
<template>
<ds-space
margin="large"
style="text-align: center">
<ds-button
:disabled="disabled || loading"
danger
size="x-large"
icon="heart"
@click="shout" />
<ds-space margin-bottom="xx-small" />
<ds-text color="soft">
<ds-heading
style="display: inline"
tag="h3">{{ shoutedCount }}x</ds-heading> Empfohlen
</ds-text>
</ds-space>
</template>
<script>
import gql from 'graphql-tag'
export default {
props: {
count: { type: Number, default: 0 },
postId: { type: String, default: null }
},
data() {
return {
loading: false,
disabled: false,
shoutedCount: this.count
}
},
methods: {
shout() {
this.loading = true
this.$apollo
.mutate({
mutation: gql`
mutation($myId: ID!, $postId: ID!) {
AddUserShouted(from: { id: $myId }, to: { id: $postId }) {
from {
id
}
}
}
`,
variables: {
myId: this.$store.getters['auth/user'].id,
postId: this.postId
}
})
.then(() => {
this.loading = false
this.disabled = true
this.shoutedCount++
this.$emit('update')
})
}
}
}
</script>

View File

@ -10,7 +10,12 @@
<div <div
class="content" class="content"
v-html="post.content" /> v-html="post.content" />
<ds-space margin-top="large"/> <!-- Shout Button -->
<ds-space margin="xx-large" />
<hc-shout-button
v-if="post.author"
:count="post.shoutedCount"
:post-id="post.id" />
<!-- Categories --> <!-- Categories -->
<div class="tags"> <div class="tags">
<ds-icon name="compass" /> <ds-tag <ds-icon name="compass" /> <ds-tag
@ -19,13 +24,14 @@
</div> </div>
<!-- Tags --> <!-- Tags -->
<template v-if="post.tags && post.tags.length"> <template v-if="post.tags && post.tags.length">
<ds-space margin="xx-small"/>
<div class="tags"> <div class="tags">
<ds-icon name="tags" /> <ds-tag <ds-icon name="tags" /> <ds-tag
v-for="tag in post.tags" v-for="tag in post.tags"
:key="tag.id"><ds-icon name="tag" /> {{ tag.name }}</ds-tag> :key="tag.id"><ds-icon name="tag" /> {{ tag.name }}</ds-tag>
</div> </div>
</template> </template>
<ds-space margin-bottom="large" /> <ds-space margin="small"/>
<!-- Comments --> <!-- Comments -->
<ds-section <ds-section
slot="footer"> slot="footer">
@ -54,8 +60,13 @@
<hc-author :post="comment" /> <hc-author :post="comment" />
</ds-space> </ds-space>
<div <div
style="padding-left: 32px;" v-if="!comment.deleted"
style="padding-left: 40px;"
v-html="comment.contentExcerpt" /> v-html="comment.contentExcerpt" />
<ds-text
v-else
style="padding-left: 40px; font-weight: bold;"
color="soft"><ds-icon name="ban" /> Vom Benutzer gelöscht</ds-text>
</div> </div>
<ds-space margin-bottom="small" /> <ds-space margin-bottom="small" />
</div> </div>
@ -69,6 +80,7 @@
<script> <script>
import gql from 'graphql-tag' import gql from 'graphql-tag'
import HcAuthor from '~/components/Author.vue' import HcAuthor from '~/components/Author.vue'
import HcShoutButton from '~/components/ShoutButton.vue'
export default { export default {
transition: { transition: {
@ -76,7 +88,8 @@ export default {
mode: 'out-in' mode: 'out-in'
}, },
components: { components: {
HcAuthor HcAuthor,
HcShoutButton
}, },
data() { data() {
@ -118,6 +131,7 @@ export default {
comments(orderBy: _id_desc) { comments(orderBy: _id_desc) {
id id
contentExcerpt contentExcerpt
deleted
author { author {
User { User {
id id
@ -134,12 +148,7 @@ export default {
categories { categories {
name name
} }
shoutedBy { shoutedCount
name
friends {
name
}
}
} }
} }
`), `),

View File

@ -170,6 +170,12 @@
height: $input-height-large; height: $input-height-large;
} }
.ds-button-size-x-large {
font-size: $font-size-x-large;
padding: $input-padding-vertical-large $space-base;
height: $input-height-x-large;
}
.ds-button-icon-only { .ds-button-icon-only {
width: $input-height; width: $input-height;
padding: 0; padding: 0;
@ -186,6 +192,10 @@
&.ds-button-size-large { &.ds-button-size-large {
width: $input-height-large; width: $input-height-large;
} }
&.ds-button-size-x-large {
width: $input-height-x-large;
}
} }
.ds-button-text { .ds-button-text {

View File

@ -16,3 +16,8 @@ $input-padding-vertical-large: $space-x-small;
$input-height-large: calc( $input-height-large: calc(
#{$font-size-large * $line-height-base} + #{($input-padding-vertical-large + $input-border-size) * 2} #{$font-size-large * $line-height-base} + #{($input-padding-vertical-large + $input-border-size) * 2}
); );
$input-padding-vertical-x-large: $space-small;
$input-height-x-large: calc(
#{$font-size-x-large * $line-height-base} + #{($input-padding-vertical-x-large + $input-border-size) * 2}
);