Use a component for carousel dots

- Show 5 dots by default
- First and last one from current index are smaller
- Other ones are hidden
This commit is contained in:
2020-03-25 12:19:48 +01:00
parent 093c87d156
commit 498f3c0c17
3 changed files with 48 additions and 11 deletions

View File

@@ -12,6 +12,7 @@
// Components
import IconArrow from '../atoms/IconArrow'
import Counter from '../atoms/Counter'
import PaginationDots from '../molecules/PaginationDots'
// Props
export let photos
@@ -45,7 +46,6 @@
currentIndex = (currentIndex >= photos.length) ? 0 : currentIndex
} else {
currentIndex = direction
console.log('Go to photo', direction, currentIndex)
}
// Send current photo to event
@@ -203,12 +203,8 @@
</div>
</div>
<ol class="carousel__dots">
{#each photos as page, index}
<li class:active={page === currentPhoto} on:click={() => goToPhoto(index)}>
<button aria-label="Go to photo #{index + 1}"></button>
</li>
{/each}
</ol>
<PaginationDots {photos} {currentIndex}
on:goToIndex={event => currentIndex = event.detail.index}
/>
</div>
{/if}