fs-timeline.vue 1.4 KB

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