@thinkpixellab-public/px-vue 3.0.71 → 3.0.73
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.
|
@@ -17,14 +17,14 @@ ar
|
|
|
17
17
|
<template>
|
|
18
18
|
<div :class="bem()">
|
|
19
19
|
<button
|
|
20
|
-
v-if="!disabled"
|
|
20
|
+
v-if="!disabled && !arrowsHidden"
|
|
21
21
|
:class="[bem('button', { start: true, visible: arrowStartVisible }), buttonClass]"
|
|
22
22
|
@click="scrollPages(-1)"
|
|
23
23
|
aria-label="Scroll to previous"
|
|
24
24
|
:disabled="!arrowStartVisible"
|
|
25
25
|
>
|
|
26
26
|
<slot name="button" :location="'start'">
|
|
27
|
-
<span :class="bem('arrow-icon')">
|
|
27
|
+
<span :class="[bem('arrow-icon'), iconClass]">
|
|
28
28
|
<px-icon :src="arrowStartSrc" size="0.8em" />
|
|
29
29
|
</span>
|
|
30
30
|
</slot>
|
|
@@ -35,14 +35,14 @@ ar
|
|
|
35
35
|
</div>
|
|
36
36
|
|
|
37
37
|
<button
|
|
38
|
-
v-if="!disabled"
|
|
38
|
+
v-if="!disabled && !arrowsHidden"
|
|
39
39
|
:class="[bem('button', { end: true, visible: arrowEndVisible }), buttonClass]"
|
|
40
40
|
@click="scrollPages(1)"
|
|
41
41
|
aria-label="Scroll to next"
|
|
42
42
|
:disabled="!arrowEndVisible"
|
|
43
43
|
>
|
|
44
44
|
<slot name="button" :location="'end'">
|
|
45
|
-
<span :class="bem('arrow-icon')">
|
|
45
|
+
<span :class="[bem('arrow-icon'), iconClass]">
|
|
46
46
|
<px-icon :src="arrowEndSrc" size="0.8em" />
|
|
47
47
|
</span>
|
|
48
48
|
</slot>
|
|
@@ -65,7 +65,9 @@ export default {
|
|
|
65
65
|
arrowStartSrc: { type: String, default: require('../assets/icons/nav-prev.svg') },
|
|
66
66
|
arrowEndSrc: { type: String, default: require('../assets/icons/nav-next.svg') },
|
|
67
67
|
buttonClass: { type: String, default: null },
|
|
68
|
+
iconClass: { type: String, default: null },
|
|
68
69
|
disabled: { type: Boolean, default: false },
|
|
70
|
+
arrowsHidden: { type: Boolean, default: false },
|
|
69
71
|
},
|
|
70
72
|
data() {
|
|
71
73
|
return {
|
|
@@ -112,6 +114,16 @@ export default {
|
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
116
|
},
|
|
117
|
+
|
|
118
|
+
scrollToElement(el) {
|
|
119
|
+
if (this.$refs.scroller) {
|
|
120
|
+
const left = el.offsetLeft - this.$refs.scroller.offsetWidth / 2;
|
|
121
|
+
this.$refs.scroller.scrollTo({
|
|
122
|
+
left: left,
|
|
123
|
+
behavior: 'smooth',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
},
|
|
115
127
|
},
|
|
116
128
|
};
|
|
117
129
|
</script>
|
|
@@ -122,10 +134,13 @@ export default {
|
|
|
122
134
|
.px-arrow-scroller {
|
|
123
135
|
// prettier-ignore
|
|
124
136
|
@include grid-art((
|
|
125
|
-
'auto
|
|
137
|
+
'auto | 1fr | auto |',
|
|
126
138
|
'arrow-start | scroller | arrow-end | auto'
|
|
127
139
|
));
|
|
128
140
|
|
|
141
|
+
align-items: center;
|
|
142
|
+
align-content: center;
|
|
143
|
+
|
|
129
144
|
&__button {
|
|
130
145
|
position: relative;
|
|
131
146
|
align-self: center;
|
|
@@ -150,13 +165,19 @@ export default {
|
|
|
150
165
|
.px-arrow-scroller__arrow-icon {
|
|
151
166
|
@include button-icon(
|
|
152
167
|
(
|
|
153
|
-
padding: 0.1em 1em
|
|
168
|
+
padding: 0.1em 1em,
|
|
154
169
|
cursor: pointer,
|
|
155
|
-
display:
|
|
156
|
-
|
|
157
|
-
|
|
170
|
+
display: flex,
|
|
171
|
+
align-items: center,
|
|
172
|
+
justify-content: center,
|
|
158
173
|
)
|
|
159
174
|
);
|
|
175
|
+
|
|
176
|
+
@include media-until-mobile {
|
|
177
|
+
min-width: 1em;
|
|
178
|
+
padding-left: 0;
|
|
179
|
+
padding-right: 0;
|
|
180
|
+
}
|
|
160
181
|
}
|
|
161
182
|
}
|
|
162
183
|
|
|
@@ -1,78 +1,20 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
|
|
3
|
-
but provides a consistent interface for communicating between a single component that does
|
|
4
|
-
the detection and other components that subscribe to an eventbus and update a property called
|
|
5
|
-
isMobile.
|
|
6
|
-
|
|
7
|
-
Sample usage using a css variable for detecting mobile (this keeps css and js in sync):
|
|
8
|
-
|
|
9
|
-
### MyLayout.vue (or other global component)
|
|
10
|
-
|
|
11
|
-
// add PxBaseMobileAware as a mixin
|
|
12
|
-
import PxBaseMobileAware from '@thinkpixellab-public/px-vue/components/PxBaseMobileAware.vue';
|
|
13
|
-
mixins: [PxBaseMobileAware],
|
|
14
|
-
|
|
15
|
-
// add a resize handler and call setGlobalIsMobile
|
|
16
|
-
resize() {
|
|
17
|
-
if (this.$el) {
|
|
18
|
-
const cssMobile = getComputedStyle(this.$el).getPropertyValue('--is-mobile');
|
|
19
|
-
this.setGlobalIsMobile(cssMobile.toLowerCase().trim() == 'true');
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
// add a css variable that changes with the viewport
|
|
24
|
-
|
|
25
|
-
.my-layout {
|
|
26
|
-
--is-mobile: false;
|
|
27
|
-
@include media-until-mobile() {
|
|
28
|
-
--is-mobile: true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
### MyComponent.vue
|
|
33
|
-
|
|
34
|
-
// use PxBaseMobileAware as a mixin
|
|
35
|
-
import PxBaseMobileAware from '@thinkpixellab-public/px-vue/components/PxBaseMobileAware.vue';
|
|
36
|
-
mixins: [PxBaseMobileAware]
|
|
37
|
-
|
|
38
|
-
// use the isMobile property as needed in a template
|
|
39
|
-
<div> This is mobile: {{isMobile ? 'yup' : 'nope' }} </div>
|
|
40
|
-
|
|
41
|
-
// or in code
|
|
42
|
-
watch: {
|
|
43
|
-
isMobile(nv) {
|
|
44
|
-
// do something when isMobile changes
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
Must be used in conjuction with PxBaseMobileProvide. See notes in that file for details.
|
|
49
3
|
-->
|
|
50
4
|
|
|
51
5
|
<script>
|
|
52
|
-
import utils from '../utils/utils.js';
|
|
53
|
-
|
|
54
6
|
export default {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (utils.getQueryBool('alwaysMobile')) {
|
|
60
|
-
this.isMobile = true;
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (this.$globalOn) {
|
|
65
|
-
this.$globalOn('mobile-changed', isMobile => {
|
|
66
|
-
this.isMobile = isMobile;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
7
|
+
inject: {
|
|
8
|
+
mediaQuery: {
|
|
9
|
+
default: { isMobile: null, currentBreakpoint: null },
|
|
10
|
+
},
|
|
69
11
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
12
|
+
computed: {
|
|
13
|
+
isMobile() {
|
|
14
|
+
return this.mediaQuery.isMobile;
|
|
15
|
+
},
|
|
16
|
+
currentBreakpoint() {
|
|
17
|
+
return this.mediaQuery.currentBreakpoint;
|
|
76
18
|
},
|
|
77
19
|
},
|
|
78
20
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
Use for global mobile / media query awareness in javascript. Provides values for isMobile and
|
|
4
|
+
currentBreakpoint that can be used in any component.
|
|
5
|
+
|
|
6
|
+
Use this in parent component or layout to provide the values to child components. Use
|
|
7
|
+
PxBaseMobileAware in child components to inject the values.
|
|
8
|
+
|
|
9
|
+
In many cases you can just add this as a mixin but if that component also has a resize method
|
|
10
|
+
then be sure to call this.updateMediaQuery() from the resize method.
|
|
11
|
+
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import PxBaseResize from './PxBaseResize.vue';
|
|
16
|
+
export default {
|
|
17
|
+
provide() {
|
|
18
|
+
return {
|
|
19
|
+
mediaQuery: this.mediaQuery,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
mixins: [PxBaseResize],
|
|
23
|
+
data() {
|
|
24
|
+
return { mediaQuery: { isMobile: null, currentBreakpoint: null } };
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
methods: {
|
|
28
|
+
updateMediaQuery() {
|
|
29
|
+
this.mediaQuery.isMobile =
|
|
30
|
+
getComputedStyle(document.documentElement).getPropertyValue('--is-mobile').trim() ==
|
|
31
|
+
'true';
|
|
32
|
+
|
|
33
|
+
this.mediaQuery.currentBreakpoint = getComputedStyle(document.documentElement)
|
|
34
|
+
.getPropertyValue('--breakpoint')
|
|
35
|
+
.trim();
|
|
36
|
+
},
|
|
37
|
+
resize() {
|
|
38
|
+
this.updateMediaQuery();
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style lang="scss">
|
|
45
|
+
@use '@/px-styles.config.scss' as *;
|
|
46
|
+
@use '@thinkpixellab/px-edge-shared/styles/px-styles-fluent.scss' as fluent;
|
|
47
|
+
@include fluent.fluent() {
|
|
48
|
+
@include media-breakpoint-vars;
|
|
49
|
+
}
|
|
50
|
+
</style>
|