@thinkpixellab-public/px-vue 3.0.68 → 3.0.70
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/PxArrowScroller.vue +1 -1
- package/components/PxBaseActiveTab.vue +50 -0
- package/components/PxFlip.vue +78 -0
- package/components/PxGsapScrubber.vue +7 -4
- package/components/PxIconButton.vue +8 -0
- package/components/PxMenu.vue +240 -0
- package/components/PxMenuItem.vue +147 -0
- package/components/PxSvg.vue +5 -1
- package/dev/demos/Demo-PxFlip.vue +87 -0
- package/dev/demos/Demo-PxFloat.vue +1 -1
- package/dev/demos/Demo-PxMenu.vue +90 -0
- package/dev/dev.vue +5 -1
- package/package.json +2 -2
- package/utils/balanceText.js +2 -2
|
@@ -55,7 +55,7 @@ ar
|
|
|
55
55
|
// import Component from '~/components/Component.vue';
|
|
56
56
|
// import Mixin from '~/components/Mixin.vue';
|
|
57
57
|
import PxBaseResize from './PxBaseResize.vue';
|
|
58
|
-
import PxIcon from '
|
|
58
|
+
import PxIcon from './PxIcon.vue';
|
|
59
59
|
|
|
60
60
|
export default {
|
|
61
61
|
name: 'px-arrow-scroller',
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
|
|
5
|
+
To perform an action the first time the browser tab becomes active, override the browserTabFirstActive() method.
|
|
6
|
+
|
|
7
|
+
To watch for changes to the browser tab's active state, watch the isBrowserTabActive property.
|
|
8
|
+
|
|
9
|
+
-->
|
|
10
|
+
<script>
|
|
11
|
+
export default {
|
|
12
|
+
data() {
|
|
13
|
+
return { isBrowserTabActive: false, browserTabActivationCount: 0 };
|
|
14
|
+
},
|
|
15
|
+
mounted() {
|
|
16
|
+
if (typeof document == undefined) {
|
|
17
|
+
console.warn('Unable to create visibility change listener. No document object.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
document.addEventListener('visibilitychange', this.onTabVisibilityChange);
|
|
22
|
+
this.onTabVisibilityChange();
|
|
23
|
+
},
|
|
24
|
+
beforeDestroy() {
|
|
25
|
+
document.removeEventListener('visibilitychange', this.onTabVisibilityChange);
|
|
26
|
+
},
|
|
27
|
+
methods: {
|
|
28
|
+
onTabVisibilityChange() {
|
|
29
|
+
if (document.visibilityState === 'visible') {
|
|
30
|
+
this.isBrowserTabActive = true;
|
|
31
|
+
this.browserTabActivationCount++;
|
|
32
|
+
|
|
33
|
+
if (this.browserTabActivationCount == 1) {
|
|
34
|
+
if (this.browserTabFirstActive) {
|
|
35
|
+
this.browserTabFirstActive();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
this.isBrowserTabActive = false;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// OVERRIDE this method to perform an action the first time the browser tab becomes active
|
|
44
|
+
//
|
|
45
|
+
// browserTabFirstActive() {
|
|
46
|
+
// console.log('browser tab first active');}
|
|
47
|
+
// }
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Usage:
|
|
3
|
+
|
|
4
|
+
<px-flip :states="['select', 'interact']" :current="'select'">
|
|
5
|
+
<template :state="state">
|
|
6
|
+
<div :class="bem('container', { state })">
|
|
7
|
+
<div data-pxflip>...</div>
|
|
8
|
+
<div data-pxflip>...</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
</px-flip>
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div :class="bem()">
|
|
16
|
+
<!-- in the component -->
|
|
17
|
+
<slot name="default" :state="currentStateValue">
|
|
18
|
+
<!-- fallback -->
|
|
19
|
+
</slot>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
// import { mapState } from 'vuex';
|
|
25
|
+
// import Component from '~/components/Component.vue';
|
|
26
|
+
import { gsap } from 'gsap';
|
|
27
|
+
import { Flip } from 'gsap/Flip';
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
name: 'px-flip',
|
|
31
|
+
// components: { Component },
|
|
32
|
+
// mixins: [ Mixin ],
|
|
33
|
+
props: {
|
|
34
|
+
states: { type: Array, default: null },
|
|
35
|
+
current: { type: String, default: null },
|
|
36
|
+
otherProps: { type: String, default: 'opacity,color,backgroundColor' },
|
|
37
|
+
selector: { type: String, default: '[data-flip]' },
|
|
38
|
+
targets: { default: null },
|
|
39
|
+
},
|
|
40
|
+
data() {
|
|
41
|
+
return { currentStateValue: this.current };
|
|
42
|
+
},
|
|
43
|
+
// computed: {},
|
|
44
|
+
watch: {
|
|
45
|
+
async current(nv) {
|
|
46
|
+
const targetElements = this.targets || this.$el.querySelectorAll(this.selector);
|
|
47
|
+
|
|
48
|
+
console.log(targetElements);
|
|
49
|
+
|
|
50
|
+
// save initial state
|
|
51
|
+
const state = Flip.getState(targetElements, { props: this.otherProps, absolute: true });
|
|
52
|
+
|
|
53
|
+
// make state changes
|
|
54
|
+
this.currentStateValue = nv;
|
|
55
|
+
|
|
56
|
+
await this.$nextTick();
|
|
57
|
+
// animate from the old state to the new one
|
|
58
|
+
// animate from the previous state to the current one:
|
|
59
|
+
|
|
60
|
+
Flip.from(state, {
|
|
61
|
+
duration: 1,
|
|
62
|
+
ease: 'power1.inOut',
|
|
63
|
+
absolute: true,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
mounted() {
|
|
68
|
+
gsap.registerPlugin(Flip);
|
|
69
|
+
},
|
|
70
|
+
// methods: {},
|
|
71
|
+
};
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<style lang="scss">
|
|
75
|
+
.px-flip {
|
|
76
|
+
// add styles here
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -81,13 +81,16 @@ export default {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
this.timeline = t;
|
|
84
|
-
this.progress = this.timeline.progress();
|
|
85
|
-
this.isPlaying = !this.timeline.paused();
|
|
86
84
|
|
|
87
|
-
this.timeline
|
|
85
|
+
if (this.timeline) {
|
|
88
86
|
this.progress = this.timeline.progress();
|
|
89
87
|
this.isPlaying = !this.timeline.paused();
|
|
90
|
-
|
|
88
|
+
|
|
89
|
+
this.timeline.eventCallback('onUpdate', () => {
|
|
90
|
+
this.progress = this.timeline.progress();
|
|
91
|
+
this.isPlaying = !this.timeline.paused();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
91
94
|
},
|
|
92
95
|
pause() {
|
|
93
96
|
if (this.timeline) {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
:viewBox="svgViewBox"
|
|
30
30
|
:height="calcHeight"
|
|
31
31
|
:width="calcWidth"
|
|
32
|
+
:title="title"
|
|
32
33
|
/>
|
|
33
34
|
</button>
|
|
34
35
|
</template>
|
|
@@ -111,5 +112,12 @@ export default {
|
|
|
111
112
|
color: accent(-2);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
115
|
+
|
|
116
|
+
&--subtle {
|
|
117
|
+
opacity: 0.33;
|
|
118
|
+
&:hover {
|
|
119
|
+
opacity: 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
</style>
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The general idea here is that you define a context menu and then use the v-context-menu
|
|
3
|
+
directive to assign it to an element and pass in optional context.
|
|
4
|
+
|
|
5
|
+
The directive creates a handler for the element's contextmenu event and shows the appropriate
|
|
6
|
+
context menu with the provided context.
|
|
7
|
+
|
|
8
|
+
Here is what all of that looks like:
|
|
9
|
+
|
|
10
|
+
// define the context menu
|
|
11
|
+
|
|
12
|
+
<px-menu ref="mymenu" :items="[
|
|
13
|
+
{
|
|
14
|
+
id: 'copy',
|
|
15
|
+
icon: require('myicon.svg'),
|
|
16
|
+
label: 'Copy',
|
|
17
|
+
|
|
18
|
+
// function with a single arg which will be the context from the directive
|
|
19
|
+
handler: 'onContextMenuCopy',
|
|
20
|
+
|
|
21
|
+
// visible / enabled can be a function or bool
|
|
22
|
+
enabled: (ctx) => ctx.isSomething,
|
|
23
|
+
visible: true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'copy',
|
|
27
|
+
icon: require('myicon.svg'),
|
|
28
|
+
label: 'Copy',
|
|
29
|
+
|
|
30
|
+
// function with a single arg which will be the context from the directive
|
|
31
|
+
handler: 'onContextMenuCopy',
|
|
32
|
+
|
|
33
|
+
// visible / enabled can be a function or bool
|
|
34
|
+
enabled: (ctx) => ctx.isSomething,
|
|
35
|
+
visible: true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
isSeparator: true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'advanced',
|
|
42
|
+
label: 'Advanced',
|
|
43
|
+
items: [],
|
|
44
|
+
},
|
|
45
|
+
]" />
|
|
46
|
+
|
|
47
|
+
// use the context menu (no context)
|
|
48
|
+
<div v-context-menu="'mymenu'" />
|
|
49
|
+
|
|
50
|
+
// use the context menu (pass dynamic mydata as context)
|
|
51
|
+
<div v-context-menu:[mydata]="'mymenu'" />
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
-->
|
|
55
|
+
<template>
|
|
56
|
+
<px-float
|
|
57
|
+
v-bind="{
|
|
58
|
+
placement: 'right-start',
|
|
59
|
+
...floatProps,
|
|
60
|
+
}"
|
|
61
|
+
:popup-class="bem('popup')"
|
|
62
|
+
ref="popup"
|
|
63
|
+
variant="none"
|
|
64
|
+
@hide="afterHide"
|
|
65
|
+
>
|
|
66
|
+
<div :class="bem()">
|
|
67
|
+
<slot v-for="item in items" :item="item" :data="data" :done="hide">
|
|
68
|
+
<PxMenuItem
|
|
69
|
+
:key="item.id"
|
|
70
|
+
:separator="item.separator"
|
|
71
|
+
:label="item.label"
|
|
72
|
+
:hint="item.hint"
|
|
73
|
+
:items="item.items"
|
|
74
|
+
:icon="item.icon"
|
|
75
|
+
:visible="item.visible"
|
|
76
|
+
:disabled="item.disabled"
|
|
77
|
+
:handler="item.handler"
|
|
78
|
+
:iconSize="calcIconSize"
|
|
79
|
+
:iconClass="iconClass"
|
|
80
|
+
:data="data"
|
|
81
|
+
@done="hide"
|
|
82
|
+
@iconsized="iconSized"
|
|
83
|
+
/>
|
|
84
|
+
</slot>
|
|
85
|
+
</div>
|
|
86
|
+
</px-float>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<script>
|
|
90
|
+
import PxFloat from './PxFloat.vue';
|
|
91
|
+
import PxMenuItem from './PxMenuItem.vue';
|
|
92
|
+
|
|
93
|
+
// ================================================================================
|
|
94
|
+
// Component
|
|
95
|
+
// ================================================================================
|
|
96
|
+
|
|
97
|
+
const PxMenu = {
|
|
98
|
+
name: 'px-menu',
|
|
99
|
+
components: { PxFloat, PxMenuItem },
|
|
100
|
+
mixins: [],
|
|
101
|
+
props: {
|
|
102
|
+
items: { type: Array, default: null },
|
|
103
|
+
iconSize: { type: [String, Number], default: 1 },
|
|
104
|
+
iconClass: { type: String, default: null },
|
|
105
|
+
floatProps: { type: Object, default: null },
|
|
106
|
+
},
|
|
107
|
+
data() {
|
|
108
|
+
return {
|
|
109
|
+
data: null,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
computed: {
|
|
113
|
+
calcIconSize() {
|
|
114
|
+
if (this.items.find(item => !!item.icon)) {
|
|
115
|
+
return this.iconSize;
|
|
116
|
+
}
|
|
117
|
+
return 0;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
methods: {
|
|
121
|
+
showAtCursor(mouseEvent, data) {
|
|
122
|
+
this.data = data;
|
|
123
|
+
this.$refs.popup?.showAtCursor(mouseEvent);
|
|
124
|
+
},
|
|
125
|
+
show(data) {
|
|
126
|
+
this.data = data;
|
|
127
|
+
this.$refs.popup?.show();
|
|
128
|
+
},
|
|
129
|
+
hide() {
|
|
130
|
+
this.$refs.popup?.hide();
|
|
131
|
+
},
|
|
132
|
+
afterHide() {
|
|
133
|
+
this.data = null;
|
|
134
|
+
},
|
|
135
|
+
iconSized(e) {
|
|
136
|
+
console.log(e);
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// ================================================================================
|
|
142
|
+
// Directives
|
|
143
|
+
// ================================================================================
|
|
144
|
+
|
|
145
|
+
const contextMenuDirective = {
|
|
146
|
+
//bind: (el, binding, vnode) => {
|
|
147
|
+
bind(el, binding, vnode) {
|
|
148
|
+
if (!binding || !vnode) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
binding.el = vnode?.elm;
|
|
153
|
+
binding.contextMenuHandler = e => {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
e.stopPropagation();
|
|
156
|
+
|
|
157
|
+
const name = binding?.value;
|
|
158
|
+
const data = binding?.arg;
|
|
159
|
+
const $refs = vnode?.context?.$refs;
|
|
160
|
+
|
|
161
|
+
if ($refs && name in $refs) {
|
|
162
|
+
const menu = $refs[name];
|
|
163
|
+
|
|
164
|
+
if (typeof menu?.show == 'function') {
|
|
165
|
+
menu.showAtCursor(e, data);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
if (binding.el) {
|
|
171
|
+
binding.el.addEventListener('contextmenu', binding.contextMenuHandler);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
unbind(el, binding) {
|
|
175
|
+
if (binding.el) {
|
|
176
|
+
binding.el.removeEventListener('contextmenu', binding.contextMenuHandler);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const menuDirective = {
|
|
182
|
+
//bind: (el, binding, vnode) => {
|
|
183
|
+
bind(el, binding, vnode) {
|
|
184
|
+
if (!binding || !vnode) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
binding.el = vnode?.elm;
|
|
189
|
+
binding.contextMenuHandler = e => {
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
|
|
193
|
+
const name = binding?.value;
|
|
194
|
+
const data = binding?.arg;
|
|
195
|
+
const $refs = vnode?.context?.$refs;
|
|
196
|
+
|
|
197
|
+
if ($refs && name in $refs) {
|
|
198
|
+
const menu = $refs[name];
|
|
199
|
+
|
|
200
|
+
if (typeof menu?.show == 'function') {
|
|
201
|
+
menu.show(e, data);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
if (binding.el) {
|
|
207
|
+
binding.el.addEventListener('click', binding.contextMenuHandler);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
unbind(el, binding) {
|
|
211
|
+
if (binding.el) {
|
|
212
|
+
binding.el.removeEventListener('click', binding.contextMenuHandler);
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export {
|
|
218
|
+
PxMenu as default,
|
|
219
|
+
contextMenuDirective as contextMenuDirective,
|
|
220
|
+
menuDirective as menuDirective,
|
|
221
|
+
};
|
|
222
|
+
</script>
|
|
223
|
+
|
|
224
|
+
<style lang="scss">
|
|
225
|
+
@use '../styles/px.scss' as *;
|
|
226
|
+
.px-menu {
|
|
227
|
+
font-family: get('font-family');
|
|
228
|
+
background-color: clr(page-bg);
|
|
229
|
+
color: clr(page-fg);
|
|
230
|
+
border-radius: get('controls:border-radius');
|
|
231
|
+
overflow: hidden;
|
|
232
|
+
display: flex;
|
|
233
|
+
flex-direction: column;
|
|
234
|
+
justify-content: stretch;
|
|
235
|
+
|
|
236
|
+
&__popup {
|
|
237
|
+
@include css-map(popup());
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
</style>
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Describe this component...
|
|
3
|
+
-->
|
|
4
|
+
<template>
|
|
5
|
+
<button
|
|
6
|
+
v-if="!separator && isVisible"
|
|
7
|
+
:class="bem({ clicked, disabled: isDisabled })"
|
|
8
|
+
:title="hint"
|
|
9
|
+
:disabled="isDisabled"
|
|
10
|
+
@click="onClick"
|
|
11
|
+
>
|
|
12
|
+
<span
|
|
13
|
+
ref="icon"
|
|
14
|
+
v-if="iconSize"
|
|
15
|
+
:class="[bem('icon'), iconClass]"
|
|
16
|
+
:style="{ minWidth: cssEmFallback(iconSize) }"
|
|
17
|
+
>
|
|
18
|
+
<PxIcon :src="icon" :size="cssEmFallback(iconSize)" size-bias="width" />
|
|
19
|
+
</span>
|
|
20
|
+
<span :class="bem('label')">
|
|
21
|
+
{{ label }}
|
|
22
|
+
</span>
|
|
23
|
+
</button>
|
|
24
|
+
|
|
25
|
+
<hr v-else-if="visible" :class="bem({ separator: true })" :visible="isVisible" />
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import PxIcon from './PxIcon.vue';
|
|
30
|
+
|
|
31
|
+
// import { mapState } from 'vuex';
|
|
32
|
+
// import Component from '~/components/Component.vue';
|
|
33
|
+
// import Mixin from '~/components/Mixin.vue';
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
name: 'px-menu-item',
|
|
37
|
+
components: { PxIcon },
|
|
38
|
+
// mixins: [ Mixin ],
|
|
39
|
+
props: {
|
|
40
|
+
separator: { type: Boolean, default: false },
|
|
41
|
+
label: { type: String, default: null },
|
|
42
|
+
hint: { type: String, default: null },
|
|
43
|
+
items: { type: Array, default: null },
|
|
44
|
+
icon: { type: String, default: null },
|
|
45
|
+
iconSize: { type: [String, Number], default: 1 },
|
|
46
|
+
iconClass: { type: String, default: null },
|
|
47
|
+
disabled: { type: [Function, Boolean], default: false },
|
|
48
|
+
visible: { type: [Function, Boolean], default: true },
|
|
49
|
+
handler: { type: Function, default: null },
|
|
50
|
+
data: { default: null },
|
|
51
|
+
},
|
|
52
|
+
data() {
|
|
53
|
+
return {
|
|
54
|
+
// used only to track visual state
|
|
55
|
+
clicked: false,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
computed: {
|
|
59
|
+
isVisible() {
|
|
60
|
+
if (typeof this.visible == 'boolean') {
|
|
61
|
+
return this.visible;
|
|
62
|
+
}
|
|
63
|
+
if (typeof this.visible == 'function') {
|
|
64
|
+
return this.visible(this.data);
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
isDisabled() {
|
|
69
|
+
if (typeof this.disabled == 'boolean') {
|
|
70
|
+
return this.disabled;
|
|
71
|
+
}
|
|
72
|
+
if (typeof this.disabled == 'function') {
|
|
73
|
+
return this.disabled(this.data);
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
// watch: {},
|
|
79
|
+
mounted() {
|
|
80
|
+
this.clicked = false;
|
|
81
|
+
},
|
|
82
|
+
methods: {
|
|
83
|
+
onClick() {
|
|
84
|
+
this.clicked = true;
|
|
85
|
+
|
|
86
|
+
if (typeof this.handler == 'function') {
|
|
87
|
+
this.handler(this.data);
|
|
88
|
+
}
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
this.$emit('done');
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style lang="scss">
|
|
98
|
+
@use '../styles/px.scss' as *;
|
|
99
|
+
|
|
100
|
+
.px-menu-item {
|
|
101
|
+
@include control-reset();
|
|
102
|
+
font-size: inherit;
|
|
103
|
+
background-color: inherit;
|
|
104
|
+
color: inherit;
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
gap: 0.5em;
|
|
108
|
+
min-width: 7em;
|
|
109
|
+
max-width: 20em;
|
|
110
|
+
white-space: wrap;
|
|
111
|
+
line-height: 1.33;
|
|
112
|
+
text-align: left;
|
|
113
|
+
padding: 0.33em 1em;
|
|
114
|
+
|
|
115
|
+
&__icon {
|
|
116
|
+
margin-left: -0.25em;
|
|
117
|
+
flex: none;
|
|
118
|
+
display: flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&__label {
|
|
123
|
+
white-space: nowrap;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&--clicked,
|
|
127
|
+
&:hover {
|
|
128
|
+
background-color: clr(select);
|
|
129
|
+
color: contrast-color(clr(select));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&:disabled {
|
|
133
|
+
background-color: transparent !important;
|
|
134
|
+
color: inherit !important;
|
|
135
|
+
opacity: 0.5;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&--separator {
|
|
139
|
+
background-color: currentColor;
|
|
140
|
+
opacity: 0.25;
|
|
141
|
+
height: 1px;
|
|
142
|
+
min-height: 1px;
|
|
143
|
+
max-height: 1px;
|
|
144
|
+
padding: 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
</style>
|
package/components/PxSvg.vue
CHANGED
|
@@ -23,10 +23,11 @@
|
|
|
23
23
|
<inline-svg
|
|
24
24
|
class="px-svg"
|
|
25
25
|
:transformSource="transform"
|
|
26
|
-
:src="src"
|
|
26
|
+
:src="src || ''"
|
|
27
27
|
:viewBox="svgViewBox"
|
|
28
28
|
:height="calcHeight"
|
|
29
29
|
:width="calcWidth"
|
|
30
|
+
:title="title"
|
|
30
31
|
v-on="$listeners"
|
|
31
32
|
/>
|
|
32
33
|
</template>
|
|
@@ -59,6 +60,9 @@ export default {
|
|
|
59
60
|
|
|
60
61
|
// string replacements to be made on the svg (we replace black with currentColor by default)
|
|
61
62
|
replacements: { type: Object, default: null },
|
|
63
|
+
|
|
64
|
+
// set the title for accessibility
|
|
65
|
+
title: { type: String, default: null },
|
|
62
66
|
},
|
|
63
67
|
data() {
|
|
64
68
|
return { svgWidth: null, svgHeight: null, svgViewBox: null };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Describe this component...
|
|
3
|
+
-->
|
|
4
|
+
<template>
|
|
5
|
+
<div :class="bem()">
|
|
6
|
+
<PxFlip :states="['open', 'close']" :current="currentState">
|
|
7
|
+
<template #default="{ state }">
|
|
8
|
+
{{ state }}
|
|
9
|
+
<br />
|
|
10
|
+
<br />
|
|
11
|
+
<span :class="bem('container', { state })">
|
|
12
|
+
<span data-flip />
|
|
13
|
+
<span data-flip />
|
|
14
|
+
<span data-flip />
|
|
15
|
+
</span>
|
|
16
|
+
</template>
|
|
17
|
+
</PxFlip>
|
|
18
|
+
<button @click="toggleState">Toggle</button>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
// import { mapState } from 'vuex';
|
|
24
|
+
// import Component from '~/components/Component.vue';
|
|
25
|
+
// import Mixin from '~/components/Mixin.vue';
|
|
26
|
+
|
|
27
|
+
import PxFlip from '../../components/PxFlip.vue';
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
name: 'demo-px-flip',
|
|
31
|
+
components: { PxFlip },
|
|
32
|
+
|
|
33
|
+
// mixins: [ Mixin ],
|
|
34
|
+
// props: { a: { type: Boolean, default: false } },
|
|
35
|
+
data() {
|
|
36
|
+
return {
|
|
37
|
+
currentState: 'open',
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
// computed: {},
|
|
41
|
+
// watch: {},
|
|
42
|
+
// mounted() {},
|
|
43
|
+
methods: {
|
|
44
|
+
toggleState() {
|
|
45
|
+
if (this.currentState == 'open') {
|
|
46
|
+
this.currentState = 'close';
|
|
47
|
+
} else {
|
|
48
|
+
this.currentState = 'open';
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<style lang="scss">
|
|
56
|
+
@use '../../styles/px.scss' as *;
|
|
57
|
+
.demo-px-flip {
|
|
58
|
+
padding: 5em;
|
|
59
|
+
&__container {
|
|
60
|
+
width: 4em;
|
|
61
|
+
height: 4em;
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
position: relative;
|
|
66
|
+
|
|
67
|
+
span {
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 0.5em;
|
|
70
|
+
background-color: currentColor;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&--state-open {
|
|
74
|
+
span {
|
|
75
|
+
transform: rotate(0deg) scale(1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&--state-close {
|
|
80
|
+
span {
|
|
81
|
+
transform: scale(0.5);
|
|
82
|
+
opacity: 0.5;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
</style>
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
<!-- mouse -->
|
|
43
43
|
<div :class="bem('button')" @click="showMouseFloat">Mouse</div>
|
|
44
|
-
<px-float ref="mouseFloat" :placement="'bottom-start'" variant="
|
|
44
|
+
<px-float ref="mouseFloat" :placement="'bottom-start'" variant="dialog sm">
|
|
45
45
|
Positioned with showAtCursor! (Note: needs to be done pogramatically because we only
|
|
46
46
|
have access to mouse coordinates in a mouse event.)
|
|
47
47
|
</px-float>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Describe this component...
|
|
3
|
+
-->
|
|
4
|
+
<template>
|
|
5
|
+
<div :class="bem()">
|
|
6
|
+
<PxMenu
|
|
7
|
+
ref="menu"
|
|
8
|
+
:items="[
|
|
9
|
+
{
|
|
10
|
+
id: 'copy',
|
|
11
|
+
label: 'Copy',
|
|
12
|
+
icon: require('../../assets/feather/copy.svg'),
|
|
13
|
+
iconSize: 1,
|
|
14
|
+
handler: onCopy,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'paste',
|
|
18
|
+
label: 'Paste',
|
|
19
|
+
icon: require('../../assets/feather/clipboard.svg'),
|
|
20
|
+
iconSize: 1,
|
|
21
|
+
handler: onPaste,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'sep1',
|
|
25
|
+
separator: true,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'paste2',
|
|
29
|
+
label: 'Paste',
|
|
30
|
+
|
|
31
|
+
iconSize: 1,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'paste3',
|
|
35
|
+
label: 'Paste',
|
|
36
|
+
icon: require('../../assets/feather/clipboard.svg'),
|
|
37
|
+
iconSize: 1.5,
|
|
38
|
+
},
|
|
39
|
+
]"
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<div :class="bem('target')" v-context-menu:[mydata]="'menu'" v-if="visible">
|
|
43
|
+
Right Click Me!
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<button @click="visible = !visible">{{ visible ? 'Hide' : 'Show' }}</button>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
// import { mapState } from 'vuex';
|
|
52
|
+
// import Component from '~/components/Component.vue';
|
|
53
|
+
// import Mixin from '~/components/Mixin.vue';
|
|
54
|
+
|
|
55
|
+
import { contextMenuDirective } from '../../components/PxMenu.vue';
|
|
56
|
+
import PxMenu from '../../components/PxMenu.vue';
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
name: 'demo-px-menu',
|
|
60
|
+
components: { PxMenu },
|
|
61
|
+
directives: { contextMenu: contextMenuDirective },
|
|
62
|
+
// mixins: [ Mixin ],
|
|
63
|
+
// props: { a: { type: Boolean, default: false } },
|
|
64
|
+
data() {
|
|
65
|
+
return { visible: true, mydata: 'This is some data.' };
|
|
66
|
+
},
|
|
67
|
+
// computed: {},
|
|
68
|
+
// watch: {},
|
|
69
|
+
// mounted() {},
|
|
70
|
+
methods: {
|
|
71
|
+
onCopy(data) {
|
|
72
|
+
console.log('copy: ' + data);
|
|
73
|
+
},
|
|
74
|
+
onPaste(data) {
|
|
75
|
+
console.log('paste: ' + data);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<style lang="scss">
|
|
82
|
+
@use '../../styles/px.scss' as *;
|
|
83
|
+
.demo-px-menu {
|
|
84
|
+
&__target {
|
|
85
|
+
width: 300px;
|
|
86
|
+
height: 300px;
|
|
87
|
+
background-color: orange;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
</style>
|
package/dev/dev.vue
CHANGED
|
@@ -18,6 +18,8 @@ import DemoPxStylesPreview from './demos/Demo-PxStylesPreview.vue';
|
|
|
18
18
|
import DemoPxPivot from './demos/Demo-PxPivot.vue';
|
|
19
19
|
import DemoPxFloat from './demos/Demo-PxFloat.vue';
|
|
20
20
|
import DemoPxContain from './demos/Demo-PxContain.vue';
|
|
21
|
+
import DemoPxMenu from './demos/Demo-PxMenu.vue';
|
|
22
|
+
import DemoPxFlip from './demos/Demo-PxFlip.vue';
|
|
21
23
|
|
|
22
24
|
export default Vue.extend({
|
|
23
25
|
components: {
|
|
@@ -32,6 +34,8 @@ export default Vue.extend({
|
|
|
32
34
|
DemoPxPivot,
|
|
33
35
|
DemoPxFloat,
|
|
34
36
|
DemoPxContain,
|
|
37
|
+
DemoPxMenu,
|
|
38
|
+
DemoPxFlip,
|
|
35
39
|
},
|
|
36
40
|
name: 'ServeDev',
|
|
37
41
|
data() {
|
|
@@ -44,7 +48,7 @@ export default Vue.extend({
|
|
|
44
48
|
const params = new Proxy(new URLSearchParams(window.location.search), {
|
|
45
49
|
get: (searchParams, prop) => searchParams.get(prop),
|
|
46
50
|
});
|
|
47
|
-
this.componentToRender = params.component || '
|
|
51
|
+
this.componentToRender = params.component || 'DemoPxFlip';
|
|
48
52
|
console.log(`this.componentToRender: ${this.componentToRender}`);
|
|
49
53
|
},
|
|
50
54
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thinkpixellab-public/px-vue",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.70",
|
|
4
4
|
"description": "General purpose Vue components and helpers that can be used across projects.",
|
|
5
5
|
"author": "Pixel Lab",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/thinkpixellab/px-vue.git"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"serve": "vue-cli-service serve dev/serve.js"
|
|
12
|
+
"serve": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve dev/serve.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@floating-ui/dom": "^1.0.1",
|
package/utils/balanceText.js
CHANGED
|
@@ -110,8 +110,8 @@ function textElementIsMultipleLines(element) {
|
|
|
110
110
|
// Update the first word variable in the dom
|
|
111
111
|
firstWord = document.getElementById('element-first-word');
|
|
112
112
|
|
|
113
|
-
firstWordHeight = firstWord
|
|
114
|
-
elementHeight = element
|
|
113
|
+
firstWordHeight = firstWord?.offsetHeight;
|
|
114
|
+
elementHeight = element?.offsetHeight;
|
|
115
115
|
|
|
116
116
|
// Restore the original element text
|
|
117
117
|
element.innerHTML = ORIGINAL_ELEMENT_TEXT;
|