diff --git a/docs/svelte-carousel-logo-md.png b/docs/svelte-carousel-logo-md.png new file mode 100644 index 0000000..042ccdc Binary files /dev/null and b/docs/svelte-carousel-logo-md.png differ diff --git a/src/docs/Carousel.svx b/src/docs/Carousel.svx index 09fb9d3..827f4f3 100644 --- a/src/docs/Carousel.svx +++ b/src/docs/Carousel.svx @@ -3,6 +3,7 @@ import Carousel from '../components/Carousel/Carousel.svelte' import Color from './Color.svelte' import AlbumsPreview from './AlbumsPreview/AlbumsPreview.svelte' + import Divider from './Divider.svelte' const colors = [ { color: '#85d78b', text: '#85d78b' }, @@ -15,8 +16,18 @@ { color: '#25842b', text: '#25842b' }, { color: '#1f7125', text: '#1f7125' }, ] + + const images = [ + 'https://cdn.pixabay.com/photo/2017/03/13/10/25/hummingbird-2139278_1280.jpg', + 'https://cdn.pixabay.com/photo/2016/03/27/19/49/nature-1283976_1280.jpg', + 'https://cdn.pixabay.com/photo/2018/07/09/18/17/apple-3526737_1280.jpg', + 'https://cdn.pixabay.com/photo/2016/08/30/16/05/leaf-1631181_1280.jpg', + 'https://cdn.pixabay.com/photo/2019/11/13/11/01/meadow-4623279_1280.jpg' + ] +# Features + ## Single item {#each colors as { color, text } (color)} @@ -32,6 +43,8 @@ ``` + + ## Multiple items {#each _.chunk(colors, 3) as colorsChunk, chunkIndex (chunkIndex)} @@ -55,6 +68,185 @@ ``` -## Albums preview or Marketplace item pictures + +## Autoplay + + {#each colors as { color, text } (color)} + + {/each} + + +```jsx + + {#each colors as { color, text } (color)} + + {/each} + +``` + + + +## Lazy loading + + {#each images as src, imageIndex (src)} +
+ {#if loaded.includes(imageIndex)} + + {/if} +
+ {/each} +
+ +```jsx + + {#each images as src, imageIndex (src)} +
+ {#if loaded.includes(imageIndex)} + + {/if} +
+ {/each} +
+``` + + + +## Use case + +# Installation +```bash +yarn add svelte-carousel +npm install svelte-carousel +``` + +Import css in App component +```jsx + +``` + +# Props +| Prop | Type | Default | Description | +|----------------------|------------|-------------|-----------------------------------------------| +| arrows | boolean | true | Enable Next/Prev arrows | +| infinite | boolean | true | Infinite looping | +| initialPageIndex | number | 0 | Page to start on | +| speed | number | 500 | Transition speed (ms) | +| autoplay | boolean | false | Enables auto play of pages | +| autoplaySpeed | number | 3000 | Auto play change interval | +| autoplayDirection | string | 3000 | Auto play change direction (`next` or `prev`) | +| dots | boolean | true | Current page indicator dots | + +# Slots + +## `prev` and `next` +They are used for customizing prev and next buttons. + +Slot props: + +| Prop | Type | Description | +|--------------------|-------------|---------------------------------------| +| `showPrevPage` | `function` | Call it to switch to the previos page | +| `showNextPage` | `function` | Call it to switch to the next page | + +```jsx + +
+ +
+
+ +
+ +
+``` + +## `dots` + +This slot is used for customizing dots appearance. + +Slot props: + +| Prop | Type | Description | +|---------------------|---------- --|---------------------------------------------| +| `currentPageIndex` | `number` | Represents current page index (start from 0) | +| `pagesCount` | `number` | Total pages amount | +| `showPage` | `function` | Takes index as page to be shown | + +```jsx + +
+ +
+ +
+``` + +## Default slot + +This slot takes content for the carousel. + +Slot props: + +| Prop | Type | Description | +|-------------------|------------|----------------------------------------------------------------------| +| `loaded` | `number[]` | Contains indexes of pages to be loaded. Can be used for lazy loading | + +```jsx + +
+ +
+ +
+``` + + + + \ No newline at end of file diff --git a/src/docs/Color.svelte b/src/docs/Color.svelte index 36dda72..029ec7b 100644 --- a/src/docs/Color.svelte +++ b/src/docs/Color.svelte @@ -11,7 +11,7 @@ \ No newline at end of file diff --git a/src/docs/Layouts/Main.svelte b/src/docs/Layouts/Main.svelte index d31b03e..552e5e1 100644 --- a/src/docs/Layouts/Main.svelte +++ b/src/docs/Layouts/Main.svelte @@ -1,9 +1,25 @@ + +
-
-
- +
+ +
+
+ +