@dative-gpi/foundation-shared-components 0.0.44 → 0.0.45
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/FSCheckbox.vue +1 -1
- package/components/FSFadeOut.vue +47 -13
- package/components/FSImage.vue +49 -33
- package/components/FSRadio.vue +1 -1
- package/components/FSSwitch.vue +2 -2
- package/package.json +4 -4
- package/styles/components/fs_fade_out.scss +2 -6
- package/styles/components/fs_image.scss +0 -4
- package/styles/components/fs_switch.scss +1 -0
|
@@ -102,7 +102,7 @@ export default defineComponent({
|
|
|
102
102
|
if (!props.editable) {
|
|
103
103
|
return {
|
|
104
104
|
"--fs-checkbox-cursor" : "default",
|
|
105
|
-
"--fs-checkbox-checkbox-color": lights.
|
|
105
|
+
"--fs-checkbox-checkbox-color": (props.modelValue || props.indeterminate) ? colors.value.light : lights.base,
|
|
106
106
|
"--fs-checkbox-color" : lights.dark
|
|
107
107
|
};
|
|
108
108
|
}
|
package/components/FSFadeOut.vue
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
|
-
import { computed, defineComponent, onMounted, PropType, ref } from "vue";
|
|
15
|
+
import { computed, defineComponent, onMounted, PropType, ref, watch } from "vue";
|
|
16
16
|
|
|
17
|
-
import { useColors } from "@dative-gpi/foundation-shared-components/composables";
|
|
17
|
+
import { useBreakpoints, useColors, useDebounce } from "@dative-gpi/foundation-shared-components/composables";
|
|
18
18
|
import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
19
19
|
import { sizeToVar } from "@dative-gpi/foundation-shared-components/utils";
|
|
20
20
|
|
|
@@ -42,24 +42,26 @@ export default defineComponent({
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
setup(props) {
|
|
45
|
+
const { windowWidth } = useBreakpoints();
|
|
46
|
+
const { debounce } = useDebounce();
|
|
45
47
|
const { getColors } = useColors();
|
|
46
48
|
|
|
47
49
|
const backgrounds = getColors(ColorEnum.Background);
|
|
48
50
|
|
|
49
51
|
const fadeOutRef = ref(null);
|
|
50
|
-
const topMaskHeight = ref("0px");
|
|
51
52
|
const bottomMaskHeight = ref("0px");
|
|
53
|
+
const topMaskHeight = ref("0px");
|
|
52
54
|
|
|
53
55
|
const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
|
|
54
56
|
return {
|
|
55
|
-
"--fs-fade-out-height"
|
|
56
|
-
"--fs-fade-out-width"
|
|
57
|
-
"--fs-fade-out-padding"
|
|
58
|
-
"--fs-fade-out-mask-color"
|
|
59
|
-
"--fs-fade-out-top-mask-height"
|
|
60
|
-
"--fs-fade-out-top-mask-top"
|
|
61
|
-
"--fs-fade-out-bottom-mask-height": bottomMaskHeight.value,
|
|
62
|
-
"--fs-fade-out-bottom-mask-bottom": bottomPadding.value
|
|
57
|
+
"--fs-fade-out-height" : sizeToVar(props.height),
|
|
58
|
+
"--fs-fade-out-width" : sizeToVar(props.width),
|
|
59
|
+
"--fs-fade-out-padding" : sizeToVar(props.padding),
|
|
60
|
+
"--fs-fade-out-mask-color" : backgrounds.base,
|
|
61
|
+
"--fs-fade-out-top-mask-height" : topMaskHeight.value,
|
|
62
|
+
"--fs-fade-out-top-mask-top" : topPadding.value,
|
|
63
|
+
"--fs-fade-out-bottom-mask-height" : bottomMaskHeight.value,
|
|
64
|
+
"--fs-fade-out-bottom-mask-bottom" : bottomPadding.value
|
|
63
65
|
};
|
|
64
66
|
});
|
|
65
67
|
|
|
@@ -107,7 +109,16 @@ export default defineComponent({
|
|
|
107
109
|
}
|
|
108
110
|
});
|
|
109
111
|
|
|
110
|
-
const onScroll = ({ target }): void => {
|
|
112
|
+
const onScroll = ({ target }): void => debounce(() => {
|
|
113
|
+
const currentTopMaskHeight = target.children[0].clientHeight;
|
|
114
|
+
const currentBottomMaskHeight = target.children[target.children.length - 1].clientHeight;
|
|
115
|
+
const contentHeight = target.scrollHeight - currentTopMaskHeight - currentBottomMaskHeight;
|
|
116
|
+
|
|
117
|
+
if (target.clientHeight >= contentHeight) {
|
|
118
|
+
bottomMaskHeight.value = "0px";
|
|
119
|
+
topMaskHeight.value = "0px";
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
111
122
|
if (target.scrollHeight - target.scrollTop - target.clientHeight < 1) {
|
|
112
123
|
bottomMaskHeight.value = "0px";
|
|
113
124
|
}
|
|
@@ -120,7 +131,28 @@ export default defineComponent({
|
|
|
120
131
|
else {
|
|
121
132
|
topMaskHeight.value = sizeToVar(props.maskHeight);
|
|
122
133
|
}
|
|
123
|
-
}
|
|
134
|
+
}, 25);
|
|
135
|
+
|
|
136
|
+
const onResize = (): void => debounce(() => {
|
|
137
|
+
if (fadeOutRef.value) {
|
|
138
|
+
const currentTopMaskHeight = fadeOutRef.value.children[0].clientHeight;
|
|
139
|
+
const currentBottomMaskHeight = fadeOutRef.value.children[fadeOutRef.value.children.length - 1].clientHeight;
|
|
140
|
+
const contentHeight = fadeOutRef.value.scrollHeight - currentTopMaskHeight - currentBottomMaskHeight;
|
|
141
|
+
|
|
142
|
+
if (fadeOutRef.value.clientHeight < contentHeight) {
|
|
143
|
+
if (fadeOutRef.value.scrollHeight - fadeOutRef.value.scrollTop - fadeOutRef.value.clientHeight > 0) {
|
|
144
|
+
bottomMaskHeight.value = sizeToVar(props.maskHeight);
|
|
145
|
+
}
|
|
146
|
+
if (fadeOutRef.value.scrollTop > 0) {
|
|
147
|
+
topMaskHeight.value = sizeToVar(props.maskHeight);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
bottomMaskHeight.value = "0px";
|
|
152
|
+
topMaskHeight.value = "0px";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, 200);
|
|
124
156
|
|
|
125
157
|
onMounted((): void => {
|
|
126
158
|
if (fadeOutRef.value) {
|
|
@@ -130,6 +162,8 @@ export default defineComponent({
|
|
|
130
162
|
}
|
|
131
163
|
});
|
|
132
164
|
|
|
165
|
+
watch(() => windowWidth.value, onResize);
|
|
166
|
+
|
|
133
167
|
return {
|
|
134
168
|
fadeOutRef,
|
|
135
169
|
style,
|
package/components/FSImage.vue
CHANGED
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-img
|
|
3
3
|
class="fs-image"
|
|
4
|
+
ref="imageRef"
|
|
4
5
|
:height="computedHeight"
|
|
5
6
|
:width="computedWidth"
|
|
6
7
|
:cover="$props.cover"
|
|
7
8
|
:style="style"
|
|
8
9
|
:src="source"
|
|
10
|
+
@error="onError"
|
|
9
11
|
v-bind="$attrs"
|
|
10
12
|
>
|
|
11
13
|
<template #placeholder>
|
|
12
14
|
<FSLoader
|
|
13
|
-
class="fs-load
|
|
15
|
+
class="fs-image-load"
|
|
14
16
|
height="100%"
|
|
15
17
|
width="100%"
|
|
16
18
|
:borderRadius="$props.borderRadius"
|
|
17
19
|
/>
|
|
18
20
|
</template>
|
|
21
|
+
<template #error>
|
|
22
|
+
<FSLoader
|
|
23
|
+
v-if="!blurHash"
|
|
24
|
+
class="fs-image-load"
|
|
25
|
+
height="100%"
|
|
26
|
+
width="100%"
|
|
27
|
+
:borderRadius="$props.borderRadius"
|
|
28
|
+
/>
|
|
29
|
+
<canvas
|
|
30
|
+
ref="canvasRef"
|
|
31
|
+
/>
|
|
32
|
+
</template>
|
|
19
33
|
</v-img>
|
|
20
34
|
</template>
|
|
21
35
|
|
|
22
36
|
<script lang="ts">
|
|
23
|
-
import { computed, defineComponent,
|
|
37
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
38
|
+
import { decode, isBlurhashValid } from "blurhash";
|
|
24
39
|
|
|
25
|
-
import {
|
|
40
|
+
import { useImageBlurHash } from "@dative-gpi/foundation-shared-services/composables";
|
|
41
|
+
import { IMAGE_RAW_URL } from "@dative-gpi/foundation-shared-services/config/urls";
|
|
26
42
|
import { sizeToVar } from "@dative-gpi/foundation-shared-components/utils";
|
|
27
43
|
|
|
28
44
|
import FSLoader from "./FSLoader.vue";
|
|
@@ -65,12 +81,15 @@ export default defineComponent({
|
|
|
65
81
|
}
|
|
66
82
|
},
|
|
67
83
|
setup(props) {
|
|
68
|
-
const {
|
|
69
|
-
|
|
84
|
+
const { get: fetchBlurHash, entity: blurHash } = useImageBlurHash();
|
|
85
|
+
|
|
86
|
+
const imageRef = ref(null);
|
|
87
|
+
const canvasRef = ref(null);
|
|
70
88
|
|
|
71
89
|
const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
|
|
72
90
|
return {
|
|
73
|
-
"--fs-image-border-radius": sizeToVar(props.borderRadius)
|
|
91
|
+
"--fs-image-border-radius" : sizeToVar(props.borderRadius),
|
|
92
|
+
"--fs-image-blurhash-opacity": blurHash.value ? "1" : "0"
|
|
74
93
|
}
|
|
75
94
|
});
|
|
76
95
|
|
|
@@ -113,44 +132,41 @@ export default defineComponent({
|
|
|
113
132
|
});
|
|
114
133
|
|
|
115
134
|
const source = computed((): string | null => {
|
|
116
|
-
if (
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
if (image.value) {
|
|
120
|
-
return image.value;
|
|
121
|
-
}
|
|
122
|
-
if (fetchingBlurHash.value) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
if (blurHash.value) {
|
|
126
|
-
return blurHash.value.blurHash;
|
|
135
|
+
if (props.imageId) {
|
|
136
|
+
return IMAGE_RAW_URL(props.imageId);
|
|
127
137
|
}
|
|
128
138
|
return null;
|
|
129
139
|
});
|
|
130
140
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
watch(() => props.imageId, () => {
|
|
136
|
-
fetch();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const fetch = async () => {
|
|
140
|
-
if (!props.imageId) {
|
|
141
|
-
return;
|
|
141
|
+
const onError = (): void => {
|
|
142
|
+
if (props.imageId) {
|
|
143
|
+
fetchBlurHash(props.imageId);
|
|
142
144
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
watch(() => blurHash.value, () => {
|
|
148
|
+
if (canvasRef.value && imageRef.value) {
|
|
149
|
+
if (blurHash.value && isBlurhashValid(blurHash.value.blurHash).result) {
|
|
150
|
+
const ctx = canvasRef.value.getContext("2d");
|
|
151
|
+
if (ctx) {
|
|
152
|
+
const pixels = decode(blurHash.value.blurHash, imageRef.value.$el.clientWidth, imageRef.value.$el.clientHeight);
|
|
153
|
+
const imageData = ctx.createImageData(imageRef.value.$el.clientWidth, imageRef.value.$el.clientHeight);
|
|
154
|
+
imageData.data.set(pixels);
|
|
155
|
+
ctx.putImageData(imageData, 0, 0);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
146
158
|
}
|
|
147
|
-
}
|
|
159
|
+
});
|
|
148
160
|
|
|
149
161
|
return {
|
|
150
162
|
computedHeight,
|
|
151
163
|
computedWidth,
|
|
164
|
+
canvasRef,
|
|
165
|
+
imageRef,
|
|
166
|
+
blurHash,
|
|
152
167
|
source,
|
|
153
|
-
style
|
|
168
|
+
style,
|
|
169
|
+
onError
|
|
154
170
|
};
|
|
155
171
|
}
|
|
156
172
|
});
|
package/components/FSRadio.vue
CHANGED
|
@@ -96,7 +96,7 @@ export default defineComponent({
|
|
|
96
96
|
if (!props.editable) {
|
|
97
97
|
return {
|
|
98
98
|
"--fs-radio-cursor" : "default",
|
|
99
|
-
"--fs-radio-radio-color": lights.
|
|
99
|
+
"--fs-radio-radio-color": props.selected ? colors.value.light : lights.base,
|
|
100
100
|
"--fs-radio-color" : lights.dark
|
|
101
101
|
};
|
|
102
102
|
}
|
package/components/FSSwitch.vue
CHANGED
|
@@ -99,7 +99,7 @@ export default defineComponent({
|
|
|
99
99
|
return {
|
|
100
100
|
"--fs-switch-translate-x": props.modelValue ? "8px" : "-8px",
|
|
101
101
|
"--fs-switch-cursor" : "default",
|
|
102
|
-
"--fs-switch-track-color": lights.
|
|
102
|
+
"--fs-switch-track-color": props.modelValue ? colors.value.light : lights.base,
|
|
103
103
|
"--fs-switch-thumb-color": backgrounds.base,
|
|
104
104
|
"--fs-switch-color" : lights.dark
|
|
105
105
|
};
|
|
@@ -107,7 +107,7 @@ export default defineComponent({
|
|
|
107
107
|
return {
|
|
108
108
|
"--fs-switch-translate-x": props.modelValue ? "8px" : "-8px",
|
|
109
109
|
"--fs-switch-cursor" : "pointer",
|
|
110
|
-
"--fs-switch-track-color": props.modelValue ? colors.value.base :
|
|
110
|
+
"--fs-switch-track-color": props.modelValue ? colors.value.base : lights.dark,
|
|
111
111
|
"--fs-switch-thumb-color": backgrounds.base,
|
|
112
112
|
"--fs-switch-color" : darks.base
|
|
113
113
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.45",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "0.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "0.0.45",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "0.0.45",
|
|
15
15
|
"@fontsource/montserrat": "^5.0.16",
|
|
16
16
|
"@lexical/clipboard": "^0.12.5",
|
|
17
17
|
"@lexical/history": "^0.12.5",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"sass": "^1.69.5",
|
|
33
33
|
"sass-loader": "^13.3.2"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "4af778193801da465615d1718cc5562e3297d651"
|
|
36
36
|
}
|
|
@@ -12,25 +12,21 @@
|
|
|
12
12
|
.fs-fade-out-top {
|
|
13
13
|
pointer-events: none;
|
|
14
14
|
position: sticky;
|
|
15
|
-
display: flex;
|
|
16
15
|
z-index: 10;
|
|
17
|
-
height: var(--fs-fade-out-top-mask-height);
|
|
18
16
|
min-height: var(--fs-fade-out-top-mask-height);
|
|
19
17
|
width: 100%;
|
|
20
18
|
top: var(--fs-fade-out-top-mask-top);
|
|
21
|
-
transition: all 0.
|
|
19
|
+
transition: all 0.14s cubic-bezier(0.4, 0, 0.2, 1);
|
|
22
20
|
background: linear-gradient(to top, transparent 0, var(--fs-fade-out-mask-color) var(--fs-fade-out-top-mask-height));
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
.fs-fade-out-bottom {
|
|
26
24
|
pointer-events: none;
|
|
27
25
|
position: sticky;
|
|
28
|
-
display: flex;
|
|
29
26
|
z-index: 10;
|
|
30
|
-
height: var(--fs-fade-out-bottom-mask-height);
|
|
31
27
|
min-height: var(--fs-fade-out-bottom-mask-height);
|
|
32
28
|
width: 100%;
|
|
33
29
|
bottom: var(--fs-fade-out-bottom-mask-bottom);
|
|
34
|
-
transition: all 0.
|
|
30
|
+
transition: all 0.14s cubic-bezier(0.4, 0, 0.2, 1);
|
|
35
31
|
background: linear-gradient(to bottom, transparent 0, var(--fs-fade-out-mask-color) var(--fs-fade-out-bottom-mask-height));
|
|
36
32
|
}
|