@energie360/ui-library 0.1.23 → 0.1.24
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/badge/u-badge.vue +2 -2
- package/components/card-amount/card-amount.scss +7 -0
- package/components/card-amount/u-card-amount.vue +21 -0
- package/components/card-amount-illustrated/card-amount-illustrated.scss +35 -0
- package/components/card-amount-illustrated/u-card-amount-illustrated.vue +80 -0
- package/components/card-contact/card-contact.scss +5 -3
- package/components/card-contact/u-card-contact.vue +15 -10
- package/components/card-footer/u-card-footer.vue +6 -2
- package/components/card-group/card-group.scss +25 -11
- package/components/card-group/u-card-group.vue +59 -4
- package/components/chip/chip.scss +31 -4
- package/components/chip/u-chip.vue +5 -2
- package/components/index.js +4 -0
- package/components/progress-bar/progress-bar.scss +5 -9
- package/components/progress-bar/u-progress-bar.vue +3 -6
- package/components/richtext/richtext.scss +2 -0
- package/components/skeleton-loader/u-skeleton-loader.vue +1 -1
- package/components/slider/slider.scss +1 -0
- package/components/slider/u-slider.vue +26 -15
- package/components/slider-progress-animation/slider-progress-animation.scss +25 -0
- package/components/slider-progress-animation/u-slider-progress-animation.vue +65 -0
- package/components/sprite-animation/sprite-animation.scss +7 -0
- package/components/sprite-animation/u-sprite-animation.vue +169 -0
- package/components/table/cell-progress-bar.scss +4 -0
- package/components/table/u-cell-icon-group.vue +12 -7
- package/components/table/u-cell-progress-bar.vue +5 -5
- package/components/text-block/text-block.scss +18 -14
- package/components/text-block/u-text-block.vue +17 -11
- package/elements/index.js +0 -1
- package/elements/select-chip/select-chip.scss +1 -1
- package/elements/select-chip/u-select-chip.vue +7 -6
- package/package.json +3 -1
- package/utils/functions/animate.js +258 -0
- package/wizard/wizard-layout/u-wizard-layout-block.vue +2 -2
- package/wizard/wizard-top-bar/u-wizard-top-bar.vue +0 -8
- package/elements/range-slider/u-range-slider.vue +0 -138
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/*
|
|
2
|
+
NOTE: This is old code, but it still works for very simple animation stuff.
|
|
3
|
+
Maybe refactor it (and use ts probably...).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { scaleValue } from '../math/scale-value.js'
|
|
7
|
+
|
|
8
|
+
// /**
|
|
9
|
+
// * Animate multiple props on an element
|
|
10
|
+
// * (Heavily inspired by GSAPs TweenLite.to method.)
|
|
11
|
+
// *
|
|
12
|
+
// * @param el
|
|
13
|
+
// * @param duration
|
|
14
|
+
// * @param props
|
|
15
|
+
// * @param easing
|
|
16
|
+
// * @param delay
|
|
17
|
+
// * @param settle
|
|
18
|
+
// * @param stagger
|
|
19
|
+
// * @param onAbort
|
|
20
|
+
// * @param onStart
|
|
21
|
+
// * @param onComplete
|
|
22
|
+
// * @param onUpdate
|
|
23
|
+
// */
|
|
24
|
+
// export const animateProps = ({
|
|
25
|
+
// el,
|
|
26
|
+
// duration,
|
|
27
|
+
// props,
|
|
28
|
+
// easing,
|
|
29
|
+
// delay,
|
|
30
|
+
// settle,
|
|
31
|
+
// stagger,
|
|
32
|
+
// onAbort,
|
|
33
|
+
// onStart,
|
|
34
|
+
// onComplete,
|
|
35
|
+
// onUpdate,
|
|
36
|
+
// }) => {
|
|
37
|
+
// if (el === undefined || duration === undefined || props === undefined) {
|
|
38
|
+
// throw new Error('Required arguments (el, props, duration) not set.')
|
|
39
|
+
// }
|
|
40
|
+
//
|
|
41
|
+
// if (el instanceof window.HTMLElement || el instanceof window.SVGElement) {
|
|
42
|
+
// el = [el]
|
|
43
|
+
// }
|
|
44
|
+
//
|
|
45
|
+
// let startTime
|
|
46
|
+
// let value
|
|
47
|
+
// let renderId
|
|
48
|
+
// let started = false
|
|
49
|
+
// let posTotal
|
|
50
|
+
// let pos
|
|
51
|
+
// let currentTimeDiff
|
|
52
|
+
// let paused = false
|
|
53
|
+
// let pauseTime
|
|
54
|
+
//
|
|
55
|
+
// onAbort = onAbort || function () {}
|
|
56
|
+
// onStart = onStart || function () {}
|
|
57
|
+
// onComplete = onComplete || function () {}
|
|
58
|
+
// onUpdate = onUpdate || function () {}
|
|
59
|
+
// easing =
|
|
60
|
+
// easing ||
|
|
61
|
+
// function (x) {
|
|
62
|
+
// return x
|
|
63
|
+
// }
|
|
64
|
+
// delay = delay || 0
|
|
65
|
+
// settle = settle || 0
|
|
66
|
+
// stagger = stagger || 0
|
|
67
|
+
//
|
|
68
|
+
// const additionalDuration = stagger * (el.length - 1)
|
|
69
|
+
//
|
|
70
|
+
// const set = ({ element, props, pos }) => {
|
|
71
|
+
// for (let i = 0; i < props.length; i++) {
|
|
72
|
+
// value =
|
|
73
|
+
// (props[i].prefix || '') +
|
|
74
|
+
// translateValue(easing(pos), 0, 1, props[i].start, props[i].end, 3) +
|
|
75
|
+
// (props[i].suffix || '')
|
|
76
|
+
//
|
|
77
|
+
// element.style[props[i].propName] = value
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
//
|
|
81
|
+
// const setProps = (ts) => {
|
|
82
|
+
// currentTimeDiff = ts - startTime
|
|
83
|
+
// posTotal = currentTimeDiff / (duration + additionalDuration)
|
|
84
|
+
//
|
|
85
|
+
// for (let i = 0; i < el.length; i++) {
|
|
86
|
+
// if (currentTimeDiff < i * stagger + duration && currentTimeDiff >= i * stagger) {
|
|
87
|
+
// pos = (currentTimeDiff - i * stagger) / duration
|
|
88
|
+
//
|
|
89
|
+
// set({ element: el[i], props, pos })
|
|
90
|
+
// } else if (currentTimeDiff >= i * stagger + duration) {
|
|
91
|
+
// set({ element: el[i], props, pos: 1 })
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
//
|
|
95
|
+
// onUpdate({
|
|
96
|
+
// progress: posTotal,
|
|
97
|
+
// time: currentTimeDiff,
|
|
98
|
+
// })
|
|
99
|
+
// }
|
|
100
|
+
//
|
|
101
|
+
// const anim = (ts) => {
|
|
102
|
+
// if (ts - startTime < 0) {
|
|
103
|
+
// // Don't animate when startTime is not reached (i.e. a delay has been set)
|
|
104
|
+
// renderId = window.requestAnimationFrame(anim)
|
|
105
|
+
// return
|
|
106
|
+
// }
|
|
107
|
+
//
|
|
108
|
+
// // Animation is finished.
|
|
109
|
+
// // Set all props to their defined end values.
|
|
110
|
+
// if (ts - startTime >= duration + additionalDuration) {
|
|
111
|
+
// setProps(startTime + duration + additionalDuration)
|
|
112
|
+
//
|
|
113
|
+
// // Fire callback
|
|
114
|
+
// setTimeout(function () {
|
|
115
|
+
// onComplete()
|
|
116
|
+
// }, settle)
|
|
117
|
+
//
|
|
118
|
+
// return
|
|
119
|
+
// }
|
|
120
|
+
//
|
|
121
|
+
// if (!started) {
|
|
122
|
+
// onStart()
|
|
123
|
+
//
|
|
124
|
+
// started = true
|
|
125
|
+
// }
|
|
126
|
+
//
|
|
127
|
+
// // animation
|
|
128
|
+
// setProps(ts)
|
|
129
|
+
// renderId = window.requestAnimationFrame(anim)
|
|
130
|
+
// }
|
|
131
|
+
//
|
|
132
|
+
// startTime = window.performance.now() + delay
|
|
133
|
+
// renderId = window.requestAnimationFrame(anim)
|
|
134
|
+
//
|
|
135
|
+
// return {
|
|
136
|
+
// pause: () => {
|
|
137
|
+
// window.cancelAnimationFrame(renderId)
|
|
138
|
+
// pauseTime = window.performance.now()
|
|
139
|
+
// paused = true
|
|
140
|
+
// },
|
|
141
|
+
// resume: () => {
|
|
142
|
+
// if (paused) {
|
|
143
|
+
// // start anim again
|
|
144
|
+
// startTime += window.performance.now() - pauseTime
|
|
145
|
+
// window.requestAnimationFrame(anim)
|
|
146
|
+
// paused = false
|
|
147
|
+
// }
|
|
148
|
+
// },
|
|
149
|
+
// abort: () => {
|
|
150
|
+
// window.cancelAnimationFrame(renderId)
|
|
151
|
+
//
|
|
152
|
+
// // Fire callback
|
|
153
|
+
// onAbort()
|
|
154
|
+
// },
|
|
155
|
+
// }
|
|
156
|
+
// }
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
*
|
|
160
|
+
* @param duration
|
|
161
|
+
* @param start
|
|
162
|
+
* @param end
|
|
163
|
+
* @param easing
|
|
164
|
+
* @param delay
|
|
165
|
+
* @param onAbort
|
|
166
|
+
* @param onStart
|
|
167
|
+
* @param onComplete
|
|
168
|
+
* @param onUpdate
|
|
169
|
+
* @returns {{abort: *}}
|
|
170
|
+
*/
|
|
171
|
+
export const animateValue = (
|
|
172
|
+
{ duration, start, end, easing, delay, onAbort, onStart, onComplete, onUpdate } = {
|
|
173
|
+
duration: 200,
|
|
174
|
+
start: 0,
|
|
175
|
+
end: 0,
|
|
176
|
+
delay: 0,
|
|
177
|
+
easing: (x) => x,
|
|
178
|
+
},
|
|
179
|
+
) => {
|
|
180
|
+
onAbort = onAbort || function () {}
|
|
181
|
+
onStart = onStart || function () {}
|
|
182
|
+
onComplete = onComplete || function () {}
|
|
183
|
+
onUpdate = onUpdate || function () {}
|
|
184
|
+
|
|
185
|
+
let startTime
|
|
186
|
+
let pos
|
|
187
|
+
let value
|
|
188
|
+
let renderId
|
|
189
|
+
|
|
190
|
+
delay = delay || 0
|
|
191
|
+
|
|
192
|
+
easing =
|
|
193
|
+
easing ||
|
|
194
|
+
function (x) {
|
|
195
|
+
return x
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const anim = (ts) => {
|
|
199
|
+
if (startTime === undefined) {
|
|
200
|
+
startTime = ts
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (ts - startTime >= duration) {
|
|
204
|
+
onUpdate.call(null, end)
|
|
205
|
+
onComplete.call(null, end)
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// animation
|
|
210
|
+
pos = (ts - startTime) / duration
|
|
211
|
+
|
|
212
|
+
value = scaleValue(easing(pos), 0, 1, start, end, 3)
|
|
213
|
+
onUpdate.call(null, value)
|
|
214
|
+
|
|
215
|
+
renderId = requestAnimationFrame(anim)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (delay) {
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
onStart()
|
|
221
|
+
renderId = requestAnimationFrame(anim)
|
|
222
|
+
}, delay)
|
|
223
|
+
} else {
|
|
224
|
+
onStart()
|
|
225
|
+
renderId = requestAnimationFrame(anim)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
abort: () => {
|
|
230
|
+
window.cancelAnimationFrame(renderId)
|
|
231
|
+
|
|
232
|
+
// Fire callback
|
|
233
|
+
onAbort.call(null, value)
|
|
234
|
+
},
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// export const timer = (cb, delay) => {
|
|
239
|
+
// let instance = {};
|
|
240
|
+
// let timerId;
|
|
241
|
+
// let startTime;
|
|
242
|
+
// let remaining = delay;
|
|
243
|
+
//
|
|
244
|
+
// instance.resume = () => {
|
|
245
|
+
// startTime = window.performance.now();
|
|
246
|
+
// clearTimeout(timerId);
|
|
247
|
+
// timerId = setTimeout(cb, remaining);
|
|
248
|
+
// };
|
|
249
|
+
//
|
|
250
|
+
// instance.pause = () => {
|
|
251
|
+
// clearTimeout(timerId);
|
|
252
|
+
// remaining -= window.performance.now() - startTime;
|
|
253
|
+
// };
|
|
254
|
+
//
|
|
255
|
+
// instance.resume();
|
|
256
|
+
//
|
|
257
|
+
// return instance;
|
|
258
|
+
// };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
// NOTE: URangeSlider as a base widget was a good idea.
|
|
3
|
-
// But at the moment not really usable.
|
|
4
|
-
// Maybe deprecate it.
|
|
5
|
-
|
|
6
|
-
import { useTemplateRef, onMounted, useId, watch } from 'vue'
|
|
7
|
-
import { scaleValue } from '../../utils/math/scale-value'
|
|
8
|
-
|
|
9
|
-
export interface RangeSlider {
|
|
10
|
-
label: string
|
|
11
|
-
min?: number
|
|
12
|
-
max?: number
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const { min = 0, max = 100 } = defineProps<RangeSlider>()
|
|
16
|
-
|
|
17
|
-
const id = useId()
|
|
18
|
-
const model = defineModel<number>()
|
|
19
|
-
const thumbEl = useTemplateRef('thumb')
|
|
20
|
-
const lowerFillEl = useTemplateRef('lower-fill')
|
|
21
|
-
let thumbWidth
|
|
22
|
-
|
|
23
|
-
const setThumbPosition = () => {
|
|
24
|
-
const position = scaleValue(Number(model.value), Number(min), Number(max), 0, 100, 2)
|
|
25
|
-
thumbEl.value.style.left = `${position}%`
|
|
26
|
-
|
|
27
|
-
lowerFillEl.value.style.width = `calc(${position}% + ${thumbWidth / 2}px)`
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
onMounted(() => {
|
|
31
|
-
// Store thumb width. We'll judt assume that this won't change during runtime.
|
|
32
|
-
thumbWidth = thumbEl.value.getBoundingClientRect().width
|
|
33
|
-
|
|
34
|
-
setThumbPosition()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
watch(model, () => {
|
|
38
|
-
setThumbPosition()
|
|
39
|
-
})
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<template>
|
|
43
|
-
<div class="range-slider">
|
|
44
|
-
<label class="visually-hidden" :for="id">{{ label }}</label>
|
|
45
|
-
<div class="range-slider__input">
|
|
46
|
-
<input
|
|
47
|
-
:id
|
|
48
|
-
v-model="model"
|
|
49
|
-
type="range"
|
|
50
|
-
:min
|
|
51
|
-
:max
|
|
52
|
-
@input="setThumbPosition"
|
|
53
|
-
@change="setThumbPosition"
|
|
54
|
-
/>
|
|
55
|
-
</div>
|
|
56
|
-
<div class="range-slider__slider">
|
|
57
|
-
<div class="range-slider__track">
|
|
58
|
-
<div ref="lower-fill" class="range-slider__lower-fill"></div>
|
|
59
|
-
<div ref="thumb" class="range-slider__thumb"></div>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</template>
|
|
64
|
-
|
|
65
|
-
<style lang="scss" scoped>
|
|
66
|
-
@use '../../base/abstracts' as a;
|
|
67
|
-
|
|
68
|
-
.range-slider {
|
|
69
|
-
--range-height: 24px;
|
|
70
|
-
--range-width: 100%;
|
|
71
|
-
--range-border-radius: 0;
|
|
72
|
-
--range-upper-fill-color: rgba(150, 150, 150);
|
|
73
|
-
--range-lower-fill-color: rgb(0, 150, 0);
|
|
74
|
-
--range-thumb-height: 24px;
|
|
75
|
-
--range-thumb-width: 12px;
|
|
76
|
-
--range-thumb-border-radius: 0;
|
|
77
|
-
--range-thumb-background-color: rgb(0, 0, 0);
|
|
78
|
-
--range-thumb-transform: none;
|
|
79
|
-
--range-thumb-transition: none;
|
|
80
|
-
|
|
81
|
-
/* "display: contents" would be better, but it still has some accessiblity issues -> https://ericwbailey.website/published/display-contents-considered-harmful/ */
|
|
82
|
-
position: relative;
|
|
83
|
-
display: inline-flex;
|
|
84
|
-
width: var(--range-width);
|
|
85
|
-
height: var(--range-height);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.range-slider__input {
|
|
89
|
-
display: flex;
|
|
90
|
-
width: 100%;
|
|
91
|
-
|
|
92
|
-
input {
|
|
93
|
-
width: 100%;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.range-slider__slider {
|
|
98
|
-
position: absolute;
|
|
99
|
-
top: 0;
|
|
100
|
-
left: 0;
|
|
101
|
-
width: 100%;
|
|
102
|
-
height: 100%;
|
|
103
|
-
pointer-events: none;
|
|
104
|
-
background-color: var(--range-upper-fill-color);
|
|
105
|
-
border-radius: var(--range-border-radius);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.range-slider__thumb {
|
|
109
|
-
position: relative;
|
|
110
|
-
height: var(--range-thumb-height);
|
|
111
|
-
width: var(--range-thumb-width);
|
|
112
|
-
background-color: var(--range-thumb-background-color);
|
|
113
|
-
border-radius: var(--range-thumb-border-radius);
|
|
114
|
-
transform: var(--range-thumb-transform);
|
|
115
|
-
transition: var(--range-thumb-transition);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.range-slider__track {
|
|
119
|
-
position: relative;
|
|
120
|
-
width: calc(100% - var(--range-thumb-width));
|
|
121
|
-
height: 100%;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.range-slider__lower-fill {
|
|
125
|
-
position: absolute;
|
|
126
|
-
top: 0;
|
|
127
|
-
left: 0;
|
|
128
|
-
height: 100%;
|
|
129
|
-
border-top-left-radius: var(--range-border-radius);
|
|
130
|
-
border-bottom-left-radius: var(--range-border-radius);
|
|
131
|
-
background-color: var(--range-lower-fill-color);
|
|
132
|
-
min-width: var(--range-thumb-width);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.visually-hidden {
|
|
136
|
-
@include a.visually-hidden;
|
|
137
|
-
}
|
|
138
|
-
</style>
|