1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<template>
<b-popover
:placement="placement"
triggers="focus"
:show.sync="show"
custom-class="popover-heigth-100"
:target="`popover-choice-${id}`"
@hidden="onHidden"
>
<b-button
id="popover-choice-button"
variant="popover"
:class="{ 'selected-choice-button': scale === topPosition }"
@mouseover="scale = topPosition"
@click="
() => {
show = false;
firstAction();
}
"
>
{{ fitstOption }}
</b-button>
<b-button
id="popover-choice-button"
variant="popover"
:class="{ 'selected-choice-button': scale === bottomPosition }"
@mouseover="scale = bottomPosition"
@click="
() => {
show = false;
secondAction();
}
"
>
{{ secondOption }}
</b-button>
<div class="slider" :style="`left: 5px; top: ${scale}px;`"></div>
</b-popover>
</template>
<script>
export default {
props: {
id: {
type: Number,
default: null,
},
fitstOption: {
type: String,
default: null,
},
secondOption: {
type: String,
default: null,
},
chosenOption: {
type: String,
default: null,
},
firstAction: {
type: Function,
default: null,
},
secondAction: {
type: Function,
default: null,
},
placement: {
type: String,
default: 'bottom',
},
},
data() {
return {
topPosition: 5,
bottomPosition: 33,
show: false,
scale: 5,
};
},
methods: {
onHidden() {
if (this.secondOption === this.chosenOption) {
this.scale = this.bottomPosition;
} else {
this.scale = this.topPosition;
}
},
},
};
</script>
<style lang="scss">
#popover-unit-ractive {
padding-left: 5px;
}
.hovered-unit-button {
color: $white;
}
</style>
<style lang="scss" scoped>
#popover-choice-button {
width: 89px;
}
.slider {
width: 89px;
height: 28px;
border-radius: 8px;
background-color: $red-brand-primary;
box-shadow: 1px 2px 4px -1px rgb(79 37 37 / 40%) inset;
position: absolute;
transition: ease-in 0.2s;
z-index: -1;
}
</style>
|