whychdw
2021-06-03 2baa58f9515a661d53118344e237e3441300b24f
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
<template>
    <div class="thermometer" :class="{ active: state}">
        <div class="line"></div>
        <div class="arc"></div>
    </div>
</template>
 
<script>
export default {
    props: ['switch'],
    data() {
        return {
            state: false
        }
    },
    watch: {
        'switch': {
            handler(val) {
                this.state = val
            },
            deep: true
        },
    },
    mounted() {
        this.state = this.switch
    }
}
</script>
 
<style scoped>
.thermometer {
    width: 16px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
 
.line {
    width: 8px;
    height: 54px;
    background-color: #ffffff;
    border-radius: 4px 4px 0 0;
    overflow: hidden;
    position: relative;
}
 
.thermometer.active .line::before {
    content: "";
    display: block;
    width: 6px;
    height: 100%;
    position: absolute;
    bottom: 0;
    left: 1px;
    background: -webkit-linear-gradient(top, #ffffff, #318bf1);
}
 
.arc {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #ffffff;
    margin-top: -1px;
    overflow: hidden;
    position: relative;
}
 
.thermometer.active .arc::before {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #318bf1;
    position: absolute;
    bottom: -1px;
    left: -1px;
}
</style>