Carousel.jsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Carousel } from 'antd'
  2. import { LeftCircleFilled, RightCircleFilled } from '@ant-design/icons'
  3. import defaultPhoto from '../../materials/default-photo.png'
  4. const SampleNextArrow = (props) => {
  5. const { onClick } = props
  6. return (
  7. <div className="NextArrow" onClick={onClick}>
  8. <RightCircleFilled />
  9. </div>
  10. )
  11. }
  12. const SamplePrevArrow = (props) => {
  13. const { onClick } = props
  14. return (
  15. <div className="PreviousArrow" onClick={onClick}>
  16. <LeftCircleFilled />
  17. </div>
  18. )
  19. }
  20. export const MyCarousel = ({ images = [] }) => {
  21. return (
  22. <>
  23. <div className="MyCarousel">
  24. <Carousel
  25. effect="fade"
  26. arrows
  27. nextArrow={<SampleNextArrow />}
  28. prevArrow={<SamplePrevArrow />}
  29. >
  30. {images ? (
  31. images?.map(
  32. (i, index) =>
  33. i?.url && (
  34. <div key={index}>
  35. <img key={index} className="PostImage" src={'/' + i?.url} />
  36. </div>
  37. ),
  38. )
  39. ) : (
  40. <div>
  41. <img className="PostImage" src={defaultPhoto} />
  42. </div>
  43. )}
  44. </Carousel>
  45. </div>
  46. </>
  47. )
  48. }