@abi-software/gallery 0.3.2-beta → 0.3.2

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.
@@ -1,250 +1,250 @@
1
- <template>
2
- <div ref="myButton" class="gallery">
3
- <div class="gallery-strip">
4
- <a v-if="items.length > 1" href="#" :class="['oval', 'prev', { disabled: !isPrevPossible }]" @click.prevent="goPrev">
5
- <span class="progress-button">&lsaquo;</span>
6
- </a>
7
- <div v-else style="width: 2rem" />
8
- <div class="filler" />
9
- <div class="card-line">
10
- <span v-for="(item, index) in windowedItems" :key="'card_' + index" :class="['key-image-span', { active: isActive(index) }]">
11
- <card
12
- v-if="item"
13
- :data="item"
14
- :body-style="bodyStyle"
15
- :image-container-style="imageContainerStyle"
16
- :image-style="imageStyle"
17
- :width="cardWidth"
18
- :height="cardHeight"
19
- :shadow="shadow"
20
- :show-card-details="showCardDetails"
21
- @card-clicked="cardClicked"
22
- />
23
- </span>
24
- </div>
25
- <div class="filler" />
26
- <a v-if="items.length > 1" href="#" :class="['oval', 'next', { disabled: !isNextPossible }]" @click.prevent="goNext">
27
- <span class="progress-button">&rsaquo;</span>
28
- </a>
29
- <div v-else style="width: 2rem" />
30
- </div>
31
- <div :style="bottomSpacer" />
32
- <index-indicator v-if="canShowIndicatorBar" :count="itemCount" :current="currentIndex" @clicked="indicatorClicked" />
33
- </div>
34
- </template>
35
-
36
- <script>
37
- import IndexIndicator from './IndexIndicator'
38
- import Card from './Card'
39
-
40
- function convertRemToPixels(rem) {
41
- if (typeof window !== 'undefined') {
42
- return rem * parseFloat(window.getComputedStyle(document.documentElement).fontSize)
43
- }
44
- return rem * 16
45
- }
46
-
47
- export default {
48
- name: 'Gallery',
49
- components: { IndexIndicator, Card },
50
- props: {
51
- items: {
52
- type: Array,
53
- default: () => {
54
- return []
55
- },
56
- },
57
- maxWidth: {
58
- type: Number,
59
- required: true,
60
- },
61
- cardWidth: {
62
- type: Number,
63
- default: 13.8,
64
- },
65
- showIndicatorBar: {
66
- type: Boolean,
67
- default: true,
68
- },
69
- highlightActive: {
70
- type: Boolean,
71
- default: true,
72
- },
73
- showCardDetails: {
74
- type: Boolean,
75
- default: true,
76
- },
77
- bodyStyle: {
78
- type: Object,
79
- default: () => {
80
- return { padding: '20px', background: '#ffffff' }
81
- },
82
- },
83
- bottomSpacer: {
84
- type: Object,
85
- default: () => {
86
- return { minHeight: '4rem' }
87
- },
88
- },
89
- imageContainerStyle: {
90
- type: Object,
91
- default: () => {
92
- return {}
93
- },
94
- },
95
- imageStyle: {
96
- type: Object,
97
- default: () => {
98
- return {}
99
- },
100
- },
101
- metaData: {
102
- type: Object,
103
- default: () => {
104
- return {
105
- datasetVersion: -1,
106
- datasetId: -1,
107
- }
108
- },
109
- },
110
- description: {
111
- type: String,
112
- default: '',
113
- },
114
- shadow: {
115
- type: String,
116
- default: 'always',
117
- },
118
- },
119
- data() {
120
- return {
121
- count: 0,
122
- currentIndex: 0,
123
- controlHeight: 2,
124
- controlWidth: 2,
125
- }
126
- },
127
- computed: {
128
- itemCount() {
129
- return this.items.length
130
- },
131
- isPrevPossible() {
132
- return this.currentIndex > 0
133
- },
134
- isNextPossible() {
135
- return this.currentIndex < this.itemCount - 1
136
- },
137
- cardHeight() {
138
- return 0.78 * this.cardWidth
139
- },
140
- cardLineWidth() {
141
- const cardSpacing = 0.25
142
- return this.itemCount * (this.cardWidth + cardSpacing) - cardSpacing
143
- },
144
- numberOfItemsVisible() {
145
- // The maximum width we are allowed minus two buttons for next and previous
146
- // divided by the width of a card.
147
- // const n = this.itemCount - 1
148
- const cardSpacingPx = convertRemToPixels(0.5)
149
- const buttonPx = convertRemToPixels(2)
150
- const cardWidthPx = convertRemToPixels(this.cardWidth)
151
- const cardItems = (this.maxWidth - 2 * buttonPx - 2 * cardSpacingPx) / (1.1 * cardWidthPx)
152
- //Display at least one item
153
- return Math.max(1, Math.floor(cardItems))
154
- },
155
- canShowIndicatorBar() {
156
- const indicatorWidth = convertRemToPixels(1)
157
- const indicatorAllowance = this.maxWidth / (indicatorWidth * this.itemCount)
158
- return this.showIndicatorBar && indicatorAllowance > 0.1 && this.itemCount > 1
159
- },
160
- valueAdjustment() {
161
- const halfWindow = Math.floor(this.numberOfItemsVisible / 2)
162
- let valueAdjust = this.currentIndex - halfWindow
163
- if (valueAdjust < 0) {
164
- valueAdjust = 0
165
- } else if (valueAdjust + this.numberOfItemsVisible > this.itemCount) {
166
- valueAdjust = this.itemCount - this.numberOfItemsVisible
167
- }
168
-
169
- return valueAdjust
170
- },
171
- windowedItems() {
172
- let myArray = []
173
- for (let i = 0; i < this.numberOfItemsVisible; i++) {
174
- myArray.push(this.items[i + this.valueAdjustment])
175
- }
176
- return myArray
177
- },
178
- },
179
- methods: {
180
- cardClicked(payload) {
181
- this.$emit('card-clicked', payload)
182
- },
183
- isActive(index) {
184
- return this.currentIndex - this.valueAdjustment === index && this.highlightActive
185
- },
186
- goNext() {
187
- this.currentIndex += 1
188
- },
189
- goPrev() {
190
- this.currentIndex -= 1
191
- },
192
- indicatorClicked(index) {
193
- if (this.currentIndex !== index) {
194
- this.currentIndex = index
195
- }
196
- },
197
- },
198
- }
199
- </script>
200
-
201
- <style scoped>
202
- .oval {
203
- width: 2rem;
204
- height: 2rem;
205
- line-height: 2rem;
206
- box-shadow: 0 0.125rem 0.25rem 0 rgba(0, 0, 0, 0.25);
207
- border: solid 1px var(--pale-grey);
208
- background-color: #ffffff;
209
- border-radius: 1rem;
210
- display: flex;
211
- justify-content: center;
212
- user-select: none;
213
- }
214
-
215
- .gallery-strip,
216
- .card-line {
217
- display: flex;
218
- flex-wrap: nowrap;
219
- justify-content: space-around;
220
- align-items: center;
221
- }
222
-
223
- .card-line {
224
- flex-grow: 2;
225
- }
226
-
227
- .progress-button {
228
- font-size: 1.5rem;
229
- font-weight: bold;
230
- color: #8300bf;
231
- }
232
-
233
- .filler {
234
- flex-grow: 1;
235
- }
236
-
237
- .key-image-span.active {
238
- transform: scale(1.1);
239
- }
240
-
241
- a.prev:not(.underline),
242
- a.next:not(.underline) {
243
- text-decoration: none;
244
- }
245
-
246
- .disabled {
247
- opacity: 0.5;
248
- pointer-events: none;
249
- }
250
- </style>
1
+ <template>
2
+ <div ref="myButton" class="gallery">
3
+ <div class="gallery-strip">
4
+ <a v-if="items.length > 1" href="#" :class="['oval', 'prev', { disabled: !isPrevPossible }]" @click.prevent="goPrev">
5
+ <span class="progress-button">&lsaquo;</span>
6
+ </a>
7
+ <div v-else style="width: 2rem" />
8
+ <div class="filler" />
9
+ <div class="card-line">
10
+ <span v-for="(item, index) in windowedItems" :key="'card_' + index" :class="['key-image-span', { active: isActive(index) }]">
11
+ <card
12
+ v-if="item"
13
+ :data="item"
14
+ :body-style="bodyStyle"
15
+ :image-container-style="imageContainerStyle"
16
+ :image-style="imageStyle"
17
+ :width="cardWidth"
18
+ :height="cardHeight"
19
+ :shadow="shadow"
20
+ :show-card-details="showCardDetails"
21
+ @card-clicked="cardClicked"
22
+ />
23
+ </span>
24
+ </div>
25
+ <div class="filler" />
26
+ <a v-if="items.length > 1" href="#" :class="['oval', 'next', { disabled: !isNextPossible }]" @click.prevent="goNext">
27
+ <span class="progress-button">&rsaquo;</span>
28
+ </a>
29
+ <div v-else style="width: 2rem" />
30
+ </div>
31
+ <div :style="bottomSpacer" />
32
+ <index-indicator v-if="canShowIndicatorBar" :count="itemCount" :current="currentIndex" @clicked="indicatorClicked" />
33
+ </div>
34
+ </template>
35
+
36
+ <script>
37
+ import IndexIndicator from './IndexIndicator'
38
+ import Card from './Card'
39
+
40
+ function convertRemToPixels(rem) {
41
+ if (typeof window !== 'undefined') {
42
+ return rem * parseFloat(window.getComputedStyle(document.documentElement).fontSize)
43
+ }
44
+ return rem * 16
45
+ }
46
+
47
+ export default {
48
+ name: 'Gallery',
49
+ components: { IndexIndicator, Card },
50
+ props: {
51
+ items: {
52
+ type: Array,
53
+ default: () => {
54
+ return []
55
+ },
56
+ },
57
+ maxWidth: {
58
+ type: Number,
59
+ default: 3,
60
+ },
61
+ cardWidth: {
62
+ type: Number,
63
+ default: 13.8,
64
+ },
65
+ showIndicatorBar: {
66
+ type: Boolean,
67
+ default: true,
68
+ },
69
+ highlightActive: {
70
+ type: Boolean,
71
+ default: true,
72
+ },
73
+ showCardDetails: {
74
+ type: Boolean,
75
+ default: true,
76
+ },
77
+ bodyStyle: {
78
+ type: Object,
79
+ default: () => {
80
+ return { padding: '20px', background: '#ffffff' }
81
+ },
82
+ },
83
+ bottomSpacer: {
84
+ type: Object,
85
+ default: () => {
86
+ return { minHeight: '4rem' }
87
+ },
88
+ },
89
+ imageContainerStyle: {
90
+ type: Object,
91
+ default: () => {
92
+ return {}
93
+ },
94
+ },
95
+ imageStyle: {
96
+ type: Object,
97
+ default: () => {
98
+ return {}
99
+ },
100
+ },
101
+ metaData: {
102
+ type: Object,
103
+ default: () => {
104
+ return {
105
+ datasetVersion: -1,
106
+ datasetId: -1,
107
+ }
108
+ },
109
+ },
110
+ description: {
111
+ type: String,
112
+ default: '',
113
+ },
114
+ shadow: {
115
+ type: String,
116
+ default: 'always',
117
+ },
118
+ },
119
+ data() {
120
+ return {
121
+ count: 0,
122
+ currentIndex: 0,
123
+ controlHeight: 2,
124
+ controlWidth: 2,
125
+ }
126
+ },
127
+ computed: {
128
+ itemCount() {
129
+ return this.items.length
130
+ },
131
+ isPrevPossible() {
132
+ return this.currentIndex > 0
133
+ },
134
+ isNextPossible() {
135
+ return this.currentIndex < this.itemCount - 1
136
+ },
137
+ cardHeight() {
138
+ return 0.78 * this.cardWidth
139
+ },
140
+ cardLineWidth() {
141
+ const cardSpacing = 0.25
142
+ return this.itemCount * (this.cardWidth + cardSpacing) - cardSpacing
143
+ },
144
+ numberOfItemsVisible() {
145
+ // The maximum width we are allowed minus two buttons for next and previous
146
+ // divided by the width of a card.
147
+ // const n = this.itemCount - 1
148
+ const cardSpacingPx = convertRemToPixels(0.5)
149
+ const buttonPx = convertRemToPixels(2)
150
+ const cardWidthPx = convertRemToPixels(this.cardWidth)
151
+ const cardItems = (this.maxWidth - 2 * buttonPx - 2 * cardSpacingPx) / (1.1 * cardWidthPx)
152
+ //Display at least one item
153
+ return Math.max(1, Math.floor(cardItems))
154
+ },
155
+ canShowIndicatorBar() {
156
+ const indicatorWidth = convertRemToPixels(1)
157
+ const indicatorAllowance = this.maxWidth / (indicatorWidth * this.itemCount)
158
+ return this.showIndicatorBar && indicatorAllowance > 0.1 && this.itemCount > 1
159
+ },
160
+ valueAdjustment() {
161
+ const halfWindow = Math.floor(this.numberOfItemsVisible / 2)
162
+ let valueAdjust = this.currentIndex - halfWindow
163
+ if (valueAdjust < 0) {
164
+ valueAdjust = 0
165
+ } else if (valueAdjust + this.numberOfItemsVisible > this.itemCount) {
166
+ valueAdjust = this.itemCount - this.numberOfItemsVisible
167
+ }
168
+
169
+ return valueAdjust
170
+ },
171
+ windowedItems() {
172
+ let myArray = []
173
+ for (let i = 0; i < this.numberOfItemsVisible; i++) {
174
+ myArray.push(this.items[i + this.valueAdjustment])
175
+ }
176
+ return myArray
177
+ },
178
+ },
179
+ methods: {
180
+ cardClicked(payload) {
181
+ this.$emit('card-clicked', payload)
182
+ },
183
+ isActive(index) {
184
+ return this.currentIndex - this.valueAdjustment === index && this.highlightActive
185
+ },
186
+ goNext() {
187
+ this.currentIndex += 1
188
+ },
189
+ goPrev() {
190
+ this.currentIndex -= 1
191
+ },
192
+ indicatorClicked(index) {
193
+ if (this.currentIndex !== index) {
194
+ this.currentIndex = index
195
+ }
196
+ },
197
+ },
198
+ }
199
+ </script>
200
+
201
+ <style scoped>
202
+ .oval {
203
+ width: 2rem;
204
+ height: 2rem;
205
+ line-height: 2rem;
206
+ box-shadow: 0 0.125rem 0.25rem 0 rgba(0, 0, 0, 0.25);
207
+ border: solid 1px var(--pale-grey);
208
+ background-color: #ffffff;
209
+ border-radius: 1rem;
210
+ display: flex;
211
+ justify-content: center;
212
+ user-select: none;
213
+ }
214
+
215
+ .gallery-strip,
216
+ .card-line {
217
+ display: flex;
218
+ flex-wrap: nowrap;
219
+ justify-content: space-around;
220
+ align-items: center;
221
+ }
222
+
223
+ .card-line {
224
+ flex-grow: 2;
225
+ }
226
+
227
+ .progress-button {
228
+ font-size: 1.5rem;
229
+ font-weight: bold;
230
+ color: #8300bf;
231
+ }
232
+
233
+ .filler {
234
+ flex-grow: 1;
235
+ }
236
+
237
+ .key-image-span.active {
238
+ transform: scale(1.1);
239
+ }
240
+
241
+ a.prev:not(.underline),
242
+ a.next:not(.underline) {
243
+ text-decoration: none;
244
+ }
245
+
246
+ .disabled {
247
+ opacity: 0.5;
248
+ pointer-events: none;
249
+ }
250
+ </style>
@@ -1,45 +1,45 @@
1
- <template>
2
- <div class="indicator-container">
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
- />
9
- </div>
10
- </template>
11
-
12
- <script>
13
- export default {
14
- name: 'IndexIndicator',
15
- props: {
16
- count: {
17
- type: Number,
18
- default: 0,
19
- },
20
- current: {
21
- type: Number,
22
- default: 0,
23
- },
24
- },
25
- }
26
- </script>
27
-
28
- <style scoped>
29
- .indicator-container {
30
- display: flex;
31
- justify-content: center;
32
- }
33
- .indicator {
34
- width: 1rem;
35
- height: 1rem;
36
- border-radius: 50%;
37
- background-color: #e4e7ed;
38
- margin-left: 0.25rem;
39
- margin-right: 0.25rem;
40
- }
41
-
42
- .indicator.active {
43
- background-color: #8300bf;
44
- }
45
- </style>
1
+ <template>
2
+ <div class="indicator-container">
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
+ />
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ export default {
14
+ name: 'IndexIndicator',
15
+ props: {
16
+ count: {
17
+ type: Number,
18
+ default: 0,
19
+ },
20
+ current: {
21
+ type: Number,
22
+ default: 0,
23
+ },
24
+ },
25
+ }
26
+ </script>
27
+
28
+ <style scoped>
29
+ .indicator-container {
30
+ display: flex;
31
+ justify-content: center;
32
+ }
33
+ .indicator {
34
+ width: 1rem;
35
+ height: 1rem;
36
+ border-radius: 50%;
37
+ background-color: #e4e7ed;
38
+ margin-left: 0.25rem;
39
+ margin-right: 0.25rem;
40
+ }
41
+
42
+ .indicator.active {
43
+ background-color: #8300bf;
44
+ }
45
+ </style>
package/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import Gallery from './components/Gallery.vue'
2
- export default Gallery
1
+ import Gallery from './components/Gallery.vue'
2
+ export default Gallery
@@ -0,0 +1,2 @@
1
+ import Gallery from './components/Gallery.vue'
2
+ export default Gallery
package/src/main.js CHANGED
@@ -1,2 +1,8 @@
1
- import Gallery from './components/Gallery.vue'
2
- export default Gallery
1
+ import Vue from 'vue'
2
+ import App from './App.vue'
3
+
4
+ Vue.config.productionTip = false
5
+
6
+ new Vue({
7
+ render: (h) => h(App),
8
+ }).$mount('#app')