Carousel.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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
  8. style={{
  9. fontSize: '50px',
  10. color: '#41607d',
  11. position: 'absolute',
  12. left: '100%',
  13. top: '50%',
  14. margin: 'auto',
  15. paddingLeft: '20px',
  16. textShadow: 'black 1px 0 10px',
  17. }}
  18. onClick={onClick}
  19. >
  20. <RightCircleFilled />
  21. </div>
  22. )
  23. }
  24. const SamplePrevArrow = (props) => {
  25. const { onClick } = props
  26. return (
  27. <div
  28. style={{
  29. color: '#41607d',
  30. fontSize: '50px',
  31. position: 'absolute',
  32. margin: 'auto',
  33. right: '100%',
  34. top: '50%',
  35. paddingRight: '20px',
  36. }}
  37. onClick={onClick}
  38. >
  39. <LeftCircleFilled />
  40. </div>
  41. )
  42. }
  43. export const MyCarousel = ({ images = [] }) => {
  44. return (
  45. <>
  46. <div className="MyCarousel">
  47. <Carousel
  48. effect="fade"
  49. arrows
  50. nextArrow={<SampleNextArrow />}
  51. prevArrow={<SamplePrevArrow />}
  52. >
  53. {images ? (
  54. images?.map(
  55. (i, index) =>
  56. i?.url && (
  57. <div key={index}>
  58. <img key={index} className="PostImage" src={'/' + i?.url} />
  59. </div>
  60. ),
  61. )
  62. ) : (
  63. <div >
  64. <img className="PostImage" src={photoNotFound} />
  65. </div>
  66. )}
  67. </Carousel>
  68. </div>
  69. </>
  70. )
  71. }