@eturnity/eturnity_reusable_components 7.45.5-EPDM-11313-EPDM-11314.1 → 7.45.5-EPDM-11314.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.45.5-EPDM-11313-EPDM-11314.1",
3
+ "version": "7.45.5-EPDM-11314.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -11,7 +11,7 @@
11
11
  :type="type"
12
12
  >
13
13
  <LabelComponent :has-icon="Boolean(icon)">
14
- <Icon v-if="icon" :name="icon" :color="iconColor" size="14px" />
14
+ <Icon v-if="icon" :name="icon" size="14px" />
15
15
  {{ text }}
16
16
  </LabelComponent>
17
17
  </ButtonContainer>
@@ -112,11 +112,6 @@
112
112
  default: null,
113
113
  type: String,
114
114
  },
115
- iconColor: {
116
- required: false,
117
- default: '',
118
- type: String,
119
- },
120
115
  text: {
121
116
  required: true,
122
117
  type: String,
@@ -0,0 +1,144 @@
1
+ import defaultInfoCardProps from './defaultProps'
2
+ import InfoCard from './index.vue'
3
+ import theme from '@/assets/theme'
4
+
5
+ export default {
6
+ title: 'InfoCard',
7
+ component: InfoCard,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ type: {
11
+ description: 'Defines preset styles',
12
+ control: 'select',
13
+ options: ['info', 'warning'],
14
+ },
15
+ minWidth: {
16
+ description: '',
17
+ },
18
+ color: {
19
+ description: 'Color of text and icon (can overwrite preset styles)',
20
+ control: {
21
+ type: 'color',
22
+ presetColors: [
23
+ theme.colors.grey3,
24
+ theme.colors.grey4,
25
+ theme.colors.red,
26
+ ],
27
+ },
28
+ },
29
+ alignItems: {
30
+ description: 'Icon and text alignment (can overwrite preset styles)',
31
+ control: 'select',
32
+ options: ['flex-start', 'flex-end', 'center'],
33
+ },
34
+ padding: {
35
+ description: 'Info card padding (can overwrite preset styles)',
36
+ },
37
+ borderColor: {
38
+ description: 'Info card border color (can overwrite preset styles)',
39
+ control: {
40
+ type: 'color',
41
+ presetColors: [
42
+ theme.colors.grey3,
43
+ theme.colors.grey4,
44
+ theme.colors.red,
45
+ ],
46
+ },
47
+ },
48
+ borderStyle: {
49
+ description: 'Info card border style (can overwrite preset styles)',
50
+ control: 'select',
51
+ options: ['dashed', 'dotted', 'inset', 'dashed solid', 'none'],
52
+ },
53
+
54
+ // info card content slot
55
+ default: {
56
+ description: 'Info card slot content',
57
+ },
58
+ },
59
+ }
60
+
61
+ // To use:
62
+ // <InfoCard
63
+ // type="warning"
64
+ // min-width="auto'
65
+ // color="red"
66
+ // align-items="center"
67
+ // padding="100px"
68
+ // border-color="red"
69
+ // border-style="solid"
70
+ // >
71
+ // Some Text
72
+ // </InfoCard>
73
+ // all props after "min-width" are used to overwrite the preset styles set by "type"
74
+
75
+ const Template = (args) => {
76
+ return {
77
+ components: { InfoCard },
78
+ setup() {
79
+ return { args }
80
+ },
81
+ template: `
82
+ <InfoCard v-bind="args">
83
+ {{ args.default }}
84
+ </InfoCard>
85
+ `,
86
+ }
87
+ }
88
+
89
+ export const Default = Template.bind({})
90
+ Default.args = {
91
+ ...defaultInfoCardProps,
92
+ }
93
+
94
+ export const InfoCardTypeWarning = Template.bind({})
95
+ InfoCardTypeWarning.args = {
96
+ ...defaultInfoCardProps,
97
+ type: 'warning',
98
+ }
99
+
100
+ export const InfoCardTypeInfoMinWidth = Template.bind({})
101
+ InfoCardTypeInfoMinWidth.args = {
102
+ ...defaultInfoCardProps,
103
+
104
+ minWidth: '250px',
105
+ }
106
+
107
+ export const InfoCardTypeInfoColorOverwritten = Template.bind({})
108
+ InfoCardTypeInfoColorOverwritten.args = {
109
+ ...defaultInfoCardProps,
110
+
111
+ color: theme.colors.red,
112
+ }
113
+
114
+ export const InfoCardTypeWarningAlignItemsOverwritten = Template.bind({})
115
+ InfoCardTypeWarningAlignItemsOverwritten.args = {
116
+ ...defaultInfoCardProps,
117
+ type: 'warning',
118
+ default:
119
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
120
+
121
+ alignItems: 'center',
122
+ }
123
+
124
+ export const InfoCardTypeWarningPaddingOverwritten = Template.bind({})
125
+ InfoCardTypeWarningPaddingOverwritten.args = {
126
+ ...defaultInfoCardProps,
127
+ type: 'warning',
128
+
129
+ padding: '50px',
130
+ }
131
+
132
+ export const InfoCardTypeInfoBorderColorOverwritten = Template.bind({})
133
+ InfoCardTypeInfoBorderColorOverwritten.args = {
134
+ ...defaultInfoCardProps,
135
+
136
+ borderColor: theme.colors.red,
137
+ }
138
+
139
+ export const InfoCardTypeInfoBorderStyleOverwritten = Template.bind({})
140
+ InfoCardTypeInfoBorderStyleOverwritten.args = {
141
+ ...defaultInfoCardProps,
142
+
143
+ borderStyle: 'solid none',
144
+ }
@@ -0,0 +1,7 @@
1
+ const defaultInfoCardProps = {
2
+ // info card content slot
3
+ default:
4
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
5
+ }
6
+
7
+ export default defaultInfoCardProps
@@ -1,19 +1,21 @@
1
1
  <template>
