@abi-software/gallery 0.1.3-alpha.9 → 0.1.5-beta.0
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/.prettierrc +1 -2
- package/babel.config.js +11 -2
- package/dist/fonts/element-icons.535877f5.woff +0 -0
- package/dist/fonts/element-icons.732389de.ttf +0 -0
- package/dist/gallery.common.js +12488 -1364
- package/dist/gallery.common.js.map +1 -1
- package/dist/gallery.umd.js +12492 -1368
- package/dist/gallery.umd.js.map +1 -1
- package/dist/gallery.umd.min.js +1 -1
- package/dist/gallery.umd.min.js.map +1 -1
- package/dist/img/logo-sparc-wave-primary.8ed83a51.svg +1 -0
- package/jest.config.js +2 -2
- package/package.json +3 -1
- package/src/App.vue +1 -1
- package/src/assets/data-icon.png +0 -0
- package/src/assets/flatmap-thumbnail.png +0 -0
- package/src/assets/logo-sparc-wave-primary.svg +1 -0
- package/src/assets/scaffold-light.png +0 -0
- package/src/assets/video-default.png +0 -0
- package/src/components/Card.vue +181 -34
- package/src/components/Gallery.vue +100 -82
- package/src/components/IndexIndicator.vue +12 -5
- package/src/index.js +0 -1
- package/src/mixins/GalleryHelpers.js +105 -0
- package/tests/unit/example.spec.js +10 -10
- package/.eslintignore +0 -1
- package/dist/img/2d_image_icon.ba9f38c6.svg +0 -1
- package/dist/img/3d_image_icon.d9b382be.svg +0 -1
- package/dist/img/scaffold_image_icon.e13d202e.svg +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg id="logo-sparc-wave-primary" data-name="logo-sparc-wave-primary" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 400 190.5854"><defs><linearGradient id="linear-gradient" y1="96.3505" x2="400" y2="96.3505" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0b00bf"/><stop offset="1" stop-color="#bc00fc"/></linearGradient></defs><title>SPARC Logo</title><path d="M396.6976,128.6248l-146.2735-3.38a6.5358,6.5358,0,0,0-6.1378,3.9236l-.0612.1407-13.673,31.4482L202.9416,9.5333l-.01-.0685a8.9823,8.9823,0,0,0-17.6624-.0114L163.673,125.3819,3.298,129.2886a3.38,3.38,0,0,0,.0269,6.7592L169.34,138.7635a6.5939,6.5939,0,0,0,6.5373-5.1457l.0571-.2546,17.8534-79.5649L221.26,185.1237l.0256.1243A6.7593,6.7593,0,0,0,234.092,186.52L254.9005,138.66l141.7971-3.2762a3.3805,3.3805,0,0,0,0-6.7592Z" style="fill:url(#linear-gradient)"/><path d="M25.6793,0C41.3957,0,51.057,10.0926,51.057,26.0972v9.5162H36.2053V26.0972c0-7.3532-3.8945-11.8219-10.526-11.8219-6.7768,0-10.6691,4.4687-10.6691,11.8219,0,3.8945,1.2982,7.3533,5.4786,11.3908l19.754,18.601C46.5861,62.1441,52.21,68.7778,52.21,79.88c0,16.0047-9.95,26.0973-25.9543,26.0973C10.108,105.9776.1585,95.885.1585,79.88V70.362H15.01V79.88c0,7.3533,4.0375,11.822,11.2455,11.822,7.065,0,11.1025-4.4687,11.1025-11.822,0-4.4709-2.1628-8.6514-6.0551-12.2576L11.1158,48.7357C3.043,41.2372.1585,34.8939.1585,25.666.1585,10.0926,9.82,0,25.6793,0Z" style="fill:#0e0e19"/><path d="M99.7971,69.7856v35.1821H84.9454V1.01h25.3755c16.0047,0,26.0973,10.0926,26.0973,26.0973V43.6883c0,16.15-10.0926,26.0973-26.0973,26.0973Zm10.3808-13.9849c7.2081,0,11.3908-4.3257,11.3908-11.6789V26.6759c0-7.21-4.1827-11.6811-11.3908-11.6811H99.7971V55.8007Z" style="fill:#0e0e19"/><path d="M278.5812,108.147H263.73V4.1893h26.0972c16.0047,0,26.0973,10.0926,26.0973,26.0972v14.13c0,9.95-4.3257,17.7363-11.3908,22.205,4.1827,12.6889,10.0926,29.9917,13.8418,41.5254h-15.14L290.6914,70.3708h-12.11Zm11.1-51.7632c7.21,0,11.3907-4.3257,11.3907-11.5338V29.8553c0-7.21-4.18-11.6812-11.3907-11.6812h-11.1v38.21Z" style="fill:#0e0e19"/><path d="M399.844,73.5414V83.06c0,16.0047-9.9474,26.0973-25.9521,26.0973-16.15,0-26.0972-10.0926-26.0972-26.0973V29.2766c0-16.0046,9.9473-26.0972,26.0972-26.0972,16.0047,0,25.9521,10.0926,25.9521,26.0972v9.5161h-14.85V29.2766c0-7.3532-4.0374-11.822-11.1025-11.822-7.21,0-11.2477,4.4688-11.2477,11.822V83.06c0,7.3533,4.0375,11.822,11.2477,11.822,7.0651,0,11.1025-4.4687,11.1025-11.822V73.5414Z" style="fill:#0e0e19"/></svg>
|
package/jest.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
preset:
|
|
3
|
-
}
|
|
2
|
+
preset: '@vue/cli-plugin-unit-jest',
|
|
3
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/gallery",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/hsorby/mapcore-gallery.git"
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@abi-software/svg-sprite": "^0.1.11",
|
|
20
20
|
"@babel/code-frame": "^7.12.11",
|
|
21
|
+
"axios": "^0.26.1",
|
|
22
|
+
"babel-plugin-component": "^1.1.1",
|
|
21
23
|
"core-js": "^3.8.3",
|
|
22
24
|
"element-ui": "^2.15.0",
|
|
23
25
|
"vue": "^2.6.11"
|
package/src/App.vue
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg id="logo-sparc-wave-primary" data-name="logo-sparc-wave-primary" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 400 190.5854"><defs><linearGradient id="linear-gradient" y1="96.3505" x2="400" y2="96.3505" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0b00bf"/><stop offset="1" stop-color="#bc00fc"/></linearGradient></defs><title>SPARC Logo</title><path d="M396.6976,128.6248l-146.2735-3.38a6.5358,6.5358,0,0,0-6.1378,3.9236l-.0612.1407-13.673,31.4482L202.9416,9.5333l-.01-.0685a8.9823,8.9823,0,0,0-17.6624-.0114L163.673,125.3819,3.298,129.2886a3.38,3.38,0,0,0,.0269,6.7592L169.34,138.7635a6.5939,6.5939,0,0,0,6.5373-5.1457l.0571-.2546,17.8534-79.5649L221.26,185.1237l.0256.1243A6.7593,6.7593,0,0,0,234.092,186.52L254.9005,138.66l141.7971-3.2762a3.3805,3.3805,0,0,0,0-6.7592Z" style="fill:url(#linear-gradient)"/><path d="M25.6793,0C41.3957,0,51.057,10.0926,51.057,26.0972v9.5162H36.2053V26.0972c0-7.3532-3.8945-11.8219-10.526-11.8219-6.7768,0-10.6691,4.4687-10.6691,11.8219,0,3.8945,1.2982,7.3533,5.4786,11.3908l19.754,18.601C46.5861,62.1441,52.21,68.7778,52.21,79.88c0,16.0047-9.95,26.0973-25.9543,26.0973C10.108,105.9776.1585,95.885.1585,79.88V70.362H15.01V79.88c0,7.3533,4.0375,11.822,11.2455,11.822,7.065,0,11.1025-4.4687,11.1025-11.822,0-4.4709-2.1628-8.6514-6.0551-12.2576L11.1158,48.7357C3.043,41.2372.1585,34.8939.1585,25.666.1585,10.0926,9.82,0,25.6793,0Z" style="fill:#0e0e19"/><path d="M99.7971,69.7856v35.1821H84.9454V1.01h25.3755c16.0047,0,26.0973,10.0926,26.0973,26.0973V43.6883c0,16.15-10.0926,26.0973-26.0973,26.0973Zm10.3808-13.9849c7.2081,0,11.3908-4.3257,11.3908-11.6789V26.6759c0-7.21-4.1827-11.6811-11.3908-11.6811H99.7971V55.8007Z" style="fill:#0e0e19"/><path d="M278.5812,108.147H263.73V4.1893h26.0972c16.0047,0,26.0973,10.0926,26.0973,26.0972v14.13c0,9.95-4.3257,17.7363-11.3908,22.205,4.1827,12.6889,10.0926,29.9917,13.8418,41.5254h-15.14L290.6914,70.3708h-12.11Zm11.1-51.7632c7.21,0,11.3907-4.3257,11.3907-11.5338V29.8553c0-7.21-4.18-11.6812-11.3907-11.6812h-11.1v38.21Z" style="fill:#0e0e19"/><path d="M399.844,73.5414V83.06c0,16.0047-9.9474,26.0973-25.9521,26.0973-16.15,0-26.0972-10.0926-26.0972-26.0973V29.2766c0-16.0046,9.9473-26.0972,26.0972-26.0972,16.0047,0,25.9521,10.0926,25.9521,26.0972v9.5161h-14.85V29.2766c0-7.3532-4.0374-11.822-11.1025-11.822-7.21,0-11.2477,4.4688-11.2477,11.822V83.06c0,7.3533,4.0375,11.822,11.2477,11.822,7.0651,0,11.1025-4.4687,11.1025-11.822V73.5414Z" style="fill:#0e0e19"/></svg>
|
|
Binary file
|
|
Binary file
|
package/src/components/Card.vue
CHANGED
|
@@ -1,37 +1,69 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-card :style="{ padding: '0px' }" class="card">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class="triangle-icon"
|
|
13
|
-
:style="`height: ${triangleHeight * 0.25}rem;top: ${triangleHeight * 0.15}rem;right: ${triangleHeight * 0.15}rem`"
|
|
14
|
-
:src="typeIcon"
|
|
15
|
-
@click="$emit('view')"
|
|
2
|
+
<el-card :shadow="shadow" :body-style="bodyStyle" :style="{ padding: '0px', maxWidth: width + 'rem' }" class="card">
|
|
3
|
+
<div v-loading="!isReady">
|
|
4
|
+
<div :style="imageStyle">
|
|
5
|
+
<img :src="thumbnail" alt="thumbnail loading ..." :style="imageStyle" />
|
|
6
|
+
</div>
|
|
7
|
+
<div v-if="false" class="image-overlay">
|
|
8
|
+
<div
|
|
9
|
+
class="triangle-right-corner"
|
|
10
|
+
:style="`border-left-width: ${triangleHeight * 1.2}rem; border-top-width: ${triangleHeight}rem;`"
|
|
11
|
+
@click="openLinkInNewTab"
|
|
16
12
|
/>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
<el-tooltip class="item" :content="`View ${data.type}`" placement="left">
|
|
14
|
+
<img
|
|
15
|
+
class="triangle-icon"
|
|
16
|
+
:style="`height: ${triangleHeight * 0.25}rem;top: ${triangleHeight * 0.15}rem;right: ${triangleHeight * 0.15}rem`"
|
|
17
|
+
:src="typeIcon"
|
|
18
|
+
@click="openLinkInNewTab"
|
|
19
|
+
/>
|
|
20
|
+
</el-tooltip>
|
|
21
|
+
</div>
|
|
22
|
+
<div v-if="showCardDetails" class="details">
|
|
23
|
+
<p>
|
|
24
|
+
<b>{{ data.type }}</b>
|
|
25
|
+
</p>
|
|
26
|
+
<el-popover ref="galleryPopover" :content="data.title" placement="top" trigger="hover" popper-class="gallery-popper" />
|
|
27
|
+
<p class="title" v-popover:galleryPopover>
|
|
28
|
+
{{ data.title }}
|
|
29
|
+
</p>
|
|
30
|
+
<el-button class="button" @click.prevent="cardClicked"> View {{ data.type }}</el-button>
|
|
31
|
+
</div>
|
|
25
32
|
</div>
|
|
26
33
|
</el-card>
|
|
27
34
|
</template>
|
|
28
35
|
|
|
29
36
|
<script>
|
|
30
37
|
// import { SvgIcon } from '@abi-software/svg-sprite'
|
|
38
|
+
import axios from 'axios'
|
|
39
|
+
import Vue from 'vue'
|
|
40
|
+
import { Button, Card, Popover } from 'element-ui'
|
|
41
|
+
Vue.use(Button)
|
|
42
|
+
Vue.use(Card)
|
|
43
|
+
Vue.use(Popover)
|
|
44
|
+
|
|
45
|
+
function isValidHttpUrl(string) {
|
|
46
|
+
let url = undefined
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
url = new URL(string)
|
|
50
|
+
} catch (_) {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
return url.protocol === 'http:' || url.protocol === 'https:'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const getRequest = async (url, params, timeout) => {
|
|
57
|
+
return await axios({
|
|
58
|
+
method: 'get',
|
|
59
|
+
url,
|
|
60
|
+
params,
|
|
61
|
+
timeout,
|
|
62
|
+
})
|
|
63
|
+
}
|
|
31
64
|
|
|
32
65
|
export default {
|
|
33
66
|
name: 'GalleryCard',
|
|
34
|
-
// components: { SvgIcon },
|
|
35
67
|
props: {
|
|
36
68
|
data: {
|
|
37
69
|
type: Object,
|
|
@@ -48,16 +80,41 @@ export default {
|
|
|
48
80
|
showCardDetails: {
|
|
49
81
|
type: Boolean,
|
|
50
82
|
},
|
|
83
|
+
bodyStyle: {
|
|
84
|
+
type: Object,
|
|
85
|
+
default: () => {
|
|
86
|
+
return { padding: '20px', background: '#ffffff' }
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
imageStyle: {
|
|
90
|
+
type: Object,
|
|
91
|
+
default: () => {
|
|
92
|
+
return {}
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
shadow: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: 'always',
|
|
98
|
+
},
|
|
51
99
|
},
|
|
52
100
|
data() {
|
|
53
101
|
return {
|
|
102
|
+
ro: null,
|
|
54
103
|
triangleSize: 4,
|
|
104
|
+
thumbnail: undefined,
|
|
105
|
+
defaultImg: require('../assets/logo-sparc-wave-primary.svg'),
|
|
55
106
|
}
|
|
56
107
|
},
|
|
57
108
|
computed: {
|
|
109
|
+
isReady() {
|
|
110
|
+
return this.data.title && this.thumbnail && (this.data.link || this.data.userData)
|
|
111
|
+
},
|
|
58
112
|
imageHeight() {
|
|
59
113
|
return this.showCardDetails ? this.height * 0.525 : this.height
|
|
60
114
|
},
|
|
115
|
+
imageWidth() {
|
|
116
|
+
return this.width - 2 * this.marginDetails
|
|
117
|
+
},
|
|
61
118
|
triangleHeight() {
|
|
62
119
|
return this.height * 0.237
|
|
63
120
|
},
|
|
@@ -65,24 +122,89 @@ export default {
|
|
|
65
122
|
return this.height * 0.076
|
|
66
123
|
},
|
|
67
124
|
typeIcon() {
|
|
68
|
-
if (this.data.type == '3D Image') {
|
|
69
|
-
|
|
70
|
-
} else if (this.data.type == '3D Scaffold') {
|
|
71
|
-
|
|
125
|
+
// if (this.data.type == '3D Image') {
|
|
126
|
+
// return require('../assets/3d_image_icon.svg')
|
|
127
|
+
// } else if (this.data.type == '3D Scaffold') {
|
|
128
|
+
// return require('../assets/scaffold_image_icon.svg')
|
|
129
|
+
// }
|
|
130
|
+
return undefined // require('@/assets/data-icon.png')
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
methods: {
|
|
134
|
+
cardClicked: function () {
|
|
135
|
+
if (this.data.link) {
|
|
136
|
+
const link = document.createElement('a')
|
|
137
|
+
link.href = this.data.link
|
|
138
|
+
link.target = '_blank'
|
|
139
|
+
document.body.appendChild(link)
|
|
140
|
+
link.click()
|
|
141
|
+
link.remove()
|
|
72
142
|
}
|
|
73
|
-
|
|
143
|
+
if (this.data.userData) {
|
|
144
|
+
this.$emit('card-clicked', this.data.userData)
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
downloadThumbnail: function (url, info) {
|
|
148
|
+
getRequest(url, {}, 11000).then(
|
|
149
|
+
(response) => {
|
|
150
|
+
let data = response.data
|
|
151
|
+
if (data.startsWith('data:')) {
|
|
152
|
+
this.thumbnail = response.data
|
|
153
|
+
} else {
|
|
154
|
+
if (this.data.mimetype) {
|
|
155
|
+
this.thumbnail = `data:${this.data.mimetype};base64,${response.data}`
|
|
156
|
+
} else {
|
|
157
|
+
this.thumbnail = response.data
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
(reason) => {
|
|
162
|
+
if (reason.message.includes('timeout') && reason.message.includes('exceeded') && info.fetchAttempts < 3) {
|
|
163
|
+
info.fetchAttempts += 1
|
|
164
|
+
this.downloadThumbnail(url, info)
|
|
165
|
+
} else {
|
|
166
|
+
this.thumbnail = this.defaultImg
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
)
|
|
74
170
|
},
|
|
75
171
|
},
|
|
172
|
+
created() {
|
|
173
|
+
//Check if thumbnail is set as url and mimetype is also set
|
|
174
|
+
if (this.data.thumbnail) {
|
|
175
|
+
if (isValidHttpUrl(this.data.thumbnail) && this.data.mimetype) {
|
|
176
|
+
this.downloadThumbnail(this.data.thumbnail, { fetchAttempts: 0 })
|
|
177
|
+
} else {
|
|
178
|
+
this.thumbnail = this.data.thumbnail
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
this.thumbnail = this.defaultImg
|
|
182
|
+
}
|
|
183
|
+
},
|
|
76
184
|
}
|
|
77
185
|
</script>
|
|
78
186
|
|
|
79
187
|
<style scoped>
|
|
80
|
-
.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
188
|
+
.button {
|
|
189
|
+
z-index: 10;
|
|
190
|
+
font-family: Asap;
|
|
191
|
+
font-size: 14px;
|
|
192
|
+
font-weight: normal;
|
|
193
|
+
font-stretch: normal;
|
|
194
|
+
font-style: normal;
|
|
195
|
+
line-height: normal;
|
|
196
|
+
letter-spacing: normal;
|
|
197
|
+
background-color: #8300bf;
|
|
198
|
+
border: #8300bf;
|
|
199
|
+
color: white;
|
|
200
|
+
cursor: pointer;
|
|
201
|
+
margin-top: 8px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.button:hover {
|
|
205
|
+
background: #8300bf;
|
|
206
|
+
box-shadow: -3px 2px 4px 0 rgba(0, 0, 0, 0.25);
|
|
207
|
+
color: #fff;
|
|
86
208
|
}
|
|
87
209
|
|
|
88
210
|
.card {
|
|
@@ -92,6 +214,12 @@ export default {
|
|
|
92
214
|
text-align: left;
|
|
93
215
|
}
|
|
94
216
|
|
|
217
|
+
.title {
|
|
218
|
+
overflow-x: hidden;
|
|
219
|
+
text-overflow: ellipsis;
|
|
220
|
+
white-space: nowrap;
|
|
221
|
+
}
|
|
222
|
+
|
|
95
223
|
p.bold {
|
|
96
224
|
font-weight: bold;
|
|
97
225
|
}
|
|
@@ -113,3 +241,22 @@ p.bold {
|
|
|
113
241
|
border-top: solid #8300bf;
|
|
114
242
|
}
|
|
115
243
|
</style>
|
|
244
|
+
|
|
245
|
+
<style>
|
|
246
|
+
.gallery-popper {
|
|
247
|
+
background: #f3ecf6 !important;
|
|
248
|
+
border: 1px solid #8300bf;
|
|
249
|
+
border-radius: 4px;
|
|
250
|
+
color: #303133 !important;
|
|
251
|
+
font-size: 12px;
|
|
252
|
+
line-height: 1rem;
|
|
253
|
+
height: 1rem;
|
|
254
|
+
padding: 10px;
|
|
255
|
+
}
|
|
256
|
+
.gallery-popper.el-popper[x-placement^='top'] .popper__arrow {
|
|
257
|
+
border-top-color: #8300bf !important;
|
|
258
|
+
}
|
|
259
|
+
.gallery-popper.el-popper[x-placement^='top'] .popper__arrow:after {
|
|
260
|
+
border-top-color: #f3ecf6 !important;
|
|
261
|
+
}
|
|
262
|
+
</style>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="myButton" class="gallery">
|
|
3
3
|
<div class="gallery-strip">
|
|
4
|
-
<a href="#" :class="['oval', 'prev', { disabled: !isPrevPossible }]" @click.prevent="goPrev">
|
|
4
|
+
<a v-if="items.length > 1" href="#" :class="['oval', 'prev', { disabled: !isPrevPossible }]" @click.prevent="goPrev">
|
|
5
5
|
<span class="progress-button">‹</span>
|
|
6
6
|
</a>
|
|
7
|
-
<div
|
|
7
|
+
<div v-else style="width: 2rem" />
|
|
8
|
+
<div class="filler" />
|
|
8
9
|
<div class="card-line">
|
|
9
10
|
<span
|
|
10
11
|
v-for="(item, index) in items"
|
|
@@ -12,36 +13,27 @@
|
|
|
12
13
|
:style="{ display: displayState(index) }"
|
|
13
14
|
:class="['key-image-span', { active: isActive(index) }]"
|
|
14
15
|
>
|
|
15
|
-
<card
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
:ref="'key_image_' + thumbnail_image.id"
|
|
27
|
-
:src="thumbnail_image.img"
|
|
28
|
-
alt="thumbnail missing"
|
|
29
|
-
class="thumbnail thumbnail-100"
|
|
30
|
-
:height="slideNaturalHeight"
|
|
31
|
-
:width="slideNaturalWidth"
|
|
32
|
-
/>
|
|
33
|
-
</a>
|
|
34
|
-
</nuxt-link> -->
|
|
35
|
-
<!-- <div class="overlay" :style="`background-color: ${imageOverlayColour(index)}`" /> -->
|
|
16
|
+
<card
|
|
17
|
+
v-if="isVisible(index)"
|
|
18
|
+
:data="item"
|
|
19
|
+
:body-style="bodyStyle"
|
|
20
|
+
:image-style="imageStyle"
|
|
21
|
+
:width="cardWidth"
|
|
22
|
+
:height="cardHeight"
|
|
23
|
+
:shadow="shadow"
|
|
24
|
+
:show-card-details="showCardDetails"
|
|
25
|
+
@card-clicked="cardClicked"
|
|
26
|
+
/>
|
|
36
27
|
</span>
|
|
37
28
|
</div>
|
|
38
|
-
<div class="filler"
|
|
39
|
-
<a href="#" :class="['oval', 'next', { disabled: !isNextPossible }]" @click.prevent="goNext">
|
|
29
|
+
<div class="filler" />
|
|
30
|
+
<a v-if="items.length > 1" href="#" :class="['oval', 'next', { disabled: !isNextPossible }]" @click.prevent="goNext">
|
|
40
31
|
<span class="progress-button">›</span>
|
|
41
32
|
</a>
|
|
33
|
+
<div v-else style="width: 2rem" />
|
|
42
34
|
</div>
|
|
43
|
-
<div v-if="showIndicatorBar"
|
|
44
|
-
<index-indicator v-if="showIndicatorBar" :count="itemCount" :current="currentIndex" />
|
|
35
|
+
<div v-if="showIndicatorBar && items.length > 1" :style="bottomSpacer" />
|
|
36
|
+
<index-indicator v-if="showIndicatorBar && items.length > 1" :count="itemCount" :current="currentIndex" @clicked="indicatorClicked" />
|
|
45
37
|
</div>
|
|
46
38
|
</template>
|
|
47
39
|
|
|
@@ -50,10 +42,10 @@ import IndexIndicator from './IndexIndicator'
|
|
|
50
42
|
import Card from './Card'
|
|
51
43
|
|
|
52
44
|
function convertRemToPixels(rem) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return rem * 16
|
|
45
|
+
if (typeof window !== 'undefined') {
|
|
46
|
+
return rem * parseFloat(window.getComputedStyle(document.documentElement).fontSize)
|
|
47
|
+
}
|
|
48
|
+
return rem * 16
|
|
57
49
|
}
|
|
58
50
|
|
|
59
51
|
export default {
|
|
@@ -68,7 +60,11 @@ export default {
|
|
|
68
60
|
},
|
|
69
61
|
maxWidth: {
|
|
70
62
|
type: Number,
|
|
71
|
-
|
|
63
|
+
required: true,
|
|
64
|
+
},
|
|
65
|
+
cardWidth: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: 13.8,
|
|
72
68
|
},
|
|
73
69
|
showIndicatorBar: {
|
|
74
70
|
type: Boolean,
|
|
@@ -82,6 +78,24 @@ export default {
|
|
|
82
78
|
type: Boolean,
|
|
83
79
|
default: true,
|
|
84
80
|
},
|
|
81
|
+
bodyStyle: {
|
|
82
|
+
type: Object,
|
|
83
|
+
default: () => {
|
|
84
|
+
return { padding: '20px', background: '#ffffff' }
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
imageStyle: {
|
|
88
|
+
type: Object,
|
|
89
|
+
default: () => {
|
|
90
|
+
return {}
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
bottomSpacer: {
|
|
94
|
+
type: Object,
|
|
95
|
+
default: () => {
|
|
96
|
+
return { minHeight: '4rem' }
|
|
97
|
+
},
|
|
98
|
+
},
|
|
85
99
|
metaData: {
|
|
86
100
|
type: Object,
|
|
87
101
|
default: () => {
|
|
@@ -95,6 +109,10 @@ export default {
|
|
|
95
109
|
type: String,
|
|
96
110
|
default: '',
|
|
97
111
|
},
|
|
112
|
+
shadow: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: 'always',
|
|
115
|
+
},
|
|
98
116
|
},
|
|
99
117
|
data() {
|
|
100
118
|
return {
|
|
@@ -102,7 +120,7 @@ export default {
|
|
|
102
120
|
currentIndex: 0,
|
|
103
121
|
controlHeight: 2,
|
|
104
122
|
controlWidth: 2,
|
|
105
|
-
|
|
123
|
+
visibleIndecies: [],
|
|
106
124
|
}
|
|
107
125
|
},
|
|
108
126
|
computed: {
|
|
@@ -125,32 +143,24 @@ export default {
|
|
|
125
143
|
numberOfItemsVisible() {
|
|
126
144
|
// The maximum width we are allowed minus two buttons for next and previous
|
|
127
145
|
// divided by the width of a card.
|
|
128
|
-
const n = this.itemCount - 1
|
|
146
|
+
// const n = this.itemCount - 1
|
|
129
147
|
const cardSpacingPx = convertRemToPixels(0.5)
|
|
130
148
|
const buttonPx = convertRemToPixels(2)
|
|
131
149
|
const cardWidthPx = convertRemToPixels(this.cardWidth)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
while (i < n) {
|
|
135
|
-
const roomRequired = itemsVisibleRough * cardWidthPx + 2 * buttonPx + itemsVisibleRough * cardSpacingPx
|
|
136
|
-
if (roomRequired < this.maxWidth) {
|
|
137
|
-
itemsVisibleRough += 1
|
|
138
|
-
} else {
|
|
139
|
-
i = n
|
|
140
|
-
}
|
|
141
|
-
i += 1
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return itemsVisibleRough
|
|
150
|
+
const cardItems = (this.maxWidth - 2 * buttonPx - 2 * cardSpacingPx) / (1.1 * cardWidthPx)
|
|
151
|
+
return Math.max(1, Math.floor(cardItems))
|
|
145
152
|
},
|
|
146
153
|
},
|
|
147
154
|
methods: {
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
cardClicked(payload) {
|
|
156
|
+
this.$emit('card-clicked', payload)
|
|
150
157
|
},
|
|
151
158
|
isActive(index) {
|
|
152
159
|
return this.currentIndex === index && this.highlightActive
|
|
153
160
|
},
|
|
161
|
+
isVisible(index) {
|
|
162
|
+
return this.visibleIndecies.includes(index)
|
|
163
|
+
},
|
|
154
164
|
goNext() {
|
|
155
165
|
this.currentIndex += 1
|
|
156
166
|
},
|
|
@@ -158,32 +168,46 @@ export default {
|
|
|
158
168
|
this.currentIndex -= 1
|
|
159
169
|
},
|
|
160
170
|
displayState(index) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
let rawIndicies = [this.currentIndex]
|
|
167
|
-
for (let i = 1; i <= halfVisible; i++) {
|
|
168
|
-
rawIndicies.push(this.currentIndex + i)
|
|
169
|
-
rawIndicies.push(this.currentIndex - i)
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (!oddImagesVisible) {
|
|
173
|
-
rawIndicies.pop()
|
|
171
|
+
return this.visibleIndecies.includes(index) ? undefined : 'none'
|
|
172
|
+
},
|
|
173
|
+
indicatorClicked(index) {
|
|
174
|
+
if (this.currentIndex !== index) {
|
|
175
|
+
this.currentIndex = index
|
|
174
176
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
created() {
|
|
180
|
+
this._visibleIndecies = []
|
|
181
|
+
},
|
|
182
|
+
watch: {
|
|
183
|
+
currentIndex: {
|
|
184
|
+
handler: function () {
|
|
185
|
+
const oddImagesVisible = this.numberOfItemsVisible % 2 === 1
|
|
186
|
+
let halfVisible = this.numberOfItemsVisible / 2
|
|
187
|
+
if (oddImagesVisible) {
|
|
188
|
+
halfVisible = (this.numberOfItemsVisible - 1) / 2
|
|
189
|
+
}
|
|
190
|
+
let rawIndicies = [this.currentIndex]
|
|
191
|
+
for (let i = 1; i <= halfVisible; i++) {
|
|
192
|
+
rawIndicies.push(this.currentIndex + i)
|
|
193
|
+
rawIndicies.push(this.currentIndex - i)
|
|
183
194
|
}
|
|
184
|
-
}
|
|
185
195
|
|
|
186
|
-
|
|
196
|
+
if (!oddImagesVisible) {
|
|
197
|
+
rawIndicies.pop()
|
|
198
|
+
}
|
|
199
|
+
this.visibleIndecies = []
|
|
200
|
+
for (let v of rawIndicies) {
|
|
201
|
+
if (v < 0) {
|
|
202
|
+
this.visibleIndecies.push(v + this.numberOfItemsVisible)
|
|
203
|
+
} else if (v >= this.itemCount) {
|
|
204
|
+
this.visibleIndecies.push(v - this.numberOfItemsVisible)
|
|
205
|
+
} else {
|
|
206
|
+
this.visibleIndecies.push(v)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
immediate: true,
|
|
187
211
|
},
|
|
188
212
|
},
|
|
189
213
|
}
|
|
@@ -198,6 +222,9 @@ export default {
|
|
|
198
222
|
border: solid 1px var(--pale-grey);
|
|
199
223
|
background-color: #ffffff;
|
|
200
224
|
border-radius: 1rem;
|
|
225
|
+
display: flex;
|
|
226
|
+
justify-content: center;
|
|
227
|
+
user-select: none;
|
|
201
228
|
}
|
|
202
229
|
|
|
203
230
|
.gallery-strip,
|
|
@@ -215,10 +242,7 @@ export default {
|
|
|
215
242
|
.progress-button {
|
|
216
243
|
font-size: 1.5rem;
|
|
217
244
|
font-weight: bold;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
.bottom-spacer {
|
|
221
|
-
min-height: 4rem;
|
|
245
|
+
color: #8300bf;
|
|
222
246
|
}
|
|
223
247
|
|
|
224
248
|
.filler {
|
|
@@ -233,12 +257,6 @@ a.prev:not(.underline),
|
|
|
233
257
|
a.next:not(.underline) {
|
|
234
258
|
text-decoration: none;
|
|
235
259
|
}
|
|
236
|
-
a.prev {
|
|
237
|
-
justify-content: flex-start;
|
|
238
|
-
}
|
|
239
|
-
a.next {
|
|
240
|
-
justify-content: flex-end;
|
|
241
|
-
}
|
|
242
260
|
|
|
243
261
|
.disabled {
|
|
244
262
|
opacity: 0.5;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="indicator-container">
|
|
3
|
-
<div
|
|
3
|
+
<div
|
|
4
|
+
v-for="(number, index) in count"
|
|
5
|
+
:key="'indicator_' + number"
|
|
6
|
+
:class="['indicator', { active: current === index }]"
|
|
7
|
+
@click="$emit('clicked', index)"
|
|
8
|
+
/>
|
|
4
9
|
</div>
|
|
5
10
|
</template>
|
|
6
11
|
|
|
@@ -26,13 +31,15 @@ export default {
|
|
|
26
31
|
justify-content: center;
|
|
27
32
|
}
|
|
28
33
|
.indicator {
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
34
|
+
width: 1rem;
|
|
35
|
+
height: 1rem;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
background-color: #e4e7ed;
|
|
31
38
|
margin-left: 0.25rem;
|
|
32
39
|
margin-right: 0.25rem;
|
|
33
|
-
background-color: #cccccc;
|
|
34
40
|
}
|
|
41
|
+
|
|
35
42
|
.indicator.active {
|
|
36
|
-
background-color: #
|
|
43
|
+
background-color: #8300bf;
|
|
37
44
|
}
|
|
38
45
|
</style>
|
package/src/index.js
CHANGED