2021-08-20 20:06:28 +00:00
|
|
|
<template>
|
|
|
|
<div class="source">
|
2021-08-27 12:43:14 +00:00
|
|
|
<div
|
2021-08-30 16:21:14 +00:00
|
|
|
:class="getCssClass"
|
2021-08-27 12:43:14 +00:00
|
|
|
@click="clicked"
|
|
|
|
>
|
|
|
|
<div class="source__source">
|
|
|
|
{{ source.name }}
|
|
|
|
</div>
|
2021-08-20 20:06:28 +00:00
|
|
|
</div>
|
2021-09-05 19:30:13 +00:00
|
|
|
<div v-if="badgeCount" class="source__badge">
|
|
|
|
<div class="source__badge-count">
|
|
|
|
{{ badgeCount }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-20 20:06:28 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2021-08-30 16:21:14 +00:00
|
|
|
props: ['source', 'selectable'],
|
2021-08-27 12:43:14 +00:00
|
|
|
computed: {
|
2021-08-30 16:21:14 +00:00
|
|
|
getCssClass() {
|
|
|
|
return {
|
|
|
|
'source__container': true,
|
|
|
|
'source__container-selectable': this.selectable,
|
|
|
|
'source__container__selected': this.isSelected(),
|
|
|
|
}
|
2021-08-27 12:43:14 +00:00
|
|
|
},
|
2021-09-05 19:30:13 +00:00
|
|
|
badgeCount() {
|
|
|
|
const revelation = this.$store.state.round.revelation || {}
|
|
|
|
const votes = revelation.votes || {}
|
|
|
|
const list = votes[this.source.id] || []
|
|
|
|
return list.length
|
|
|
|
},
|
2021-08-27 12:43:14 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
isSelected() {
|
|
|
|
return this.$store.state.selection.selection[this.source.id]
|
|
|
|
},
|
|
|
|
clicked() {
|
2021-08-30 16:21:14 +00:00
|
|
|
if (!this.selectable) return
|
|
|
|
|
2021-08-27 12:43:14 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2021-08-20 20:06:28 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.source {
|
|
|
|
position: absolute;
|
|
|
|
width: 180px;
|
|
|
|
height: 30px;
|
|
|
|
margin: -15px 0 0 -90px;
|
2021-08-27 12:43:14 +00:00
|
|
|
|
|
|
|
&__container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
max-width: 180px;
|
|
|
|
height: 1.4em;
|
|
|
|
padding: 4px;
|
|
|
|
border: 1px solid #e0e0e0;
|
|
|
|
border-radius: 10px;
|
2021-09-05 19:33:02 +00:00
|
|
|
background-color: #6040c0;
|
2021-08-27 12:43:14 +00:00
|
|
|
color: #ffffff;
|
|
|
|
|
2021-08-30 16:21:14 +00:00
|
|
|
&-selectable {
|
|
|
|
&:hover {
|
2021-09-05 19:33:02 +00:00
|
|
|
background-color: #c0a0f0;
|
|
|
|
color: #402080;
|
2021-08-30 16:21:14 +00:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
&.source__container__selected {
|
|
|
|
background-color: #ffffff;
|
|
|
|
box-shadow: 0 0 10px #ffffff;
|
|
|
|
}
|
2021-08-27 12:43:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-30 16:21:14 +00:00
|
|
|
&__selected {
|
|
|
|
background-color: #d0d0d0;
|
2021-08-27 12:43:14 +00:00
|
|
|
color: #402080;
|
2021-08-30 16:21:14 +00:00
|
|
|
box-shadow: 0 0 10px #d0d0d0;
|
2021-08-27 12:43:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-20 20:06:28 +00:00
|
|
|
|
|
|
|
&__source {
|
|
|
|
width: 100%;
|
|
|
|
font-family: "Wendy One";
|
|
|
|
text-align: center;
|
2021-08-27 12:43:14 +00:00
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
user-select: none;
|
2021-08-20 20:06:28 +00:00
|
|
|
}
|
|
|
|
|
2021-09-05 19:30:13 +00:00
|
|
|
&__badge {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
position: absolute;
|
|
|
|
right: -12px;
|
|
|
|
top: -16px;
|
|
|
|
width: 24px;
|
|
|
|
height: 24px;
|
|
|
|
background-color: #6040c0;
|
|
|
|
border: 2px solid #ffffff;
|
|
|
|
border-radius: 14px;
|
|
|
|
color: #c0c060;
|
|
|
|
font-family: "Wendy One";
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
|
|
&-count {
|
|
|
|
width: 100%;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
2021-08-20 20:06:28 +00:00
|
|
|
}
|
|
|
|
</style>
|