Cristiano Magro
10 days ago b4849707f7cd990a76061f4fa4bf71b66cae0f76
commit | author | age
9dfbe6 1 <template>
CM 2     <ul>
3         <li :class="{ active: activeOption === 'poor' }">
4             <button type="button" @click="activate('poor')">Poor</button>
5         </li>
6         <li :class="{ active: activeOption === 'average' }">
7             <button type="button" @click="activate('average')">Average</button>
8         </li>
9         <li :class="{ active: activeOption === 'great' }">
10             <button type="button" @click="activate('great')">Great</button>
11         </li>
12     </ul>
13 </template>
14
15 <script>export default {
b48497 16     props: ['modelValue'],
CM 17     emits: ['update:modelValue'],
18     // data() {
19     //     return {
20     //         activeOption: null,
21     //     };
22     // },
23     computed: {
24         activeOption(){
25             return this.modelValue;
26         }
9dfbe6 27     },
CM 28     methods: {
29         activate(option) {
b48497 30             // this.activeOption = option;
CM 31             this.$emit('update:modelValue', option);
9dfbe6 32         }
CM 33     }
34
35 }
36 </script>
37
38 <style scoped>
39 .active {
40     border-color: purple;
41 }
42
43 .active button {
44     color: purple;
45 }
46
47 ul {
48     list-style: none;
49     margin: 0.5rem 0;
50     padding: 0;
51     display: flex;
52 }
53
54 li {
55     margin: 0 1rem;
56     border: 1px solid #ccc;
57     padding: 1rem;
58     display: flex;
59     align-items: center;
60 }
61
62 button {
63     font: inherit;
64     border: none;
65     background-color: transparent;
66     cursor: pointer;
67 }
68 </style>