mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
refactor EmotionButton
This commit is contained in:
parent
e9ad67d39b
commit
90d1e50b9e
55
webapp/components/EmotionButton/EmotionButton.vue
Normal file
55
webapp/components/EmotionButton/EmotionButton.vue
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<template>
|
||||||
|
<div class="emotion-button">
|
||||||
|
<base-button :id="emotion" circle ghost @click="$emit('toggleEmotion', emotion)">
|
||||||
|
<img :src="emojiPath" />
|
||||||
|
</base-button>
|
||||||
|
<label class="label" :for="emotion">{{ $t(`contribution.emotions-label.${emotion}`) }}</label>
|
||||||
|
<p v-if="count !== null" class="count">{{ emotionCount }}x</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
emojiPath: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
emotion: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
emotionCount: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.emotion-button {
|
||||||
|
flex-grow: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
> .base-button {
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
padding: $space-xxx-small;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
> .label {
|
||||||
|
margin-top: $space-xx-small;
|
||||||
|
font-size: $font-size-small;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .count {
|
||||||
|
margin: $space-xx-small 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,29 +1,26 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-flex :gutter="{ lg: 'large' }" class="emotions-flex">
|
<div class="emotions-button-group">
|
||||||
<ds-flex-item
|
<emotion-button
|
||||||
v-for="emotion in Object.keys(PostsEmotionsCountByEmotion)"
|
v-for="emotion in Object.keys(PostsEmotionsCountByEmotion)"
|
||||||
:key="emotion"
|
:key="emotion"
|
||||||
:width="{ lg: '100%' }"
|
:emojiPath="iconPath(emotion)"
|
||||||
>
|
|
||||||
<hc-emotions-button
|
|
||||||
@toggleEmotion="toggleEmotion"
|
|
||||||
:PostsEmotionsCountByEmotion="PostsEmotionsCountByEmotion"
|
|
||||||
:iconPath="iconPath(emotion)"
|
|
||||||
:emotion="emotion"
|
:emotion="emotion"
|
||||||
|
:emotionCount="PostsEmotionsCountByEmotion[emotion]"
|
||||||
|
@toggleEmotion="toggleEmotion"
|
||||||
/>
|
/>
|
||||||
</ds-flex-item>
|
</div>
|
||||||
</ds-flex>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import HcEmotionsButton from '~/components/EmotionsButton/EmotionsButton'
|
import EmotionButton from '~/components/EmotionButton/EmotionButton'
|
||||||
import { PostsEmotionsByCurrentUser } from '~/graphql/PostQuery.js'
|
import { PostsEmotionsByCurrentUser } from '~/graphql/PostQuery.js'
|
||||||
import PostMutations from '~/graphql/PostMutations.js'
|
import PostMutations from '~/graphql/PostMutations.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
HcEmotionsButton,
|
EmotionButton,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
post: { type: Object, default: () => {} },
|
post: { type: Object, default: () => {} },
|
||||||
@ -115,3 +112,9 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.emotions-button-group {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -1,55 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="emotions-button">
|
|
||||||
<base-button circle ghost @click="toggleEmotion(emotion)">
|
|
||||||
<img :src="iconPath" />
|
|
||||||
</base-button>
|
|
||||||
<ds-space margin-bottom="xx-small" />
|
|
||||||
<div class="emotions-mobile-space">
|
|
||||||
<p class="emotions-label">{{ $t(`contribution.emotions-label.${emotion}`) }}</p>
|
|
||||||
<p style="display: inline" :key="PostsEmotionsCountByEmotion[emotion]">
|
|
||||||
{{ PostsEmotionsCountByEmotion[emotion] }}x
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
iconPath: { type: String, default: null },
|
|
||||||
PostsEmotionsCountByEmotion: { type: Object, default: () => {} },
|
|
||||||
emotion: { type: String, default: null },
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
toggleEmotion(emotion) {
|
|
||||||
this.$emit('toggleEmotion', emotion)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style lang="scss">
|
|
||||||
.emotions-button {
|
|
||||||
> .base-button {
|
|
||||||
padding: 0;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
padding: 2px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.emotions-flex {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.emotions-label {
|
|
||||||
font-size: $font-size-small;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: 960px) {
|
|
||||||
.emotions-mobile-space {
|
|
||||||
margin-bottom: 32px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -47,13 +47,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<ds-space margin-top="x-large">
|
<ds-space margin-top="x-large">
|
||||||
<ds-flex :gutter="{ lg: 'small' }">
|
<ds-flex :gutter="{ lg: 'small' }">
|
||||||
<ds-flex-item
|
<ds-flex-item :width="{ lg: '75%', md: '75%', sm: '75%', base: '100%' }">
|
||||||
:width="{ lg: '75%', md: '75%', sm: '75%', base: '100%' }"
|
|
||||||
class="emotions-buttons-mobile"
|
|
||||||
>
|
|
||||||
<hc-emotions :post="post" />
|
<hc-emotions :post="post" />
|
||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
<ds-flex-item :width="{ lg: '10%', md: '3%', sm: '3%' }" />
|
|
||||||
<!-- Shout Button -->
|
<!-- Shout Button -->
|
||||||
<ds-flex-item
|
<ds-flex-item
|
||||||
:width="{ lg: '15%', md: '22%', sm: '22%', base: '100%' }"
|
:width="{ lg: '15%', md: '22%', sm: '22%', base: '100%' }"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user