2
2
  <InfoContainer
3
- :min-width="minWidth"
4
- :color="color"
5
3
  :align-items="alignItems"
6
- :padding="padding"
7
4
  :border-color="borderColor"
8
5
  :border-style="borderStyle"
6
+ :color="color"
7
+ data-test-id="info_card_wrapper"
8
+ :min-width="minWidth"
9
+ :padding="padding"
9
10
  :preset-styles="presetStyles"
10
11
  >
11
12
  <RCIcon
13
+ :color="color ? color : presetStyles.iconColor"
14
+ data-test-id="info_card_icon"
12
15
  name="info"
13
16
  size="24px"
14
- :color="color ? color : presetStyles.iconColor"
15
17
  />
16
- <TextContainer>
18
+ <TextContainer data-test-id="info_card_text_container">
17
19
  <slot></slot>
18
20
  </TextContainer>
19
21
  </InfoContainer>
@@ -75,29 +77,37 @@
75
77
  minWidth: {
76
78
  required: false,
77
79
  type: String,
80
+ default: '',
78
81
  },
79
82
  color: {
80
83
  required: false,
84
+ type: String,
85
+ default: '',
81
86
  },
82
87
  alignItems: {
83
88
  required: false,
84
89
  type: String,
90
+ default: '',
85
91
  },
86
92
  padding: {
87
93
  required: false,
88
94
  type: String,
95
+ default: '',
89
96
  },
90
97
  borderColor: {
91
98
  required: false,
92
99
  type: String,
100
+ default: '',
93
101
  },
94
102
  borderStyle: {
95
103
  required: false,
96
104
  type: String,
105
+ default: '',
97
106
  },
98
107
  },
99
108
  computed: {
100
109
  isInfo() {
110
+ // this property is used for tests
101
111
  return this.type === 'info'
102
112
  },
103
113
  isWarning() {
@@ -0,0 +1,56 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import RCInfoCard from '@/components/infoCard'
3
+ import RCIcon from '@/components/icon'
4
+ import defaultInfoCardProps from './defaultProps'
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('mocked-icon-url.svg')),
10
+ }))
11
+
12
+ describe('RCInfoCard.vue', () => {
13
+ it('info card is rendered with icon and correct text', async () => {
14
+ const wrapper = mount(RCInfoCard, {
15
+ props: { ...defaultInfoCardProps },
16
+ slots: {
17
+ default: defaultInfoCardProps.default,
18
+ },
19
+ global: {
20
+ provide: {
21
+ theme,
22
+ },
23
+ },
24
+ })
25
+
26
+ const iconComponent = wrapper.findComponent(RCIcon)
27
+ const infoCardText = wrapper.find(
28
+ '[data-test-id="info_card_text_container"]'
29
+ )
30
+
31
+ expect(iconComponent.exists()).toBe(true)
32
+ expect(infoCardText.exists()).toBe(true)
33
+ expect(infoCardText.text()).toContain(defaultInfoCardProps.default)
34
+ }),
35
+ it('info card rendered with type info have correct computed values', async () => {
36
+ const wrapper = mount(RCInfoCard, {
37
+ props: { ...defaultInfoCardProps },
38
+ slots: {
39
+ default: defaultInfoCardProps.default,
40
+ },
41
+ global: {
42
+ provide: {
43
+ theme,
44
+ },
45
+ },
46
+ })
47
+
48
+ expect(wrapper.vm.isInfo).toBe(true)
49
+ expect(wrapper.vm.isWarning).toBe(false)
50
+
51
+ await wrapper.setProps({ type: 'warning' })
52
+
53
+ expect(wrapper.vm.isInfo).toBe(false)
54
+ expect(wrapper.vm.isWarning).toBe(true)
55
+ })
56
+ })
@@ -1,6 +1,4 @@
1
1
  const defaultRadioButtonProps = {
2
- dataId: 'radio_buttons',
3
- name: 'options',
4
2
  options: [
5
3
  {
6
4
  label: 'Option 1',
@@ -204,7 +204,7 @@
204
204
  `
205
205
 
206
206
  const selectorProps = {
207
- disabled: String,
207
+ disabled: Boolean,
208
208
  selectWidth: String,
209
209
  paddingLeft: String,
210
210
  showBorder: Boolean,
@@ -542,6 +542,7 @@
542
542
  },
543
543
  disabled: {
544
544
  required: false,
545
+ type: Boolean,
545
546
  default: false,
546
547
  },
547
548
  isAutoSearch: {