Steps.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. after?: any;
  10. }
  11. interface StepsProps {
  12. title: string | React.ReactNode;
  13. data: StepItemProps[];
  14. style?: any;
  15. }
  16. const ItemDefaultImg = require('/public/images/home/bottom-1.png');
  17. const StepsItem = (props: StepItemProps) => {
  18. return (
  19. <div className={props.after ? 'step-item step-bar ' : 'step-item step-bar arrow-1'}>
  20. <div className={'step-item-title'} onClick={props.onClick}>
  21. <div className={'step-item-img'}>
  22. <img src={props.url || ItemDefaultImg} />
  23. </div>
  24. <span>{props.title}</span>
  25. </div>
  26. <div className={'step-item-content'}>{props.content}</div>
  27. </div>
  28. );
  29. };
  30. const Steps = (props: StepsProps) => {
  31. return (
  32. <div className={'home-step'}>
  33. <Title title={props.title} />
  34. <div
  35. className={'home-step-items'}
  36. style={{
  37. gridTemplateColumns: `repeat(${props.data ? props.data.length : 1}, 1fr)`,
  38. minHeight: props.style?.height,
  39. gridColumnGap: props?.style?.gridColumnGap,
  40. }}
  41. >
  42. {props.data &&
  43. props.data.map((item) => <StepsItem {...item} after={props.style ? true : false} />)}
  44. </div>
  45. </div>
  46. );
  47. };
  48. export default Steps;