@thinkpixellab-public/px-vue 3.0.33 → 3.0.34
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.
- package/package.json +1 -1
- package/plugins/common.js +11 -1
- package/utils/cssStr.js +26 -1
package/package.json
CHANGED
package/plugins/common.js
CHANGED
|
@@ -5,7 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import bem from '../utils/bem';
|
|
7
7
|
import isServer from '../utils/isServer.js';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
cssPx,
|
|
10
|
+
cssEm,
|
|
11
|
+
cssPcnt,
|
|
12
|
+
cssUrl,
|
|
13
|
+
cssVar,
|
|
14
|
+
cssUnitFallback,
|
|
15
|
+
cssEmFallback,
|
|
16
|
+
} from '../utils/cssStr.js';
|
|
9
17
|
import aspect from './filters/aspect.js';
|
|
10
18
|
import kebab from './filters/kebab.js';
|
|
11
19
|
import slug from './filters/slug.js';
|
|
@@ -22,6 +30,8 @@ export default {
|
|
|
22
30
|
Vue.prototype.cssPcnt = cssPcnt;
|
|
23
31
|
Vue.prototype.cssUrl = cssUrl;
|
|
24
32
|
Vue.prototype.cssVar = cssVar;
|
|
33
|
+
Vue.prototype.cssUnitFallback = cssUnitFallback;
|
|
34
|
+
Vue.prototype.cssEmFallback = cssEmFallback;
|
|
25
35
|
|
|
26
36
|
// filters
|
|
27
37
|
// note: filters can be called as methods with something like
|
package/utils/cssStr.js
CHANGED
|
@@ -58,4 +58,29 @@ function cssVar(val) {
|
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
/*
|
|
62
|
+
Add the specified unit if no other unit is specified.
|
|
63
|
+
|
|
64
|
+
cssUnitFallback('10px', 'em) => '10px'
|
|
65
|
+
cssUnitFallback('10', 'em') => '10em'
|
|
66
|
+
cssUnitFallback(10, 'em') => '10em'
|
|
67
|
+
*/
|
|
68
|
+
function cssUnitFallback(val, fallback) {
|
|
69
|
+
if (!val) {
|
|
70
|
+
return val;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
val = val.toString().trim();
|
|
74
|
+
const num = typeof val == 'number' ? val : parseFloat(val.toString().trim());
|
|
75
|
+
const unit = val.replace(/[0-9]/g, '').trim() || fallback;
|
|
76
|
+
return `${num}${unit}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
Ems version of cssUnitFallback
|
|
81
|
+
*/
|
|
82
|
+
function cssEmFallback(val) {
|
|
83
|
+
return cssUnitFallback(val, 'em');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { cssPx, cssEm, cssPcnt, cssUrl, cssVar, cssUnitFallback, cssEmFallback };
|