@eturnity/eturnity_reusable_components 7.39.5-qa-elisee-7.42.1 → 7.45.1
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/theme.js +0 -3
- package/src/components/banner/infoBanner/InfoBanner.spec.js +70 -0
- package/src/components/banner/infoBanner/InfoBanner.stories.js +42 -0
- package/src/components/banner/infoBanner/index.vue +59 -19
- package/src/components/icon/index.vue +2 -2
- package/src/components/infoCard/index.vue +9 -36
- package/src/components/infoText/index.vue +6 -24
- package/src/components/inputs/inputText/InputText.stories.js +60 -55
- package/src/components/inputs/inputText/index.vue +8 -49
- package/src/components/inputs/radioButton/RadioButton.stories.js +63 -44
- package/src/components/inputs/radioButton/defaultProps.js +33 -0
- package/src/components/inputs/radioButton/index.vue +56 -20
- package/src/components/inputs/radioButton/radioButton.spec.js +269 -0
- package/src/assets/svgIcons/compass.svg +0 -1
- package/src/assets/svgIcons/pause.svg +0 -6
- package/src/components/inputs/inputText/inputText.spec.js +0 -588
- package/src/components/roundTabs/index.vue +0 -107
package/package.json
CHANGED
package/src/assets/theme.js
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import { h } from 'vue'
|
3
|
+
import { mount } from '@vue/test-utils'
|
4
|
+
import InfoBanner from '@/components/banner/infoBanner'
|
5
|
+
import theme from '@/assets/theme'
|
6
|
+
|
7
|
+
jest.mock('@/components/icon/iconCache.mjs', () => ({
|
8
|
+
// need to mock this due to how jest handles import.meta
|
9
|
+
fetchIcon: jest.fn(() => Promise.resolve('')),
|
10
|
+
}))
|
11
|
+
|
12
|
+
describe('Info Banner Component', () => {
|
13
|
+
const props = {
|
14
|
+
isOpen: false,
|
15
|
+
buttonLabel: 'Gotcha',
|
16
|
+
}
|
17
|
+
|
18
|
+
const global = {
|
19
|
+
provide: {
|
20
|
+
theme,
|
21
|
+
},
|
22
|
+
}
|
23
|
+
|
24
|
+
it('info banner is shown when isOpen props is true', async () => {
|
25
|
+
const wrapper = mount(InfoBanner, {
|
26
|
+
props,
|
27
|
+
global,
|
28
|
+
})
|
29
|
+
|
30
|
+
const bannerWrapper = wrapper.find('[data-test-id="info_banner_wrapper"]')
|
31
|
+
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
|
+
})
|
38
|
+
|
39
|
+
it('info banner slots is display when user passed slots content', async () => {
|
40
|
+
const titleText = 'Sample title'
|
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
|
+
|
52
|
+
const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
|
53
|
+
expect(modalTitleEl.text()).toBe(titleText)
|
54
|
+
const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
|
55
|
+
expect(modalBodyEl.text()).toBe(bodyText)
|
56
|
+
})
|
57
|
+
|
58
|
+
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
|
+
const modalCloseButton = wrapper.find('.close')
|
65
|
+
await modalCloseButton.trigger('click')
|
66
|
+
expect(wrapper.emitted('on-close')).toBeTruthy()
|
67
|
+
const emittedEvent = wrapper.emitted('on-close')
|
68
|
+
expect(emittedEvent).toHaveLength(1)
|
69
|
+
})
|
70
|
+
})
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import InfoBanner from './index.vue'
|
2
|
+
import theme from '@/assets/theme'
|
3
|
+
export default {
|
4
|
+
title: 'InfoBanner',
|
5
|
+
component: InfoBanner,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
}
|
8
|
+
|
9
|
+
// <RCInfoBanner
|
10
|
+
// :isOpen="true"
|
11
|
+
// buttonLabel="Got it"
|
12
|
+
// @on-close="handleClose"
|
13
|
+
// >
|
14
|
+
// <template #title>Sample title</template>
|
15
|
+
// <template #body>Sample body</template>
|
16
|
+
// </RCInfoBanner>
|
17
|
+
|
18
|
+
export const Default = {
|
19
|
+
args: {
|
20
|
+
isOpen: false,
|
21
|
+
buttonLabel: 'Got it',
|
22
|
+
},
|
23
|
+
}
|
24
|
+
|
25
|
+
export const OpenedInfoBanner = {
|
26
|
+
args: {
|
27
|
+
isOpen: true,
|
28
|
+
buttonLabel: 'Got it',
|
29
|
+
},
|
30
|
+
render: (args) => ({
|
31
|
+
components: { InfoBanner },
|
32
|
+
setup() {
|
33
|
+
return { args }
|
34
|
+
},
|
35
|
+
template: `
|
36
|
+
<InfoBanner v-bind="args">
|
37
|
+
<template #title>Sample title</template>
|
38
|
+
<template #body>Sample body</template>
|
39
|
+
</InfoBanner>
|
40
|
+
`,
|
41
|
+
}),
|
42
|
+
}
|
@@ -1,45 +1,75 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
2
|
+
<RCModal
|
3
|
+
data-test-id="info_banner_wrapper"
|
4
|
+
:is-open="isOpen"
|
5
|
+
@on-close="closeModal"
|
6
|
+
>
|
3
7
|
<ModalContainer>
|
4
|
-
<
|
8
|
+
<ModalTitle v-if="$slots.title" data-test-id="modal_title">
|
5
9
|
<slot name="title"></slot>
|
6
|
-
</
|
7
|
-
<
|
10
|
+
</ModalTitle>
|
11
|
+
<TextContainer v-if="$slots.body" data-test-id="modal_body">
|
8
12
|
<slot name="body"></slot>
|
9
|
-
</
|
10
|
-
<
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
</template>
|
13
|
+
</TextContainer>
|
14
|
+
<ButtonContainer>
|
15
|
+
<RCButton
|
16
|
+
data-test-id="modal_buttons"
|
17
|
+
min-width="150px"
|
18
|
+
:text="buttonText"
|
19
|
+
type="primary"
|
20
|
+
@click="closeModal"
|
21
|
+
/>
|
22
|
+
</ButtonContainer>
|
20
23
|
</ModalContainer>
|
21
|
-
</
|
24
|
+
</RCModal>
|
22
25
|
</template>
|
23
26
|
<script>
|
24
27
|
import styled from 'vue3-styled-components'
|
25
|
-
import
|
28
|
+
import RCModal from '@/components/modals/modal'
|
29
|
+
import RCButton from '@/components/buttons/mainButton'
|
26
30
|
|
27
31
|
const ModalContainer = styled.div`
|
28
32
|
width: 450px;
|
33
|
+
display: flex;
|
34
|
+
flex-direction: column;
|
29
35
|
min-height: 205px;
|
30
36
|
padding: 40px 40px 30px 40px;
|
31
37
|
`
|
38
|
+
|
39
|
+
const ModalTitle = styled.div`
|
40
|
+
color: ${(props) => props.theme.colors.black};
|
41
|
+
font-family: inherit;
|
42
|
+
font-size: 18px;
|
43
|
+
font-style: normal;
|
44
|
+
font-weight: 700;
|
45
|
+
line-height: 120%;
|
46
|
+
text-transform: uppercase;
|
47
|
+
`
|
32
48
|
const ButtonContainer = styled.div`
|
33
49
|
display: inline-flex;
|
34
|
-
|
50
|
+
flex-grow: 1;
|
51
|
+
align-items: flex-end;
|
35
52
|
gap: 20px;
|
36
53
|
`
|
54
|
+
const TextContainer = styled.div`
|
55
|
+
color: ${(props) => props.theme.colors.black};
|
56
|
+
font-family: inherit;
|
57
|
+
font-size: 13px;
|
58
|
+
font-style: normal;
|
59
|
+
font-weight: 400;
|
60
|
+
line-height: normal;
|
61
|
+
padding: 30px 0px;
|
62
|
+
white-space: pre-wrap;
|
63
|
+
`
|
37
64
|
export default {
|
38
65
|
name: 'InfoModal',
|
39
66
|
components: {
|
40
67
|
ModalContainer,
|
68
|
+
ModalTitle,
|
69
|
+
TextContainer,
|
41
70
|
ButtonContainer,
|
42
|
-
|
71
|
+
RCModal,
|
72
|
+
RCButton,
|
43
73
|
},
|
44
74
|
props: {
|
45
75
|
isOpen: {
|
@@ -47,6 +77,16 @@
|
|
47
77
|
default: false,
|
48
78
|
type: Boolean,
|
49
79
|
},
|
80
|
+
buttonLabel: {
|
81
|
+
default: null,
|
82
|
+
type: String,
|
83
|
+
},
|
84
|
+
},
|
85
|
+
computed: {
|
86
|
+
buttonText() {
|
87
|
+
//work around for storybook not finding the $gettext function
|
88
|
+
return this.buttonLabel || this.$gettext('Got it')
|
89
|
+
},
|
50
90
|
},
|
51
91
|
methods: {
|
52
92
|
closeModal() {
|
@@ -111,10 +111,10 @@
|
|
111
111
|
props.backgroundColor ? props.backgroundColor : 'transparent'};
|
112
112
|
padding: ${(props) => (props.backgroundColor ? '3px' : '0')};
|
113
113
|
}
|
114
|
-
svg path
|
114
|
+
svg path {
|
115
115
|
${({ theme, color }) => color && `fill: ${theme.colors[color] || color};`}
|
116
116
|
}
|
117
|
-
&:hover svg path
|
117
|
+
&:hover svg path {
|
118
118
|
${({ theme, hoveredColor }) =>
|
119
119
|
hoveredColor && `fill: ${theme.colors[hoveredColor] || hoveredColor};`}
|
120
120
|
}
|
@@ -1,10 +1,6 @@
|
|
1
1
|
<template>
|
2
|
-
<InfoContainer
|
3
|
-
|
4
|
-
:border-color="borderColor"
|
5
|
-
:has-dashed-border="hasDashedBorder"
|
6
|
-
>
|
7
|
-
<RCIcon :color="color" name="info" size="24px" />
|
2
|
+
<InfoContainer>
|
3
|
+
<RCIcon name="info" size="24px" :color="color" />
|
8
4
|
<TextContainer>
|
9
5
|
<slot></slot>
|
10
6
|
</TextContainer>
|
@@ -14,24 +10,12 @@
|
|
14
10
|
<script>
|
15
11
|
import styled from 'vue3-styled-components'
|
16
12
|
import RCIcon from '../icon'
|
17
|
-
|
18
|
-
|
19
|
-
hasDashedBorder: Boolean,
|
20
|
-
borderColor: String,
|
21
|
-
}
|
22
|
-
const InfoContainer = styled('div', propsContainer)`
|
13
|
+
|
14
|
+
const InfoContainer = styled.div`
|
23
15
|
display: flex;
|
24
16
|
gap: 15px;
|
25
|
-
padding:
|
26
|
-
border: 1px ${(props) =>
|
27
|
-
${(props) =>
|
28
|
-
props.theme.colors[props.borderColor]
|
29
|
-
? props.theme.colors[props.borderColor]
|
30
|
-
: props.borderColor};
|
31
|
-
background-color: ${(props) =>
|
32
|
-
props.theme.colors[props.backgroundColor]
|
33
|
-
? props.theme.colors[props.backgroundColor]
|
34
|
-
: props.backgroundColor};
|
17
|
+
padding: 20px;
|
18
|
+
border: 1px dashed ${(props) => props.theme.colors.grey4};
|
35
19
|
border-radius: 4px;
|
36
20
|
`
|
37
21
|
|
@@ -49,19 +33,8 @@
|
|
49
33
|
},
|
50
34
|
props: {
|
51
35
|
color: {
|
52
|
-
required: false
|
53
|
-
}
|
54
|
-
|
55
|
-
required: false,
|
56
|
-
},
|
57
|
-
hasDashedBorder: {
|
58
|
-
required: false,
|
59
|
-
default: true,
|
60
|
-
},
|
61
|
-
borderColor: {
|
62
|
-
required: false,
|
63
|
-
default: 'grey4',
|
64
|
-
},
|
65
|
-
},
|
36
|
+
required: false
|
37
|
+
}
|
38
|
+
}
|
66
39
|
}
|
67
40
|
</script>
|
@@ -2,6 +2,7 @@
|
|
2
2
|
<ComponentWrapper>
|
3
3
|
<IconWrapper :size="size">
|
4
4
|
<IconImg
|
5
|
+
data-test-id="infoText_trigger"
|
5
6
|
@click.prevent="toggleShowInfo()"
|
6
7
|
@mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
|
7
8
|
@mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
|
@@ -18,11 +19,10 @@
|
|
18
19
|
:align-arrow="alignArrow"
|
19
20
|
:half-computed-text-info-width="halfComputedTextInfoWidth"
|
20
21
|
:icon-size="size"
|
21
|
-
:info-position="infoPosition"
|
22
22
|
:max-width="maxWidth"
|
23
23
|
:width="width"
|
24
24
|
><slot></slot>
|
25
|
-
<span v-
|
25
|
+
<span v-html="text"></span>
|
26
26
|
</TextOverlay>
|
27
27
|
</IconWrapper>
|
28
28
|
</ComponentWrapper>
|
@@ -45,14 +45,10 @@
|
|
45
45
|
alignArrow: String,
|
46
46
|
width: String,
|
47
47
|
halfComputedTextInfoWidth: Number,
|
48
|
-
infoPosition: String,
|
49
48
|
}
|
50
49
|
const TextOverlay = styled('div', textAttrs)`
|
51
50
|
position: absolute;
|
52
|
-
${(props) =>
|
53
|
-
props.infoPosition == 'top'
|
54
|
-
? 'bottom : calc(' + props.iconSize + ' + 15px)'
|
55
|
-
: 'top : calc(' + props.iconSize + ' + 15px)'};
|
51
|
+
top: ${(props) => 'calc(' + props.iconSize + ' + 15px)'};
|
56
52
|
${(props) =>
|
57
53
|
props.alignArrow === 'left'
|
58
54
|
? 'left: calc(' + props.iconSize + ' /2 - 18px)'
|
@@ -68,17 +64,14 @@
|
|
68
64
|
font-weight: 400;
|
69
65
|
line-height: normal;
|
70
66
|
border-radius: 4px;
|
71
|
-
z-index:
|
67
|
+
z-index: 99;
|
72
68
|
color: ${(props) => props.theme.colors.white};
|
73
69
|
|
74
70
|
:before {
|
75
71
|
content: '';
|
76
72
|
background-color: ${(props) => props.theme.colors.black};
|
77
73
|
position: absolute;
|
78
|
-
|
79
|
-
${(props) =>
|
80
|
-
props.infoPosition == 'top' ? 'bottom : -10px' : 'top: 2px'};
|
81
|
-
|
74
|
+
top: 2px;
|
82
75
|
${(props) =>
|
83
76
|
props.alignArrow === 'left'
|
84
77
|
? 'left:40px;'
|
@@ -122,37 +115,26 @@
|
|
122
115
|
props: {
|
123
116
|
text: {
|
124
117
|
required: false,
|
125
|
-
default: '',
|
126
|
-
type: String,
|
127
118
|
},
|
128
119
|
size: {
|
129
120
|
required: false,
|
130
121
|
default: '14px',
|
131
|
-
type: String,
|
132
|
-
},
|
133
|
-
infoPosition: {
|
134
|
-
required: false,
|
135
|
-
default: 'bottom',
|
136
|
-
type: String,
|
137
122
|
},
|
138
123
|
alignArrow: {
|
139
124
|
required: false,
|
140
125
|
default: 'center',
|
141
|
-
type: String,
|
142
126
|
},
|
143
127
|
openTrigger: {
|
144
128
|
required: false,
|
145
129
|
default: 'onHover', // onHover, onClick
|
146
|
-
type: String,
|
147
130
|
},
|
148
131
|
width: {
|
149
132
|
required: false,
|
150
133
|
default: '200px',
|
151
|
-
type: String,
|
152
134
|
},
|
153
135
|
maxWidth: {
|
154
|
-
default: '400px',
|
155
136
|
type: String,
|
137
|
+
default: '400px',
|
156
138
|
},
|
157
139
|
},
|
158
140
|
data() {
|
@@ -3,68 +3,73 @@ import InputText from './index.vue'
|
|
3
3
|
export default {
|
4
4
|
title: 'InputText',
|
5
5
|
component: InputText,
|
6
|
-
|
6
|
+
// argTypes: {},
|
7
7
|
}
|
8
8
|
|
9
|
-
|
10
|
-
//
|
11
|
-
|
12
|
-
//
|
13
|
-
|
14
|
-
|
15
|
-
// :isError="checkErrors()"
|
16
|
-
// :errorMessage="This is my error message"
|
17
|
-
// infoTextAlign="right" // left by default
|
18
|
-
// infoTextMessage="My info message"
|
19
|
-
// label="Question 5"
|
20
|
-
// alignItems="horizontal" // horizontal, vertical
|
21
|
-
// inputWidth="250px"
|
22
|
-
// minWidth="100px"
|
23
|
-
// />
|
9
|
+
const Template = (args, { argTypes }) => ({
|
10
|
+
// Components used in your story `template` are defined in the `components` object
|
11
|
+
components: { InputText },
|
12
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
13
|
+
props: Object.keys(argTypes),
|
14
|
+
template: '<input-text v-bind="$props" />',
|
24
15
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
16
|
+
// import InputText from "@eturnity/eturnity_reusable_components/src/components/inputs/inputText"
|
17
|
+
// To use:
|
18
|
+
// <input-text
|
19
|
+
// placeholder="Company name"
|
20
|
+
// :value="companyName"
|
21
|
+
// @input-change="onInputChange({ value: $event, type: 'companyName' })"
|
22
|
+
// :isError="checkErrors()"
|
23
|
+
// :errorMessage="This is my error message"
|
24
|
+
// infoTextAlign="right" // left by default
|
25
|
+
// infoTextMessage="My info message"
|
26
|
+
// label="Question 5"
|
27
|
+
// alignItems="horizontal" // horizontal, vertical
|
28
|
+
// inputWidth="250px"
|
29
|
+
// minWidth="100px"
|
30
|
+
// />
|
31
|
+
})
|
32
|
+
|
33
|
+
export const Default = Template.bind({})
|
34
|
+
Default.args = {
|
35
|
+
placeholder: 'Company name',
|
36
|
+
disabled: false,
|
37
|
+
value: '',
|
38
|
+
inputWidth: '200px',
|
39
|
+
minWidth: '10ch',
|
40
|
+
unitName: 'pc',
|
41
|
+
isError: false,
|
42
|
+
textAlign: 'left',
|
36
43
|
}
|
37
44
|
|
38
|
-
export const
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
},
|
45
|
+
export const hasError = Template.bind({})
|
46
|
+
hasError.args = {
|
47
|
+
placeholder: 'Enter Value',
|
48
|
+
errorMessage: 'This field is required',
|
49
|
+
isError: true,
|
50
|
+
disabled: false,
|
51
|
+
inputWidth: '200px',
|
46
52
|
}
|
47
53
|
|
48
|
-
export const Disabled = {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
},
|
54
|
+
export const Disabled = Template.bind({})
|
55
|
+
Disabled.args = {
|
56
|
+
placeholder: 'Enter Value',
|
57
|
+
disabled: true,
|
58
|
+
value: '',
|
59
|
+
inputWidth: '200px',
|
60
|
+
isError: false,
|
56
61
|
}
|
57
62
|
|
58
|
-
export const WithLabel = {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
export const WithLabel = Template.bind({})
|
64
|
+
WithLabel.args = {
|
65
|
+
placeholder: 'Company name',
|
66
|
+
disabled: false,
|
67
|
+
label: 'What is the best company in Switzerland?',
|
68
|
+
value: 'Eturnity',
|
69
|
+
inputWidth: '200px',
|
70
|
+
unitName: 'pc',
|
71
|
+
isError: false,
|
72
|
+
errorMessage: 'Maximum 5 characters',
|
73
|
+
textAlign: 'left',
|
74
|
+
alignItems: 'vertical',
|
70
75
|
}
|