@fortawesome/free-solid-svg-icons#faSlidersH JavaScript Examples

The following examples show how to use @fortawesome/free-solid-svg-icons#faSlidersH. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From Webiu with MIT License 5 votes vote down vote up
Carousel = ({data, header}) =>  {

	const [currentImageIndex, setCurrentImageIndex] = useState(0);

	const previousSlide = () => {
		const lastIndex = data.length - 1;
		const shouldResetIndex = currentImageIndex === 0;
		const index =  shouldResetIndex ? lastIndex : currentImageIndex - 1;

		setCurrentImageIndex(index);
	}

	const nextSlide = () => {
		const lastIndex = data.length - 1;
		const shouldResetIndex = currentImageIndex === lastIndex;
		const index =  shouldResetIndex ? 0 : currentImageIndex + 1;

		setCurrentImageIndex(index);
	}

    const ImageSlide = ({ url }) => {
        return (
          <div className="image-slide">
            <div className="slider-image-div">
              <img className="slider-image" src={url.image} alt="slider-logo" />
            </div>
            <div className="slider-title">
              <h4>{url.title}</h4><hr />
            </div>           
            <div className="slider-content">
              <p>{url.content}</p>
            </div>
          </div>
        );
    }

    return (
        <div>
        {header ? <div className="header-component">
            <h2><FontAwesomeIcon className="icon-h2" icon={faSlidersH} /> {header}</h2>
        </div> : null}
        <Container>
            {data ? <div className="carousel">
                <FontAwesomeIcon className="icon icon-left" icon={faArrowLeft} onClick={previousSlide} />
                <ImageSlide url={ data[currentImageIndex] } />
                <FontAwesomeIcon className="icon icon-right" icon={faArrowRight} onClick={nextSlide} />
            </div> : null}
        </Container>
        </div>
    );
}