@thinkpixellab-public/px-vue 3.0.85 → 3.0.86

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.
@@ -6,7 +6,7 @@
6
6
  export default {
7
7
  inject: {
8
8
  mediaQuery: {
9
- default: { isMobile: null, currentBreakpoint: null },
9
+ default: { isMobile: null, currentBreakpoint: null, breakpoints: {} },
10
10
  },
11
11
  },
12
12
  computed: {
@@ -17,5 +17,26 @@ export default {
17
17
  return this.mediaQuery.currentBreakpoint;
18
18
  },
19
19
  },
20
+ mounted() {
21
+ // setTimeout(() => {
22
+ // console.log(this.mediaQuery.breakpoints);
23
+ // }, 100);
24
+ },
25
+ methods: {
26
+ isBreakpointOrSmaller(breakpoint) {
27
+ if (this.currentBreakpoint === null) {
28
+ return false;
29
+ }
30
+
31
+ if (this.currentBreakpoint === breakpoint) {
32
+ return true;
33
+ }
34
+
35
+ return (
36
+ this.mediaQuery.breakpoints[breakpoint] >=
37
+ this.mediaQuery.breakpoints[this.currentBreakpoint]
38
+ );
39
+ },
40
+ },
20
41
  };
21
42
  </script>
@@ -21,9 +21,38 @@ export default {
21
21
  },
22
22
  mixins: [PxBaseResize],
23
23
  data() {
24
- return { mediaQuery: { isMobile: null, currentBreakpoint: null } };
24
+ return { mediaQuery: { isMobile: null, currentBreakpoint: null, breakpoints: {} } };
25
25
  },
26
+ mounted() {
27
+ const breakpointNames = getComputedStyle(document.documentElement)
28
+ .getPropertyValue('--breakpoint-names')
29
+ .trim()
30
+ .split(' ');
26
31
 
32
+ const breakpointSizes = getComputedStyle(document.documentElement)
33
+ .getPropertyValue('--breakpoint-sizes')
34
+ .trim()
35
+ .split(' ');
36
+
37
+ if (breakpointNames.length !== breakpointSizes.length) {
38
+ console.warn('Breakpoint names and sizes do not match');
39
+ return;
40
+ }
41
+
42
+ try {
43
+ this.mediaQuery.breakpoints = Object.fromEntries(
44
+ breakpointNames
45
+ .map((name, index) => {
46
+ return [name, parseInt(breakpointSizes[index])];
47
+ })
48
+ .sort((a, b) => a[1] - b[1])
49
+ );
50
+ } catch {
51
+ console.warn(
52
+ 'Could not parse breakpoint sizes. Check the format of the breakpoint-sizes variable in the theme file.'
53
+ );
54
+ }
55
+ },
27
56
  methods: {
28
57
  updateMediaQuery() {
29
58
  this.mediaQuery.isMobile =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.85",
3
+ "version": "3.0.86",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",