@erst-vg/vg-design-wrapper 1.0.5 → 1.0.7

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.
@@ -0,0 +1,207 @@
1
+ <template>
2
+ <nav class="pagination" :aria-label="$t('erhvervsfremme.content.application.pagination.label')">
3
+ <div v-if="isMobile" class="mobile d-flex" data-testid="mobile-container">
4
+ <button
5
+ id="firstButton"
6
+ class="button button-arrow button-first"
7
+ :class="{ hidden: currentPage === 1 }"
8
+ type="button"
9
+ :aria-label="$t('erhvervsfremme.content.application.pagination.first.button.aria_label')"
10
+ @click="toPage(1)"
11
+ >
12
+ <VgIcon icon="paginationFirstPage" focusable="false" aria-hidden="true" />
13
+ </button>
14
+ <button
15
+ id="prevButton"
16
+ class="button button-arrow button-previous"
17
+ :class="{ hidden: currentPage === 1 }"
18
+ type="button"
19
+ :aria-label="$t('erhvervsfremme.content.application.pagination.previous.button.aria_label')"
20
+ @click="prevPage"
21
+ >
22
+ <VgIcon icon="paginationChevronLeft" focusable="false" aria-hidden="true" />
23
+ </button>
24
+ <span class="pagination-mobile">{{ paginationMobile }}</span>
25
+ <button
26
+ id="nextButton"
27
+ class="button button-arrow button-next"
28
+ :class="{ hidden: currentPage === pageCount }"
29
+ type="button"
30
+ :aria-label="$t('erhvervsfremme.content.application.pagination.next.button.aria_label')"
31
+ @click="nextPage"
32
+ >
33
+ <VgIcon icon="paginationChevronRight" focusable="false" aria-hidden="true" />
34
+ </button>
35
+ <button
36
+ id="lastButton"
37
+ class="button button-arrow button-last"
38
+ :class="{ hidden: currentPage === pageCount }"
39
+ type="button"
40
+ :aria-label="$t('erhvervsfremme.content.application.pagination.last.button.aria_label')"
41
+ @click="toPage(pageCount)"
42
+ >
43
+ <VgIcon icon="paginationLastPage" focusable="false" aria-hidden="true" />
44
+ </button>
45
+ </div>
46
+ <template v-else>
47
+ <!-- PREVIOUS BUTTON -->
48
+ <button
49
+ id="prevButton"
50
+ class="button button-link mr-4"
51
+ type="button"
52
+ :class="{ hidden: currentPage === 1 }"
53
+ :aria-label="$t('erhvervsfremme.content.application.pagination.backwards.button')"
54
+ data-testid="button-forrige"
55
+ @click="prevPage"
56
+ >
57
+ <VgIcon icon="paginationChevronLeft" focusable="false" aria-hidden="true" />
58
+ {{ $t('erhvervsfremme.content.application.pagination.backwards.button') }}
59
+ </button>
60
+ <!-- BEFORE DOTS -->
61
+ <template v-if="currentPage > 4">
62
+ <button
63
+ v-if="pageCount > 5"
64
+ :id="`toPage-${1}`"
65
+ class="button button-pagination"
66
+ type="button"
67
+ :aria-label="$t('erhvervsfremme.content.application.pagination.goto') + 1"
68
+ @click="toPage(1)"
69
+ >
70
+ 1
71
+ </button>
72
+ <div v-if="pageCount > 6" class="dots">...</div>
73
+ </template>
74
+ <!-- BETWEEN DOTS -->
75
+ <button
76
+ v-for="pageNum in previousPages"
77
+ :id="`toPage-${pageNum}`"
78
+ :key="pageNum"
79
+ class="button button-pagination"
80
+ type="button"
81
+ :aria-label="$t('erhvervsfremme.content.application.pagination.goto') + pageNum"
82
+ @click="toPage(pageNum)"
83
+ >
84
+ {{ pageNum }}
85
+ </button>
86
+ <button
87
+ :id="`toPage-${currentPage}`"
88
+ class="button button-pagination button-active"
89
+ type="button"
90
+ :aria-label="$t('erhvervsfremme.content.application.pagination.currentpage') + currentPage"
91
+ >
92
+ {{ currentPage }}
93
+ </button>
94
+ <button
95
+ v-for="pageNum in upcomingPages"
96
+ :id="`toPage-${pageNum}`"
97
+ :key="pageNum"
98
+ class="button button-pagination"
99
+ type="button"
100
+ data-testid="button-step"
101
+ :aria-label="$t('erhvervsfremme.content.application.pagination.goto') + pageNum"
102
+ @click="toPage(pageNum)"
103
+ >
104
+ {{ pageNum }}
105
+ </button>
106
+ <!-- AFTER DOTS -->
107
+ <template v-if="pageCount - currentPage > 3">
108
+ <div v-if="pageCount > 6" class="dots">...</div>
109
+ <button
110
+ v-if="pageCount > 5"
111
+ :id="`toPage-${pageCount}`"
112
+ class="button button-pagination"
113
+ type="button"
114
+ :aria-label="$t('erhvervsfremme.content.application.pagination.goto') + pageCount"
115
+ @click="toPage(pageCount)"
116
+ >
117
+ {{ pageCount }}
118
+ </button>
119
+ </template>
120
+ <button
121
+ id="nextButton"
122
+ class="button button-link ml-0"
123
+ type="button"
124
+ :class="{ hidden: currentPage === pageCount }"
125
+ data-testid="button-naeste"
126
+ @click="nextPage"
127
+ >
128
+ {{ $t('erhvervsfremme.content.application.pagination.forwards.button') }}
129
+ <VgIcon icon="paginationChevronRight" focusable="false" aria-hidden="true" />
130
+ </button>
131
+ </template>
132
+ </nav>
133
+ </template>
134
+
135
+ <script setup lang="ts">
136
+ import VgIcon from '@/components/VgIcon.vue';
137
+ import { ParamType } from '@/utils/tekstnoegle-util';
138
+ import range from 'lodash/range';
139
+ import { computed, inject, onUnmounted, ref } from 'vue';
140
+
141
+ const $t: (tekstnoegle: string, params?: ParamType) => string = inject('$t')!;
142
+
143
+ const emits = defineEmits(['toPage']);
144
+ const props = defineProps({
145
+ currentPage: {
146
+ type: Number,
147
+ required: true
148
+ },
149
+ pageCount: {
150
+ type: Number,
151
+ required: true
152
+ }
153
+ });
154
+
155
+ const paginationMobile = computed(() => $t('erhvervsfremme.content.application.pagination.mobile', [props.currentPage, props.pageCount]));
156
+
157
+ const isMobile = computed(() => width.value < 768);
158
+
159
+ const pagesAroundCurrent = computed((): number[] => {
160
+ let first;
161
+ if (props.currentPage < 5) {
162
+ first = 1;
163
+ } else if (props.pageCount - props.currentPage < 3) {
164
+ first = props.pageCount - 4;
165
+ } else {
166
+ first = props.currentPage - 1;
167
+ }
168
+ let last;
169
+ if (props.pageCount - props.currentPage < 4) {
170
+ last = props.pageCount;
171
+ } else if (props.currentPage < 5) {
172
+ last = 5;
173
+ } else {
174
+ last = props.currentPage + 1;
175
+ }
176
+ return range(first, last + 1);
177
+ });
178
+
179
+ const previousPages = computed(() => pagesAroundCurrent.value.filter(num => num < props.currentPage));
180
+ const upcomingPages = computed(() => pagesAroundCurrent.value.filter(num => num > props.currentPage));
181
+
182
+ const prevPage = (): void => {
183
+ if (props.currentPage > 1) {
184
+ toPage(props.currentPage - 1);
185
+ }
186
+ };
187
+ const nextPage = (): void => {
188
+ if (props.currentPage < props.pageCount) {
189
+ toPage(props.currentPage + 1);
190
+ }
191
+ };
192
+ const toPage = (num: number): void => {
193
+ emits('toPage', num);
194
+ };
195
+
196
+ const width = ref(window.innerWidth);
197
+
198
+ const handleResize = (): void => {
199
+ width.value = window.innerWidth;
200
+ };
201
+
202
+ window.addEventListener('resize', handleResize);
203
+
204
+ onUnmounted(() => {
205
+ window.removeEventListener('resize', handleResize);
206
+ });
207
+ </script>
@@ -32,6 +32,12 @@
32
32
  word-break: break-word;
33
33
  }
34
34
  }
35
+
36
+ // Skal overskrive regel fra Designsystemet
37
+ + button {
38
+ margin-top: 0;
39
+ margin-left: 8px;
40
+ }
35
41
  }
36
42
 
37
43
  .button-primary {
@@ -137,7 +137,7 @@ $grid-breakpoints: (
137
137
 
138
138
  // Breakpoints specificeret til zoom og kigger derfor på em
139
139
  // Bruges særlig til mindre skærme, så koden kan opfylde tilgængelighedskrav
140
- $zoom-sm: 25em;
140
+ $zoom-sm: 20em;
141
141
  $zoom-xs: 15em;
142
142
  $zoom-breakpoints: (
143
143
  xs: $zoom-xs,