Skip to content

Commit 3ce20fe

Browse files
committed
Add VPSwiper
1 parent 7f21166 commit 3ce20fe

File tree

8 files changed

+127
-161
lines changed

8 files changed

+127
-161
lines changed

.vitepress/theme/components/FullscreenButton.vue

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<script setup>
2+
// noinspection NpmUsedModulesInstalled
3+
import { ref } from 'vue'
4+
import { Swiper, SwiperSlide } from 'swiper/vue'
5+
import { Keyboard, Mousewheel, Navigation, Pagination, EffectCoverflow } from 'swiper/modules'
6+
import 'swiper/css'
7+
import 'swiper/css/navigation'
8+
import 'swiper/css/pagination'
9+
import 'swiper/css/effect-coverflow'
10+
11+
const props = defineProps({
12+
baseUrl: { type: String, required: true },
13+
numberOfSlides: { type: Number, required: true },
14+
slidesPerView: { type: Number, default: 1 },
15+
breakpoints: { type: Object, default: () => ({}) },
16+
lazyPreloadPrevNext: { type: Number, default: 2 },
17+
height: { type: String, default: '496px' },
18+
buttonText: { type: String, default: 'View in Fullscreen' },
19+
keyboard: { type: Boolean, default: true },
20+
mousewheel: { type: Boolean, default: true },
21+
navigation: { type: Boolean, default: true },
22+
grabCursor: { type: Boolean, default: true },
23+
loop: { type: Boolean, default: true },
24+
})
25+
26+
const swiperEl = ref(null)
27+
const requestFullscreen = () => {
28+
// noinspection JSUnresolvedReference
29+
swiperEl?.value?.$el?.requestFullscreen?.()
30+
}
31+
</script>
32+
33+
<style>
34+
:root {
35+
--swiper-pagination-fraction-color: var(--vp-c-purple-1);
36+
--swiper-navigation-color: var(--vp-c-purple-1);
37+
--swiper-navigation-sides-offset: 4px;
38+
}
39+
40+
.swiper {
41+
background-color: var(--vp-code-block-bg);
42+
border-radius: 8px;
43+
}
44+
45+
.swiper img {
46+
width: 100%;
47+
height: 100%;
48+
object-fit: contain;
49+
}
50+
51+
.inline-button {
52+
font-weight: bold;
53+
display: inline-flex;
54+
align-items: center;
55+
gap: 0.5rem;
56+
}
57+
</style>
58+
59+
<template>
60+
<button @click="requestFullscreen" class="inline-button">
61+
<svg
62+
xmlns="http://www.w3.org/2000/svg"
63+
width="24"
64+
height="24"
65+
viewBox="0 0 24 24"
66+
fill="none"
67+
stroke="currentColor"
68+
stroke-width="2"
69+
stroke-linecap="round"
70+
stroke-linejoin="round"
71+
class="lucide lucide-fullscreen-icon lucide-fullscreen"
72+
>
73+
<path d="M3 7V5a2 2 0 0 1 2-2h2" />
74+
<path d="M17 3h2a2 2 0 0 1 2 2v2" />
75+
<path d="M21 17v2a2 2 0 0 1-2 2h-2" />
76+
<path d="M7 21H5a2 2 0 0 1-2-2v-2" />
77+
<rect width="10" height="8" x="7" y="8" rx="1" />
78+
</svg>
79+
<span>{{ props.buttonText }}</span>
80+
</button>
81+
82+
<ClientOnly>
83+
<Swiper
84+
ref="swiperEl"
85+
:modules="[Keyboard, Mousewheel, Navigation, Pagination, EffectCoverflow]"
86+
:slides-per-view="props.slidesPerView"
87+
:breakpoints="props.breakpoints"
88+
:pagination="{ clickable: true, type: 'fraction' }"
89+
:coverflow-effect="{ slideShadows: false }"
90+
:keyboard="props.keyboard"
91+
:mousewheel="props.mousewheel"
92+
:navigation="props.navigation"
93+
:grab-cursor="props.grabCursor"
94+
:loop="props.loop"
95+
:lazy-preload-prev-next="props.lazyPreloadPrevNext"
96+
effect="coverflow"
97+
class="swiper"
98+
:style="{ height: props.height }"
99+
>
100+
<SwiperSlide v-for="i in props.numberOfSlides" :key="i">
101+
<img :src="`${props.baseUrl}/${i}.jpg`" :alt="`Loading ${i}`" loading="lazy" />
102+
</SwiperSlide>
103+
</Swiper>
104+
</ClientOnly>
105+
</template>

