@thinkpixellab-public/px-vue 3.0.71 → 3.0.72

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,20 @@ export default {
112
114
  });
113
115
  }
114
116
  },
117
+
118
+ scrollToElement(el) {
119
+ if (this.$refs.scroller) {
120
+ console.log(`el.offsetLeft: ${el.offsetLeft}`);
121
+
122
+ //const left = el.offsetLeft - this.$refs.scroller.offsetWidth;
123
+ const left = el.offsetLeft - this.$refs.scroller.offsetWidth / 2;
124
+
125
+ this.$refs.scroller.scrollTo({
126
+ left: left,
127
+ behavior: 'smooth',
128
+ });
129
+ }
130
+ },
115
131
  },
116
132
  };
117
133
  </script>
@@ -122,10 +138,13 @@ export default {
122
138
  .px-arrow-scroller {
123
139
  // prettier-ignore
124
140
  @include grid-art((
125
- 'auto | 1fr | auto |',
141
+ 'auto | 1fr | auto |',
126
142
  'arrow-start | scroller | arrow-end | auto'
127
143
  ));
128
144
 
145
+ align-items: center;
146
+ align-content: center;
147
+
129
148
  &__button {
130
149
  position: relative;
131
150
  align-self: center;
@@ -150,13 +169,19 @@ export default {
150
169
  .px-arrow-scroller__arrow-icon {
151
170
  @include button-icon(
152
171
  (
153
- padding: 0.1em 1em 0.25em,
172
+ padding: 0.1em 1em,
154
173
  cursor: pointer,
155
- display: block,
156
- alignItems: center,
157
- min-height: null,
174
+ display: flex,
175
+ align-items: center,
176
+ justify-content: center,
158
177
  )
159
178
  );
179
+
180
+ @include media-until-mobile {
181
+ min-width: 1em;
182
+ padding-left: 0;
183
+ padding-right: 0;
184
+ }
160
185
  }
161
186
  }
162
187
 
@@ -1,78 +1,20 @@
1
1
  <!--
2
- Use for global mobile awareness in javascript. This doesn't actually handle mobile detection
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
- data() {
56
- return { isMobile: null };
57
- },
58
- mounted() {
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
- methods: {
71
- setGlobalIsMobile(isMobile) {
72
- if (this.$globalEmit) {
73
- this.$globalEmit('mobile-changed', isMobile);
74
- this.isMobile = isMobile;
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.71",
3
+ "version": "3.0.72",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",