@eturnity/eturnity_reusable_components 7.48.1-dev-14.0 → 7.48.1-qa-elisee-7.51.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.48.1-dev-14.0",
3
+ "version": "7.48.1-qa-elisee-7.51.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -1,3 +1,3 @@
1
- <svg fill="none" height="16" viewbox="14 12 12 16" width="12" xmlns="http://www.w3.org/2000/svg">
1
+ <svg fill="none" height="16" viewbox="14 12 12 16" width="16" xmlns="http://www.w3.org/2000/svg">
2
2
  <path clip-rule="evenodd" d="M16.5 18.25V16.5C16.5 14.567 18.067 13 20 13C21.933 13 23.5 14.567 23.5 16.5V18.25H25.25V27H14.75V18.25H16.5ZM18.25 16.5C18.25 15.5335 19.0335 14.75 20 14.75C20.9665 14.75 21.75 15.5335 21.75 16.5V18.25H18.25V16.5ZM19.125 24.375V20.875H20.875V24.375H19.125Z" fill="#263238" fill-rule="evenodd"></path>
3
3
  </svg>
@@ -12,7 +12,6 @@ const theme = {
12
12
  white: '#ffffff',
13
13
  blue: '#48a2d0',
14
14
  red: '#ff5656',
15
- pureRed: '#ff0000',
16
15
  blue1: '#e4efff',
17
16
  brightBlue: '#0068DE',
18
17
  grey1: '#666',
@@ -3,24 +3,14 @@ import IconCollection from './iconCollection.vue'
3
3
  export default {
4
4
  title: 'icon',
5
5
  component: IconCollection,
6
- // argTypes: {},
7
6
  }
8
7
 
9
- const Template = (args, { argTypes }) => ({
10
- // Components used in your story `template` are defined in the `components` object
8
+ const Template = (args) => ({
11
9
  components: { IconCollection },
12
- // The story's `args` need to be mapped into the template through the `setup()` method
13
- props: Object.keys(argTypes),
14
- template: '<IconCollection v-bind="$props" />',
15
-
16
- // import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
17
- // How to use:
18
- //<icon
19
- // name="House" //required. a svg file named [name].svg should be present in /assets/svgIcons
20
- // color="red"
21
- // hoveredColor="blue"
22
- // size="60px" by default, this is 30px
23
- // />
10
+ setup() {
11
+ return { args }
12
+ },
13
+ template: '<IconCollection v-bind="args" />',
24
14
  })
25
15
 
26
16
  export const Default = Template.bind({})
@@ -28,14 +18,14 @@ Default.args = {
28
18
  size: '30px',
29
19
  }
30
20
 
31
- export const withColor = Template.bind({})
32
- withColor.args = {
21
+ export const WithColor = Template.bind({})
22
+ WithColor.args = {
33
23
  size: '30px',
34
24
  color: 'red',
35
25
  hoveredColor: 'crimson',
36
26
  }
37
27
 
38
- export const large = Template.bind({})
39
- large.args = {
28
+ export const Large = Template.bind({})
29
+ Large.args = {
40
30
  size: '60px',
41
31
  }
@@ -0,0 +1,66 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import RCIcon from '@/components/icon'
3
+ import theme from '@/assets/theme'
4
+ import 'jest-styled-components'
5
+ jest.mock('@/components/icon/iconCache.mjs', () => ({
6
+ fetchIcon: jest.fn(() => Promise.resolve('mocked-icon-url.svg')),
7
+ }))
8
+
9
+ describe('RCIcon.vue', () => {
10
+ it('renders icon with default props', async () => {
11
+ const wrapper = mount(RCIcon, {
12
+ props: { name: 'House' },
13
+ global: {
14
+ provide: {
15
+ theme,
16
+ },
17
+ },
18
+ })
19
+
20
+ const iconWrapper = wrapper.find('[data-test-id="icon_wrapper"]')
21
+ const iconImage = wrapper.find('[data-test-id="icon_image"]')
22
+
23
+ expect(iconWrapper.exists()).toBe(true)
24
+ expect(iconImage.exists()).toBe(true)
25
+ expect(wrapper.props('size')).toBe('30px')
26
+ })
27
+
28
+ it('renders striked line when isStriked is true', async () => {
29
+ const wrapper = mount(RCIcon, {
30
+ props: {
31
+ name: 'House',
32
+ isStriked: true,
33
+ color: 'red',
34
+ },
35
+ global: {
36
+ provide: {
37
+ theme,
38
+ },
39
+ },
40
+ })
41
+
42
+ const strikedLine = wrapper.find('[data-test-id="icon_striked_line"]')
43
+ expect(strikedLine.exists()).toBe(true)
44
+ })
45
+
46
+ it('applies correct styling based on props', async () => {
47
+ const wrapper = mount(RCIcon, {
48
+ props: {
49
+ name: 'House',
50
+ size: '60px',
51
+ color: 'red',
52
+ hoveredColor: 'blue',
53
+ backgroundColor: 'yellow',
54
+ },
55
+ global: {
56
+ provide: {
57
+ theme,
58
+ },
59
+ },
60
+ })
61
+
62
+ const iconImage = wrapper.find('[data-test-id="icon_image"]')
63
+ expect(iconImage.exists()).toBe(true)
64
+ // Add assertions for styling if needed
65
+ })
66
+ })
@@ -2,6 +2,7 @@
2
2
  <Wrapper>
3
3
  <IconWrapper v-for="iconItem in iconList" :key="iconItem.name">
4
4
  <div>
5
+ color:{{ color }}
5
6
  <RCIcon
6
7
  :color="color"
7
8
  :hovered-color="hoveredColor"
@@ -39,9 +40,9 @@
39
40
  name: 'CollectionComponent',
40
41
  components: { RCIcon, IconWrapper, Wrapper },
41
42
  props: {
42
- size: { required: false },
43
- color: { required: false },
44
- hoveredColor: { required: false },
43
+ size: { required: false, type: String, default: '30px' },
44
+ color: { required: false, type: String, default: 'white' },
45
+ hoveredColor: { required: false, type: String, default: 'grey' },
45
46
  },
46
47
  data() {
47
48
  return {
@@ -1,14 +1,24 @@
1
1
  <template>
2
- <Wrapper :cursor="cursor" :disabled="disabled" :size="size">
2
+ <Wrapper
3
+ :cursor="cursor"
4
+ data-test-id="icon_wrapper"
5
+ :disabled="disabled"
6
+ :size="size"
7
+ >
3
8
  <IconImage
4
9
  :animation="animation"
5
10
  :background-color="backgroundColor"
6
11
  :color="color"
12
+ data-test-id="icon_image"
7
13
  :hovered-color="hoveredColor"
8
14
  >
9
- <i v-html="icon.html"></i>
15
+ <i data-test-id="icon_svg" v-html="icon.html"></i>
10
16
  </IconImage>
11
- <StrikedLine v-if="isStriked" :color="color" />
17
+ <StrikedLine
18
+ v-if="isStriked"
19
+ :color="color"
20
+ data-test-id="icon_striked_line"
21
+ />
12
22
  </Wrapper>
13
23
  </template>
14
24
 
@@ -1,21 +1,11 @@
1
1
  <template>
2
2
  <InfoContainer
3
- :align-items="alignItems"
3
+ background-color="backgrounColor"
4
4
  :border-color="borderColor"
5
- :border-style="borderStyle"
6
- :color="color"
7
- data-test-id="info_card_wrapper"
8
- :min-width="minWidth"
9
- :padding="padding"
10
- :preset-styles="presetStyles"
5
+ :has-dashed-border="hasDashedBorder"
11
6
  >
12
- <RCIcon
13
- :color="iconColor ? iconColor : presetStyles.iconColor"
14
- data-test-id="info_card_icon"
15
- name="info"
16
- size="24px"
17
- />
18
- <TextContainer data-test-id="info_card_text_container">
7
+ <RCIcon :color="color" name="info" size="24px" />
8
+ <TextContainer>
19
9
  <slot></slot>
20
10
  </TextContainer>
21
11
  </InfoContainer>
@@ -23,37 +13,26 @@
23
13
 
24
14
  <script>
25
15
  import styled from 'vue3-styled-components'
26
- import theme from '../../assets/theme.js'
27
16
  import RCIcon from '../icon'
28
-
29
- const infoContainerAttrs = {
30
- minWidth: String,
31
- color: String,
32
- alignItems: String,
33
- padding: String,
17
+ const propsContainer = {
18
+ backgroundColor: String,
19
+ hasDashedBorder: Boolean,
34
20
  borderColor: String,
35
- borderStyle: String,
36
- presetStyles: Object,
37
21
  }
38
- const InfoContainer = styled('div', infoContainerAttrs)`
22
+ const InfoContainer = styled('div', propsContainer)`
39
23
  display: flex;
40
- align-items: ${(props) =>
41
- props.alignItems ? props.alignItems : props.presetStyles.alignItems};
42
24
  gap: 15px;
43
- min-width: ${(props) => props.minWidth};
44
- padding: ${(props) =>
45
- props.padding ? props.padding : props.presetStyles.padding};
46
- color: ${(props) => (props.color ? props.color : props.presetStyles.color)};
47
- border-radius: 4px;
25
+ padding: 15px;
26
+ border: 1px ${(props) => (props.hasDashedBorder ? 'dashed' : 'solid')}
27
+ ${(props) =>
28
+ props.theme.colors[props.borderColor]
29
+ ? props.theme.colors[props.borderColor]
30
+ : props.borderColor};
48
31
  background-color: ${(props) =>
49
- props.backgroundColor
50
- ? props.backgroundColor
51
- : props.presetStyles.backgroundColor};
52
- border-width: ${(props) => props.presetStyles.borderWidth};
53
- border-style: ${(props) =>
54
- props.borderStyle ? props.borderStyle : props.presetStyles.borderStyle};
55
- border-color: ${(props) =>
56
- props.borderColor ? props.borderColor : props.presetStyles.borderColor};
32
+ props.theme.colors[props.backgroundColor]
33
+ ? props.theme.colors[props.backgroundColor]
34
+ : props.backgroundColor};
35
+ border-radius: 4px;
57
36
  `
58
37
 
59
38
  const TextContainer = styled.div`
@@ -69,83 +48,19 @@
69
48
  TextContainer,
70
49
  },
71
50
  props: {
72
- type: {
73
- required: false,
74
- type: String,
75
- default: 'info',
76
- },
77
- minWidth: {
78
- required: false,
79
- type: String,
80
- default: '',
81
- },
82
- iconColor: {
83
- required: false,
84
- type: String,
85
- default: '',
86
- },
87
51
  color: {
88
52
  required: false,
89
- type: String,
90
- default: '',
91
53
  },
92
- alignItems: {
54
+ backgrounColor: {
93
55
  required: false,
94
- type: String,
95
- default: '',
96
56
  },
97
- padding: {
57
+ hasDashedBorder: {
98
58
  required: false,
99
- type: String,
100
- default: '',
59
+ default: true,
101
60
  },
102
61
  borderColor: {
103
62
  required: false,
104
- type: String,
105
- default: '',
106
- },
107
- borderStyle: {
108
- required: false,
109
- type: String,
110
- default: '',
111
- },
112
- },
113
- computed: {
114
- isInfo() {
115
- // this property is used for tests
116
- return this.type === 'info'
117
- },
118
- isWarning() {
119
- return this.type === 'warning'
120
- },
121
- isErrorMinor() {
122
- return this.type === 'error_minor'
123
- },
124
- presetStyles() {
125
- // the types that doesn't have explicit border anyway have it transparent
126
- // to avoid flickering in case the same info card would switch the types
127
- let stylesCollection = {
128
- alignItems: 'flex-start',
129
- padding: '20px',
130
- borderWidth: '1px',
131
- borderStyle: 'solid',
132
- borderColor: 'transparent',
133
- }
134
-
135
- if (this.isWarning) {
136
- stylesCollection.color = theme.colors.white
137
- stylesCollection.backgroundColor = theme.colors.yellow
138
- stylesCollection.iconColor = theme.colors.white
139
- } else if (this.isErrorMinor) {
140
- stylesCollection.borderStyle = 'dashed'
141
- stylesCollection.borderColor = theme.colors.pureRed
142
- stylesCollection.iconColor = theme.colors.pureRed
143
- } else {
144
- stylesCollection.borderStyle = 'dashed'
145
- stylesCollection.borderColor = theme.colors.grey4
146
- }
147
-
148
- return stylesCollection
63
+ default: 'grey4',
149
64
  },
150
65
  },
151
66
  }
@@ -4,6 +4,7 @@
4
4
  v-if="hasLabelSlot"
5
5
  :align-items="alignItems"
6
6
  :border-color="borderColor"
7
+ :is-disabled="disabled"
7
8
  :is-error="isError"
8
9
  :is-interactive="isInteractive"
9
10
  :no-border="noBorder"
@@ -273,18 +274,22 @@
273
274
  : props.theme.colors.mediumGray};
274
275
  `
275
276
 
276
- const LabelWrapper = styled('div', inputProps)`
277
+ const LabelWrapper = styled('div')`
277
278
  display: flex;
278
279
  align-items: center;
279
280
  gap: 10px;
280
281
  margin-bottom: 8px;
281
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
282
282
  `
283
283
  const LabelSlotWrapper = styled('div', inputProps)`
284
284
  display: flex;
285
285
  gap: 10px;
286
286
  align-items: center;
287
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
287
+ cursor: ${(props) =>
288
+ props.isDisabled
289
+ ? 'not-allowed'
290
+ : props.isInteractive
291
+ ? 'ew-resize'
292
+ : 'auto'};
288
293
  border: ${(props) =>
289
294
  props.alignItems == 'vertical'
290
295
  ? 'none'
@@ -760,12 +765,18 @@
760
765
  }
761
766
  },
762
767
  initInteraction(e) {
768
+ if (this.disabled) {
769
+ return
770
+ }
763
771
  this.focusInput()
764
772
  e.preventDefault()
765
773
  window.addEventListener('mousemove', this.interact, false)
766
774
  window.addEventListener('mouseup', this.stopInteract, false)
767
775
  },
768
776
  interact(e) {
777
+ if (this.disabled) {
778
+ return
779
+ }
769
780
  e.preventDefault()
770
781
  let value = parseFloat(this.value || 0)
771
782
  value += parseFloat(this.interactionStep) * parseInt(e.movementX)
@@ -1,4 +1,6 @@
1
1
  const defaultRadioButtonProps = {
2
+ dataId: 'radio_buttons',
3
+ name: 'options',
2
4
  options: [
3
5
  {
4
6
  label: 'Option 1',
@@ -43,6 +43,7 @@
43
43
  buttonBgColor || colorMode == 'dark' ? 'transparentBlack1' : 'white'
44
44
  "
45
45
  class="select-button"
46
+ :color-mode="colorMode"
46
47
  :data-id="dataId"
47
48
  :disabled="disabled"
48
49
  :font-color="
@@ -86,7 +87,6 @@
86
87
  />
87
88
  <Selector
88
89
  v-else
89
- :disabled="disabled"
90
90
  :padding-left="paddingLeft"
91
91
  :select-width="selectWidth"
92
92
  :show-border="showBorder"
@@ -97,9 +97,7 @@
97
97
  <Icon
98
98
  v-if="isDropdownOpen"
99
99
  :color="
100
- caretColor || disabled
101
- ? 'grey2'
102
- : colorMode == 'dark'
100
+ caretColor || colorMode == 'dark'
103
101
  ? 'white'
104
102
  : 'transparentBlack1'
105
103
  "
@@ -109,9 +107,7 @@
109
107
  <Icon
110
108
  v-else
111
109
  :color="
112
- caretColor || disabled
113
- ? 'grey2'
114
- : colorMode == 'dark'
110
+ caretColor || colorMode == 'dark'
115
111
  ? 'white'
116
112
  : 'transparentBlack1'
117
113
  "
@@ -204,13 +200,11 @@
204
200
  `
205
201
 
206
202
  const selectorProps = {
207
- disabled: Boolean,
208
203
  selectWidth: String,
209
204
  paddingLeft: String,
210
205
  showBorder: Boolean,
211
206
  }
212
207
  const Selector = styled('div', selectorProps)`
213
- color: ${(props) => (props.disabled ? props.theme.colors.grey2 : '')};
214
208
  ${(props) =>
215
209
  props.selectWidth === '100%'
216
210
  ? 'width: 100%;'
@@ -281,6 +275,7 @@
281
275
  noRelative: Boolean,
282
276
  tablePaddingLeft: String,
283
277
  showDisabledBackground: Boolean,
278
+ colorMode: String,
284
279
  }
285
280
  const SelectButton = styled('div', selectButtonAttrs)`
286
281
  position: ${(props) => (props.noRelative ? 'static' : 'relative')};
@@ -318,12 +313,16 @@
318
313
  `}
319
314
  background-color:${(props) =>
320
315
  props.disabled && props.showDisabledBackground
321
- ? props.theme.colors.grey5
316
+ ? props.colorMode == 'dark'
317
+ ? props.theme.transparentBlack1
318
+ : props.theme.colors.grey5
322
319
  : props.theme.colors[props.bgColor]
323
320
  ? props.theme.colors[props.bgColor]
324
321
  : props.bgColor};
325
322
  color: ${(props) =>
326
- props.theme.colors[props.fontColor]
323
+ props.disabled
324
+ ? props.theme.colors.grey2
325
+ : props.theme.colors[props.fontColor]
327
326
  ? props.theme.colors[props.fontColor]
328
327
  : props.fontColor};
329
328
  ${(props) => (props.disabled ? 'pointer-events: none' : '')};
@@ -542,7 +541,6 @@
542
541
  },
543
542
  disabled: {
544
543
  required: false,
545
- type: Boolean,
546
544
  default: false,
547
545
  },
548
546
  isAutoSearch: {
@@ -621,7 +619,7 @@
621
619
  if (this.isDropdownOpen) {
622
620
  return this.$refs.dropdown.$el.childElementCount > 1
623
621
  ? this.$refs.dropdown.$el.childElementCount
624
- : !!this.$refs.dropdown.$el.children[0]
622
+ : this.$refs.dropdown.$el.children[0]
625
623
  ? this.$refs.dropdown.$el.children[0].childElementCount
626
624
  : 0
627
625
  }
@@ -5,7 +5,7 @@
5
5
  :is-open="isOpen"
6
6
  :position="position"
7
7
  >
8
- <ModalContainer :overflow="overflowRule" @click="onClickModalContainer">
8
+ <ModalContainer @click="onClickModalContainer">
9
9
  <Spinner v-if="isLoading" :limited-to-modal="true" size="50px" />
10
10
  <ContentContainer :visible="!isLoading">
11
11
  <slot></slot>
@@ -67,8 +67,7 @@
67
67
  }
68
68
  `
69
69
 
70
- const modalContainerAttrs = { overflow: String }
71
- const ModalContainer = styled('div', modalContainerAttrs)`
70
+ const ModalContainer = styled.div`
72
71
  align-self: center;
73
72
  justify-self: center;
74
73
  position: relative;
@@ -76,7 +75,7 @@
76
75
  border-radius: 4px;
77
76
  background: white;
78
77
  margin: 0 auto;
79
- overflow: ${(props) => props.overflow};
78
+ overflow: auto;
80
79
  max-width: 95%;
81
80
  max-height: 95%;
82
81
  min-width: 100px;
@@ -153,11 +152,6 @@
153
152
  type: Boolean,
154
153
  default: true,
155
154
  },
156
- overflowRule: {
157
- required: false,
158
- type: String,
159
- default: 'auto',
160
- },
161
155
  },
162
156
  watch: {
163
157
  isOpen: {
@@ -254,6 +254,9 @@
254
254
  activeDropdown: null,
255
255
  }
256
256
  },
257
+ mounted() {
258
+ this.activeDropdown = this.activeParentTab
259
+ },
257
260
  methods: {
258
261
  toggleActiveDropdown(value) {
259
262
  if (this.activeDropdown === value) {
@@ -263,17 +266,5 @@
263
266
  }
264
267
  },
265
268
  },
266
- watch: {
267
- activeTab: {
268
- // once active tab is received, check if any parent
269
- // tab is active and if so open according dropdown
270
- handler() {
271
- if (this.activeParentTab) {
272
- this.activeDropdown = this.activeParentTab
273
- }
274
- },
275
- once: true,
276
- },
277
- },
278
269
  }
279
270
  </script>
@@ -10,11 +10,7 @@
10
10
  ref="tableRef"
11
11
  :is-position-absolute="doesTableContainDraggables"
12
12
  >
13
- <TableWrapper
14
- class="main-table-wrapper"
15
- :full-width="fullWidth"
16
- :is-overflow-hidden="isOverflowHidden"
17
- >
13
+ <TableWrapper class="main-table-wrapper" :full-width="fullWidth">
18
14
  <SpinnerWrapper v-if="isLoading">
19
15
  <Spinner />
20
16
  </SpinnerWrapper>
@@ -74,12 +70,12 @@
74
70
  `}
75
71
  `
76
72
 
77
- const wrapperAttrs = { fullWidth: Boolean, isOverflowHidden: Boolean }
73
+ const wrapperAttrs = { fullWidth: Boolean }
78
74
  const TableWrapper = styled('div', wrapperAttrs)`
79
75
  width: ${(props) => (props.fullWidth ? '100%' : 'fit-content')};
80
76
  max-width: 100%;
81
- ${(props) =>
82
- props.isOverflowHidden ? 'overflow-x: auto; overflow-y: hidden;' : ''}
77
+ overflow-x: auto;
78
+ overflow-y: hidden;
83
79
 
84
80
  ::-webkit-scrollbar {
85
81
  height: 10px; //height of the whole scrollbar area
@@ -413,10 +409,6 @@
413
409
  required: false,
414
410
  default: false,
415
411
  },
416
- isOverflowHidden: {
417
- required: false,
418
- default: true,
419
- },
420
412
  titleText: {
421
413
  required: false,
422
414
  default: null,
@@ -1,170 +0,0 @@
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 the text (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
- iconColor: {
30
- description: 'Color of the icon (can overwrite preset styles)',
31
- control: {
32
- type: 'color',
33
- presetColors: [
34
- theme.colors.grey3,
35
- theme.colors.grey4,
36
- theme.colors.red,
37
- ],
38
- },
39
- },
40
- alignItems: {
41
- description: 'Icon and text alignment (can overwrite preset styles)',
42
- control: 'select',
43
- options: ['flex-start', 'flex-end', 'center'],
44
- },
45
- padding: {
46
- description: 'Info card padding (can overwrite preset styles)',
47
- },
48
- borderColor: {
49
- description: 'Info card border color (can overwrite preset styles)',
50
- control: {
51
- type: 'color',
52
- presetColors: [
53
- theme.colors.grey3,
54
- theme.colors.grey4,
55
- theme.colors.red,
56
- ],
57
- },
58
- },
59
- borderStyle: {
60
- description: 'Info card border style (can overwrite preset styles)',
61
- control: 'select',
62
- options: ['dashed', 'dotted', 'inset', 'dashed solid', 'none'],
63
- },
64
-
65
- // info card content slot
66
- default: {
67
- description: 'Info card slot content',
68
- },
69
- },
70
- }
71
-
72
- // To use:
73
- // <InfoCard
74
- // type="warning"
75
- // min-width="auto'
76
- // color="red"
77
- // align-items="center"
78
- // padding="100px"
79
- // border-color="red"
80
- // border-style="solid"
81
- // >
82
- // Some Text
83
- // </InfoCard>
84
- // all props after "min-width" are used to overwrite the preset styles set by "type"
85
-
86
- const Template = (args) => {
87
- return {
88
- components: { InfoCard },
89
- setup() {
90
- return { args }
91
- },
92
- template: `
93
- <InfoCard v-bind="args">
94
- {{ args.default }}
95
- </InfoCard>
96
- `,
97
- }
98
- }
99
-
100
- export const Default = Template.bind({})
101
- Default.args = {
102
- ...defaultInfoCardProps,
103
- }
104
-
105
- export const InfoCardTypeWarning = Template.bind({})
106
- InfoCardTypeWarning.args = {
107
- ...defaultInfoCardProps,
108
- type: 'warning',
109
- }
110
-
111
- export const InfoCardTypeErrorMinor = Template.bind({})
112
- InfoCardTypeErrorMinor.args = {
113
- ...defaultInfoCardProps,
114
- type: 'error_minor',
115
- }
116
-
117
- export const InfoCardTypeInfoMinWidth = Template.bind({})
118
- InfoCardTypeInfoMinWidth.args = {
119
- ...defaultInfoCardProps,
120
-
121
- minWidth: '250px',
122
- }
123
-
124
- export const InfoCardTypeInfoColorOverwritten = Template.bind({})
125
- InfoCardTypeInfoColorOverwritten.args = {
126
- ...defaultInfoCardProps,
127
-
128
- color: theme.colors.green,
129
- }
130
-
131
- export const InfoCardTypeInfoIconColorOverwritten = Template.bind({})
132
- InfoCardTypeInfoIconColorOverwritten.args = {
133
- ...defaultInfoCardProps,
134
-
135
- iconColor: theme.colors.green,
136
- }
137
-
138
- export const InfoCardTypeWarningAlignItemsOverwritten = Template.bind({})
139
- InfoCardTypeWarningAlignItemsOverwritten.args = {
140
- ...defaultInfoCardProps,
141
- type: 'warning',
142
- default:
143
- '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.',
144
-
145
- alignItems: 'center',
146
- }
147
-
148
- export const InfoCardTypeWarningPaddingOverwritten = Template.bind({})
149
- InfoCardTypeWarningPaddingOverwritten.args = {
150
- ...defaultInfoCardProps,
151
- type: 'warning',
152
-
153
- padding: '50px',
154
- }
155
-
156
- export const InfoCardTypeErrorMinorBorderColorOverwritten = Template.bind({})
157
- InfoCardTypeErrorMinorBorderColorOverwritten.args = {
158
- ...defaultInfoCardProps,
159
- type: 'error_minor',
160
-
161
- borderColor: theme.colors.green,
162
- }
163
-
164
- export const InfoCardTypeErrorMinorBorderStyleOverwritten = Template.bind({})
165
- InfoCardTypeErrorMinorBorderStyleOverwritten.args = {
166
- ...defaultInfoCardProps,
167
- type: 'error_minor',
168
-
169
- borderStyle: 'solid none',
170
- }
@@ -1,7 +0,0 @@
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,64 +0,0 @@
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
- expect(wrapper.vm.isErrorMinor).toBe(false)
51
-
52
- await wrapper.setProps({ type: 'warning' })
53
-
54
- expect(wrapper.vm.isInfo).toBe(false)
55
- expect(wrapper.vm.isWarning).toBe(true)
56
- expect(wrapper.vm.isErrorMinor).toBe(false)
57
-
58
- await wrapper.setProps({ type: 'error_minor' })
59
-
60
- expect(wrapper.vm.isInfo).toBe(false)
61
- expect(wrapper.vm.isWarning).toBe(false)
62
- expect(wrapper.vm.isErrorMinor).toBe(true)
63
- })
64
- })