@eturnity/eturnity_reusable_components 7.45.5-EPDM-10609.6 → 7.45.5-EPDM-10609.8
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/package.json
CHANGED
@@ -8,11 +8,16 @@
|
|
8
8
|
@mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
|
9
9
|
@mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
|
10
10
|
>
|
11
|
-
<Dot
|
11
|
+
<Dot
|
12
|
+
v-if="type === 'dot'"
|
13
|
+
:color="dotColor"
|
14
|
+
data-test-id="infoText_dot"
|
15
|
+
/>
|
12
16
|
<IconComponent
|
13
17
|
v-else
|
14
18
|
:color="iconColor"
|
15
19
|
cursor="pointer"
|
20
|
+
data-test-id="infoText_info"
|
16
21
|
name="info"
|
17
22
|
:size="size"
|
18
23
|
/>
|
@@ -21,6 +26,7 @@
|
|
21
26
|
<TextOverlay
|
22
27
|
v-if="showInfo"
|
23
28
|
:align-arrow="alignArrow"
|
29
|
+
data-test-id="info_text_wrapper"
|
24
30
|
:half-computed-text-info-width="halfComputedTextInfoWidth"
|
25
31
|
:icon-size="size"
|
26
32
|
:info-position="infoPosition"
|
@@ -87,11 +93,9 @@
|
|
87
93
|
: props.alignArrow === 'left'
|
88
94
|
? 'left: calc(' + props.iconSize + ' /2 - 18px)'
|
89
95
|
: props.alignArrow === 'center'
|
90
|
-
? 'left: calc((-' + props.width + ' + ' + props.iconSize + ') /2
|
96
|
+
? 'left: calc((-' + props.width + ' + ' + props.iconSize + ') /2)'
|
91
97
|
: 'right: calc(' + props.iconSize + ' /2 - 17px)'};
|
92
98
|
|
93
|
-
${(props) => (props.infoPosition === 'left' ? 'right' : 'left')} : 0;
|
94
|
-
|
95
99
|
text-align: left;
|
96
100
|
background: ${(props) => props.theme.colors.black};
|
97
101
|
padding: 10px;
|
@@ -172,30 +176,26 @@
|
|
172
176
|
type: String,
|
173
177
|
required: false,
|
174
178
|
default: '14px',
|
175
|
-
type: String,
|
176
179
|
},
|
177
180
|
infoPosition: {
|
178
181
|
required: false,
|
179
|
-
default: 'bottom',
|
182
|
+
default: 'bottom', // top, bottom
|
180
183
|
type: String,
|
181
184
|
},
|
182
185
|
alignArrow: {
|
183
186
|
type: String,
|
184
187
|
required: false,
|
185
|
-
default: 'center',
|
186
|
-
type: String,
|
188
|
+
default: 'center', // left, center, right
|
187
189
|
},
|
188
190
|
openTrigger: {
|
189
191
|
type: String,
|
190
192
|
required: false,
|
191
193
|
default: 'onHover', // onHover, onClick
|
192
|
-
type: String,
|
193
194
|
},
|
194
195
|
width: {
|
195
196
|
type: String,
|
196
197
|
required: false,
|
197
198
|
default: '165px',
|
198
|
-
type: String,
|
199
199
|
},
|
200
200
|
maxWidth: {
|
201
201
|
default: '400px',
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import { mount } from '@vue/test-utils'
|
3
|
+
import InfoText from '@/components/infoText'
|
4
|
+
import theme from '@/assets/theme'
|
5
|
+
|
6
|
+
jest.mock('@/components/icon/iconCache.mjs', () => ({
|
7
|
+
// need to mock this due to how jest handles import.meta
|
8
|
+
fetchIcon: jest.fn(() => Promise.resolve('close_for_modals,_tool_tips.svg')),
|
9
|
+
}))
|
10
|
+
|
11
|
+
describe('InfoText Component', () => {
|
12
|
+
let wrapper
|
13
|
+
|
14
|
+
beforeEach(() => {
|
15
|
+
wrapper = mount(InfoText, {
|
16
|
+
props: {
|
17
|
+
text: 'default text',
|
18
|
+
size: '14px',
|
19
|
+
infoPosition: 'bottom',
|
20
|
+
alignArrow: 'center',
|
21
|
+
openTrigger: 'onHover',
|
22
|
+
width: '165px',
|
23
|
+
maxWidth: '165px',
|
24
|
+
shouldUseTeleport: false,
|
25
|
+
dotColor: '#00009f',
|
26
|
+
type: 'info',
|
27
|
+
},
|
28
|
+
global: {
|
29
|
+
provide: {
|
30
|
+
theme,
|
31
|
+
},
|
32
|
+
},
|
33
|
+
})
|
34
|
+
})
|
35
|
+
|
36
|
+
test('renders InfoText component with default props', () => {
|
37
|
+
expect(wrapper.find('[data-test-id="infoText_info"]').exists()).toBe(true)
|
38
|
+
expect(wrapper.vm.text).toContain('default text')
|
39
|
+
expect(wrapper.vm.size).toContain('14px')
|
40
|
+
expect(wrapper.vm.infoPosition).toContain('bottom')
|
41
|
+
expect(wrapper.vm.alignArrow).toContain('center')
|
42
|
+
})
|
43
|
+
|
44
|
+
test('openTrigger prop is set to onClick', async () => {
|
45
|
+
await wrapper.setProps({ openTrigger: 'onClick' })
|
46
|
+
|
47
|
+
//should not see text upon hover
|
48
|
+
expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
|
49
|
+
false
|
50
|
+
)
|
51
|
+
//should see text upon click
|
52
|
+
await wrapper.find('[data-test-id="infoText_trigger"]').trigger('click')
|
53
|
+
expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
|
54
|
+
true
|
55
|
+
)
|
56
|
+
})
|
57
|
+
|
58
|
+
test('position type is dot', async () => {
|
59
|
+
await wrapper.setProps({ type: 'dot' })
|
60
|
+
expect(wrapper.find('[data-test-id="infoText_dot"]').exists()).toBe(true)
|
61
|
+
})
|
62
|
+
})
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import InfoText from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'infoText',
|
5
|
+
component: InfoText,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
}
|
11
|
+
|
12
|
+
// import InfoText from "@eturnity/eturnity_reusable_components/src/components/infoText"
|
13
|
+
//To use:
|
14
|
+
// <info-text
|
15
|
+
// text="Veritatis et quasi architecto beatae vitae"
|
16
|
+
// size="20px"
|
17
|
+
// alignArrow="right" // which side the arrow should be on
|
18
|
+
// />
|
19
|
+
|
20
|
+
export const Default = {
|
21
|
+
args: {
|
22
|
+
text: 'default text',
|
23
|
+
size: '14px',
|
24
|
+
infoPosition: 'bottom',
|
25
|
+
alignArrow: 'center',
|
26
|
+
openTrigger: 'onHover',
|
27
|
+
width: '165px',
|
28
|
+
maxWidth: '165px',
|
29
|
+
shouldUseTeleport: false,
|
30
|
+
dotColor: '#00009f',
|
31
|
+
type: 'info',
|
32
|
+
},
|
33
|
+
}
|
34
|
+
|
35
|
+
export const Dot = {
|
36
|
+
args: {
|
37
|
+
...Default.args,
|
38
|
+
type: 'dot',
|
39
|
+
},
|
40
|
+
}
|
41
|
+
|
42
|
+
//will only show the info text on click
|
43
|
+
export const OnClick = {
|
44
|
+
args: {
|
45
|
+
...Default.args,
|
46
|
+
openTrigger: 'onClick',
|
47
|
+
},
|
48
|
+
}
|