@thinkpixellab-public/px-vue 4.0.25 → 4.0.26
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/components/PxBalancedText.vue +14 -1
- package/components/PxCardGrid.vue +2 -7
- package/package.json +1 -1
- package/utils/textWidth.js +11 -1
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<component
|
|
12
12
|
v-if="hasHtml"
|
|
13
13
|
:class="[bem('inner', { html: true }), innerClass]"
|
|
14
|
+
:style="innerStyle"
|
|
14
15
|
:is="calcInnerTag"
|
|
15
16
|
ref="text"
|
|
16
17
|
v-html="html"
|
|
@@ -47,8 +48,16 @@ export default {
|
|
|
47
48
|
*/
|
|
48
49
|
innerTag: { type: String, default: null },
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Class applied to the inner element.
|
|
53
|
+
*/
|
|
51
54
|
innerClass: { type: String, default: null },
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Style applied to the inner element.
|
|
58
|
+
*/
|
|
59
|
+
innerStyle: { type: [String, Object], default: null },
|
|
60
|
+
|
|
52
61
|
/**
|
|
53
62
|
* Html that gets set on the inner tag element
|
|
54
63
|
*/
|
|
@@ -131,6 +140,7 @@ export default {
|
|
|
131
140
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
132
141
|
},
|
|
133
142
|
isHeadless() {
|
|
143
|
+
// TODO: replace with isUnderTest
|
|
134
144
|
if (isServer()) {
|
|
135
145
|
return false;
|
|
136
146
|
}
|
|
@@ -182,6 +192,9 @@ export default {
|
|
|
182
192
|
}
|
|
183
193
|
}
|
|
184
194
|
},
|
|
195
|
+
getInnerTextRef() {
|
|
196
|
+
return this.$refs.text;
|
|
197
|
+
},
|
|
185
198
|
},
|
|
186
199
|
};
|
|
187
200
|
</script>
|
|
@@ -137,6 +137,7 @@ You can define a template using space notation like this:
|
|
|
137
137
|
<script>
|
|
138
138
|
import aspect from '../plugins/filters/aspect.js';
|
|
139
139
|
import PxBaseItems from '../bases/PxBaseItems.vue';
|
|
140
|
+
import PxBaseResize from '../bases/PxBaseResize.vue';
|
|
140
141
|
|
|
141
142
|
// prettier-ignore
|
|
142
143
|
const defaultTemplates = {
|
|
@@ -193,7 +194,7 @@ const cardCountInRowTemplate = rowTemplate => {
|
|
|
193
194
|
|
|
194
195
|
export default {
|
|
195
196
|
name: 'px-card-grid',
|
|
196
|
-
mixins: [PxBaseItems],
|
|
197
|
+
mixins: [PxBaseResize, PxBaseItems],
|
|
197
198
|
props: {
|
|
198
199
|
templates: { type: Object, default: () => defaultTemplates },
|
|
199
200
|
maxColumns: { type: Number, default: 6 },
|
|
@@ -327,12 +328,6 @@ export default {
|
|
|
327
328
|
},
|
|
328
329
|
},
|
|
329
330
|
mounted() {
|
|
330
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
331
|
-
this.resize();
|
|
332
|
-
});
|
|
333
|
-
this.resizeObserver.observe(this.$el);
|
|
334
|
-
|
|
335
|
-
this.resize();
|
|
336
331
|
this.updateRowTemplates();
|
|
337
332
|
},
|
|
338
333
|
beforeDestroy() {
|
package/package.json
CHANGED
package/utils/textWidth.js
CHANGED
|
@@ -27,11 +27,21 @@ const getCssProp = (element, prop) => {
|
|
|
27
27
|
return window.getComputedStyle(element, null).getPropertyValue(prop);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const getFontFromElement = element => {
|
|
30
|
+
const getFontFromElement = (element, asObject = false) => {
|
|
31
31
|
const fontWeight = getCssProp(element, 'font-weight') || 'normal';
|
|
32
32
|
const fontSize = getCssProp(element, 'font-size') || '16px';
|
|
33
33
|
const fontFamily = getCssProp(element, 'font-family') || 'sans-serif';
|
|
34
34
|
|
|
35
|
+
if (asObject) {
|
|
36
|
+
const lineHeight = getCssProp(element, 'line-height') || 1.2;
|
|
37
|
+
return {
|
|
38
|
+
fontWeight,
|
|
39
|
+
fontSize,
|
|
40
|
+
fontFamily,
|
|
41
|
+
lineHeight,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
return `${fontWeight} ${fontSize} ${fontFamily}`;
|
|
36
46
|
};
|
|
37
47
|
|