@thinkpixellab-public/px-vue 3.0.21 → 3.0.22

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.
@@ -0,0 +1,126 @@
1
+ <!--
2
+ Creates a horizontally scrolling container with an invisible scrollbar and arrows on either side
3
+ to scroll to the beginning or end of the container.
4
+
5
+ <px-arrow-scroller :arrow-start-src="require(...)" :arrow-end-src="require(...)">
6
+ ...
7
+ </px-arrow-scroller>
8
+
9
+ -->
10
+ <template>
11
+ <div :class="bem()">
12
+ <px-icon-button
13
+ :class="[bem('arrow', { start: true, visible: arrowStartVisible }), arrowClass]"
14
+ :src="arrowStartSrc"
15
+ size="0.8em"
16
+ @click="scrollTo(0)"
17
+ />
18
+
19
+ <div :class="bem('scroller')" ref="scroller" @scroll="updateScrollArrows">
20
+ <slot />
21
+ </div>
22
+
23
+ <px-icon-button
24
+ :class="[bem('arrow', { end: true, visible: arrowEndVisible }), arrowClass]"
25
+ :src="arrowEndSrc"
26
+ size="0.8em"
27
+ @click="scrollTo(100000)"
28
+ />
29
+ </div>
30
+ </template>
31
+
32
+ <script>
33
+ // import { mapState } from 'vuex';
34
+ // import Component from '~/components/Component.vue';
35
+ // import Mixin from '~/components/Mixin.vue';
36
+ import PxBaseResize from './PxBaseResize.vue';
37
+ import PxIconButton from '@thinkpixellab-public/px-vue/components/PxIconButton.vue';
38
+
39
+ export default {
40
+ name: 'px-arrow-scroller',
41
+ components: { PxIconButton },
42
+ mixins: [PxBaseResize, PxIconButton],
43
+ props: {
44
+ arrowStartSrc: { type: String, default: null },
45
+ arrowEndSrc: { type: String, default: null },
46
+ arrowClass: { type: String, default: null },
47
+ },
48
+ data() {
49
+ return {
50
+ arrowsVisible: false,
51
+ arrowStartVisible: false,
52
+ arrowEndVisible: false,
53
+ };
54
+ },
55
+ // computed: {},
56
+ // watch: {},
57
+ // mounted() {},
58
+ methods: {
59
+ resize() {
60
+ this.updateScrollArrows();
61
+ },
62
+ updateScrollArrows() {
63
+ const scroller = this.$refs.scroller;
64
+
65
+ if (!scroller) {
66
+ return;
67
+ }
68
+
69
+ const fromStart = scroller.scrollLeft;
70
+ const fromEnd = scroller.scrollWidth - scroller.scrollLeft - scroller.clientWidth;
71
+
72
+ this.arrowsVisible = scroller.clientWidth > scroller.scrollWidth;
73
+ this.arrowStartVisible = fromStart > 2;
74
+ this.arrowEndVisible = fromEnd > 2;
75
+ },
76
+
77
+ scrollTo(x) {
78
+ if (this.$refs.scroller) {
79
+ this.$refs.scroller.scrollTo({
80
+ left: x,
81
+ behavior: 'smooth',
82
+ });
83
+ }
84
+ },
85
+ },
86
+ };
87
+ </script>
88
+
89
+ <style lang="scss">
90
+ @use '../styles/px.scss' as *;
91
+
92
+ .px-arrow-scroller {
93
+ // prettier-ignore
94
+ @include grid-art((
95
+ 'auto | 1fr | auto |',
96
+ 'arrow-start | scroller | arrow-end | auto'
97
+ ));
98
+
99
+ &__arrow {
100
+ padding: 0.1em 1em 0.25em;
101
+
102
+ &--start {
103
+ grid-area: arrow-start;
104
+ }
105
+
106
+ &--end {
107
+ grid-area: arrow-end;
108
+ }
109
+
110
+ @include transition(opacity, $dur: 200ms);
111
+ opacity: 0;
112
+ pointer-events: none;
113
+
114
+ &--visible {
115
+ opacity: 1;
116
+ pointer-events: visible;
117
+ }
118
+ }
119
+
120
+ &__scroller {
121
+ grid-area: scroller;
122
+ overflow-x: auto;
123
+ @include invisible-scrollbar;
124
+ }
125
+ }
126
+ </style>
@@ -68,7 +68,6 @@ export default {
68
68
  </script>
69
69
 
70
70
  <style lang="scss">
71
- @import '@/styles/include.scss';
72
71
  .px-qr-code {
73
72
  aspect-ratio: 1;
74
73
  width: 256px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.21",
3
+ "version": "3.0.22",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",