-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathSlideShow.vue
More file actions
276 lines (236 loc) 路 6.42 KB
/
Copy pathSlideShow.vue
File metadata and controls
276 lines (236 loc) 路 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!--
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div :class="$style.wrapper">
<!-- The "wave" background for the logo on the first page-->
<Transition
:enterClass="waveTransitionClasses.enter"
:enterActiveClass="waveTransitionClasses.active"
:leaveActiveClass="waveTransitionClasses.active"
:leaveToClass="waveTransitionClasses.leave">
<div v-if="isFirstPage" :class="$style.background_circle" />
</Transition>
<!-- Bar on the modal top -->
<div :class="$style.background_bar" />
<!-- Back button on mobile if not first page -->
<NcButton
v-if="!isFirstPage"
:aria-label="t('firstrunwizard', 'Go to previous page')"
:class="$style.button_back"
variant="tertiary-no-background"
@click="currentIndex -= 1">
<template #icon>
<NcIconSvgWrapper :path="mdiArrowLeft" />
</template>
</NcButton>
<!-- Custom close button to fix color contrast on first page -->
<NcButton
:aria-label="t('firstrunwizard', 'Close')"
:class="$style.button_close"
:variant="isFirstPage ? 'tertiary-on-primary' : 'tertiary-no-background'"
@click="$emit('close')">
<template #icon>
<NcIconSvgWrapper :path="mdiClose" />
</template>
</NcButton>
<!-- The first page has the logo within a "wave" style background -->
<div v-if="isFirstPage" :class="$style.logo" />
<!-- The page that is currently show wrapped in a slide transition -->
<Transition
mode="out-in"
:enterClass="transitionClasses.enter"
:enterActiveClass="transitionClasses.active"
:leaveActiveClass="transitionClasses.active"
:leaveToClass="transitionClasses.leave">
<component :is="currentPage.component" :scrollerClasses="isFirstPage ? $style.first_page_scroller : ''" />
</Transition>
<!-- Next button(s) -->
<div :class="$style.button_wrapper">
<NcButton
v-for="button, index of currentPage.buttons"
:key="button.to"
alignment="center-reverse"
:variant="index === currentPage.buttons.length - 1 ? 'primary' : 'secondary'"
:wide="index === currentPage.buttons.length - 1"
@click="goToPage(button.to)">
<template v-if="!isLastPage" #icon>
<NcIconSvgWrapper :path="mdiArrowRight" />
</template>
{{ button.label }}
</NcButton>
</div>
</div>
</template>
<script setup lang="ts">
import type { IPage } from '../pages.ts'
import { mdiArrowLeft, mdiArrowRight, mdiClose } from '@mdi/js'
import { translate as t } from '@nextcloud/l10n'
import { imagePath } from '@nextcloud/router'
import { computed, ref, useCssModule, watch } from 'vue'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
const currentIndex = defineModel<number>({ required: true })
const props = defineProps<{
pages: IPage[]
}>()
defineEmits<{
close: []
}>()
/**
* True if the transition effect should be reversed (e.g. going back)
*/
const reverseTransition = ref(false)
const currentPage = computed(() => props.pages[currentIndex.value]!)
const isFirstPage = computed(() => currentIndex.value === 0)
const isLastPage = computed(() => currentIndex.value === (props.pages.length - 1))
const cssLogoUrl = `url('${imagePath('firstrunwizard', 'nextcloudLogo.svg')}')`
const transitions = useCssModule('transitions')
/**
* The transition effect to use for the page change
*/
const transitionClasses = computed(() => {
const direction = reverseTransition.value ? 'right' : 'left'
return {
active: transitions['slide-active'],
enter: transitions[`slide-${direction}-enter`],
leave: transitions[`slide-${direction}-leave-to`],
}
})
/**
* The transition effect for the wave on the first page
*/
const waveTransitionClasses = computed(() => {
const direction = reverseTransition.value ? 'down' : 'up'
return {
active: transitions['slide-active'],
enter: transitions[`slide-${direction}-enter`],
leave: transitions[`slide-${direction}-leave-to`],
}
})
/**
* When we show a previous page we want to reverse the transition
*/
watch(() => currentIndex.value, (newPage, oldPage) => {
if (newPage < oldPage) {
reverseTransition.value = true
} else {
reverseTransition.value = false
}
})
/**
* Move to page with given ID
*
* @param pageId ID of the page to got to
*/
function goToPage(pageId: string) {
const id = props.pages.findIndex((page) => page.id === pageId)
currentIndex.value = id
}
</script>
<style module lang="scss">
.wrapper {
position: relative;
overflow: hidden;
padding: calc(var(--default-grid-baseline) * 5);
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;
min-height: min(590px, calc(100dvh - 2 * var(--header-height)));
}
.background_circle {
height: 6000px;
width: 6000px;
border-radius: 3000px;
background-color: var(--color-primary-element);
position: absolute;
top: -5900px;
left: calc( -3000px + 50%);
}
.background_bar {
position:absolute;
top: 0;
left: 0;
width: 100%;
height: 10px;
background-color: var(--color-primary-element);
}
.button_back {
position: absolute!important;
top: var(--default-grid-baseline);
left: var(--default-grid-baseline);
}
.button_close {
position: absolute!important;
top: var(--default-grid-baseline);
right: var(--default-grid-baseline);
}
.button_wrapper {
display: flex;
flex-wrap: wrap;
gap: 22px;
width: 100%;
// Do not change width of buttons
> * {
flex: 0 0 fit-content;
}
// stretch the last one
> *:last-of-type {
flex: 1 0 fit-content;
}
}
.logo {
height: 70px;
background-image: var(--image-logoheader, var(--image-logo, v-bind(cssLogoUrl)));
background-repeat: no-repeat;
background-position: center;
background-size: 100px;
margin: auto;
position: absolute;
left: 0;
width: 100%;
pointer-events: none;
}
// Compensate logo height on first page
.first_page_scroller {
margin-top: calc(var(--default-grid-baseline) * 8 + 70px) !important;
}
</style>
<style module="transitions">
/**
* The transition classes
*/
.slide-active {
transition: all .2s;
}
.slide-left-enter {
opacity: 0;
transform: translateX(30%);
}
.slide-left-leave-to {
opacity: 0;
transform: translateX(-30%);
}
.slide-right-enter {
opacity: 0;
transform: translateX(-30%);
}
.slide-right-leave-to {
opacity: 0;
transform: translateX(30%);
}
.slide-up-enter {
top: calc(-5900px);
}
.slide-up-leave-to {
top: calc(-5900px - 80px);
}
.slide-down-enter {
top: calc(-5900px - 80px);
}
.slide-down-leave-to {
top: calc(-5900px);
}
</style>