Skip to content

Commit

Permalink
feat(render): Add slots to allow custom navigation and pagination (SS…
Browse files Browse the repository at this point in the history
…ENSE#293)

Allow custom components to be used for rendering pagination and navigation, with access to the `carousel` provider.
  • Loading branch information
adam-26 authored and quinnlangille committed Oct 19, 2018
1 parent fa2369e commit e9e5714
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
24 changes: 24 additions & 0 deletions docs/source/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,27 @@ Stage padding option adds left and right padding style (in pixels) onto VueCarou
* **Type**: `Number`
* **Default**: `0`

## Custom Pagination & Navigation

Use named slots to render pagination and navigation using components.

``` html
<carousel>
<slide>
Slide 1 Content
</slide>
<slide>
Slide 2 Content
</slide>

<numbered-pagination slot="pagination" />
<stylish-navigation slot="navigation" />
</carousel>
```

Your components can access the `carousel` provider by adding the following to you component configuration:

```js
name: "numbered-pagination",
inject: ["carousel"]
```
25 changes: 13 additions & 12 deletions src/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@
</div>
</div>

<pagination
v-if="paginationEnabled"
@paginationclick="goToPage($event, 'pagination')"
/>

<navigation
v-if="navigationEnabled && isNavigationRequired"
:clickTargetSize="navigationClickTargetSize"
:nextLabel="navigationNextLabel"
:prevLabel="navigationPrevLabel"
@navigationclick="handleNavigation"
/>
<slot name="pagination" v-if="paginationEnabled">
<pagination @paginationclick="goToPage($event, 'pagination')"/>
</slot>

<slot name="navigation" v-if="navigationEnabled">
<navigation
v-if="isNavigationRequired"
:clickTargetSize="navigationClickTargetSize"
:nextLabel="navigationNextLabel"
:prevLabel="navigationPrevLabel"
@navigationclick="handleNavigation"
/>
</slot>
</section>
</template>
<script>
Expand Down

0 comments on commit e9e5714

Please sign in to comment.