Skip to content

Commit

Permalink
Reverse page number labels
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed Jan 20, 2024
1 parent ac2b552 commit 60579b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/ssr-carousel-dots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.ssr-carousel-dots
button.ssr-carousel-dot-button(
v-for='i in pages' :key='i'
:aria-label='`Go to ${pageLabel} ${i}`'
:aria-label='makeLabel(i)'
:aria-disabled='isDisabled(i)'
@click='$emit("goto", i - 1)')

Expand All @@ -29,9 +29,15 @@ export default
boundedIndex: Number
pages: Number
pageLabel: String
rtl: Boolean

methods:

# Make the label for the dot
makeLabel: (index) ->
pageNumber = if @rtl then @pages - index + 1 else @index
"Go to #{@pageLabel} #{pageNumber}"

# Check if dot index shuold be disabled
isDisabled: (index) -> @boundedIndex == index - 1

Expand Down
2 changes: 1 addition & 1 deletion src/ssr-carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
//- Dots navigation
ssr-carousel-dots(
v-if='showDots'
v-bind='{ boundedIndex, pages, pageLabel }'
v-bind='{ boundedIndex, pages, pageLabel, rtl }'
@goto='gotoDot')
template(#dot='props'): slot(name='dot' v-bind='props')

Expand Down

0 comments on commit 60579b9

Please sign in to comment.