|
|
@@ -0,0 +1,108 @@
|
|
|
+<template>
|
|
|
+ <div class="signal-box">
|
|
|
+ <ul>
|
|
|
+ <li
|
|
|
+ v-for="(item, idex) in list"
|
|
|
+ :key="idex"
|
|
|
+ :class="item.class"
|
|
|
+ />
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { ref, watch } from 'vue'
|
|
|
+
|
|
|
+const props = defineProps<{
|
|
|
+ signalValue: number
|
|
|
+}>()
|
|
|
+
|
|
|
+const list = ref([
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ class: 'signal-default'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ class: 'signal-default'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 3,
|
|
|
+ class: 'signal-default'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 4,
|
|
|
+ class: 'signal-default'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 5,
|
|
|
+ class: 'signal-default'
|
|
|
+ }
|
|
|
+])
|
|
|
+
|
|
|
+watch(() => props.signalValue, (v: number) => {
|
|
|
+ list.value.forEach((el: { id: number, class: string }) => {
|
|
|
+ if (el.id <= v) {
|
|
|
+ if (v <= 2) {
|
|
|
+ el.class = 'signal-red'
|
|
|
+ } else if (v <= 4) {
|
|
|
+ el.class = 'signal-yellow'
|
|
|
+ } else {
|
|
|
+ el.class = 'signal-green'
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ el.class = 'signal-default'
|
|
|
+ }
|
|
|
+ })
|
|
|
+}, { immediate: true })
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+.signal-box {
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-start;
|
|
|
+ justify-content: center;
|
|
|
+ height: 23px;
|
|
|
+ width: 23px;
|
|
|
+ position: relative;
|
|
|
+ z-index: 3;
|
|
|
+
|
|
|
+ ul {
|
|
|
+ height: 21px;
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-end;
|
|
|
+ }
|
|
|
+
|
|
|
+ li {
|
|
|
+ width: 4px;
|
|
|
+ height: 5px;
|
|
|
+ border-radius: 10px;
|
|
|
+ list-style: none;
|
|
|
+ margin: 0 0.5px;
|
|
|
+
|
|
|
+ @for $i from 1 through 5 {
|
|
|
+ &:nth-child(#{$i}) {
|
|
|
+ height: $i*5 - ($i - 1) +px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .signal-default {
|
|
|
+ background: rgba(0, 0, 0, 0.3);
|
|
|
+ }
|
|
|
+
|
|
|
+ .signal-red {
|
|
|
+ background-color: red;
|
|
|
+ }
|
|
|
+
|
|
|
+ .signal-yellow {
|
|
|
+ background-color: #e7d055;
|
|
|
+ }
|
|
|
+
|
|
|
+ .signal-green {
|
|
|
+ background-color: #32cd32;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|