@thinkpixellab-public/px-vue 3.0.85 → 3.0.87
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.
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Automatically computes line clamp based on the available height and current line height.
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<component :is="tag" :class="bem()"
|
|
5
|
+
<component :is="tag" :class="bem()">
|
|
6
6
|
<span
|
|
7
|
+
v-if="enabled"
|
|
7
8
|
:class="bem('clamp')"
|
|
8
9
|
:style="{
|
|
9
10
|
'-webkit-line-clamp': lineCount,
|
|
@@ -15,6 +16,11 @@
|
|
|
15
16
|
{{ text }}
|
|
16
17
|
</slot>
|
|
17
18
|
</span>
|
|
19
|
+
<span v-else>
|
|
20
|
+
<slot>
|
|
21
|
+
{{ text }}
|
|
22
|
+
</slot>
|
|
23
|
+
</span>
|
|
18
24
|
</component>
|
|
19
25
|
</template>
|
|
20
26
|
|
|
@@ -25,6 +31,7 @@ export default {
|
|
|
25
31
|
name: 'px-auto-clamp',
|
|
26
32
|
mixins: [PxBaseResize],
|
|
27
33
|
props: {
|
|
34
|
+
enabled: { type: Boolean, default: true },
|
|
28
35
|
text: { type: String, default: null },
|
|
29
36
|
tag: { type: String, default: 'div' },
|
|
30
37
|
},
|
|
@@ -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,22 @@ export default {
|
|
|
17
17
|
return this.mediaQuery.currentBreakpoint;
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
+
|
|
21
|
+
methods: {
|
|
22
|
+
isBreakpointOrSmaller(breakpoint) {
|
|
23
|
+
if (this.currentBreakpoint === null) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (this.currentBreakpoint === breakpoint) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
this.mediaQuery.breakpoints[breakpoint] >=
|
|
33
|
+
this.mediaQuery.breakpoints[this.currentBreakpoint]
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
},
|
|
20
37
|
};
|
|
21
38
|
</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 =
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
variantValue() {
|
|
19
19
|
return (
|
|
20
20
|
(this.variantBase ? `${this.variantBase} ` : '') +
|
|
21
|
-
(this.variant !== 'default' ? this.variant : this.variantDefault)
|
|
21
|
+
(this.variant && this.variant !== 'default' ? this.variant : this.variantDefault)
|
|
22
22
|
);
|
|
23
23
|
},
|
|
24
24
|
},
|
package/package.json
CHANGED
package/utils/bem.js
CHANGED
|
@@ -32,7 +32,8 @@ function hyphenate(str, shouldHyphenate = true) {
|
|
|
32
32
|
// Get block name
|
|
33
33
|
function getBlockName(component) {
|
|
34
34
|
if (!component.$options._blockName) {
|
|
35
|
-
let block = component
|
|
35
|
+
let block = 'bemBlockName' in component && component.bemBlockName();
|
|
36
|
+
block = block || component.$options.name || component.$options._componentTag;
|
|
36
37
|
if (block && block.indexOf('/') > -1) {
|
|
37
38
|
block = block.split('/').pop().split('.')[0];
|
|
38
39
|
}
|