@thinkpixellab-public/px-vue 3.0.22 → 3.0.24
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.
|
@@ -3,29 +3,48 @@
|
|
|
3
3
|
to scroll to the beginning or end of the container.
|
|
4
4
|
|
|
5
5
|
<px-arrow-scroller :arrow-start-src="require(...)" :arrow-end-src="require(...)">
|
|
6
|
+
|
|
7
|
+
<template #button>
|
|
8
|
+
// this can look like a button but it will ultimately be wrapped by a button
|
|
9
|
+
// element so it should probably be a span
|
|
10
|
+
</template>
|
|
6
11
|
...
|
|
7
12
|
</px-arrow-scroller>
|
|
13
|
+
ar
|
|
14
|
+
|
|
8
15
|
|
|
9
16
|
-->
|
|
10
17
|
<template>
|
|
11
18
|
<div :class="bem()">
|
|
12
|
-
<
|
|
13
|
-
:class="[bem('
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
<button
|
|
20
|
+
:class="[bem('button', { start: true, visible: arrowStartVisible }), buttonClass]"
|
|
21
|
+
@click="scrollPages(-1)"
|
|
22
|
+
aria-label="Scroll to previous"
|
|
23
|
+
:disabled="!arrowStartVisible"
|
|
24
|
+
>
|
|
25
|
+
<slot name="button" :location="'start'">
|
|
26
|
+
<span :class="bem('arrow-icon')">
|
|
27
|
+
<px-icon :src="arrowStartSrc" size="0.8em" />
|
|
28
|
+
</span>
|
|
29
|
+
</slot>
|
|
30
|
+
</button>
|
|
18
31
|
|
|
19
32
|
<div :class="bem('scroller')" ref="scroller" @scroll="updateScrollArrows">
|
|
20
33
|
<slot />
|
|
21
34
|
</div>
|
|
22
35
|
|
|
23
|
-
<
|
|
24
|
-
:class="[bem('
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
<button
|
|
37
|
+
:class="[bem('button', { end: true, visible: arrowEndVisible }), buttonClass]"
|
|
38
|
+
@click="scrollPages(1)"
|
|
39
|
+
aria-label="Scroll to next"
|
|
40
|
+
:disabled="!arrowEndVisible"
|
|
41
|
+
>
|
|
42
|
+
<slot name="button" :location="'end'">
|
|
43
|
+
<span :class="bem('arrow-icon')">
|
|
44
|
+
<px-icon :src="arrowEndSrc" size="0.8em" />
|
|
45
|
+
</span>
|
|
46
|
+
</slot>
|
|
47
|
+
</button>
|
|
29
48
|
</div>
|
|
30
49
|
</template>
|
|
31
50
|
|
|
@@ -34,16 +53,16 @@
|
|
|
34
53
|
// import Component from '~/components/Component.vue';
|
|
35
54
|
// import Mixin from '~/components/Mixin.vue';
|
|
36
55
|
import PxBaseResize from './PxBaseResize.vue';
|
|
37
|
-
import
|
|
56
|
+
import PxIcon from '@thinkpixellab-public/px-vue/components/PxIcon.vue';
|
|
38
57
|
|
|
39
58
|
export default {
|
|
40
59
|
name: 'px-arrow-scroller',
|
|
41
|
-
components: {
|
|
42
|
-
mixins: [PxBaseResize,
|
|
60
|
+
components: { PxIcon },
|
|
61
|
+
mixins: [PxBaseResize, PxIcon],
|
|
43
62
|
props: {
|
|
44
|
-
arrowStartSrc: { type: String, default:
|
|
45
|
-
arrowEndSrc: { type: String, default:
|
|
46
|
-
|
|
63
|
+
arrowStartSrc: { type: String, default: require('../assets/icons/nav-prev.svg') },
|
|
64
|
+
arrowEndSrc: { type: String, default: require('../assets/icons/nav-next.svg') },
|
|
65
|
+
buttonClass: { type: String, default: null },
|
|
47
66
|
},
|
|
48
67
|
data() {
|
|
49
68
|
return {
|
|
@@ -74,6 +93,14 @@ export default {
|
|
|
74
93
|
this.arrowEndVisible = fromEnd > 2;
|
|
75
94
|
},
|
|
76
95
|
|
|
96
|
+
scrollPages(pageCount) {
|
|
97
|
+
if (this.$refs.scroller) {
|
|
98
|
+
let pageSize = this.$refs.scroller.offsetWidth;
|
|
99
|
+
let scrollX = Math.max(0, this.$refs.scroller.scrollLeft + pageSize * pageCount);
|
|
100
|
+
this.scrollTo(scrollX);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
|
|
77
104
|
scrollTo(x) {
|
|
78
105
|
if (this.$refs.scroller) {
|
|
79
106
|
this.$refs.scroller.scrollTo({
|
|
@@ -96,8 +123,9 @@ export default {
|
|
|
96
123
|
'arrow-start | scroller | arrow-end | auto'
|
|
97
124
|
));
|
|
98
125
|
|
|
99
|
-
&
|
|
100
|
-
|
|
126
|
+
&__button {
|
|
127
|
+
position: relative;
|
|
128
|
+
align-self: center;
|
|
101
129
|
|
|
102
130
|
&--start {
|
|
103
131
|
grid-area: arrow-start;
|
|
@@ -115,6 +143,18 @@ export default {
|
|
|
115
143
|
opacity: 1;
|
|
116
144
|
pointer-events: visible;
|
|
117
145
|
}
|
|
146
|
+
|
|
147
|
+
.px-arrow-scroller__arrow-icon {
|
|
148
|
+
@include button-icon(
|
|
149
|
+
(
|
|
150
|
+
padding: 0.1em 1em 0.25em,
|
|
151
|
+
cursor: pointer,
|
|
152
|
+
display: block,
|
|
153
|
+
alignItems: center,
|
|
154
|
+
min-height: null,
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
}
|
|
118
158
|
}
|
|
119
159
|
|
|
120
160
|
&__scroller {
|
|
@@ -202,6 +202,7 @@ export default {
|
|
|
202
202
|
debug: { type: Boolean, default: false },
|
|
203
203
|
getItemCountFn: { default: null },
|
|
204
204
|
getItemFn: { default: null },
|
|
205
|
+
centerSingleRow: { type: Boolean, default: true },
|
|
205
206
|
},
|
|
206
207
|
|
|
207
208
|
data() {
|
|
@@ -212,14 +213,23 @@ export default {
|
|
|
212
213
|
},
|
|
213
214
|
computed: {
|
|
214
215
|
gridStyle() {
|
|
216
|
+
let rowCount = this.rows?.length || 0;
|
|
217
|
+
let colCount = this.columnCount;
|
|
218
|
+
|
|
219
|
+
if (this.centerSingleRow && rowCount == 1) {
|
|
220
|
+
colCount = 0;
|
|
221
|
+
this.rows[0].forEach(sp => {
|
|
222
|
+
colCount += sp.name == 'wide' ? 2 : 1;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
215
226
|
const defAspect = aspect(this.cardAspect);
|
|
216
227
|
const wideAspect = (this.cardMinWidth * 2 + this.gap) / (this.cardMinWidth / defAspect);
|
|
217
|
-
const maxGridWidth =
|
|
218
|
-
this.cardMaxWidth * this.columnCount + this.gap * (this.columnCount - 1);
|
|
228
|
+
const maxGridWidth = this.cardMaxWidth * colCount + this.gap * (this.columnCount - 1);
|
|
219
229
|
|
|
220
230
|
return {
|
|
221
231
|
// prettier-ignore
|
|
222
|
-
gridTemplateColumns: `repeat(${
|
|
232
|
+
gridTemplateColumns: `repeat(${colCount}, 1fr)`,
|
|
223
233
|
maxWidth: this.cssPx(maxGridWidth),
|
|
224
234
|
'--gap': this.cssPx(this.gap),
|
|
225
235
|
'--aspect': defAspect,
|
package/components/PxVueTest.vue
CHANGED
|
@@ -664,9 +664,7 @@ export default {
|
|
|
664
664
|
},
|
|
665
665
|
},
|
|
666
666
|
methods: {
|
|
667
|
-
toggleButtonChange(nv) {
|
|
668
|
-
console.log(`selectedKeys: 👉 ${JSON.stringify(nv, null, 4)}`);
|
|
669
|
-
},
|
|
667
|
+
toggleButtonChange(nv) {},
|
|
670
668
|
onValidChanged(isValid, id) {
|
|
671
669
|
this.$set(this.validation, id, isValid);
|
|
672
670
|
},
|
package/package.json
CHANGED
package/utils/utils.js
CHANGED
|
@@ -81,6 +81,25 @@ export default {
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Breaks an array into "chunks" of n items. Returns an array of arrays.
|
|
86
|
+
* @param {} arr The array
|
|
87
|
+
* @param {} size The number of items in each chunk
|
|
88
|
+
*/
|
|
89
|
+
arrayChunk: function (arr, size) {
|
|
90
|
+
if (!arr || arr.length == 0) {
|
|
91
|
+
return [[]];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const chunks = [];
|
|
95
|
+
|
|
96
|
+
for (let i = 0; i < arr.length; i += size) {
|
|
97
|
+
chunks.push(arr.slice(i, i + size));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return chunks;
|
|
101
|
+
},
|
|
102
|
+
|
|
84
103
|
/**
|
|
85
104
|
* Returns an object representing the current query string parameters.
|
|
86
105
|
*/
|