|
| 1 | +import React, { useRef } from 'react'; |
| 2 | +import Carousel from 'react-gallery-carousel'; |
| 3 | +import 'react-gallery-carousel/dist/index.css'; |
| 4 | +import { Button } from 'react-responsive-button'; |
| 5 | + |
| 6 | +const Carousel8 = ({ images }) => { |
| 7 | + const carouselRef = useRef(null); |
| 8 | + |
| 9 | + return ( |
| 10 | + <section className='section' aria-labelledby='example8'> |
| 11 | + <header className='section-header'> |
| 12 | + <h2 id='example8'> |
| 13 | + Example 8: Default carousel with custom elements{' '} |
| 14 | + <small>(available from v0.4.0)</small>{' '} |
| 15 | + <a href='https://yifanai.com/rgc8'>code</a> |
| 16 | + </h2> |
| 17 | + <p> |
| 18 | + To use custom elements, set the widget props (e.g.{' '} |
| 19 | + <code>hasLeftButton</code>, <code>hasRightButton</code>) to{' '} |
| 20 | + <code>false</code>, then pass the custom elements to the{' '} |
| 21 | + <code>elements</code> prop. |
| 22 | + </p> |
| 23 | + </header> |
| 24 | + <div className='carousel-container'> |
| 25 | + <Carousel |
| 26 | + ref={carouselRef} |
| 27 | + images={images} |
| 28 | + isMaximized={false} |
| 29 | + hasSizeButton={false} |
| 30 | + hasMediaButton={false} |
| 31 | + hasIndexBoard={false} |
| 32 | + hasLeftButton={false} |
| 33 | + hasRightButton={false} |
| 34 | + elements={ |
| 35 | + <> |
| 36 | + <Button |
| 37 | + style={{ |
| 38 | + position: 'absolute', |
| 39 | + top: '50%', |
| 40 | + left: 0, |
| 41 | + transform: 'translateY(-50%)', |
| 42 | + borderRadius: 0 |
| 43 | + }} |
| 44 | + aria-label='Go to the slide on the left' |
| 45 | + onClick={() => carouselRef.current.goLeft()} |
| 46 | + > |
| 47 | + <span |
| 48 | + className='icon-text' |
| 49 | + role='img' |
| 50 | + aria-label='left' |
| 51 | + style={{ |
| 52 | + fontSize: 'min(50px, 5vw)' |
| 53 | + }} |
| 54 | + > |
| 55 | + ⬅️ |
| 56 | + </span> |
| 57 | + </Button> |
| 58 | + <Button |
| 59 | + style={{ |
| 60 | + position: 'absolute', |
| 61 | + top: '50%', |
| 62 | + right: 0, |
| 63 | + transform: 'translateY(-50%)', |
| 64 | + borderRadius: 0 |
| 65 | + }} |
| 66 | + aria-label='Go to the slide on the right' |
| 67 | + onClick={() => carouselRef.current.goRight()} |
| 68 | + > |
| 69 | + <span |
| 70 | + className='icon-text' |
| 71 | + role='img' |
| 72 | + aria-label='right' |
| 73 | + style={{ |
| 74 | + fontSize: 'min(50px, 5vw)' |
| 75 | + }} |
| 76 | + > |
| 77 | + ➡️ |
| 78 | + </span> |
| 79 | + </Button> |
| 80 | + </> |
| 81 | + } |
| 82 | + /> |
| 83 | + </div> |
| 84 | + </section> |
| 85 | + ); |
| 86 | +}; |
| 87 | + |
| 88 | +export default Carousel8; |
0 commit comments