primevue-mirror/components/lib/progressbar/ProgressBar.vue

170 lines
4.0 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
2023-04-21 13:34:40 +00:00
<div role="progressbar" :class="containerClass" aria-valuemin="0" :aria-valuenow="value" aria-valuemax="100" v-bind="ptm('root')">
<div v-if="determinate" class="p-progressbar-value p-progressbar-value-animate" :style="progressStyle" v-bind="ptm('value')">
<div v-if="value != null && value !== 0 && showValue" class="p-progressbar-label" v-bind="ptm('label')">
2022-09-14 11:26:01 +00:00
<slot>{{ value + '%' }}</slot>
</div>
2022-09-06 12:03:37 +00:00
</div>
2023-04-21 13:34:40 +00:00
<div v-if="indeterminate" class="p-progressbar-indeterminate-container" v-bind="ptm('root')">
<div class="p-progressbar-value p-progressbar-value-animate" v-bind="ptm('value')"></div>
2022-09-06 12:03:37 +00:00
</div>
</div>
</template>
<script>
2023-04-21 13:34:40 +00:00
import BaseComponent from 'primevue/basecomponent';
2022-09-06 12:03:37 +00:00
export default {
name: 'ProgressBar',
2023-04-21 13:34:40 +00:00
extends: BaseComponent,
2022-09-06 12:03:37 +00:00
props: {
value: {
type: Number,
default: null
},
mode: {
type: String,
default: 'determinate'
},
showValue: {
type: Boolean,
default: true
}
},
computed: {
containerClass() {
return [
'p-progressbar p-component',
{
'p-progressbar-determinate': this.determinate,
'p-progressbar-indeterminate': this.indeterminate
}
];
},
progressStyle() {
return {
width: this.value + '%',
display: 'flex'
};
},
indeterminate() {
return this.mode === 'indeterminate';
},
determinate() {
return this.mode === 'determinate';
}
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
</script>
<style>
.p-progressbar {
position: relative;
overflow: hidden;
}
.p-progressbar-determinate .p-progressbar-value {
height: 100%;
width: 0%;
position: absolute;
display: none;
border: 0 none;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.p-progressbar-determinate .p-progressbar-label {
display: inline-flex;
}
.p-progressbar-determinate .p-progressbar-value-animate {
transition: width 1s ease-in-out;
}
.p-progressbar-indeterminate .p-progressbar-value::before {
2022-09-14 11:26:01 +00:00
content: '';
position: absolute;
background-color: inherit;
top: 0;
left: 0;
bottom: 0;
will-change: left, right;
-webkit-animation: p-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
animation: p-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
2022-09-06 12:03:37 +00:00
}
.p-progressbar-indeterminate .p-progressbar-value::after {
content: '';
position: absolute;
background-color: inherit;
top: 0;
left: 0;
bottom: 0;
will-change: left, right;
-webkit-animation: p-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;
2022-09-14 11:26:01 +00:00
animation: p-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;
2022-09-06 12:03:37 +00:00
-webkit-animation-delay: 1.15s;
2022-09-14 11:26:01 +00:00
animation-delay: 1.15s;
2022-09-06 12:03:37 +00:00
}
@-webkit-keyframes p-progressbar-indeterminate-anim {
2022-09-14 11:26:01 +00:00
0% {
left: -35%;
right: 100%;
}
60% {
left: 100%;
right: -90%;
}
100% {
left: 100%;
right: -90%;
}
2022-09-06 12:03:37 +00:00
}
@keyframes p-progressbar-indeterminate-anim {
2022-09-14 11:26:01 +00:00
0% {
left: -35%;
right: 100%;
}
60% {
left: 100%;
right: -90%;
}
100% {
left: 100%;
right: -90%;
}
2022-09-06 12:03:37 +00:00
}
@-webkit-keyframes p-progressbar-indeterminate-anim-short {
2022-09-14 11:26:01 +00:00
0% {
left: -200%;
right: 100%;
}
60% {
left: 107%;
right: -8%;
}
100% {
left: 107%;
right: -8%;
}
2022-09-06 12:03:37 +00:00
}
@keyframes p-progressbar-indeterminate-anim-short {
2022-09-14 11:26:01 +00:00
0% {
left: -200%;
right: 100%;
}
60% {
left: 107%;
right: -8%;
}
100% {
left: 107%;
right: -8%;
}
2022-09-06 12:03:37 +00:00
}
</style>