Carousel.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { Carousel } from 'antd'
  2. import { LeftCircleFilled, RightCircleFilled } from '@ant-design/icons'
  3. import photoNotFound from '../materials/photoNotFound.png'
  4. const SampleNextArrow = (props) => {
  5. const { onClick } = props
  6. return (
  7. <div className='NextArrow'
  8. onClick={onClick}
  9. >
  10. <RightCircleFilled />
  11. </div>
  12. )
  13. }
  14. const SamplePrevArrow = (props) => {
  15. const { onClick } = props
  16. return (
  17. <div
  18. style={{
  19. color: '#41607d',
  20. fontSize: '50px',
  21. position: 'absolute',
  22. margin: 'auto',
  23. right: '100%',
  24. top: '50%',
  25. paddingRight: '20px',
  26. }}
  27. onClick={onClick}
  28. >
  29. <LeftCircleFilled />
  30. </div>
  31. )
  32. }
  33. export const MyCarousel = ({ images = [] }) => {
  34. return (
  35. <>
  36. <div className="MyCarousel">
  37. <Carousel
  38. effect="fade"
  39. arrows
  40. nextArrow={<SampleNextArrow />}
  41. prevArrow={<SamplePrevArrow />}
  42. >
  43. {images ? (
  44. images?.map(
  45. (i, index) =>
  46. i?.url && (
  47. <div key={index}>
  48. <img key={index} className="PostImage" src={'/' + i?.url} />
  49. </div>
  50. ),
  51. )
  52. ) : (
  53. <div >
  54. <img className="PostImage" src={photoNotFound} />
  55. </div>
  56. )}
  57. </Carousel>
  58. </div>
  59. </>
  60. )
  61. }