Steps.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import './index.less';
  2. import Title from '@/pages/home/components/Title';
  3. import React from 'react';
  4. interface StepItemProps {
  5. title: string | React.ReactNode;
  6. content: string | React.ReactNode;
  7. onClick: () => void;
  8. url?: string;
  9. }
  10. interface StepsProps {
  11. title: string | React.ReactNode;
  12. data: StepItemProps[];
  13. }
  14. const ItemDefaultImg = require('/public/images/home/bottom-1.png');
  15. const StepsItem = (props: StepItemProps) => {
  16. return (
  17. <div className={'step-item step-bar arrow-1'} onClick={props.onClick}>
  18. <div className={'step-item-title'}>
  19. <div className={'step-item-img'}>
  20. <img src={props.url || ItemDefaultImg} />
  21. </div>
  22. <span>{props.title}</span>
  23. </div>
  24. <div className={'step-item-content'}>{props.content}</div>
  25. </div>
  26. );
  27. };
  28. const Steps = (props: StepsProps) => {
  29. return (
  30. <div className={'home-step'}>
  31. <Title title={props.title} />
  32. <div
  33. className={'home-step-items'}
  34. style={{ gridTemplateColumns: `repeat(${props.data ? props.data.length : 1}, 1fr)` }}
  35. >
  36. {props.data && props.data.map((item) => <StepsItem {...item} />)}
  37. </div>
  38. </div>
  39. );
  40. };
  41. export default Steps;