| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <template>
- <div
- class="electric"
- :class="bgClass"
- >
- <div class="electric-panel">
- <div
- class="electric-panel-remainder"
- :style="{ width: quantity + '%' }"
- />
- </div>
- <div class="electric-berText">
- {{ quantity }}%
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { computed } from 'vue'
- const props = defineProps<{
- quantity: number
- }>()
- const bgClass = computed(() => {
- if (props.quantity >= 50) {
- return 'success'
- } if (props.quantity >= 20) {
- return 'warning'
- } if (props.quantity >= 1) {
- return 'danger'
- }
- return 'danger'
- })
- </script>
- <style scoped lang="scss">
- .electric {
- display: flex;
- justify-content: center;
- align-items: center;
- position: relative;
- color: white;
- &-panel {
- box-sizing: border-box;
- width: 25px;
- height: 15px;
- position: relative;
- border: 2px solid #ccc;
- padding: 1px;
- border-radius: 3px;
- margin-right: 5px;
- &::before {
- content: "";
- border-radius: 0 1px 1px 0;
- height: 8px;
- background: #ccc;
- width: 3px;
- position: absolute;
- top: 50%;
- right: -4px;
- transform: translateY(-50%);
- overflow: hidden;
- }
- &-remainder {
- border-radius: 1px;
- position: relative;
- height: 100%;
- width: 0%;
- left: 0;
- top: 0;
- background: #fff;
- }
- }
- &-berText {
- font-size: 15px;
- }
- }
- .success {
- color: #40d7c1;
- &>div:first-child::before,
- &>div:first-child>div {
- background-color: #40d7c1;
- }
- &>div:first-child {
- border-color: #40d7c1;
- }
- }
- .warning {
- color: #f90;
- &>div:first-child::before,
- &>div:first-child>div {
- background-color: #f90;
- }
- &>div:first-child {
- border-color: #f90;
- }
- }
- .danger {
- color: #ed4014;
- &>div:first-child::before,
- &>div:first-child>div {
- background-color: #ed4014;
- }
- &>div:first-child {
- border-color: #ed4014;
- }
- }
- </style>
|