Timeline.tsx 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { View, Text, Icon, ScrollView } from '@tarojs/components'
  2. import './Timeline.scss'
  3. import { TimelineType } from '@/utils/types'
  4. import { IconRadio, IconRadioCheck, IconRadioCross } from '../basic/Icons'
  5. export default function Component(props: { items: any[], title?: string, type?: TimelineType, showLastLine?: boolean }) {
  6. return <View className="timeline" catchMove>
  7. <View>
  8. {
  9. props.title && <Text className='timeline_title'>{props.title}</Text>
  10. }
  11. {
  12. props.items.map((item, index) => (
  13. <View className='timelineItem'>
  14. <View className='timelineContentView' style={{ background: global.isDebug ? 'red' : 'transparent' }}>
  15. {
  16. item.status == 'padding' && <IconRadio width={16} color={item.color} />
  17. }
  18. {
  19. item.status == 'done' && <IconRadioCheck width={16} color={item.color} />
  20. }
  21. {
  22. item.status == 'un_done' && <IconRadioCross width={16} color={item.color} />
  23. }
  24. <View className='timelineContentDetail'>
  25. <View className="timeline-time" style={{ color: item.color ? item.color : '#fff' }}>{item.title}</View>
  26. <View style={{ flex: 1 }} />
  27. </View>
  28. </View>
  29. <View className="timeline-detail">{item.content}
  30. {
  31. item.date && <View className="timeline-date">{item.date}</View>
  32. }
  33. </View>
  34. <View className={index !== props.items.length - 1 ? 'timeline_line1 line1_bottom_space' : 'timeline_line1 line1_bottom_zero'} />
  35. {
  36. index !== props.items.length - 1 &&
  37. <View className='timeline-line-bg' style={{ width: 16, background: global.isDebug ? 'red' : 'transparent' }}>
  38. <View className='timeline-line1'
  39. style={{ background: (props.items[index + 1].status == 'done' && item.status == 'done') ? 'linear-gradient(to top, ' + props.items[index + 1].color + ', ' + item.color + ')' : '#ffffff66' }}
  40. />
  41. </View>
  42. }
  43. {
  44. index == props.items.length - 1 && props.showLastLine &&
  45. <View className='timeline-line-bg' style={{ width: 16, background: global.isDebug ? 'red' : 'transparent' }}>
  46. <View className='timeline-line1'
  47. style={{ background: item.color }}
  48. />
  49. </View>
  50. }
  51. {/* {index !== props.items.length - 1 &&
  52. <View className='timeline-line'
  53. style={{ background: (props.items[index + 1].status == 'done' && item.status == 'done') ? 'linear-gradient(to top, ' + props.items[index + 1].color + ', ' + item.color + ')' : '#ffffff66' }}
  54. />}
  55. {
  56. index == props.items.length - 1 && props.showLastLine &&
  57. <View className='timeline-line'
  58. style={{ background: item.color }}
  59. />
  60. } */}
  61. </View>
  62. ))
  63. }
  64. </View>
  65. </View>
  66. }