@eturnity/eturnity_reusable_components 8.16.3 → 8.16.5-EPDM-12618.5
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 +1 -1
- package/src/assets/svgIcons/ac_power.svg +4 -0
- package/src/assets/svgIcons/arrow_long_left.svg +3 -0
- package/src/assets/svgIcons/arrow_long_right.svg +3 -0
- package/src/assets/svgIcons/chassis_ground_symbol.svg +27 -0
- package/src/assets/svgIcons/dc_power.svg +8 -0
- package/src/assets/svgIcons/double_arrow_long.svg +4 -0
- package/src/assets/svgIcons/ed_ac.svg +3 -0
- package/src/assets/svgIcons/ed_acgrid.svg +4 -0
- package/src/assets/svgIcons/ed_arrow_both.svg +7 -0
- package/src/assets/svgIcons/ed_arrow_left.svg +7 -0
- package/src/assets/svgIcons/ed_arrow_right.svg +7 -0
- package/src/assets/svgIcons/ed_battery.svg +10 -0
- package/src/assets/svgIcons/ed_batteryacinverter.svg +16 -0
- package/src/assets/svgIcons/ed_batteryintegratedinverter.svg +19 -0
- package/src/assets/svgIcons/ed_cirquitbreaker.svg +4 -0
- package/src/assets/svgIcons/ed_cirquitbreaker_magnetic.svg +6 -0
- package/src/assets/svgIcons/ed_cirquitbreaker_thermal.svg +4 -0
- package/src/assets/svgIcons/ed_cirquitbreaker_thermal_magnetic.svg +5 -0
- package/src/assets/svgIcons/ed_consumption.svg +3 -0
- package/src/assets/svgIcons/ed_dc.svg +6 -0
- package/src/assets/svgIcons/ed_disconnector.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_fuse.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_fuse_switch.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_loadbreak switch.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_switch.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_switch_auto_release.svg +5 -0
- package/src/assets/svgIcons/ed_energymanagement_rectangle.svg +3 -0
- package/src/assets/svgIcons/ed_evcharger.svg +19 -0
- package/src/assets/svgIcons/ed_flexiblecomponent_circle.svg +3 -0
- package/src/assets/svgIcons/ed_flexiblecomponent_square.svg +3 -0
- package/src/assets/svgIcons/ed_fuse.svg +3 -0
- package/src/assets/svgIcons/ed_ground.svg +5 -0
- package/src/assets/svgIcons/ed_heatpump.svg +4 -0
- package/src/assets/svgIcons/ed_icon_battery.svg +9 -0
- package/src/assets/svgIcons/ed_icon_circle.svg +3 -0
- package/src/assets/svgIcons/ed_icon_heatpump.svg +3 -0
- package/src/assets/svgIcons/ed_icon_inverter.svg +8 -0
- package/src/assets/svgIcons/ed_icon_optimizer.svg +11 -0
- package/src/assets/svgIcons/ed_integratedbatteryinverter.svg +10 -0
- package/src/assets/svgIcons/ed_inverter-blank.svg +3 -0
- package/src/assets/svgIcons/ed_mainsconnection.svg +3 -0
- package/src/assets/svgIcons/ed_meter_arrowleft.svg +4 -0
- package/src/assets/svgIcons/ed_meter_arrowright.svg +4 -0
- package/src/assets/svgIcons/ed_meter_bidirectional.svg +5 -0
- package/src/assets/svgIcons/ed_networkandsystemprotection_double.svg +14 -0
- package/src/assets/svgIcons/ed_networkandsystemprotection_single.svg +7 -0
- package/src/assets/svgIcons/ed_pvpanel.svg +7 -0
- package/src/assets/svgIcons/ed_rcd.svg +5 -0
- package/src/assets/svgIcons/ed_rcd_simple.svg +3 -0
- package/src/assets/svgIcons/ed_spd.svg +6 -0
- package/src/assets/svgIcons/ed_stringwithoptimizer.svg +33 -0
- package/src/assets/svgIcons/ed_stringwithoutoptimizer.svg +17 -0
- package/src/assets/svgIcons/ed_transformer.svg +3 -0
- package/src/assets/svgIcons/ground_symbol.svg +28 -0
- package/src/assets/svgIcons/move_left.svg +3 -0
- package/src/assets/svgIcons/move_right.svg +3 -0
- package/src/assets/svgIcons/rectangle.svg +3 -0
- package/src/assets/svgIcons/text_icon.svg +3 -0
- package/src/components/banner/infoBanner/InfoBanner.spec.js +29 -42
- package/src/components/errorMessage/errorMessage.spec.js +34 -0
- package/src/components/errorMessage/errorMessage.stories.js +35 -0
- package/src/components/icon/index.vue +18 -6
- package/src/components/infoText/index.vue +1 -1
- package/src/components/infoText/infoText.spec.js +6 -1
- package/src/components/inputs/inputText/index.vue +1 -3
- package/src/components/modals/actionModal/actionModal.spec.js +52 -0
- package/src/components/modals/actionModal/actionModal.stories.js +53 -0
- package/src/components/modals/actionModal/index.vue +6 -6
- package/src/components/modals/infoModal/index.vue +49 -19
- package/src/components/modals/infoModal/infoModal.spec.js +55 -0
- package/src/components/modals/infoModal/infoModal.stories.js +47 -0
- package/src/components/pageSubtitle/PageSubtitle.stories.js +0 -1
- package/src/components/tableDropdown/index.vue +6 -4
@@ -0,0 +1,3 @@
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 3C3.22386 3 3 3.22386 3 3.5V4.5C3 4.77614 2.77614 5 2.5 5C2.22386 5 2 4.77614 2 4.5V3.5C2 2.67157 2.67157 2 3.5 2H8H12.5C13.3284 2 14 2.67157 14 3.5V4.5C14 4.77614 13.7761 5 13.5 5C13.2239 5 13 4.77614 13 4.5V3.5C13 3.22386 12.7761 3 12.5 3H8.5V13H10.5C10.7761 13 11 13.2239 11 13.5C11 13.7761 10.7761 14 10.5 14H8H5.5C5.22386 14 5 13.7761 5 13.5C5 13.2239 5.22386 13 5.5 13H7.5V3H3.5Z" fill="white"/>
|
3
|
+
</svg>
|
@@ -1,5 +1,4 @@
|
|
1
1
|
/* eslint-disable */
|
2
|
-
import { h } from 'vue'
|
3
2
|
import { mount } from '@vue/test-utils'
|
4
3
|
import InfoBanner from '@/components/banner/infoBanner'
|
5
4
|
import theme from '@/assets/theme'
|
@@ -10,59 +9,47 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
|
|
10
9
|
}))
|
11
10
|
|
12
11
|
describe('Info Banner Component', () => {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
12
|
+
let wrapper
|
13
|
+
|
14
|
+
beforeEach(() => {
|
15
|
+
wrapper = mount(InfoBanner, {
|
16
|
+
props: {
|
17
|
+
isOpen: true,
|
18
|
+
buttonLabel: 'Gotcha',
|
19
|
+
},
|
20
|
+
slots: {
|
21
|
+
title: 'Sample title',
|
22
|
+
body: 'Sample body text',
|
23
|
+
},
|
24
|
+
global: {
|
25
|
+
provide: {
|
26
|
+
theme,
|
27
|
+
},
|
28
|
+
},
|
29
|
+
})
|
28
30
|
})
|
29
31
|
|
32
|
+
|
33
|
+
it('info banner is shown when isOpen props is true', async () => {
|
34
|
+
|
30
35
|
const bannerWrapper = wrapper.find('[data-test-id="info_banner_wrapper"]')
|
31
36
|
expect(bannerWrapper.exists()).toBe(true)
|
32
|
-
expect(bannerWrapper.classes()).not.toContain('visible')
|
33
|
-
expect(bannerWrapper.classes()).toContain('hidden')
|
34
|
-
await wrapper.setProps({ isOpen: true })
|
35
|
-
expect(bannerWrapper.classes()).toContain('visible')
|
36
|
-
expect(bannerWrapper.classes()).not.toContain('hidden')
|
37
37
|
})
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
const bodyText = 'Sample body text'
|
42
|
-
|
43
|
-
const wrapper = mount(InfoBanner, {
|
44
|
-
props,
|
45
|
-
slots: {
|
46
|
-
title: titleText,
|
47
|
-
body: bodyText,
|
48
|
-
},
|
49
|
-
global,
|
50
|
-
})
|
51
|
-
|
39
|
+
|
40
|
+
it('info banner slots is display when user passed slots content', () => {
|
52
41
|
const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
|
53
|
-
expect(modalTitleEl.text()).toBe(
|
42
|
+
expect(modalTitleEl.text()).toBe('Sample title')
|
54
43
|
const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
|
55
|
-
expect(modalBodyEl.text()).toBe(
|
44
|
+
expect(modalBodyEl.text()).toBe('Sample body text')
|
56
45
|
})
|
57
46
|
|
58
47
|
it('info banner on-close event is emitted when modal close button is clicked', async () => {
|
59
|
-
const wrapper = mount(InfoBanner, {
|
60
|
-
props,
|
61
|
-
global,
|
62
|
-
})
|
63
|
-
|
64
48
|
const modalCloseButton = wrapper.find('.close')
|
65
|
-
|
49
|
+
|
50
|
+
modalCloseButton.trigger('click')
|
51
|
+
await wrapper.vm.$nextTick()
|
52
|
+
|
66
53
|
expect(wrapper.emitted('on-close')).toBeTruthy()
|
67
54
|
const emittedEvent = wrapper.emitted('on-close')
|
68
55
|
expect(emittedEvent).toHaveLength(1)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { mount } from '@vue/test-utils'
|
2
|
+
import ErrorMessage from '@/components/errorMessage'
|
3
|
+
import theme from '@/assets/theme'
|
4
|
+
|
5
|
+
/* eslint-disable */
|
6
|
+
|
7
|
+
describe('ErrorMessage Component', () => {
|
8
|
+
let wrapper
|
9
|
+
|
10
|
+
beforeEach(() => {
|
11
|
+
wrapper = mount(ErrorMessage, {
|
12
|
+
props: {},
|
13
|
+
slots: {
|
14
|
+
default: '<div data-test-id="fake-msg">testing</div>',
|
15
|
+
},
|
16
|
+
global: {
|
17
|
+
provide: {
|
18
|
+
theme,
|
19
|
+
},
|
20
|
+
},
|
21
|
+
})
|
22
|
+
})
|
23
|
+
|
24
|
+
test('renders ErrorMessage component with default props', () => {
|
25
|
+
expect(wrapper.findAll('[data-test-id="fake-msg"]').length).toBe(1)
|
26
|
+
})
|
27
|
+
|
28
|
+
test('applies the correct CSS class for styling', async () => {
|
29
|
+
wrapper.setProps({ marginTop: '20px' })
|
30
|
+
|
31
|
+
await wrapper.vm.$nextTick()
|
32
|
+
expect(wrapper.props().marginTop).toBe('20px')
|
33
|
+
})
|
34
|
+
})
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import ErrorMessage from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'ErrorMessage',
|
5
|
+
component: ErrorMessage,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
}
|
11
|
+
|
12
|
+
// import ErrorMessage from "@eturnity/eturnity_reusable_components/src/components/errorMessage"
|
13
|
+
//
|
14
|
+
//To use:
|
15
|
+
// <error-message>
|
16
|
+
// <span>
|
17
|
+
// testing error message
|
18
|
+
// </span>
|
19
|
+
// </error-message>
|
20
|
+
|
21
|
+
const Template = (args, { argTypes }) => ({
|
22
|
+
components: { ErrorMessage },
|
23
|
+
props: Object.keys(argTypes),
|
24
|
+
template: `
|
25
|
+
<ErrorMessage v-bind="$props">
|
26
|
+
<span>
|
27
|
+
testing error message
|
28
|
+
</span>
|
29
|
+
</ErrorMessage>`,
|
30
|
+
})
|
31
|
+
|
32
|
+
export const Default = Template.bind({})
|
33
|
+
Default.args = {
|
34
|
+
marginTop: '13px',
|
35
|
+
}
|
@@ -3,7 +3,8 @@
|
|
3
3
|
:cursor="cursor"
|
4
4
|
data-test-id="icon_wrapper"
|
5
5
|
:disabled="disabled"
|
6
|
-
:
|
6
|
+
:height="height ? height : size"
|
7
|
+
:width="width ? width : size"
|
7
8
|
>
|
8
9
|
<IconImage
|
9
10
|
:animation="animation"
|
@@ -67,6 +68,16 @@
|
|
67
68
|
default: '30px',
|
68
69
|
type: String,
|
69
70
|
},
|
71
|
+
width: {
|
72
|
+
type: String,
|
73
|
+
required: false,
|
74
|
+
default: '',
|
75
|
+
},
|
76
|
+
height: {
|
77
|
+
type: String,
|
78
|
+
required: false,
|
79
|
+
default: '',
|
80
|
+
},
|
70
81
|
cursor: {
|
71
82
|
required: false,
|
72
83
|
default: null,
|
@@ -100,7 +111,8 @@
|
|
100
111
|
})
|
101
112
|
|
102
113
|
const Wrapper = styled('div', {
|
103
|
-
|
114
|
+
height: String,
|
115
|
+
width: String,
|
104
116
|
disabled: Boolean,
|
105
117
|
cursor: String,
|
106
118
|
})`
|
@@ -108,10 +120,10 @@
|
|
108
120
|
position: relative;
|
109
121
|
align-content: center;
|
110
122
|
justify-content: center;
|
111
|
-
width: ${(props) => props.
|
112
|
-
height: ${(props) => props.
|
113
|
-
min-width: ${(props) => props.
|
114
|
-
min-height: ${(props) => props.
|
123
|
+
width: ${(props) => props.width};
|
124
|
+
height: ${(props) => props.height};
|
125
|
+
min-width: ${(props) => props.width};
|
126
|
+
min-height: ${(props) => props.height};
|
115
127
|
cursor: ${(props) => (props.disabled ? 'not-allowed' : props.cursor)};
|
116
128
|
line-height: 0;
|
117
129
|
`
|
@@ -29,6 +29,9 @@ describe('InfoText Component', () => {
|
|
29
29
|
provide: {
|
30
30
|
theme,
|
31
31
|
},
|
32
|
+
stubs: {
|
33
|
+
teleport: true
|
34
|
+
}
|
32
35
|
},
|
33
36
|
})
|
34
37
|
})
|
@@ -38,7 +41,6 @@ describe('InfoText Component', () => {
|
|
38
41
|
expect(wrapper.vm.text).toContain('default text')
|
39
42
|
expect(wrapper.vm.size).toContain('14px')
|
40
43
|
expect(wrapper.vm.infoPosition).toContain('bottom')
|
41
|
-
expect(wrapper.vm.alignArrow).toContain('center')
|
42
44
|
})
|
43
45
|
|
44
46
|
test('openTrigger prop is set to onClick', async () => {
|
@@ -48,8 +50,11 @@ describe('InfoText Component', () => {
|
|
48
50
|
expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
|
49
51
|
false
|
50
52
|
)
|
53
|
+
|
51
54
|
//should see text upon click
|
52
55
|
await wrapper.find('[data-test-id="infoText_trigger"]').trigger('click')
|
56
|
+
expect(wrapper.vm.isVisible).toBe(true)
|
57
|
+
|
53
58
|
expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
|
54
59
|
true
|
55
60
|
)
|
@@ -169,9 +169,7 @@
|
|
169
169
|
position: relative;
|
170
170
|
font-size: ${(props) => (props.fontSize ? props.fontSize : '16px')};
|
171
171
|
color: ${(props) =>
|
172
|
-
props.
|
173
|
-
? props.theme.colors.grey6
|
174
|
-
: props.isDisabled
|
172
|
+
props.isDisabled
|
175
173
|
? props.theme.colors.grey2
|
176
174
|
: props.fontColor
|
177
175
|
? props.fontColor + ' !important'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import { mount } from '@vue/test-utils'
|
3
|
+
import ActionModal from '@/components/modals/actionModal'
|
4
|
+
import theme from '@/assets/theme'
|
5
|
+
|
6
|
+
describe('ActionModal Component', () => {
|
7
|
+
let wrapper
|
8
|
+
|
9
|
+
beforeEach(() => {
|
10
|
+
wrapper = mount(ActionModal, {
|
11
|
+
props: {
|
12
|
+
isOpen: true,
|
13
|
+
buttonText: 'Close',
|
14
|
+
},
|
15
|
+
slots: {
|
16
|
+
title: 'Sample title',
|
17
|
+
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis, malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante. Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem laoreet lectus.',
|
18
|
+
buttons: '<button @click="closeAction">Close</button>',
|
19
|
+
},
|
20
|
+
global: {
|
21
|
+
provide: {
|
22
|
+
theme,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
})
|
26
|
+
})
|
27
|
+
|
28
|
+
test('renders ActionModal component with default props', () => {
|
29
|
+
expect(wrapper.find('[data-test-id="actionModal"]').exists()).toBe(true)
|
30
|
+
|
31
|
+
expect(wrapper.vm.isOpen).toBe(true)
|
32
|
+
})
|
33
|
+
|
34
|
+
test('action modal slots is display when user passed slots content', () => {
|
35
|
+
const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
|
36
|
+
expect(modalTitleEl.text()).toBe('Sample title')
|
37
|
+
|
38
|
+
const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
|
39
|
+
expect(modalBodyEl.text()).toContain('Lorem ipsum dolor sit amet')
|
40
|
+
|
41
|
+
const modalActionButton = wrapper.find('[data-test-id="modal_buttons"]')
|
42
|
+
expect(modalActionButton.text()).toContain('Close')
|
43
|
+
})
|
44
|
+
|
45
|
+
test('action modal on-close event is emitted when modal close button is clicked', async () => {
|
46
|
+
const modalCloseButton = wrapper.find('.close')
|
47
|
+
|
48
|
+
modalCloseButton.trigger('click')
|
49
|
+
await wrapper.vm.$nextTick()
|
50
|
+
expect(wrapper.emitted('on-close')).toBeTruthy()
|
51
|
+
})
|
52
|
+
})
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import ActionModal from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Components/ActionModal',
|
5
|
+
component: ActionModal,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
}
|
11
|
+
|
12
|
+
// import ActionModal from "@eturnity/eturnity_reusable_components/src/components/modals/ActionModal"
|
13
|
+
// This is a reusable modal component that can be used to display information to the user.
|
14
|
+
// To use:
|
15
|
+
// <ActionModal :isOpen="isOpen" @on-close="$emit('on-close-summary')" >
|
16
|
+
// <template #title>
|
17
|
+
// <h1>Header</h1>
|
18
|
+
// </template>
|
19
|
+
// <template #body>
|
20
|
+
// <p>Body</p>
|
21
|
+
// </template>
|
22
|
+
// <template #buttons>
|
23
|
+
// <button @click="closeModal">Close</button>
|
24
|
+
// </template>
|
25
|
+
// </ActionModal>
|
26
|
+
|
27
|
+
export const Default = {
|
28
|
+
args: {
|
29
|
+
isOpen: true,
|
30
|
+
},
|
31
|
+
render: (args) => ({
|
32
|
+
components: { ActionModal },
|
33
|
+
setup() {
|
34
|
+
return { args }
|
35
|
+
},
|
36
|
+
template: `
|
37
|
+
<ActionModal v-bind="args">
|
38
|
+
<template #title>Sample title</template>
|
39
|
+
<template #body>
|
40
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis,
|
41
|
+
malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante.
|
42
|
+
Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim
|
43
|
+
ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem
|
44
|
+
laoreet lectus.
|
45
|
+
</template>
|
46
|
+
<template #buttons>
|
47
|
+
<button @click="saveAction">Save</button>
|
48
|
+
<button @click="closeAction">Close</button>
|
49
|
+
</template>
|
50
|
+
</ActionModal>
|
51
|
+
`,
|
52
|
+
}),
|
53
|
+
}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<template>
|
2
|
-
<Modal :is-open="isOpen" @on-close="closeModal">
|
2
|
+
<Modal data-test-id="actionModal" :is-open="isOpen" @on-close="closeModal">
|
3
3
|
<ModalContainer>
|
4
|
-
<ModalTitle v-if="$slots.title">
|
4
|
+
<ModalTitle v-if="$slots.title" data-test-id="modal_title">
|
5
5
|
<slot name="title"></slot>
|
6
6
|
</ModalTitle>
|
7
|
-
<TextContainer v-if="$slots.body">
|
7
|
+
<TextContainer v-if="$slots.body" data-test-id="modal_body">
|
8
8
|
<slot name="body"></slot>
|
9
9
|
</TextContainer>
|
10
|
-
<ButtonContainer v-if="$slots.buttons">
|
10
|
+
<ButtonContainer v-if="$slots.buttons" data-test-id="modal_buttons">
|
11
11
|
<slot name="buttons"></slot>
|
12
12
|
</ButtonContainer>
|
13
13
|
</ModalContainer>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
`
|
24
24
|
const ModalTitle = styled.div`
|
25
25
|
color: ${(props) => props.theme.colors.black};
|
26
|
-
font-family:
|
26
|
+
font-family: inherit;
|
27
27
|
font-size: 18px;
|
28
28
|
font-style: normal;
|
29
29
|
font-weight: 700;
|
@@ -37,7 +37,7 @@
|
|
37
37
|
`
|
38
38
|
const TextContainer = styled.div`
|
39
39
|
color: ${(props) => props.theme.colors.black};
|
40
|
-
font-family:
|
40
|
+
font-family: inherit;
|
41
41
|
font-size: 13px;
|
42
42
|
font-style: normal;
|
43
43
|
font-weight: 400;
|
@@ -1,48 +1,78 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
2
|
+
<RCModal data-test-id="infoModal" :is-open="isOpen" @on-close="closeModal">
|
3
3
|
<ModalContainer>
|
4
|
-
<
|
4
|
+
<ModalTitle v-if="$slots.title" data-test-id="modal_title">
|
5
5
|
<slot name="title"></slot>
|
6
|
-
</
|
7
|
-
<
|
6
|
+
</ModalTitle>
|
7
|
+
<TextContainer v-if="$slots.body" data-test-id="modal_body">
|
8
8
|
<slot name="body"></slot>
|
9
|
-
</
|
10
|
-
<
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
</ButtonContainer>
|
19
|
-
</template>
|
9
|
+
</TextContainer>
|
10
|
+
<ButtonContainer>
|
11
|
+
<RCMainButton
|
12
|
+
min-width="150px"
|
13
|
+
:text="buttonText"
|
14
|
+
type="primary"
|
15
|
+
@click="closeModal"
|
16
|
+
/>
|
17
|
+
</ButtonContainer>
|
20
18
|
</ModalContainer>
|
21
|
-
</
|
19
|
+
</RCModal>
|
22
20
|
</template>
|
23
21
|
<script>
|
24
22
|
import styled from 'vue3-styled-components'
|
25
|
-
import
|
23
|
+
import RCModal from '../modal'
|
26
24
|
import RCMainButton from '../../buttons/mainButton'
|
25
|
+
|
27
26
|
const ModalContainer = styled.div`
|
28
27
|
width: 450px;
|
29
28
|
min-height: 205px;
|
30
29
|
padding: 40px 40px 30px 40px;
|
31
30
|
`
|
31
|
+
const ModalTitle = styled.div`
|
32
|
+
color: ${(props) => props.theme.colors.black};
|
33
|
+
font-family: inherit;
|
34
|
+
font-size: 18px;
|
35
|
+
font-style: normal;
|
36
|
+
font-weight: 700;
|
37
|
+
line-height: 120%;
|
38
|
+
text-transform: uppercase;
|
39
|
+
`
|
32
40
|
const ButtonContainer = styled.div`
|
33
41
|
display: inline-flex;
|
34
42
|
align-items: flex-start;
|
35
43
|
gap: 20px;
|
36
44
|
`
|
45
|
+
const TextContainer = styled.div`
|
46
|
+
color: ${(props) => props.theme.colors.black};
|
47
|
+
font-family: inherit;
|
48
|
+
font-size: 13px;
|
49
|
+
font-style: normal;
|
50
|
+
font-weight: 400;
|
51
|
+
line-height: normal;
|
52
|
+
padding: 30px 0px;
|
53
|
+
white-space: pre-wrap;
|
54
|
+
`
|
55
|
+
|
37
56
|
export default {
|
38
57
|
name: 'InfoModal',
|
39
58
|
components: {
|
59
|
+
RCModal,
|
40
60
|
ModalContainer,
|
61
|
+
ModalTitle,
|
41
62
|
ButtonContainer,
|
42
|
-
|
63
|
+
TextContainer,
|
43
64
|
RCMainButton,
|
44
65
|
},
|
45
|
-
props:
|
66
|
+
props: {
|
67
|
+
isOpen: {
|
68
|
+
type: Boolean,
|
69
|
+
required: true,
|
70
|
+
},
|
71
|
+
buttonText: {
|
72
|
+
type: String,
|
73
|
+
default: 'Got it',
|
74
|
+
},
|
75
|
+
},
|
46
76
|
methods: {
|
47
77
|
closeModal() {
|
48
78
|
this.$emit('on-close')
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import { mount } from '@vue/test-utils'
|
3
|
+
import InfoModal from '@/components/modals/infoModal'
|
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('')),
|
9
|
+
}))
|
10
|
+
|
11
|
+
|
12
|
+
describe('InfoModal Component', () => {
|
13
|
+
let wrapper
|
14
|
+
|
15
|
+
beforeEach(() => {
|
16
|
+
wrapper = mount(InfoModal, {
|
17
|
+
props: {
|
18
|
+
isOpen: true,
|
19
|
+
buttonText: 'Close',
|
20
|
+
},
|
21
|
+
slots: {
|
22
|
+
title: 'Sample title',
|
23
|
+
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis, malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante. Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem laoreet lectus.',
|
24
|
+
},
|
25
|
+
global: {
|
26
|
+
provide: {
|
27
|
+
theme,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
})
|
31
|
+
})
|
32
|
+
|
33
|
+
test('renders InfoModal component with default props', () => {
|
34
|
+
expect(wrapper.find('[data-test-id="infoModal"]').exists()).toBe(true)
|
35
|
+
|
36
|
+
expect(wrapper.vm.isOpen).toBe(true)
|
37
|
+
expect(wrapper.vm.buttonText).toContain('Close')
|
38
|
+
})
|
39
|
+
|
40
|
+
test('info modal slots is display when user passed slots content', () => {
|
41
|
+
const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
|
42
|
+
expect(modalTitleEl.text()).toBe('Sample title')
|
43
|
+
|
44
|
+
const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
|
45
|
+
expect(modalBodyEl.text()).toContain('Lorem ipsum dolor sit amet')
|
46
|
+
})
|
47
|
+
|
48
|
+
test('info modal on-close event is emitted when modal close button is clicked', async () => {
|
49
|
+
const modalCloseButton = wrapper.find('.close')
|
50
|
+
|
51
|
+
modalCloseButton.trigger('click')
|
52
|
+
await wrapper.vm.$nextTick()
|
53
|
+
expect(wrapper.emitted('on-close')).toBeTruthy()
|
54
|
+
})
|
55
|
+
})
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import InfoModal from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Components/InfoModal',
|
5
|
+
component: InfoModal,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
}
|
11
|
+
|
12
|
+
// import InfoModal from "@eturnity/eturnity_reusable_components/src/components/modals/infoModal"
|
13
|
+
// This is a reusable modal component that can be used to display information to the user.
|
14
|
+
// To use:
|
15
|
+
// <InfoModal :isOpen="isOpen" @on-close="$emit('on-close-summary')" >
|
16
|
+
// <template #title>
|
17
|
+
// <h1>Header</h1>
|
18
|
+
// </template>
|
19
|
+
// <template #body>
|
20
|
+
// <p>Body</p>
|
21
|
+
// </template>
|
22
|
+
// </InfoModal>
|
23
|
+
|
24
|
+
export const Default = {
|
25
|
+
args: {
|
26
|
+
isOpen: true,
|
27
|
+
buttonText: 'Close',
|
28
|
+
},
|
29
|
+
render: (args) => ({
|
30
|
+
components: { InfoModal },
|
31
|
+
setup() {
|
32
|
+
return { args }
|
33
|
+
},
|
34
|
+
template: `
|
35
|
+
<InfoModal v-bind="args">
|
36
|
+
<template #title>Sample title</template>
|
37
|
+
<template #body>
|
38
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis,
|
39
|
+
malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante.
|
40
|
+
Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim
|
41
|
+
ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem
|
42
|
+
laoreet lectus.
|
43
|
+
</template>
|
44
|
+
</InfoModal>
|
45
|
+
`,
|
46
|
+
}),
|
47
|
+
}
|