Skip to content

Commit 738fea1

Browse files
author
philippe lhardy
committed
reset VoteIndicator and use VoteItem
remove unused code in VoteIndicator reset VoteIndicator handles only simple variant move generic variant display in VoteItem Signed-off-by: philippe lhardy <philippe.lhardy@astrolabe.coop>
1 parent def6767 commit 738fea1

File tree

2 files changed

+36
-76
lines changed

2 files changed

+36
-76
lines changed

src/components/VoteTable/VoteIndicator.vue

Lines changed: 21 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,15 @@
44
-->
55

66
<script setup lang="ts">
7-
import { ref,computed, watch } from 'vue'
87
import CheckIcon from 'vue-material-design-icons/Check.vue'
98
import CloseIcon from 'vue-material-design-icons/Close.vue'
109
import CancelIcon from 'vue-material-design-icons/Cancel.vue'
1110
import MaybeIcon from '../AppIcons/MaybeIcon.vue'
1211
import { Answer } from '../../stores/votes.types'
13-
import { usePollStore } from '../../stores/poll.js'
14-
const pollStore = usePollStore()
15-
const chosenRank=JSON.parse(pollStore.configuration.chosenRank)
1612
1713
const ICON_SIZE = 26
1814
19-
interface Props {
20-
answer: Answer | 'locked'
21-
active?: boolean
22-
}
23-
24-
const props = defineProps<Props>()
25-
26-
const selectedRank = ref(props.answer)
27-
28-
const emit = defineEmits(['click','selectChange'])
15+
const { answer } = defineProps<{ answer: Answer | 'locked' }>()
2916
3017
const colorCodeNo = getComputedStyle(document.documentElement).getPropertyValue(
3118
'--color-error',
@@ -36,44 +23,10 @@ const colorCodeYes = getComputedStyle(document.documentElement).getPropertyValue
3623
const colorCodeMaybe = getComputedStyle(document.documentElement).getPropertyValue(
3724
'--color-warning',
3825
)
39-
40-
// Watchers
41-
watch(() => props.answer, (newValue) => {
42-
selectedRank.value = newValue
43-
})
44-
45-
// Methods
46-
const handleRankSelected = (event) => {
47-
const rank = event.target.value
48-
emit('selectChange', rank)
49-
}
50-
51-
52-
function onClick() {
53-
if (props.active) {
54-
emit('click')
55-
}
56-
}
5726
</script>
5827

5928
<template>
60-
<div class="vote-cell-container">
61-
<div v-if="pollStore.votingVariant === 'generic'" class="generic-vote">
62-
<span v-if="!props.active" class="selected-value">
63-
{{ selectedRank }}
64-
</span>
65-
<select
66-
v-else
67-
:value="selectedRank"
68-
class="vote-ranking"
69-
@change="handleRankSelected">
70-
<option disabled value=""></option>
71-
<option v-for="rank in chosenRank" :key="rank" :value="rank">
72-
{{ rank }}
73-
</option>
74-
</select>
75-
</div>
76-
<div v-else :class="['vote-indicator', props.active]" @click="onClick()">
29+
<div class="vote-indicator">
7730
<MaybeIcon
7831
v-if="answer === 'maybe'"
7932
:fill-color="colorCodeMaybe"
@@ -91,10 +44,28 @@ function onClick() {
9144
:fill-color="colorCodeNo"
9245
:size="ICON_SIZE" />
9346
</div>
94-
</div>
9547
</template>
9648

9749
<style lang="scss">
50+
.active .vote-indicator {
51+
border: 2px solid;
52+
border-radius: var(--border-radius);
53+
54+
&,
55+
* {
56+
cursor: pointer;
57+
}
58+
59+
&:hover {
60+
width: 35px;
61+
height: 35px;
62+
.material-design-icon {
63+
width: 31px;
64+
height: 31px;
65+
}
66+
}
67+
}
68+
9869
.vote-indicator {
9970
color: var(--color-polls-foreground-no);
10071
min-width: 30px;
@@ -106,39 +77,14 @@ function onClick() {
10677
&,
10778
* {
10879
transition: all 0.4s ease-in-out;
109-
margin: auto;
110-
.active & {
111-
cursor: pointer;
112-
}
11380
}
11481
115-
.active & {
116-
border: 2px solid;
117-
border-radius: var(--border-radius);
118-
.material-design-icon {
119-
width: 26px;
120-
height: 26px;
121-
}
122-
}
12382
.yes & {
12483
color: var(--color-polls-foreground-yes);
12584
}
12685
12786
.maybe & {
12887
color: var(--color-polls-foreground-maybe);
12988
}
130-
131-
.active:hover & {
132-
width: 35px;
133-
height: 35px;
134-
.material-design-icon {
135-
width: 31px;
136-
height: 31px;
137-
}
138-
}
139-
}
140-
141-
.error-message {
142-
color: var(--color-error);
14389
}
14490
</style>

src/components/VoteTable/VoteItem.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ const iconAnswer = computed(() => {
4545
</script>
4646

4747
<template>
48-
<div class="vote-item" :class="vote.answer">
48+
<div v-if="pollStore.votingVariant==='generic'" class="generic-vote">
49+
{{vote.answer}}
50+
</div>
51+
<div v-else class="vote-item" :class="vote.answer">
4952
<VoteIndicator :answer="iconAnswer" />
5053
</div>
5154
</template>
@@ -89,6 +92,17 @@ const iconAnswer = computed(() => {
8992
}
9093
}
9194
95+
.generic-vote {
96+
flex: 1;
97+
display: flex;
98+
align-items: center;
99+
justify-content: center;
100+
transition: all 0.4s ease-in-out;
101+
background-clip: content-box;
102+
border-radius: 12px;
103+
background-color: var(--color-polls-background-maybe);
104+
}
105+
92106
.list-view .locked .vote-item.current-user {
93107
background-color: revert;
94108
}

0 commit comments

Comments
 (0)