Skip to content

Commit

Permalink
fix: both arrows visible and fixed links (#1693)
Browse files Browse the repository at this point in the history
  • Loading branch information
justyna-13 authored Feb 15, 2021
1 parent 07581e0 commit d4f3447
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
34 changes: 21 additions & 13 deletions packages/vue/src/components/molecules/SfPagination/SfPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<div v-if="hasArrows" class="sf-pagination__item prev">
<component
:is="componentIs"
v-if="canGoPrev"
:class="{
'sf-button--pure': !hasRouter,
'sf-arrow--transparent': !hasRouter && !canGoPrev,
}"
:link="hasRouter ? getLinkTo(getPrev) : null"
:disabled="!hasRouter && !canGoPrev ? true : false"
aria-label="Go to previous page"
@click="hasRouter ? null : go(getPrev)"
>
Expand Down Expand Up @@ -75,11 +76,12 @@
<div v-if="hasArrows" class="sf-pagination__item next">
<component
:is="componentIs"
v-if="canGoNext"
:class="{
'sf-button--pure': !hasRouter,
'sf-arrow--transparent': !hasRouter && !canGoNext,
}"
:link="hasRouter ? getLinkTo(getNext) : null"
:disabled="!hasRouter && !canGoNext ? true : false"
aria-label="Go to previous next"
@click="hasRouter ? null : go(getNext)"
>
Expand Down Expand Up @@ -152,16 +154,20 @@ export default {
: this.current;
},
getPrev() {
return this.currentPage - 1;
return this.currentPage === this.firstVisiblePageNumber
? this.currentPage
: this.currentPage - 1;
},
canGoPrev() {
return this.getPrev > 0;
return this.currentPage !== this.firstVisiblePageNumber;
},
getNext() {
return this.currentPage + 1;
return this.currentPage === this.lastVisiblePageNumber
? this.currentPage
: this.currentPage + 1;
},
canGoNext() {
return this.getNext <= this.total;
return this.currentPage !== this.lastVisiblePageNumber;
},
showFirst() {
return this.firstVisiblePageNumber > 1;
Expand Down Expand Up @@ -202,13 +208,15 @@ export default {
this.$emit("click", page);
},
getLinkTo(page) {
const route = {
name: this.$route.name,
params: this.$route.params,
query: { ...this.$route.query, page: page.toString() },
};
const linkToPage = this.$router.resolve(route).href;
return linkToPage.slice(1);
const pageNumber = page.toString();
if (this.hasRouter) {
return {
...this.$route,
query: { ...this.$route.query, [this.pageParamName]: page },
};
} else {
return pageNumber;
}
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from "@storybook/addon-docs/blocks";

<Meta title="Releases/v0.10.2 - Latest/Change log" />
<Meta title="Releases/v0.10.2/Change log" />

# v0.10.2

Expand Down
5 changes: 3 additions & 2 deletions packages/vue/src/stories/releases/v0.10.3/v0.10.3.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import { Meta } from "@storybook/addon-docs/blocks";
## 🐛 Fixes


- SfSearchBar: add a possibility to pass listeners
- SfHero - add the condition to initialize glide.js when there is more than one item
- SfPagination: both arrows visible and fixed returned link to page,
- SfSearchBar: add a possibility to pass listeners,
- SfHero - add the condition to initialize glide.js when there is more than one item.

0 comments on commit d4f3447

Please sign in to comment.