0.3.5 • Published 5 days ago

@igloo-ui/carousel v0.3.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 days ago

Carousel

A carousel allows users to see and navigate the steps within a flow.

Installation

To install @igloo-ui/carousel in your project, you will need to run the following command using npm:

npm install @igloo-ui/carousel

If you prefer Yarn, use the following command instead:

yarn add @igloo-ui/carousel

Usage

Then to use the component in your code just import it!

import Button from '@igloo-ui/button';
import Carousel from '@igloo-ui/carousel';

const SLIDE_NUM = 3;
const [selected, setSelected] = React.useState(0);

const handlePageChange = (index) => {
  setSelected(index);
};

const handlePrimaryActionClick = () => {
  if (selected < SLIDE_NUM - 1) {
    handlePageChange(selected + 1);
  }
};

const handleSecondaryActionClick = () => {
  if (selected > 0) {
    handlePageChange(selected - 1);
  }
};

<Carousel
  onPageChange={handlePageChange}
  currentSlide={selected}
  primaryAction={
    <Button appearance={'primary'} onClick={handlePrimaryActionClick}>
      {selected < SLIDE_NUM - 1 ? 'Next' : 'Done'}
    </Button>
  }
  secondaryAction={
    <Button appearance={'secondary'} onClick={handleSecondaryActionClick}>
      {selected > 0 ? 'Prev' : 'Cancel'}
    </Button>
  }
>
  <div style={{ background: 'pink', padding: '4rem' }}>Slide 1</div>
  <div style={{ background: 'lightBlue', padding: '4rem' }}>Slide 2</div>
  <div style={{ background: 'lightGreen', padding: '4rem' }}>Slide 3</div>
</Carousel>;
0.3.5

5 days ago

0.3.4

20 days ago

0.3.3

1 month ago

0.3.2

3 months ago

0.3.1

4 months ago

0.3.0

4 months ago

0.2.4

4 months ago

0.2.3

5 months ago

0.2.2

5 months ago

0.2.1

6 months ago

0.2.0

8 months ago

0.1.3

10 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.0

1 year ago