@abi-software/gallery 0.2.1 → 0.2.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,208 +1,208 @@
1
- <template>
2
- <div ref="myButton" class="gallery">
3
- <div class="gallery-strip">
4
- <a href="#" :class="['oval', 'prev', { disabled: !isPrevPossible }]" @click.prevent="goPrev">
5
- <span class="progress-button">&lsaquo;</span>
6
- </a>
7
- <div class="filler" />
8
- <div class="card-line">
9
- <span v-for="(item, index) in windowedItems" :key="'card_' + index" :class="['key-image-span', { active: isActive(index) }]">
10
- <card :data="item" :width="cardWidth" :height="cardHeight" :show-card-details="showCardDetails" />
11
- </span>
12
- </div>
13
- <div class="filler" />
14
- <a href="#" :class="['oval', 'next', { disabled: !isNextPossible }]" @click.prevent="goNext">
15
- <span class="progress-button">&rsaquo;</span>
16
- </a>
17
- </div>
18
- <div v-if="canShowIndicatorBar" class="bottom-spacer" />
19
- <index-indicator v-if="canShowIndicatorBar" :count="itemCount" :current="currentIndex" @clicked="indicatorClicked" />
20
- </div>
21
- </template>
22
-
23
- <script>
24
- import IndexIndicator from './IndexIndicator'
25
- import Card from './Card'
26
-
27
- function convertRemToPixels(rem) {
28
- if (typeof window !== 'undefined') {
29
- return rem * parseFloat(window.getComputedStyle(document.documentElement).fontSize)
30
- }
31
- return rem * 16
32
- }
33
-
34
- export default {
35
- name: 'Gallery',
36
- components: { IndexIndicator, Card },
37
- props: {
38
- items: {
39
- type: Array,
40
- default: () => {
41
- return []
42
- },
43
- },
44
- maxWidth: {
45
- type: Number,
46
- required: true,
47
- },
48
- cardWidth: {
49
- type: Number,
50
- default: 13.8,
51
- },
52
- showIndicatorBar: {
53
- type: Boolean,
54
- default: true,
55
- },
56
- highlightActive: {
57
- type: Boolean,
58
- default: true,
59
- },
60
- showCardDetails: {
61
- type: Boolean,
62
- default: true,
63
- },
64
- metaData: {
65
- type: Object,
66
- default: () => {
67
- return {
68
- datasetVersion: -1,
69
- datasetId: -1,
70
- }
71
- },
72
- },
73
- description: {
74
- type: String,
75
- default: '',
76
- },
77
- },
78
- data() {
79
- return {
80
- count: 0,
81
- currentIndex: 0,
82
- controlHeight: 2,
83
- controlWidth: 2,
84
- }
85
- },
86
- computed: {
87
- itemCount() {
88
- return this.items.length
89
- },
90
- isPrevPossible() {
91
- return this.currentIndex > 0
92
- },
93
- isNextPossible() {
94
- return this.currentIndex < this.itemCount - 1
95
- },
96
- cardHeight() {
97
- return 0.78 * this.cardWidth
98
- },
99
- cardLineWidth() {
100
- const cardSpacing = 0.25
101
- return this.itemCount * (this.cardWidth + cardSpacing) - cardSpacing
102
- },
103
- numberOfItemsVisible() {
104
- // The maximum width we are allowed minus two buttons for next and previous
105
- // divided by the width of a card.
106
- // const n = this.itemCount - 1
107
- const cardSpacingPx = convertRemToPixels(0.5)
108
- const buttonPx = convertRemToPixels(2)
109
- const cardWidthPx = convertRemToPixels(this.cardWidth)
110
- const cardItems = (this.maxWidth - 2 * buttonPx - 2 * cardSpacingPx) / (1.1 * cardWidthPx)
111
- return Math.floor(cardItems)
112
- },
113
- canShowIndicatorBar() {
114
- const indicatorWidth = convertRemToPixels(1)
115
- const indicatorAllowance = this.maxWidth / (indicatorWidth * this.itemCount)
116
- return this.showIndicatorBar && indicatorAllowance > 0.1
117
- },
118
- valueAdjustment() {
119
- const halfWindow = Math.floor(this.numberOfItemsVisible / 2)
120
- let valueAdjust = this.currentIndex - halfWindow
121
- if (valueAdjust < 0) {
122
- valueAdjust = 0
123
- } else if (valueAdjust + this.numberOfItemsVisible > this.itemCount) {
124
- valueAdjust = this.itemCount - this.numberOfItemsVisible
125
- }
126
-
127
- return valueAdjust
128
- },
129
- windowedItems() {
130
- let myArray = []
131
- for (let i = 0; i < this.numberOfItemsVisible; i++) {
132
- myArray.push(this.items[i + this.valueAdjustment])
133
- }
134
- return myArray
135
- },
136
- },
137
- methods: {
138
- isActive(index) {
139
- return this.currentIndex - this.valueAdjustment === index && this.highlightActive
140
- },
141
- goNext() {
142
- this.currentIndex += 1
143
- },
144
- goPrev() {
145
- this.currentIndex -= 1
146
- },
147
- indicatorClicked(index) {
148
- if (this.currentIndex !== index) {
149
- this.currentIndex = index
150
- }
151
- },
152
- },
153
- }
154
- </script>
155
-
156
- <style scoped>
157
- .oval {
158
- width: 2rem;
159
- height: 2rem;
160
- line-height: 2rem;
161
- box-shadow: 0 0.125rem 0.25rem 0 rgba(0, 0, 0, 0.25);
162
- border: solid 1px var(--pale-grey);
163
- background-color: #ffffff;
164
- border-radius: 1rem;
165
- display: flex;
166
- justify-content: center;
167
- user-select: none;
168
- }
169
-
170
- .gallery-strip,
171
- .card-line {
172
- display: flex;
173
- flex-wrap: nowrap;
174
- justify-content: space-around;
175
- align-items: center;
176
- }
177
-
178
- .card-line {
179
- flex-grow: 2;
180
- }
181
-
182
- .progress-button {
183
- font-size: 1.5rem;
184
- font-weight: bold;
185
- }
186
-
187
- .bottom-spacer {
188
- min-height: 4rem;
189
- }
190
-
191
- .filler {
192
- flex-grow: 1;
193
- }
194
-
195
- .key-image-span.active {
196
- transform: scale(1.1);
197
- }
198
-
199
- a.prev:not(.underline),
200
- a.next:not(.underline) {
201
- text-decoration: none;
202
- }
203
-
204
- .disabled {
205
- opacity: 0.5;
206
- pointer-events: none;
207
- }
208
- </style>
1
+ <template>
2
+ <div ref="myButton" class="gallery">
3
+ <div class="gallery-strip">
4
+ <a href="#" :class="['oval', 'prev', { disabled: !isPrevPossible }]" @click.prevent="goPrev">
5
+ <span class="progress-button">&lsaquo;</span>
6
+ </a>
7
+ <div class="filler" />
8
+ <div class="card-line">
9
+ <span v-for="(item, index) in windowedItems" :key="'span_' + index" :class="['key-image-span', { active: isActive(index) }]">
10
+ <card v-if="item !== undefined" :key="'card_' + index" :entry="item" :width="cardWidth" :height="cardHeight" :show-card-details="showCardDetails" />
11
+ </span>
12
+ </div>
13
+ <div class="filler" />
14
+ <a href="#" :class="['oval', 'next', { disabled: !isNextPossible }]" @click.prevent="goNext">
15
+ <span class="progress-button">&rsaquo;</span>
16
+ </a>
17
+ </div>
18
+ <div v-if="canShowIndicatorBar" class="bottom-spacer" />
19
+ <index-indicator v-if="canShowIndicatorBar" :count="itemCount" :current="currentIndex" @clicked="indicatorClicked" />
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ import IndexIndicator from './IndexIndicator'
25
+ import Card from './Card'
26
+
27
+ function convertRemToPixels(rem) {
28
+ if (typeof window !== 'undefined') {
29
+ return rem * parseFloat(window.getComputedStyle(document.documentElement).fontSize)
30
+ }
31
+ return rem * 16
32
+ }
33
+
34
+ export default {
35
+ name: 'Gallery',
36
+ components: { IndexIndicator, Card },
37
+ props: {
38
+ items: {
39
+ type: Array,
40
+ default: () => {
41
+ return []
42
+ },
43
+ },
44
+ maxWidth: {
45
+ type: Number,
46
+ default: 3
47
+ },
48
+ cardWidth: {
49
+ type: Number,
50
+ default: 13.8,
51
+ },
52
+ showIndicatorBar: {
53
+ type: Boolean,
54
+ default: true,
55
+ },
56
+ highlightActive: {
57
+ type: Boolean,
58
+ default: true,
59
+ },
60
+ showCardDetails: {
61
+ type: Boolean,
62
+ default: true,
63
+ },
64
+ metaData: {
65
+ type: Object,
66
+ default: () => {
67
+ return {
68
+ datasetVersion: -1,
69
+ datasetId: -1,
70
+ }
71
+ },
72
+ },
73
+ description: {
74
+ type: String,
75
+ default: '',
76
+ },
77
+ },
78
+ data() {
79
+ return {
80
+ count: 0,
81
+ currentIndex: 0,
82
+ controlHeight: 2,
83
+ controlWidth: 2,
84
+ }
85
+ },
86
+ computed: {
87
+ itemCount() {
88
+ return this.items.length
89
+ },
90
+ isPrevPossible() {
91
+ return this.currentIndex > 0
92
+ },
93
+ isNextPossible() {
94
+ return this.currentIndex < this.itemCount - 1
95
+ },
96
+ cardHeight() {
97
+ return 0.78 * this.cardWidth
98
+ },
99
+ cardLineWidth() {
100
+ const cardSpacing = 0.25
101
+ return this.itemCount * (this.cardWidth + cardSpacing) - cardSpacing
102
+ },
103
+ numberOfItemsVisible() {
104
+ // The maximum width we are allowed minus two buttons for next and previous
105
+ // divided by the width of a card.
106
+ // const n = this.itemCount - 1
107
+ const cardSpacingPx = convertRemToPixels(0.5)
108
+ const buttonPx = convertRemToPixels(2)
109
+ const cardWidthPx = convertRemToPixels(this.cardWidth)
110
+ const cardItems = (this.maxWidth - 2 * buttonPx - 2 * cardSpacingPx) / (1.1 * cardWidthPx)
111
+ return Math.floor(cardItems)
112
+ },
113
+ canShowIndicatorBar() {
114
+ const indicatorWidth = convertRemToPixels(1)
115
+ const indicatorAllowance = this.maxWidth / (indicatorWidth * this.itemCount)
116
+ return this.showIndicatorBar && indicatorAllowance > 0.1
117
+ },
118
+ valueAdjustment() {
119
+ const halfWindow = Math.floor(this.numberOfItemsVisible / 2)
120
+ let valueAdjust = this.currentIndex - halfWindow
121
+ if (valueAdjust < 0) {
122
+ valueAdjust = 0
123
+ } else if (valueAdjust + this.numberOfItemsVisible > this.itemCount) {
124
+ valueAdjust = this.itemCount - this.numberOfItemsVisible
125
+ }
126
+
127
+ return valueAdjust
128
+ },
129
+ windowedItems() {
130
+ let myArray = []
131
+ for (let i = 0; i < this.numberOfItemsVisible; i++) {
132
+ myArray.push(this.items[i + this.valueAdjustment])
133
+ }
134
+ return myArray
135
+ },
136
+ },
137
+ methods: {
138
+ isActive(index) {
139
+ return this.currentIndex - this.valueAdjustment === index && this.highlightActive
140
+ },
141
+ goNext() {
142
+ this.currentIndex += 1
143
+ },
144
+ goPrev() {
145
+ this.currentIndex -= 1
146
+ },
147
+ indicatorClicked(index) {
148
+ if (this.currentIndex !== index) {
149
+ this.currentIndex = index
150
+ }
151
+ },
152
+ },
153
+ }
154
+ </script>
155
+
156
+ <style scoped>
157
+ .oval {
158
+ width: 2rem;
159
+ height: 2rem;
160
+ line-height: 2rem;
161
+ box-shadow: 0 0.125rem 0.25rem 0 rgba(0, 0, 0, 0.25);
162
+ border: solid 1px var(--pale-grey);
163
+ background-color: #ffffff;
164
+ border-radius: 1rem;
165
+ display: flex;
166
+ justify-content: center;
167
+ user-select: none;
168
+ }
169
+
170
+ .gallery-strip,
171
+ .card-line {
172
+ display: flex;
173
+ flex-wrap: nowrap;
174
+ justify-content: space-around;
175
+ align-items: center;
176
+ }
177
+
178
+ .card-line {
179
+ flex-grow: 2;
180
+ }
181
+
182
+ .progress-button {
183
+ font-size: 1.5rem;
184
+ font-weight: bold;
185
+ }
186
+
187
+ .bottom-spacer {
188
+ min-height: 4rem;
189
+ }
190
+
191
+ .filler {
192
+ flex-grow: 1;
193
+ }
194
+
195
+ .key-image-span.active {
196
+ transform: scale(1.1);
197
+ }
198
+
199
+ a.prev:not(.underline),
200
+ a.next:not(.underline) {
201
+ text-decoration: none;
202
+ }
203
+
204
+ .disabled {
205
+ opacity: 0.5;
206
+ pointer-events: none;
207
+ }
208
+ </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>
@@ -0,0 +1,39 @@
1
+ {
2
+ "size": 20,
3
+ "from": 0,
4
+ "query": {
5
+ "bool": {
6
+ "must": [ {
7
+ "match_phrase": {
8
+ "existing_ids.curie": {
9
+ "query": "UBERON:0000948"
10
+ }
11
+ }
12
+ } ]
13
+ }
14
+ }
15
+ }
16
+
17
+ {
18
+ "size": 20,
19
+ "from": 0,
20
+ "query": {
21
+ "bool": {
22
+ "must": [ {
23
+ "match_phrase": {
24
+ "label.aggregate": {
25
+ "query": "heart"
26
+ }
27
+ }
28
+ },
29
+ {
30
+ "term": {
31
+ "type": {
32
+ "value": "term"
33
+ }
34
+ }
35
+ } ]
36
+ }
37
+ },
38
+ "_source": ["label","existing_ids.curie"]
39
+ }
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')
@@ -1,12 +1,12 @@
1
- import { shallowMount } from '@vue/test-utils'
2
- import HelloWorld from '@/components/HelloWorld.vue'
3
-
4
- describe('HelloWorld.vue', () => {
5
- it('renders props.msg when passed', () => {
6
- const msg = 'new message'
7
- const wrapper = shallowMount(HelloWorld, {
8
- propsData: { msg },
9
- })
10
- expect(wrapper.text()).toMatch(msg)
11
- })
12
- })
1
+ import { shallowMount } from '@vue/test-utils'
2
+ import HelloWorld from '@/components/HelloWorld.vue'
3
+
4
+ describe('HelloWorld.vue', () => {
5
+ it('renders props.msg when passed', () => {
6
+ const msg = 'new message'
7
+ const wrapper = shallowMount(HelloWorld, {
8
+ propsData: { msg },
9
+ })
10
+ expect(wrapper.text()).toMatch(msg)
11
+ })
12
+ })
package/vue.config.js CHANGED
@@ -1,4 +1,4 @@
1
- // vue.config.js
2
- module.exports = {
3
- css: { extract: false },
4
- }
1
+ // vue.config.js
2
+ module.exports = {
3
+ css: { extract: false },
4
+ }