Carousel.jsx 1.4 KB

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