File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
src/Frontend/src/components Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ import { ref , watch , onMounted } from " vue" ;
3
+
4
+ const props = withDefaults (
5
+ defineProps <{
6
+ text: string ;
7
+ ellipsesStyle? : " RightSide" | " LeftSide" ;
8
+ }>(),
9
+ { ellipsesStyle: " RightSide" }
10
+ );
11
+
12
+ const textContainer = ref <HTMLElement | null >(null );
13
+ const tooltipText = ref (" " );
14
+
15
+ const updateTooltip = () => {
16
+ if (textContainer .value ) {
17
+ tooltipText .value = textContainer .value .scrollWidth > textContainer .value .clientWidth ? textContainer .value .textContent || " " : " " ;
18
+ }
19
+ };
20
+
21
+ onMounted (() => {
22
+ updateTooltip ();
23
+ });
24
+
25
+ watch ([() => props .text ], () => {
26
+ updateTooltip ();
27
+ });
28
+ </script >
29
+
30
+ <template >
31
+ <div ref =" textContainer" title =" " class =" text-container hackToPreventSafariFromShowingTooltip" :class =" { 'left-side-ellipsis': ellipsesStyle === 'LeftSide' }" v-tippy =" { content: tooltipText, maxWidth: 'none' }" >
32
+ {{ text }}
33
+ </div >
34
+ </template >
35
+
36
+ <style scoped>
37
+ .hackToPreventSafariFromShowingTooltip ::after {
38
+ content : " " ;
39
+ display : block ;
40
+ }
41
+
42
+ .left-side-ellipsis {
43
+ direction : rtl ;
44
+ text-align : left ;
45
+ }
46
+
47
+ .text-container {
48
+ white-space : nowrap ;
49
+ overflow : hidden ;
50
+ text-overflow : ellipsis ;
51
+ display : inline-block ;
52
+ }
53
+ </style >
You can’t perform that action at this time.
0 commit comments