@rypen-dev/shared-components 5.2.6 → 5.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rypen-dev/shared-components",
3
3
  "description": "Shared styles and Vuejs ui components for Rypen projects.",
4
- "version": "5.2.6",
4
+ "version": "5.2.8",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
7
  "build": "webpack --config ./webpack.config.js",
@@ -146,6 +146,11 @@ $enterprise-color: $quaternary !default;
146
146
 
147
147
  $secondary-pill-color: $secondary !default;
148
148
 
149
+ $pagination-text-color: $primary !default;
150
+ $pagination-current-color: $tertiary !default;
151
+ $pagination-hover-color: $middle-gray !default;
152
+ $pagination-disabled-color: $text-gray !default;
153
+
149
154
  // Images
150
155
  $hero-image-url: "/studio/assets/images/hero.jpg" !default;
151
156
 
@@ -1558,6 +1558,7 @@ body.hover-capable {
1558
1558
 
1559
1559
  .input-container.with-decoy {
1560
1560
  position: relative;
1561
+ padding-top: 0;
1561
1562
  margin: 0 20px 29px 0;
1562
1563
 
1563
1564
  input {
@@ -7,4 +7,153 @@ nav > ul {
7
7
  margin: 0;
8
8
  padding: 0;
9
9
  display: flex;
10
+ }
11
+
12
+ // roll our own pagination based on foundation
13
+ .pagination {
14
+ margin-bottom: 1rem;
15
+
16
+ li {
17
+ margin-right: 2px;
18
+ font-size: 0.875rem;
19
+ display: inline-block;
20
+ color: $pagination-text-color;
21
+
22
+ &.pagination-previous {
23
+ a,
24
+ span {
25
+ span::before {
26
+ content: '\AB';
27
+ display: inline-block;
28
+ margin-right: 6px;
29
+ }
30
+ }
31
+ }
32
+
33
+ &.pagination-next {
34
+ a,
35
+ span {
36
+ span::after {
37
+ content: '\BB';
38
+ display: inline-block;
39
+ margin-left: 6px;
40
+ }
41
+ }
42
+ }
43
+
44
+ &.ellipsis::after {
45
+ display: block;
46
+ content: '\2026';
47
+ padding: 3px 10px;
48
+ }
49
+
50
+ &.current {
51
+ background-color: $pagination-current-color;
52
+ padding: 3px 10px;
53
+
54
+ span,
55
+ a {
56
+ color: $white;
57
+ padding: 0;
58
+ }
59
+ }
60
+
61
+ &.disabled {
62
+ color: $pagination-disabled-color;
63
+
64
+ span {
65
+ color: $pagination-disabled-color;
66
+ }
67
+ }
68
+ }
69
+
70
+ span,
71
+ a {
72
+ display: block;
73
+ padding: 3px 10px;
74
+ color: $pagination-text-color;
75
+
76
+ &.disabled {
77
+ color: $pagination-disabled-color;
78
+ }
79
+
80
+ span {
81
+ display: inline-block;
82
+ padding: 0;
83
+ }
84
+ }
85
+
86
+ a:hover {
87
+ background-color: $pagination-hover-color;
88
+ }
89
+
90
+ @media (max-width: map-get($breakpoints, medium) - 1px) {
91
+ li {
92
+ &:first-child {
93
+ padding-left: 0 !important;
94
+
95
+ a,
96
+ span {
97
+ padding-left: 0 !important;
98
+ }
99
+ }
100
+
101
+ &:last-child {
102
+ padding-right: 0 !important;
103
+
104
+ a,
105
+ span {
106
+ padding-right: 0 !important;
107
+ }
108
+ }
109
+
110
+ &.pagination-previous,
111
+ &.pagination-next {
112
+ > a,
113
+ > span {
114
+ span {
115
+ display: none;
116
+ }
117
+ }
118
+ }
119
+
120
+ &.pagination-previous {
121
+ > a,
122
+ > span {
123
+ &::before {
124
+ content: '\AB';
125
+ display: inline-block;
126
+ margin-right: 6px;
127
+ }
128
+ }
129
+ }
130
+
131
+ &.pagination-next {
132
+ > a,
133
+ > span {
134
+ &::after {
135
+ content: '\BB';
136
+ display: inline-block;
137
+ margin-left: 6px;
138
+ }
139
+ }
140
+ }
141
+
142
+ &.ellipsis::after {
143
+ padding-left: 8px;
144
+ padding-right: 8px;
145
+ }
146
+
147
+ &.current {
148
+ padding-left: 8px;
149
+ padding-right: 8px;
150
+ }
151
+
152
+ span,
153
+ a {
154
+ padding-left: 8px;
155
+ padding-right: 8px;
156
+ }
157
+ }
158
+ }
10
159
  }
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <nav>
3
+ <ul class="pagination">
4
+ <li class="pagination-previous" :class="{ disabled: !hasPreviousPage }">
5
+ <a v-if="hasPreviousPage" @click="navigateToPrev"><span>Previous</span></a>
6
+ <span v-else><span>Previous</span></span>
7
+ </li>
8
+ <template v-if="totalPages > 0">
9
+ <li v-for="page in initialPageset" :class="{ current: page === pageIndex }">
10
+ <span v-if="page === pageIndex">{{ page + 1 }}</span>
11
+ <a v-else @click="navigateToPage(page)">{{ page + 1 }}</a>
12
+ </li>
13
+ <li v-if="showInitialEllipse" class="ellipsis"></li>
14
+ <li v-for="page in mainPageset" :class="{ current: page === pageIndex }">
15
+ <span v-if="page === pageIndex">{{ page + 1 }}</span>
16
+ <a v-else @click="navigateToPage(page)">{{ page + 1 }}</a>
17
+ </li>
18
+ <li v-if="showSubsequentEllipse" class="ellipsis"></li>
19
+ <li v-for="page in subsequentPageset" :class="{ current: page === pageIndex }">
20
+ <span v-if="page === pageIndex">{{ page + 1 }}</span>
21
+ <a v-else @click="navigateToPage(page)">{{ page + 1 }}</a>
22
+ </li>
23
+ </template>
24
+ <li v-else><span class="disabled">1</span></li>
25
+ <li class="pagination-next" :class="{ disabled: !hasNextPage }">
26
+ <a v-if="hasNextPage" @click="navigateToNext"><span>Next</span></a>
27
+ <span v-else><span>Next</span></span>
28
+ </li>
29
+ </ul>
30
+ </nav>
31
+ </template>
32
+
33
+ <script>
34
+ export default {
35
+ name: 'Pagination',
36
+ props: {
37
+ pageIndex: Number,
38
+ totalPages: Number,
39
+ maxVisiblePages: {
40
+ type: Number,
41
+ default: 7,
42
+ },
43
+ hasPreviousPage: {
44
+ type: Boolean,
45
+ default: false,
46
+ },
47
+ hasNextPage: {
48
+ type: Boolean,
49
+ default: false,
50
+ },
51
+ loading: {
52
+ type: Boolean,
53
+ default: false,
54
+ },
55
+ },
56
+ data: () => {
57
+ return {
58
+ initialPageset: [],
59
+ showInitialEllipse: false,
60
+ mainPageset: [],
61
+ subsequentPageset: [],
62
+ showSubsequentEllipse: false,
63
+ };
64
+ },
65
+ created: function () {
66
+
67
+ },
68
+ methods: {
69
+ navigateToNext() {
70
+ if (this.hasNextPage) {
71
+ this.navigateToPage(this.pageIndex + 1);
72
+ }
73
+ },
74
+ navigationToPrev() {
75
+ if (this.hasPreviousPage) {
76
+ this.navigateToPage(this.pageIndex - 1);
77
+ }
78
+ },
79
+ navigateToPage() {
80
+ if (idx !== this.pageIndex) {
81
+ this.$emit('navigate', idx);
82
+ this.$emit('top');
83
+ }
84
+ },
85
+
86
+ recalculateVisiblePages() {
87
+ this.initialPageset.splice(0);
88
+ this.showInitialEllipse = false;
89
+ this.mainPageset.splice(0);
90
+ this.showSubsequentEllipse = false;
91
+ this.subsequentPageset.splice(0);
92
+
93
+ if (this.totalPages > 0) {
94
+ if (this.totalPages > this.maxVisiblePages) {
95
+ let start = 0;
96
+ const middle = Math.floor(this.maxVisiblePages / 2);
97
+
98
+ if (this.pageIndex > (this.totalPages - middle - 1)) {
99
+ start = this.totalPages - this.maxVisiblePages;
100
+ } else if (this.pageIndex > middle) {
101
+ start = this.pageIndex - middle;
102
+ }
103
+
104
+ if (start > 0) {
105
+ this.initialPageset.push(0);
106
+ this.showInitialEllipse = true;
107
+ }
108
+
109
+ for (let i = start; i < (start + this.maxVisiblePages); i++) {
110
+ this.mainPageset.push(i);
111
+ }
112
+
113
+ if (start < this.totalPages - this.maxVisiblePages) {
114
+ this.showSubsequentEllipse = true;
115
+ this.subsequentPageset.push(this.totalPages - 1);
116
+ }
117
+ } else {
118
+ for (let i = 0; i < this.totalPages; i++) {
119
+ this.mainPageset.push(i);
120
+ }
121
+ }
122
+ }
123
+ },
124
+ },
125
+ watch: {
126
+ loading(value, prev) {
127
+ if (!value && prev) {
128
+ this.recalculateVisiblePages();
129
+ }
130
+ },
131
+ },
132
+ };
133
+ </script>