.vitepress/theme/custom.css

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,3 @@ img {
1515
.VPTeamPage {
1616
margin-top: 0 !important;
1717
}
18-
19-
/*NOTE: Swiper styles, move this out of global css */
20-
.swiper {
21-
height: 512px;
22-
/*padding-top: 4px !important;*/
23-
/*padding-bottom: 4px !important;*/
24-
background-color: var(--vp-code-block-bg);
25-
border-radius: 8px;
26-
}
27-
.swiper img {
28-
width: 100%;
29-
height: 100%;
30-
object-fit: contain;
31-
}

.vitepress/theme/index.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
11
import DefaultTheme from 'vitepress/theme'
22
import './custom.css'
33

4-
import FullscreenButton from './components/FullscreenButton.vue'
5-
6-
import { Swiper, SwiperSlide } from 'swiper/vue'
7-
import 'swiper/css'
8-
9-
import { Keyboard, Mousewheel, Navigation, Pagination, EffectCoverflow } from 'swiper/modules'
10-
import 'swiper/css/keyboard'
11-
import 'swiper/css/mousewheel'
12-
import 'swiper/css/navigation'
13-
import 'swiper/css/pagination'
14-
import 'swiper/css/effect-coverflow'
4+
import VpSwiper from './components/VPSwiper.vue'
155

166
// noinspection JSUnusedGlobalSymbols
177
export default {
188
...DefaultTheme,
199

2010
enhanceApp({ app }) {
21-
app.component('FullscreenButton', FullscreenButton)
22-
23-
app.component('Swiper', Swiper)
24-
app.component('SwiperSlide', SwiperSlide)
25-
app.config.globalProperties.Keyboard = Keyboard
26-
app.config.globalProperties.Mousewheel = Mousewheel
27-
app.config.globalProperties.Navigation = Navigation
28-
app.config.globalProperties.Pagination = Pagination
29-
app.config.globalProperties.EffectCoverflow = EffectCoverflow
11+
app.component('VpSwiper', VpSwiper)
3012
},
3113
}

docs/clients/android.md

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,8 @@ Click `Add Server` and you are done!
3434

3535
## Screenshots
3636

37-
<!--suppress CheckEmptyScriptTag, HtmlUnknownTag -->
38-
<FullscreenButton />
39-
<ClientOnly>
40-
<Swiper
41-
:modules="[Keyboard, Mousewheel, Navigation, Pagination, EffectCoverflow]"
42-
:slides-per-view="1"
43-
:breakpoints="{ 1096: { slidesPerView: 3 }}"
44-
:pagination="{ clickable: true, type: 'fraction' }"
45-
:coverflowEffect="{ slideShadows: false }"
46-
:keyboard="true"
47-
:mousewheel="true"
48-
:navigation="true"
49-
:grabCursor="true"
50-
:loop="true"
51-
:lazyPreloadPrevNext="2"
52-
:effect="'coverflow'"
53-
class="swiper">
54-
<SwiperSlide v-for="i in 18" :key="i">
55-
<img :src="`https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/django-files/android/screenshots/${i}.jpg`" alt="Loading..." loading="lazy" />
56-
</SwiperSlide>
57-
</Swiper>
58-
</ClientOnly>
37+
<VpSwiper
38+
base-url="https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/django-files/android/screenshots"
39+
:number-of-slides="18"
40+
:breakpoints="{ 1096: { slidesPerView: 3 } }"
41+
/>

docs/clients/browser.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,7 @@ Alternatively you can copy and paste your URL and Token into the Settings.
4141

4242
## Screenshots
4343

44-
<!--suppress CheckEmptyScriptTag, HtmlUnknownTag -->
45-
<FullscreenButton />
46-
<ClientOnly>
47-
<Swiper
48-
:modules="[Keyboard, Mousewheel, Navigation, Pagination, EffectCoverflow]"
49-
:slides-per-view="1"
50-
:pagination="{ clickable: true, type: 'fraction' }"
51-
:coverflowEffect="{ slideShadows: false }"
52-
:keyboard="true"
53-
:mousewheel="true"
54-
:navigation="true"
55-
:grabCursor="true"
56-
:loop="true"
57-
:lazyPreloadPrevNext="1"
58-
:effect="'coverflow'"
59-
class="swiper">
60-
<SwiperSlide v-for="i in 6" :key="i">
61-
<img :src="`https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/web-extension/docs/${i}.jpg`" alt="Loading..." loading="lazy" />
62-
</SwiperSlide>
63-
</Swiper>
64-
</ClientOnly>
44+
<VpSwiper
45+
base-url="https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/web-extension/docs"
46+
:number-of-slides="6"
47+
/>

docs/clients/ios.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ More details available on GitHub: https://github.com/django-files/ios-client
1010

1111
Get it from the Apple App Store.
1212

13-
[![Apple App Store](https://df.cssnr.com/raw/apple.png)](https://apps.apple.com/us/app/django-files/id6742523003)
13+
[![Apple App Store](https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/badges/get/apple.png)](https://apps.apple.com/us/app/django-files/id6742523003)
1414

1515
::: details View QR Code 📸
1616
[![Apple App Store](https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/ios-client/qr/apple.png)](https://apps.apple.com/us/app/django-files/id6742523003)
@@ -29,25 +29,8 @@ Click `Add Server` and you are done!
2929

3030
## Screenshots
3131

32-
<!--suppress CheckEmptyScriptTag, HtmlUnknownTag -->
33-
<FullscreenButton />
34-
<ClientOnly>
35-
<Swiper
36-
:modules="[Keyboard, Mousewheel, Navigation, Pagination, EffectCoverflow]"
37-
:slides-per-view="1"
38-
:breakpoints="{ 1096: { slidesPerView: 3 }}"
39-
:pagination="{ clickable: true, type: 'fraction' }"
40-
:coverflowEffect="{ slideShadows: false }"
41-
:keyboard="true"
42-
:mousewheel="true"
43-
:navigation="true"
44-
:grabCursor="true"
45-
:loop="true"
46-
:lazyPreloadPrevNext="2"
47-
:effect="'coverflow'"
48-
class="swiper">
49-
<SwiperSlide v-for="i in 7" :key="i">
50-
<img :src="`https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/ios-client/docs/${i}.jpg`" alt="Loading..." loading="lazy" />
51-
</SwiperSlide>
52-
</Swiper>
53-
</ClientOnly>
32+
<VpSwiper
33+
base-url="https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/ios-client/docs"
34+
:number-of-slides="7"
35+
:breakpoints="{ 1096: { slidesPerView: 3 } }"
36+
/>

docs/guides/features.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,8 @@ Missing a feature? Submit a [Feature Request](https://github.com/django-files/dj
4343

4444
## Screenshots
4545

46-
<!--suppress CheckEmptyScriptTag, HtmlUnknownTag -->
47-
<FullscreenButton />
48-
<ClientOnly>
49-
<Swiper
50-
:modules="[Keyboard, Mousewheel, Navigation, Pagination, EffectCoverflow]"
51-
:slides-per-view="1"
52-
:pagination="{ clickable: true, type: 'fraction' }"
53-
:coverflowEffect="{ slideShadows: false }"
54-
:keyboard="true"
55-
:mousewheel="true"
56-
:navigation="true"
57-
:grabCursor="true"
58-
:loop="true"
59-
:lazyPreloadPrevNext="1"
60-
:effect="'coverflow'"
61-
class="swiper" style="height: 396px;">
62-
<SwiperSlide v-for="i in 18" :key="i">
63-
<img :src="`https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/django-files/docs/${String(i).padStart(2, '0')}.jpg`" alt="Loading..." loading="lazy" />
64-
</SwiperSlide>
65-
</Swiper>
66-
</ClientOnly>
46+
<VpSwiper
47+
base-url="https://raw.githubusercontent.com/django-files/repo-images/refs/heads/master/django-files/docs"
48+
:number-of-slides="18"
49+
height="396px"
50+
/>

0 commit comments

Comments
 (0)