QuotaProgressBar.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <view class="quota-progress-bar" :style="{ '--font-scale': fontScale }">
  3. <view class="quota-label">
  4. <text class="quota-name">{{ name }}</text>
  5. <text class="quota-count">{{ remaining }} / {{ total }}</text>
  6. </view>
  7. <view class="quota-track">
  8. <view class="quota-fill" :style="{ width: percent + '%' }"></view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import fontScaleMixin from '@/mixins/font-scale.js'
  14. export default {
  15. mixins: [fontScaleMixin],
  16. name: 'QuotaProgressBar',
  17. props: {
  18. remaining: { type: Number, default: 0 },
  19. total: { type: Number, default: 0 },
  20. name: { type: String, default: '' }
  21. },
  22. computed: {
  23. percent() {
  24. if (!this.total) return 0
  25. return Math.round((this.remaining / this.total) * 100)
  26. }
  27. }
  28. }
  29. </script>
  30. <style scoped lang="scss">
  31. .quota-progress-bar {
  32. margin-bottom: 16rpx;
  33. }
  34. .quota-label {
  35. display: flex;
  36. justify-content: space-between;
  37. font-size: calc(24rpx * var(--font-scale, 1));
  38. color: $facade-text-body;
  39. margin-bottom: 8rpx;
  40. }
  41. .quota-track {
  42. height: 12rpx;
  43. background: $facade-fill;
  44. border-radius: 8rpx;
  45. overflow: hidden;
  46. }
  47. .quota-fill {
  48. height: 100%;
  49. background: $brand-primary;
  50. border-radius: 8rpx;
  51. transition: width 0.3s;
  52. }
  53. </style>