146 lines
3.2 KiB
Vue
146 lines
3.2 KiB
Vue
<template>
|
|
<div class="source">
|
|
<div
|
|
:class="getCssClass"
|
|
@click="clicked"
|
|
>
|
|
<div class="source__source">
|
|
{{ source.name }}
|
|
</div>
|
|
</div>
|
|
<div v-if="badgeCount" class="source__badge">
|
|
<div class="source__badge-count">
|
|
{{ badgeCount }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: ['source', 'selectable'],
|
|
computed: {
|
|
getCssClass() {
|
|
return {
|
|
'source__container': true,
|
|
'source__container-selectable': this.selectable,
|
|
'source__container__selected': this.isSelected(),
|
|
'source__container__hidden': this.isWrongSource(),
|
|
}
|
|
},
|
|
badgeCount() {
|
|
if (this.isWrongSource()) return 0
|
|
|
|
const revelation = this.$store.state.round.revelation || {}
|
|
const votes = revelation.votes || {}
|
|
const list = votes[this.source.id] || []
|
|
|
|
return list.length
|
|
},
|
|
},
|
|
methods: {
|
|
isWrongSource() {
|
|
const revelationSources = this.$store.state.round.revelation.sources || {}
|
|
const isRightOrWrong = revelationSources[this.source.id]
|
|
if (typeof isRightOrWrong === 'undefined') return false
|
|
|
|
return !isRightOrWrong
|
|
},
|
|
isSelected() {
|
|
return this.$store.state.selection.selection[this.source.id]
|
|
},
|
|
clicked() {
|
|
if (!this.selectable) return
|
|
|
|
if (this.isSelected()) {
|
|
this.$store.commit('selection/unselect', this.source.id)
|
|
} else {
|
|
this.$store.commit('selection/clearSelection')
|
|
this.$store.commit('selection/select', this.source.id)
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
@import '~/assets/css/components';
|
|
|
|
.source {
|
|
position: absolute;
|
|
width: 180px;
|
|
height: 30px;
|
|
margin: -15px 0 0 -90px;
|
|
|
|
&__container {
|
|
display: flex;
|
|
align-items: center;
|
|
max-width: 180px;
|
|
height: 1.4em;
|
|
padding: 4px;
|
|
border: 1px solid $secondary-box-border-color;
|
|
border-radius: 10px;
|
|
background-color: $secondary-box-background-color;
|
|
color: $secondary-box-text-color;
|
|
|
|
&-selectable {
|
|
&:hover {
|
|
background-color: #c0a0f0;
|
|
color: $primary-background-color;
|
|
cursor: pointer;
|
|
}
|
|
&.source__container__selected {
|
|
background-color: $primary-text-color;
|
|
box-shadow: 0 0 10px $primary-text-color;
|
|
}
|
|
}
|
|
|
|
&__selected {
|
|
background-color: #d0d0d0;
|
|
color: $primary-background-color;
|
|
box-shadow: 0 0 10px #d0d0d0;
|
|
}
|
|
|
|
&__hidden {
|
|
animation: source-fade-out 0.7s linear;
|
|
animation-fill-mode: forwards;
|
|
}
|
|
}
|
|
|
|
&__source {
|
|
width: 100%;
|
|
font-family: "Wendy One";
|
|
text-align: center;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
user-select: none;
|
|
}
|
|
|
|
&__badge {
|
|
display: flex;
|
|
align-items: center;
|
|
position: absolute;
|
|
right: -12px;
|
|
top: -16px;
|
|
width: 24px;
|
|
height: 24px;
|
|
background-color: $primary-box-background-color;
|
|
border: 2px solid #ffffff;
|
|
border-radius: 14px;
|
|
color: #c0c060;
|
|
font-family: "Wendy One";
|
|
font-size: 16px;
|
|
|
|
&-count {
|
|
width: 100%;
|
|
text-align: center;
|
|
user-select: none;
|
|
}
|
|
}
|
|
}
|
|
@keyframes source-fade-out {
|
|
to { opacity: 10%; }
|
|
}
|
|
</style>
|