fs-timeline.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="fs-timeline">
  3. <view class="fs-timeline-item" v-for="(item, index) in options" :key="index">
  4. <view class="fs-dot-box">
  5. <slot name="dot" :item="item" :index="index">
  6. <view
  7. class="fs-dot"
  8. :class="index === 0 ? 'bg-' + activeColorType : ''"
  9. :style="{ backgroundColor: index === 0 ? activeColor : color }"
  10. ></view>
  11. </slot>
  12. </view>
  13. <view class="fs-timeline-line"></view>
  14. <view class="content"><slot :item="item" :index="index"></slot></view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. /**
  20. * 时间轴组件
  21. * @description 时间轴组件
  22. * @property {Array} options 选项列表
  23. * @property {String} color 颜色
  24. * @property {String} activeColor 高亮颜色
  25. * @property {String} activeColorType = [primary | danger | warning | info | success] 高亮颜色类型
  26. */
  27. export default {
  28. name: 'fs-timeline'
  29. }
  30. </script>
  31. <script setup>
  32. const props = defineProps({
  33. options: Array,
  34. color: {
  35. type: String,
  36. default: '#969799'
  37. },
  38. activeColor: String,
  39. activeColorType: {
  40. type: String,
  41. default: 'primary',
  42. validator(value) {
  43. return ['primary', 'success', 'info', 'warning', 'danger'].includes(value)
  44. }
  45. }
  46. })
  47. </script>
  48. <style lang="scss" scoped>
  49. .fs-timeline {
  50. padding-left: 40rpx;
  51. &-line {
  52. position: absolute;
  53. top: 0;
  54. left: -20rpx;
  55. width: 2rpx;
  56. height: 100%;
  57. background-color: #ebedf0;
  58. }
  59. &-item {
  60. position: relative;
  61. &:last-child {
  62. .timeline-line {
  63. display: none;
  64. }
  65. }
  66. }
  67. }
  68. .fs-dot-box {
  69. position: absolute;
  70. left: -20rpx;
  71. top: 30rpx;
  72. background-color: #fff;
  73. z-index: 10;
  74. transform: translateX(-50%);
  75. }
  76. .fs-dot {
  77. width: 15rpx;
  78. height: 15rpx;
  79. border-radius: 50%;
  80. // background-color: #969799;
  81. }
  82. .content {
  83. padding: var(--gutter) 0;
  84. }
  85. </style>