fs-timeline.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 class="fs-dot"
  7. :class="index === 0 ? 'bg-' + activeColorType : ''"
  8. :style="{backgroundColor: index === 0 ? activeColor : '#969799'}">
  9. </view>
  10. </slot>
  11. </view>
  12. <view class="fs-timeline-line"></view>
  13. <view class="content"><slot :item="item" :index="index"></slot></view>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup>
  18. const props = defineProps({
  19. options: Array,
  20. colorType: String,
  21. color: String,
  22. activeColor: String,
  23. activeColorType: {
  24. type: String,
  25. default: 'primary',
  26. validator(value) {
  27. return ['primary', 'success', 'info', 'warning', 'danger'].includes(value)
  28. }
  29. }
  30. })
  31. </script>
  32. <style lang="scss" scoped>
  33. .fs-timeline {
  34. padding-left: 40rpx;
  35. &-line{
  36. position: absolute;
  37. top: 0;
  38. left: -20rpx;
  39. width: 2rpx;
  40. height: 100%;
  41. background-color: #ebedf0;
  42. }
  43. &-item{
  44. position: relative;
  45. &:last-child{
  46. .timeline-line{
  47. display: none;
  48. }
  49. }
  50. }
  51. }
  52. .fs-dot-box{
  53. position: absolute;
  54. left: -20rpx;
  55. top: 30rpx;
  56. background-color: #fff;
  57. z-index: 10;
  58. transform: translateX(-50%);
  59. }
  60. .fs-dot{
  61. width: 15rpx;
  62. height: 15rpx;
  63. border-radius: 50%;
  64. // background-color: #969799;
  65. }
  66. .content{
  67. padding: var(--gutter) 0;
  68. }
  69. </style>