@eturnity/eturnity_reusable_components 7.48.1-EPDM-12680.11 → 7.48.1-EPDM-10964.0

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.
@@ -1,225 +0,0 @@
1
- <template>
2
- <ComponentWrapper>
3
- <IconWrapper :size="size">
4
- <IconImg
5
- ref="iconImg"
6
- @click.prevent="toggleShowInfo()"
7
- @mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
8
- @mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
9
- >
10
- <IconComponent
11
- :color="iconColor"
12
- cursor="pointer"
13
- name="info"
14
- :size="size"
15
- />
16
- </IconImg>
17
- <TextOverlay
18
- v-if="showInfo"
19
- :arrow-position="arrowPosition"
20
- :icon-size="size"
21
- :max-width="maxWidth"
22
- :position="overlayPosition"
23
- :style="overlayStyle"
24
- :width="width"
25
- ><slot></slot>
26
- <span v-html="text"></span>
27
- </TextOverlay>
28
- </IconWrapper>
29
- </ComponentWrapper>
30
- </template>
31
-
32
- <script>
33
- // import InfoText from "@eturnity/eturnity_reusable_components/src/components/infoText"
34
- //To use:
35
- // <info-text
36
- // text="Veritatis et quasi architecto beatae vitae"
37
- // size="20px"
38
- // />
39
- import theme from '../../assets/theme.js'
40
- import styled from 'vue3-styled-components'
41
- import IconComponent from '../icon'
42
-
43
- const textAttrs = {
44
- iconSize: String,
45
- width: String,
46
- position: String,
47
- arrowPosition: String,
48
- }
49
- const TextOverlay = styled('div', textAttrs)`
50
- position: absolute;
51
- text-align: left;
52
- background: ${(props) => props.theme.colors.black};
53
- padding: 10px;
54
- width: ${(props) => props.width};
55
- max-width: ${(props) => props.maxWidth};
56
- font-size: 13px;
57
- font-weight: 400;
58
- line-height: normal;
59
- border-radius: 4px;
60
- z-index: 9999;
61
- color: ${(props) => props.theme.colors.white};
62
- word-wrap: break-word;
63
- overflow-wrap: break-word;
64
-
65
- :before {
66
- content: '';
67
- background-color: ${(props) => props.theme.colors.black};
68
- position: absolute;
69
- ${(props) => (props.position === 'top' ? 'bottom: -4px;' : 'top: -4px;')}
70
- ${(props) => {
71
- switch (props.arrowPosition) {
72
- case 'left':
73
- return 'left: 40px;'
74
- case 'center':
75
- return 'left: calc(50% - 4px);'
76
- case 'right':
77
- return 'right: 40px;'
78
- default:
79
- return 'left: calc(50% - 4px);'
80
- }
81
- }}
82
- height: 8px;
83
- width: 8px;
84
- transform-origin: center center;
85
- transform: rotate(45deg);
86
- }
87
-
88
- span a {
89
- color: #2cc0eb;
90
- }
91
- `
92
-
93
- const iconAttrs = { size: String }
94
- const IconWrapper = styled('div', iconAttrs)`
95
- position: relative;
96
- height: ${(props) => props.size};
97
- `
98
-
99
- const IconImg = styled.div`
100
- line-height: 0;
101
- `
102
-
103
- const ComponentWrapper = styled.div`
104
- display: inline-block;
105
- `
106
-
107
- export default {
108
- name: 'InfoText',
109
- components: {
110
- IconWrapper,
111
- TextOverlay,
112
- ComponentWrapper,
113
- IconImg,
114
- IconComponent,
115
- },
116
- props: {
117
- text: {
118
- required: false,
119
- },
120
- size: {
121
- required: false,
122
- default: '14px',
123
- },
124
- openTrigger: {
125
- required: false,
126
- default: 'onHover', // onHover, onClick
127
- },
128
- width: {
129
- required: false,
130
- default: '200px',
131
- },
132
- maxWidth: {
133
- type: String,
134
- default: '400px',
135
- },
136
- },
137
- data() {
138
- return {
139
- showInfo: false,
140
- overlayStyle: {},
141
- overlayPosition: 'top',
142
- arrowPosition: 'center',
143
- }
144
- },
145
- computed: {
146
- iconColor() {
147
- return theme.colors.mediumGray
148
- },
149
- },
150
- mounted() {
151
- window.addEventListener('resize', this.positionOverlay)
152
- },
153
- beforeUnmount() {
154
- window.removeEventListener('resize', this.positionOverlay)
155
- },
156
- methods: {
157
- toggleShowInfo() {
158
- this.showInfo = !this.showInfo
159
-
160
- if (this.showInfo) {
161
- document.addEventListener('click', this.clickOutside)
162
- this.$nextTick(() => {
163
- this.positionOverlay()
164
- })
165
- } else {
166
- document.removeEventListener('click', this.clickOutside)
167
- }
168
- },
169
- clickOutside(event) {
170
- if (this.$el.contains(event.target)) {
171
- return
172
- }
173
- this.toggleShowInfo()
174
- },
175
- positionOverlay() {
176
- const iconRect = this.$refs.iconImg.getBoundingClientRect()
177
- const overlayRect = this.$el
178
- .querySelector('.TextOverlay')
179
- .getBoundingClientRect()
180
-
181
- let top, left
182
-
183
- // Check if there's enough space above the icon
184
- if (
185
- iconRect.top > overlayRect.height + 10 &&
186
- iconRect.top > window.innerHeight / 2
187
- ) {
188
- top = -overlayRect.height - 10
189
- this.overlayPosition = 'top'
190
- } else {
191
- // If not, position it below the icon
192
- top = iconRect.height + 10
193
- this.overlayPosition = 'bottom'
194
- }
195
-
196
- left = -(overlayRect.width / 2) + iconRect.width / 2
197
-
198
- // Ensure the overlay doesn't go off-screen horizontally
199
- if (iconRect.left + left < 0) {
200
- left = -iconRect.left
201
- this.arrowPosition = 'left'
202
- } else if (
203
- iconRect.left + left + overlayRect.width >
204
- window.innerWidth
205
- ) {
206
- left = window.innerWidth - (iconRect.left + overlayRect.width)
207
- this.arrowPosition = 'right'
208
- } else {
209
- this.arrowPosition = 'center'
210
- }
211
-
212
- // Adjust vertical position if it goes off-screen
213
- const totalHeight = iconRect.top + top + overlayRect.height
214
- if (totalHeight > window.innerHeight) {
215
- top -= totalHeight - window.innerHeight + 10
216
- }
217
-
218
- this.overlayStyle = {
219
- top: `${top}px`,
220
- left: `${left}px`,
221
- }
222
- },
223
- },
224
- }
225
- </script>