@thinkpixellab-public/px-vue 4.0.25 → 4.0.27
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.
|
@@ -11,13 +11,20 @@
|
|
|
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"
|
|
17
18
|
/>
|
|
18
19
|
|
|
19
20
|
<!-- slot -->
|
|
20
|
-
<component
|
|
21
|
+
<component
|
|
22
|
+
v-else
|
|
23
|
+
:class="[bem('inner'), innerClass]"
|
|
24
|
+
:style="innerStyle"
|
|
25
|
+
:is="calcInnerTag"
|
|
26
|
+
ref="text"
|
|
27
|
+
>
|
|
21
28
|
<slot>
|
|
22
29
|
{{ text }}
|
|
23
30
|
</slot>
|
|
@@ -47,8 +54,16 @@ export default {
|
|
|
47
54
|
*/
|
|
48
55
|
innerTag: { type: String, default: null },
|
|
49
56
|
|
|
50
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Class applied to the inner element.
|
|
59
|
+
*/
|
|
51
60
|
innerClass: { type: String, default: null },
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Style applied to the inner element.
|
|
64
|
+
*/
|
|
65
|
+
innerStyle: { type: [String, Object], default: null },
|
|
66
|
+
|
|
52
67
|
/**
|
|
53
68
|
* Html that gets set on the inner tag element
|
|
54
69
|
*/
|
|
@@ -131,6 +146,7 @@ export default {
|
|
|
131
146
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
132
147
|
},
|
|
133
148
|
isHeadless() {
|
|
149
|
+
// TODO: replace with isUnderTest
|
|
134
150
|
if (isServer()) {
|
|
135
151
|
return false;
|
|
136
152
|
}
|
|
@@ -182,6 +198,9 @@ export default {
|
|
|
182
198
|
}
|
|
183
199
|
}
|
|
184
200
|
},
|
|
201
|
+
getInnerTextRef() {
|
|
202
|
+
return this.$refs.text;
|
|
203
|
+
},
|
|
185
204
|
},
|
|
186
205
|
};
|
|
187
206
|
</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/components/PxFit.vue
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
v-model:visible="visibleValue"
|
|
31
31
|
v-bind="modalProps"
|
|
32
32
|
:overlayClass="[bem('overlay-base'), overlayClass]"
|
|
33
|
-
transition-name="px-side-
|
|
33
|
+
:transition-name="'px-side-drawer__' + mode"
|
|
34
34
|
variant="none"
|
|
35
35
|
>
|
|
36
|
-
<div :id="drawerA11yId" :class="bem()">
|
|
36
|
+
<div :id="drawerA11yId" :class="bem({ mode })">
|
|
37
37
|
<div :class="drawerClass">
|
|
38
38
|
<div :class="bem('top')">
|
|
39
39
|
<div :class="bem('close')">
|
|
@@ -99,6 +99,9 @@ export default {
|
|
|
99
99
|
|
|
100
100
|
// accessibility props
|
|
101
101
|
closeButtonLabel: { type: String, default: 'Close' },
|
|
102
|
+
|
|
103
|
+
// how it appears (from the top or side)
|
|
104
|
+
mode: { type: String, default: 'side' },
|
|
102
105
|
},
|
|
103
106
|
// data() { return { b: 0 }; },
|
|
104
107
|
computed: {
|
|
@@ -120,7 +123,7 @@ export default {
|
|
|
120
123
|
|
|
121
124
|
$dur: 400ms;
|
|
122
125
|
|
|
123
|
-
@include vue-transition('px-side-
|
|
126
|
+
@include vue-transition('px-side-drawer__side') {
|
|
124
127
|
@include vt-transition {
|
|
125
128
|
@include transition(color, $dur: $dur);
|
|
126
129
|
.px-side-drawer__overlay-base {
|
|
@@ -141,6 +144,27 @@ $dur: 400ms;
|
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
146
|
|
|
147
|
+
@include vue-transition('px-side-drawer__top') {
|
|
148
|
+
@include vt-transition {
|
|
149
|
+
@include transition(color, $dur: $dur);
|
|
150
|
+
.px-side-drawer__overlay-base {
|
|
151
|
+
@include transition(opacity, $dur: $dur);
|
|
152
|
+
}
|
|
153
|
+
.px-side-drawer__drawer {
|
|
154
|
+
@include transition(transform, $dur: $dur);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@include vt-hidden() {
|
|
159
|
+
.px-side-drawer__overlay-base {
|
|
160
|
+
opacity: 0;
|
|
161
|
+
}
|
|
162
|
+
.px-side-drawer__drawer {
|
|
163
|
+
transform: translateY(-100%);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
144
168
|
.px-side-drawer {
|
|
145
169
|
position: fixed;
|
|
146
170
|
right: 0;
|
|
@@ -149,7 +173,7 @@ $dur: 400ms;
|
|
|
149
173
|
min-width: 10px;
|
|
150
174
|
|
|
151
175
|
&__overlay {
|
|
152
|
-
background-color:
|
|
176
|
+
background-color: clr(page-fg, $alpha: 0.1);
|
|
153
177
|
}
|
|
154
178
|
|
|
155
179
|
&__drawer,
|
|
@@ -206,5 +230,17 @@ $dur: 400ms;
|
|
|
206
230
|
backdrop-filter: blur(10px);
|
|
207
231
|
}
|
|
208
232
|
}
|
|
233
|
+
|
|
234
|
+
&--mode-top {
|
|
235
|
+
height: auto;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
&--mode-top & {
|
|
239
|
+
&__drawer {
|
|
240
|
+
width: 100vw;
|
|
241
|
+
max-width: 100vw;
|
|
242
|
+
height: auto;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
209
245
|
}
|
|
210
246
|
</style>
|
package/components/PxSticky.vue
CHANGED
|
@@ -5,14 +5,9 @@
|
|
|
5
5
|
<template>
|
|
6
6
|
<div
|
|
7
7
|
:class="[bem({ disabled: !enabled }), stuck ? stuckClass : unstuckClass]"
|
|
8
|
-
:style="
|
|
8
|
+
:style="elementStyle"
|
|
9
9
|
>
|
|
10
|
-
<div
|
|
11
|
-
v-show="enabled"
|
|
12
|
-
ref="sentinel"
|
|
13
|
-
:class="bem('sentinel')"
|
|
14
|
-
:style="enabled ? { top: cssPx(-(top + overlap)), height: cssPx(top + overlap) } : null"
|
|
15
|
-
></div>
|
|
10
|
+
<div v-show="enabled" ref="sentinel" :class="bem('sentinel')" :style="sentinelStyle"></div>
|
|
16
11
|
<slot :stuck="stuck" />
|
|
17
12
|
</div>
|
|
18
13
|
</template>
|
|
@@ -22,7 +17,8 @@ export default {
|
|
|
22
17
|
name: 'px-sticky',
|
|
23
18
|
props: {
|
|
24
19
|
enabled: { type: Boolean, default: true },
|
|
25
|
-
|
|
20
|
+
mode: { type: String, default: 'top' },
|
|
21
|
+
offset: { type: Number, default: 0 },
|
|
26
22
|
overlap: { type: Number, default: 1 },
|
|
27
23
|
z: { type: Number, default: 1 },
|
|
28
24
|
stuckClass: { type: String, default: '' },
|
|
@@ -34,6 +30,25 @@ export default {
|
|
|
34
30
|
stuckScrollY: null,
|
|
35
31
|
};
|
|
36
32
|
},
|
|
33
|
+
computed: {
|
|
34
|
+
elementStyle() {
|
|
35
|
+
if (this.enabled) {
|
|
36
|
+
const style = { position: 'sticky', zIndex: this.z };
|
|
37
|
+
style[this.mode] = this.cssPx(this.offset);
|
|
38
|
+
return style;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
sentinelStyle() {
|
|
44
|
+
if (this.enabled) {
|
|
45
|
+
const style = { height: this.cssPx(this.offset + this.overlap) };
|
|
46
|
+
style[this.mode] = this.cssPx(-(this.offset + this.overlap));
|
|
47
|
+
return style;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
37
52
|
watch: {
|
|
38
53
|
enabled() {
|
|
39
54
|
this.updateConnections();
|
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
|
|