44-->
55
66<script setup lang="ts">
7- import { ref ,computed , watch } from ' vue'
87import CheckIcon from ' vue-material-design-icons/Check.vue'
98import CloseIcon from ' vue-material-design-icons/Close.vue'
109import CancelIcon from ' vue-material-design-icons/Cancel.vue'
1110import MaybeIcon from ' ../AppIcons/MaybeIcon.vue'
1211import { 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
1713const 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
3017const colorCodeNo = getComputedStyle (document .documentElement ).getPropertyValue (
3118 ' --color-error' ,
@@ -36,44 +23,10 @@ const colorCodeYes = getComputedStyle(document.documentElement).getPropertyValue
3623const 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 >
0 commit comments