fleetcor-lwc 2.4.2 → 2.6.0

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/README.md CHANGED
@@ -50,6 +50,20 @@ const pathConstants = 'frontend/common/mixins.scss';
50
50
 
51
51
  ## Components
52
52
 
53
+ ```html
54
+ Radio Group Icon:
55
+ <flt-radio-group-icon
56
+ size="s"
57
+ name="city"
58
+ disabled="true"
59
+ required="true"
60
+ group="main"
61
+ options="[{icon:'///icon-path', value:'London'}, {icon:'///icon-path', value:'Leon'}]"
62
+ value="London"
63
+ ></flt-radio-group-icon>
64
+ ...
65
+ ```
66
+
53
67
  ```html
54
68
  Radio Group:
55
69
 
@@ -253,10 +267,19 @@ $FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_BG_COLOR: var(
253
267
 
254
268
  ## Release Notes:
255
269
 
270
+ - v.2.6.0
271
+
272
+ - Added new component `flt-radio-group-icon` (don't use `flt-radio-group` with icons)
273
+
274
+ - v.2.5.0
275
+
276
+ - Available icons for `flt-radio-group`
277
+
256
278
  - v.2.4.2
257
279
  - Bug fix at `flt-radio-group`
258
280
 
259
281
  ---
282
+
260
283
  - v.2.4.1
261
284
  - Change margin for items at `flt-radio-group`
262
285
 
@@ -33,6 +33,13 @@
33
33
  @media (min-width: 768px) {
34
34
  margin-top: 0;
35
35
  }
36
+
37
+ &:last-child {
38
+ margin-right: 0;
39
+ .flt-radio-item__icon {
40
+ margin-right: 0;
41
+ }
42
+ }
36
43
  }
37
44
 
38
45
  &__error-message {
@@ -0,0 +1,67 @@
1
+ import { createElement } from 'lwc'
2
+
3
+ import RadioGroupIcon from 'flt/radioGroupIcon'
4
+
5
+ describe('flt-radio-group-icon', () => {
6
+ afterEach(() => {
7
+ while (document.body.firstChild) {
8
+ document.body.removeChild(document.body.firstChild)
9
+ }
10
+ })
11
+
12
+ it('Generate default radioGroup', async () => {
13
+ const radioGroupDefault = createElement('flt-radio-group-icon', { is: RadioGroupIcon })
14
+ radioGroupDefault.required = true
15
+ radioGroupDefault.options = [
16
+ {
17
+ icon: 'Man',
18
+ value: 'man'
19
+ },
20
+ {
21
+ icon: 'Woman',
22
+ value: 'woman'
23
+ }
24
+ ]
25
+ radioGroupDefault.name = 'sex'
26
+ document.body.appendChild(radioGroupDefault)
27
+ await expect(radioGroupDefault.firstChild.classList).toContain('flt-radio-group-icon')
28
+
29
+ const errorElement = document.body.querySelector('.flt-radio-group-icon__error-message')
30
+
31
+ await expect(errorElement.classList).not.toContain(
32
+ 'flt-radio-group-icon__error-message_active'
33
+ )
34
+
35
+ let items = radioGroupDefault.firstChild.querySelectorAll('flt-radio-item-icon')
36
+ await expect(items.length).toBe(2)
37
+ let data = radioGroupDefault.getData()
38
+ await expect(data.value).toBeUndefined()
39
+ await expect(errorElement.classList).toContain('flt-radio-group-icon__error-message_active')
40
+ items[0].querySelector('.flt-radio-item-icon').click()
41
+ data = radioGroupDefault.getData()
42
+ await expect(data.value).toBe('man')
43
+ await expect(errorElement.classList).not.toContain(
44
+ 'flt-radio-group-icon__error-message_active'
45
+ )
46
+ })
47
+
48
+ it('Generate default radioGroup', async () => {
49
+ const radioGroupDefault = createElement('flt-radio-group-icon', { is: RadioGroupIcon })
50
+ radioGroupDefault.disabled = true
51
+ radioGroupDefault.options = [
52
+ {
53
+ icon: 'Man',
54
+ value: 'man'
55
+ },
56
+ {
57
+ icon: 'Woman',
58
+ value: 'woman'
59
+ }
60
+ ]
61
+ radioGroupDefault.name = 'bank'
62
+ document.body.appendChild(radioGroupDefault)
63
+
64
+ const item = radioGroupDefault.firstChild.querySelector('flt-radio-item-icon')
65
+ await expect(item.option.disabled).toBeTruthy()
66
+ })
67
+ })
@@ -0,0 +1,13 @@
1
+ <template lwc:render-mode="light">
2
+ <div class="flt-radio-group-icon">
3
+ <template for:each={optionsToDisplay} for:item="option">
4
+ <flt-radio-item-icon
5
+ key={option.key}
6
+ class="flt-radio-group-icon__item"
7
+ size={size}
8
+ option={option}
9
+ onchange={handleChange}></flt-radio-item-icon>
10
+ </template>
11
+ </div>
12
+ <div class={computedErrorMessage}>{errorMessage}</div>
13
+ </template>
@@ -0,0 +1,31 @@
1
+ import './radioGroupIcon.scss'
2
+
3
+ import { api } from 'lwc'
4
+ import { SelectElement } from 'fleetcor-lwc'
5
+
6
+ /**
7
+ * @class RadioGroupIcon
8
+ * @extends SelectElement
9
+ * @description Flt Radio Group component
10
+ */
11
+ export default class RadioGroupIcon extends SelectElement {
12
+ error
13
+
14
+ @api size = SIZES.SMALL
15
+ @api errorMessage
16
+
17
+ @api validate() {
18
+ this.error = !this.isValid()
19
+ }
20
+
21
+ get computedErrorMessage() {
22
+ return this.generateClassNameList({
23
+ 'flt-radio-group-icon__error-message': true,
24
+ 'flt-radio-group-icon__error-message_active': this.error
25
+ })
26
+ }
27
+ }
28
+
29
+ const SIZES = {
30
+ SMALL: 's'
31
+ }
@@ -0,0 +1,37 @@
1
+ @import './../../../common/mixins_aquamarine';
2
+ /* mixins */
3
+
4
+ .flt-radio-group-icon {
5
+ display: flex;
6
+ flex-wrap: wrap;
7
+
8
+ &__item {
9
+ display: inline-block;
10
+ margin: 0.5rem 0;
11
+ margin-right: 1.5rem;
12
+
13
+ @media (min-width: 768px) {
14
+ margin-top: 0;
15
+ }
16
+
17
+ &:last-child {
18
+ margin-right: 0;
19
+ .flt-radio-item__icon {
20
+ margin-right: 0;
21
+ }
22
+ }
23
+ }
24
+
25
+ &__error-message {
26
+ color: $FLT_RADIO_GROUP_ERROR_COLOR;
27
+ opacity: 0;
28
+ line-height: 0;
29
+ transition: all 0.3s;
30
+ font-size: 12px;
31
+
32
+ &_active {
33
+ opacity: 1;
34
+ line-height: 1.5;
35
+ }
36
+ }
37
+ }
@@ -52,4 +52,11 @@
52
52
  margin-right: 1rem;
53
53
  border-radius: 100%;
54
54
  }
55
+
56
+ &__icon {
57
+ width: 58px;
58
+ height: 40px;
59
+ object-fit: contain;
60
+ margin-right: 1rem;
61
+ }
55
62
  }
@@ -0,0 +1,56 @@
1
+ import { createElement } from 'lwc'
2
+
3
+ import RadioItemIcon from 'flt/radioItemIcon'
4
+
5
+ describe('flt-radio-item-icon', () => {
6
+ afterEach(() => {
7
+ while (document.body.firstChild) {
8
+ document.body.removeChild(document.body.firstChild)
9
+ }
10
+ })
11
+
12
+ it('Generate active radio item', async () => {
13
+ const radioItemDefault = createElement('flt-radio-item-icon', { is: RadioItemIcon })
14
+ radioItemDefault.option = {
15
+ icon: 'Label 1',
16
+ value: 'value 1',
17
+ selected: true,
18
+ disabled: false
19
+ }
20
+ document.body.appendChild(radioItemDefault)
21
+
22
+ await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item-icon_selected')
23
+ })
24
+
25
+ it('Generate default radio item', async () => {
26
+ const radioItemDefault = createElement('flt-radio-item-icon', { is: RadioItemIcon })
27
+ radioItemDefault.option = {
28
+ icon: 'Label 1',
29
+ value: 'value 1',
30
+ selected: false,
31
+ disabled: false
32
+ }
33
+ document.body.appendChild(radioItemDefault)
34
+
35
+ await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item-icon')
36
+ await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item-icon_size_s')
37
+ await expect(radioItemDefault.firstChild.classList).not.toContain('flt-radio-item-icon_disabled')
38
+ await expect(radioItemDefault.firstChild.classList).not.toContain('flt-radio-item-icon_selected')
39
+
40
+ await radioItemDefault.firstChild.click()
41
+ })
42
+
43
+ it('Generate disabled radio item', async () => {
44
+ const radioItemDefault = createElement('flt-radio-item-icon', { is: RadioItemIcon })
45
+ radioItemDefault.option = {
46
+ icon: 'Label 1',
47
+ value: 'value 1',
48
+ selected: false,
49
+ disabled: true
50
+ }
51
+
52
+ document.body.appendChild(radioItemDefault)
53
+
54
+ await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item-icon_disabled')
55
+ })
56
+ })
@@ -0,0 +1,6 @@
1
+ <template lwc:render-mode="light">
2
+ <div onclick={handleClick} class={styleClass} autotests-value={option.value}>
3
+ <span class="flt-radio-item-icon__circle"></span>
4
+ <img class="flt-radio-item-icon__icon" src={option.icon} alt={option.label} />
5
+ </div>
6
+ </template>
@@ -0,0 +1,33 @@
1
+ import './radioItemIcon.scss'
2
+
3
+ import { api } from 'lwc'
4
+ import { BaseElement } from 'fleetcor-lwc'
5
+
6
+ /**
7
+ * @class RadioItemIcon
8
+ * @extends BaseElement
9
+ * @description Flt Radio Item Icon component
10
+ */
11
+ export default class RadioItemIcon extends BaseElement {
12
+ @api option
13
+ @api size = SIZES.SMALL
14
+
15
+ get styleClass() {
16
+ return this.generateClassNameList({
17
+ 'flt-radio-item-icon': true,
18
+ [`flt-radio-item-icon_size_${this.size}`]: true,
19
+ 'flt-radio-item-icon_selected': this.option.selected,
20
+ 'flt-radio-item-icon_disabled': this.option.disabled
21
+ })
22
+ }
23
+
24
+ handleClick() {
25
+ if (!this.option.disabled || !this.option.selected) {
26
+ this.dispatchEvent(new CustomEvent('change', { detail: { ...this.option } }))
27
+ }
28
+ }
29
+ }
30
+
31
+ const SIZES = {
32
+ SMALL: 's'
33
+ }
@@ -0,0 +1,62 @@
1
+ @import './../../../common/mixins_aquamarine';
2
+ /* mixins */
3
+
4
+ .flt-radio-item-icon {
5
+ display: flex;
6
+ align-items: center;
7
+ cursor: pointer;
8
+
9
+ &:hover:not(.flt-radio-item-icon_disabled) &__circle {
10
+ border-color: $FLT_RADIO_GROUP_CIRCLE_HOVER_COLOR;
11
+ }
12
+
13
+ &:hover:not(.flt-radio-item-icon_disabled).flt-radio-item-icon_selected &__circle {
14
+ border-color: $FLT_RADIO_GROUP_CIRCLE_SELECTED_HOVER_COLOR;
15
+ }
16
+
17
+ &_selected &__circle {
18
+ border: 5px solid $FLT_RADIO_GROUP_CIRCLE_SELECTED_COLOR;
19
+ }
20
+
21
+ &_disabled {
22
+ cursor: not-allowed;
23
+ }
24
+
25
+ // &_disabled &__label {
26
+ // color: $FLT_RADIO_GROUP_DISABLED_COLOR;
27
+ // }
28
+
29
+ &_disabled &__circle {
30
+ border-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_COLOR;
31
+ background-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_BG_COLOR;
32
+ }
33
+
34
+ &_selected.flt-radio-item-icon_disabled &__circle {
35
+ border-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_COLOR;
36
+ background-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_BG_COLOR;
37
+ }
38
+
39
+ // &__label {
40
+ // line-height: 20px;
41
+ // font-size: 15px;
42
+ // color: $FLT_RADIO_GROUP_COLOR;
43
+ // }
44
+
45
+ &__circle {
46
+ box-sizing: border-box;
47
+ border: 1px solid $FLT_RADIO_GROUP_CIRCLE_COLOR;
48
+ width: 20px;
49
+ height: 20px;
50
+ transition: all 0.3s;
51
+ background-color: #ffffff;
52
+ margin-right: 1rem;
53
+ border-radius: 100%;
54
+ }
55
+
56
+ &__icon {
57
+ width: 58px;
58
+ height: 40px;
59
+ object-fit: contain;
60
+ margin-right: 1rem;
61
+ }
62
+ }
@@ -21,6 +21,7 @@ export default class SelectElement extends UserDataValidator {
21
21
  result = this.options.map((item) => {
22
22
  return {
23
23
  label: item.label,
24
+ icon: item.icon,
24
25
  key: `${this.name}_${item.value}`,
25
26
  disabled: this.disabled,
26
27
  value: item.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetcor-lwc",
3
- "version": "2.4.2",
3
+ "version": "2.6.0",
4
4
  "description": "LWC framework by Fleetcor",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,6 +32,7 @@
32
32
  "flt/checkbox",
33
33
  "flt/icon",
34
34
  "flt/radioGroup",
35
+ "flt/radioGroupIcon",
35
36
  "flt/tooltip"
36
37
  ]
37
38
  },