@iamproperty/components 2.9.0 → 3.0.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.
Files changed (74) hide show
  1. package/README.md +9 -130
  2. package/assets/css/core.min.css +1 -1
  3. package/assets/css/core.min.css.map +1 -1
  4. package/assets/css/style.min.css +1 -1
  5. package/assets/css/style.min.css.map +1 -1
  6. package/assets/favicons/manifest.json +32 -0
  7. package/assets/js/main.js +57 -0
  8. package/assets/js/modules/chart.js +18 -17
  9. package/assets/js/modules/nav.js +9 -8
  10. package/assets/js/modules/table.js +24 -24
  11. package/assets/js/scripts.bundle.js +20 -17
  12. package/assets/js/scripts.bundle.js.map +1 -1
  13. package/assets/js/scripts.bundle.min.js +1 -1
  14. package/assets/js/scripts.bundle.min.js.map +1 -1
  15. package/assets/sass/_functions/utilities.scss +3 -3
  16. package/assets/sass/_functions/variables.scss +3 -2
  17. package/assets/sass/_tests/colours.spec.scss +45 -0
  18. package/assets/sass/_tests/func.spec.scss +233 -0
  19. package/assets/sass/_tests/mixins.spec.scss +194 -0
  20. package/assets/sass/_tests/sass.spec.js +9 -0
  21. package/assets/sass/_tests/typography.spec.scss +36 -0
  22. package/assets/sass/components/alert.scss +1 -1
  23. package/assets/sass/components/cardDeck.scss +1 -1
  24. package/assets/sass/components/carousel.scss +4 -4
  25. package/assets/sass/components/charts.scss +1 -1
  26. package/assets/sass/components/nav.scss +5 -2
  27. package/assets/sass/components/stepper.scss +3 -3
  28. package/assets/sass/elements/panel.scss +3 -3
  29. package/assets/sass/elements/tooltips.scss +1 -1
  30. package/assets/sass/foundations/root.scss +4 -4
  31. package/assets/ts/main.js +57 -0
  32. package/assets/ts/main.js.map +1 -0
  33. package/assets/ts/main.ts +9 -9
  34. package/assets/ts/modules/accordion.js +33 -0
  35. package/assets/ts/modules/accordion.js.map +1 -0
  36. package/dist/components.es.js +2504 -0
  37. package/dist/components.umd.js +56 -3784
  38. package/dist/style.css +1 -0
  39. package/package.json +87 -87
  40. package/src/components/Accordion/Accordion.screenshot.vue +57 -0
  41. package/src/components/Accordion/Accordion.spec.js +63 -0
  42. package/src/components/Accordion/AccordionItem.vue +1 -1
  43. package/src/components/Accordion/__screenshots__/win32/laptop/Accordion.png +0 -0
  44. package/src/components/Accordion/__screenshots__/win32/mobile/Accordion.png +0 -0
  45. package/src/components/Accordion/__screenshots__/win32/tablet/Accordion.png +0 -0
  46. package/src/components/Alert/Alert.spec.js +49 -0
  47. package/src/components/Alert/Alert.vue +3 -3
  48. package/src/components/Banner/Banner.spec.js +28 -0
  49. package/src/components/CardDeck/CardDeck.spec.js +99 -0
  50. package/src/components/Carousel/Carousel.spec.js +45 -0
  51. package/src/components/Chart/Chart.spec.js +201 -0
  52. package/src/components/Chart/Chart.vue +3 -3
  53. package/src/components/Header/Header.spec.js +33 -0
  54. package/src/components/Modal/Modal.spec.js +22 -0
  55. package/src/components/Nav/Nav.spec.js +35 -0
  56. package/src/components/Nav/Nav.vue +5 -2
  57. package/src/components/Stepper/Stepper.spec.js +99 -0
  58. package/src/components/Tabs/Tab.vue +6 -0
  59. package/src/components/Tabs/Tabs.vue +15 -13
  60. package/src/components/Testimonial/Testimonial.spec.js +57 -0
  61. package/src/components/Timeline/Timeline.spec.js +17 -0
  62. package/src/elements/Table/Table.spec.js +90 -0
  63. package/src/elements/Table/Table.vue +8 -5
  64. package/src/foundations/Icon/Icon.spec.js +24 -0
  65. package/src/foundations/Logo/Logo.spec.js +56 -0
  66. package/src/vue-shim.d.ts +6 -0
  67. package/dist/components.common.js +0 -3773
  68. package/dist/components.common.js.map +0 -1
  69. package/dist/components.css +0 -2
  70. package/dist/components.css.map +0 -1
  71. package/dist/components.umd.js.map +0 -1
  72. package/dist/components.umd.min.js +0 -2
  73. package/dist/components.umd.min.js.map +0 -1
  74. package/dist/demo.html +0 -1
@@ -0,0 +1,99 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import CardDeck from './/CardDeck.vue'
3
+ import Card from '../../elements/Card/Card.vue'
4
+
5
+ describe('Card Deck component', () => {
6
+
7
+ const test = mount(CardDeck, {
8
+ propsData: {
9
+ items: [
10
+ {
11
+ link: '/components/card-deck',
12
+ title: 'Card 1',
13
+ content: `<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages..</p>`
14
+ },
15
+ {
16
+ link: '/components/card-deck',
17
+ title: 'Card 2',
18
+ content: `<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur, tortor eu faucibus facilisis, felis libero blandit dolor.</p>`
19
+ },
20
+ {
21
+ link: '/components/card-deck',
22
+ title: 'Card 3',
23
+ content: `<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur, tortor eu faucibus facilisis, felis libero blandit dolor.</p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur.</p>`
24
+ }
25
+ ]
26
+ },
27
+ slots: {
28
+ default: '<p>Hello</p>',
29
+ after: '<p>Hello 2</p>'
30
+ }
31
+ })
32
+
33
+ it('renders the content before the card deck', () => {
34
+ expect(test.html()).toContain('<p>Hello</p>')
35
+ })
36
+
37
+ it('renders the content after the card deck', () => {
38
+ expect(test.html()).toContain('<p>Hello 2</p>')
39
+ })
40
+
41
+ it('renders the card title', () => {
42
+ expect(test.html()).toContain('<span class="card-title d-block h4">Card 1</span>')
43
+ expect(test.html()).toContain('<span class="card-title d-block h4">Card 2</span>')
44
+ expect(test.html()).toContain('<span class="card-title d-block h4">Card 3</span>')
45
+ })
46
+
47
+ it('renders the correct number of cards', () => {
48
+
49
+ expect(test.findAll('.card').length).toBe(3)
50
+ })
51
+ })
52
+
53
+
54
+ describe('Property Card component', () => {
55
+
56
+ const test = mount(CardDeck, {
57
+ propsData: {
58
+ items: [
59
+ {
60
+ link: '/components/card-deck',
61
+ content: `<p>Reservation fee applies</p>`,
62
+ image: 'house.jpg',
63
+ title: '4 bed semi-detached',
64
+ subtitle: 'Burt terrace, Newcastle upon tyne',
65
+ details: {
66
+ tags: ['Modern method','Freehold'],
67
+ guideprice: '£90,000.00',
68
+ auctiontime: '19 days',
69
+ status: 'Live now',
70
+ images: 5,
71
+ videos: 2,
72
+ logo: 'logo.jpg'
73
+ }
74
+ }
75
+ ]
76
+ }
77
+ })
78
+
79
+
80
+ it('renders the property card title', () => {
81
+ expect(test.html()).toContain('<span class="card-title d-block h4">4 bed semi-detached <span class="d-block fw-normal font-body text-body small">Burt terrace, Newcastle upon tyne</span></span>')
82
+
83
+ })
84
+
85
+ it('renders the card image', () => {
86
+
87
+ expect(test.html()).toContain('<img src="house.jpg" alt="" loading="lazy" class="card-image">')
88
+ })
89
+
90
+ it('renders the card logo', () => {
91
+
92
+ expect(test.html()).toContain('<img src="logo.jpg" alt="" loading="lazy" class="card-logo">')
93
+ })
94
+
95
+ it('renders the card tags', () => {
96
+
97
+ expect(test.html()).toContain('<span class="badge rounded-pill py-2 px-3 mb-3 me-2 bg-secondary text-primary">Modern method</span>')
98
+ })
99
+ })
@@ -0,0 +1,45 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import Carousel from './Carousel.vue'
3
+
4
+ describe('Carousel component', () => {
5
+
6
+ const test = mount(Carousel, {
7
+ propsData: {
8
+ items: [
9
+ {
10
+ link: '/components/card-deck',
11
+ title: 'Card 1',
12
+ content: `<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages..</p>`
13
+ },
14
+ {
15
+ link: '/components/card-deck',
16
+ title: 'Card 2',
17
+ content: `<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur, tortor eu faucibus facilisis, felis libero blandit dolor.</p>`
18
+ },
19
+ {
20
+ link: '/components/card-deck',
21
+ title: 'Card 3',
22
+ content: `<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur, tortor eu faucibus facilisis, felis libero blandit dolor.</p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur.</p>`
23
+ }
24
+ ]
25
+ },
26
+ slots: {
27
+ default: '<p>Hello</p>'
28
+ }
29
+ })
30
+
31
+ it('renders the content before the carousel', () => {
32
+ expect(test.html()).toContain('<p>Hello</p>')
33
+ })
34
+
35
+
36
+ it('renders the correct number of columns', () => {
37
+
38
+ expect(test.findAll('.col').length).toBe(3)
39
+ })
40
+
41
+ it('renders the correct number of pips', () => {
42
+
43
+ expect(test.findAll('.carousel__controls a').length).toBe(3)
44
+ })
45
+ })
@@ -0,0 +1,201 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import Chart from './Chart.vue'
3
+
4
+ describe('Chart component', () => {
5
+
6
+ const test = mount(Chart, {
7
+ propsData: {
8
+ max: 100,
9
+ min: 0,
10
+ yaxis: [
11
+ {
12
+ value: 0,
13
+ display: '£0'
14
+ },
15
+ {
16
+ value: 50,
17
+ display: '£50'
18
+ },
19
+ {
20
+ value: 100,
21
+ display: '£100'
22
+ }
23
+ ],
24
+ fields: [
25
+ { key: 'year' },
26
+ { key: 'Growth' },
27
+ { key: 'Growth2' }
28
+ ],
29
+ items: [
30
+ {
31
+ year: '2011',
32
+ growth: '£50.0',
33
+ growth2: '£50.10'
34
+ },
35
+ {
36
+ year: '2012',
37
+ growth: '£75.00',
38
+ growth2: '£50.10'
39
+ },
40
+ {
41
+ year: '2013',
42
+ growth: '£45.00',
43
+ growth2: '£57.10'
44
+ },
45
+ {
46
+ year: '2014',
47
+ growth: '£35.00',
48
+ growth2: '£80.10'
49
+ }
50
+ ]
51
+ }
52
+ })
53
+
54
+ // On load render a table
55
+ it('renders a thead', () => {
56
+
57
+ expect(test.find('thead').exists()).toBe(true)
58
+ })
59
+
60
+ it('renders a tbody', () => {
61
+
62
+ expect(test.find('tbody').exists()).toBe(true)
63
+ })
64
+
65
+ // Render a bar chart
66
+ it('renders a y-axis', () => {
67
+
68
+ expect(test.find('.chart__yaxis').exists()).toBe(true)
69
+ })
70
+
71
+ it('renders guidelines', () => {
72
+
73
+ expect(test.find('.chart__guidelines').exists()).toBe(true)
74
+ })
75
+
76
+
77
+ it('Numeric value and percent value is added to the table cells', () => {
78
+
79
+ expect(test.html()).toContain('<td data-label="Growth" data-numeric="50" style="--bottom:0%;--percent:50%;"><span data-group="2011" data-label="Growth">£50.0</span></td>')
80
+ })
81
+
82
+ })
83
+
84
+
85
+ describe('Line Chart component', () => {
86
+
87
+ const test = mount(Chart, {
88
+ propsData: {
89
+ type: 'line',
90
+ max: 100,
91
+ min: 0,
92
+ yaxis: [
93
+ {
94
+ value: 0,
95
+ display: '£0'
96
+ },
97
+ {
98
+ value: 50,
99
+ display: '£50'
100
+ },
101
+ {
102
+ value: 100,
103
+ display: '£100'
104
+ }
105
+ ],
106
+ fields: [
107
+ { key: 'year' },
108
+ { key: 'Growth' },
109
+ { key: 'Growth2' }
110
+ ],
111
+ items: [
112
+ {
113
+ year: '2011',
114
+ growth: '£50.0',
115
+ growth2: '£50.10'
116
+ },
117
+ {
118
+ year: '2012',
119
+ growth: '£75.00',
120
+ growth2: '£50.10'
121
+ },
122
+ {
123
+ year: '2013',
124
+ growth: '£45.00',
125
+ growth2: '£57.10'
126
+ },
127
+ {
128
+ year: '2014',
129
+ growth: '£35.00',
130
+ growth2: '£80.10'
131
+ }
132
+ ]
133
+ }
134
+ })
135
+
136
+ it('SVG line is created ', () => {
137
+
138
+ expect(test.html()).toContain('<path fill="none" d="M 0 50 L 66.66666666666667 25 L 133.33333333333334 55 L 200 65 "></path>')
139
+ })
140
+
141
+
142
+ })
143
+
144
+ describe('Pie Chart component', () => {
145
+
146
+ const test = mount(Chart, {
147
+ propsData: {
148
+ type: 'pie',
149
+ max: 100,
150
+ min: 0,
151
+ yaxis: [
152
+ {
153
+ value: 0,
154
+ display: '£0'
155
+ },
156
+ {
157
+ value: 50,
158
+ display: '£50'
159
+ },
160
+ {
161
+ value: 100,
162
+ display: '£100'
163
+ }
164
+ ],
165
+ fields: [
166
+ { key: 'year' },
167
+ { key: 'Growth' },
168
+ { key: 'Growth2' }
169
+ ],
170
+ items: [
171
+ {
172
+ year: '2011',
173
+ growth: '£50.0',
174
+ growth2: '£50.10'
175
+ },
176
+ {
177
+ year: '2012',
178
+ growth: '£75.00',
179
+ growth2: '£50.10'
180
+ },
181
+ {
182
+ year: '2013',
183
+ growth: '£45.00',
184
+ growth2: '£57.10'
185
+ },
186
+ {
187
+ year: '2014',
188
+ growth: '£35.00',
189
+ growth2: '£80.10'
190
+ }
191
+ ]
192
+ }
193
+ })
194
+
195
+ it('SVG pie section is created ', () => {
196
+
197
+ expect(test.html()).toContain('<path d="M -100 1.2246467991473532e-14 A 100 100 0 0 1 100 -2.4492935982947064e-14 L 0 0"></path>')
198
+ })
199
+
200
+
201
+ })
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
 
10
10
  <div :class="`chart chart--${type}`" ref="chart">
11
-
11
+
12
12
  <div class="chart__yaxis" role="presentation">
13
13
  <div :key="index" v-for="(point,index) in yaxis" :style="`--value: ${point.value};--percent:${((point.value-min)/(max-min))*100}%;`" class="axis__point">
14
14
  <span>{{point.display}}</span>
@@ -34,11 +34,11 @@
34
34
 
35
35
  <script>
36
36
  import { ucfirst, unsnake } from '../../helpers/strings'
37
- import Table from '@/elements/Table/Table.vue'
37
+ import Table from '../../elements/Table/Table.vue'
38
38
  import chartModule from '../../../assets/js/modules/chart.js'
39
39
 
40
40
  export default {
41
- name: 'Chart',
41
+ name: 'Chart',
42
42
  components: {
43
43
  Table
44
44
  },
@@ -0,0 +1,33 @@
1
+ import { shallowMount } from '@vue/test-utils'
2
+ import Header from './Header.vue'
3
+
4
+ describe('Header component', () => {
5
+
6
+ const test = shallowMount(Header, {
7
+ propsData: {
8
+ title: 'Page title',
9
+ image: '/img/src/img.png'
10
+ },
11
+ slots: {
12
+ default: '<p>Hello</p>',
13
+ breadcrumb: '<ul class="breadcrumb"></ul>'
14
+ }
15
+ })
16
+
17
+ it('renders the page title', () => {
18
+ expect(test.html()).toContain('<h1>Page title</h1>')
19
+ })
20
+
21
+ it('renders the page description', () => {
22
+ expect(test.html()).toContain('<p>Hello</p>')
23
+ })
24
+
25
+ it('renders the breadcrumb trail', () => {
26
+ expect(test.html()).toContain('<ul class="breadcrumb"></ul>')
27
+ })
28
+
29
+ it('renders the image', () => {
30
+ expect(test.html()).toContain('<source srcset="/img/src/img.png" media="(min-width: 62em)">')
31
+ expect(test.html()).toContain('<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="">')
32
+ })
33
+ })
@@ -0,0 +1,22 @@
1
+ import { shallowMount } from '@vue/test-utils'
2
+ import Modal from './Modal.vue'
3
+
4
+ describe('Modal component', () => {
5
+
6
+ const test = shallowMount(Modal, {
7
+ propsData: {
8
+ id: 'modal'
9
+ },
10
+ slots: {
11
+ default: '<p>Hello</p>'
12
+ }
13
+ })
14
+
15
+ it('renders the close button', () => {
16
+ expect(test.html()).toContain('<a href="#close" class="btn btn-tertiary py-1 px-2"><span class="visually-hidden">Close</span>✕</a>')
17
+ })
18
+
19
+ it('renders the modal content', () => {
20
+ expect(test.html()).toContain('<p>Hello</p>')
21
+ })
22
+ })
@@ -0,0 +1,35 @@
1
+ import { shallowMount } from '@vue/test-utils'
2
+ import Nav from './Nav.vue'
3
+
4
+ describe('Nav component', () => {
5
+ /* Logo */
6
+ it('renders the iam property logo by default', () => {
7
+ const test = shallowMount(Nav, {
8
+ propsData: { }
9
+ })
10
+
11
+ expect(test.html()).toContain('<logo-stub id="property" path=\"/svg/logo.svg\" class=\"pb-0\"></logo-stub>')
12
+ })
13
+
14
+ it('renders the correct logo when a logo id is passed', () => {
15
+ const test = shallowMount(Nav, {
16
+ propsData: {
17
+ logo: 'sold'
18
+ }
19
+ })
20
+
21
+ expect(test.html()).toContain('<logo-stub id="sold" path=\"/svg/logo.svg\" class=\"pb-0\"></logo-stub>')
22
+ })
23
+
24
+ /* Menu button */
25
+ it('renders the iam property logo by default', () => {
26
+ const test = shallowMount(Nav, {
27
+ propsData: { }
28
+ })
29
+
30
+ expect(test.html()).toContain('<label for="showMenu">Menu</label>')
31
+ expect(test.html()).toContain('<input type="checkbox" name="showSearch" id="showSearch" class="d-none">')
32
+ })
33
+
34
+
35
+ })
@@ -58,8 +58,11 @@
58
58
 
59
59
  <div class="col nav__account-btn flex-row align-items-center" v-if="hasAccountSlot">
60
60
  <label for="showAccount">
61
+
61
62
  <svg class="icon" viewBox="0 0 28 28">
62
- <use xlink:href="/svg/icons.svg#icon-account"></use>
63
+ <path d="M14,28a13.861,13.861,0,0,1-9.268-3.533l-.023.047-.721-.738L3.62,23.4l.012-.023a14,14,0,1,1,20.735,0l.012.023-.367.377-.722.738-.024-.045A13.855,13.855,0,0,1,14,28Zm0-9.58a10.5,10.5,0,0,0-1.368.092c-.085.012-.17.03-.252.047-.061.013-.124.026-.187.037l-.077.013c-.266.047-.54.095-.8.165-.108.029-.215.065-.318.1-.063.022-.125.043-.188.063l-.08.026c-.223.071-.454.144-.671.234-.125.05-.245.11-.362.168l-.146.072-.045.021c-.208.1-.423.2-.623.312-.131.074-.257.158-.379.239l-.106.07-.068.044c-.176.114-.359.232-.528.359-.137.1-.267.218-.393.327l-.054.047c-.174.15-.355.306-.519.47-.132.134-.258.277-.38.416l-.018.021c-.16.184-.3.35-.437.527-.12.161-.23.33-.337.494-.076.117-.146.238-.214.356a12.495,12.495,0,0,0,17.109,0l-.022-.037c-.061-.1-.125-.212-.192-.315-.1-.156-.214-.333-.338-.5-.141-.188-.293-.363-.436-.526-.113-.13-.253-.292-.4-.438-.161-.162-.337-.314-.517-.468l-.08-.069c-.118-.1-.24-.209-.368-.307-.183-.137-.379-.264-.568-.387l-.026-.017-.106-.07c-.125-.083-.251-.166-.381-.24-.207-.118-.429-.222-.643-.322l-.024-.011-.152-.074c-.116-.057-.235-.116-.356-.165-.214-.087-.438-.159-.656-.229l-.1-.031c-.066-.021-.132-.043-.2-.066-.1-.035-.2-.07-.309-.1-.264-.07-.538-.118-.8-.165l-.078-.014c-.063-.011-.126-.024-.187-.037-.082-.017-.167-.035-.252-.047A10.483,10.483,0,0,0,14,18.421Zm0-1.473a11.871,11.871,0,0,1,1.54.1c.1.013.192.033.284.052.069.014.139.028.209.04.34.058.672.118,1,.2.14.036.278.082.412.127l.151.05c.309.1.587.188.859.3.148.059.293.127.433.194l.13.061c.306.142.553.266.775.389.188.107.368.22.535.328.26.166.489.322.7.478.156.117.316.244.49.389.209.176.412.361.622.567.156.154.3.293.43.443.209.23.4.472.542.657l.051.066c.1.134.21.272.308.416.021.031.045.061.068.09a1.267,1.267,0,0,1,.085.117,12.525,12.525,0,1,0-19.24,0c.026-.04.056-.078.084-.114s.05-.064.073-.1c.1-.141.2-.278.3-.409l.046-.059c.2-.264.378-.478.555-.672.137-.152.281-.3.417-.43.215-.21.422-.4.635-.578.18-.15.332-.271.479-.381.208-.155.433-.31.709-.486.174-.111.346-.219.526-.319.274-.153.55-.285.783-.393l.112-.053c.144-.069.293-.14.445-.2.282-.113.578-.208.864-.3l.159-.052c.132-.044.265-.088.4-.124.331-.087.675-.148,1-.2.068-.012.137-.026.2-.039.094-.019.191-.039.288-.052A11.827,11.827,0,0,1,14,16.948Z" transform="translate(0 -0.001)" />
64
+ <path d="M5.2,10.4a5.2,5.2,0,1,1,5.2-5.2A5.206,5.206,0,0,1,5.2,10.4Zm0-8.915A3.714,3.714,0,1,0,8.915,5.2,3.719,3.719,0,0,0,5.2,1.486Z" transform="translate(8.8 4.8)" />
65
+
63
66
  </svg>
64
67
  <span>My account</span>
65
68
  </label>
@@ -198,7 +201,7 @@ export default {
198
201
  return !!this.$slots.account
199
202
  },
200
203
  isMarketplace() {
201
- return this.$vnode.data.staticClass && this.$vnode.data.staticClass.includes('nav--marketplace') ? true : false;
204
+ return false;
202
205
  }
203
206
  },
204
207
  mounted(){
@@ -0,0 +1,99 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import Stepper from './Stepper.vue'
3
+ import Step from './Step.vue'
4
+
5
+ describe('Stepper component', () => {
6
+ it('renders 4 steps', () => {
7
+
8
+ const test = mount(Stepper, {
9
+ propsData: {
10
+ 'label': 'Start',
11
+ 'endlabel': 'End'
12
+ },
13
+ global: {
14
+ stubs: {
15
+ 'Step': Step
16
+ }
17
+ },
18
+ slots: {
19
+ default: `<Step status="success">Customer due diligence</Step>
20
+ <Step url="/step" status="success">Legal Preperation</Step>
21
+ <Step url="/step" current>Financial Preparation</Step>
22
+ <Step url="/step">Surveys</Step>`
23
+ }
24
+ })
25
+
26
+ expect(test.findAll('a').length).toBe(4)
27
+ })
28
+
29
+ it('renders a label when set', () => {
30
+
31
+ const test = mount(Stepper, {
32
+ propsData: {
33
+ 'label': 'Start',
34
+ 'endlabel': 'End'
35
+ },
36
+ global: {
37
+ stubs: {
38
+ 'Step': Step
39
+ }
40
+ },
41
+ slots: {
42
+ default: `<Step status="success">Customer due diligence</Step>
43
+ <Step url="/step" status="success">Legal Preperation</Step>
44
+ <Step url="/step" current>Financial Preparation</Step>
45
+ <Step url="/step">Surveys</Step>`
46
+ }
47
+ })
48
+
49
+ expect(test.find('.stepper__start').html()).toContain('Start')
50
+ })
51
+
52
+ it('renders an end label when set', () => {
53
+
54
+ const test = mount(Stepper, {
55
+ propsData: {
56
+ 'label': 'Start',
57
+ 'endlabel': 'End'
58
+ },
59
+ global: {
60
+ stubs: {
61
+ 'Step': Step
62
+ }
63
+ },
64
+ slots: {
65
+ default: `<Step status="success">Customer due diligence</Step>
66
+ <Step url="/step" status="success">Legal Preperation</Step>
67
+ <Step url="/step" current>Financial Preparation</Step>
68
+ <Step url="/step">Surveys</Step>`
69
+ }
70
+ })
71
+
72
+ expect(test.find('.stepper__end').html()).toContain('End')
73
+ })
74
+
75
+
76
+ it('sets status on steps', () => {
77
+
78
+ const test = mount(Stepper, {
79
+ propsData: {
80
+ 'label': 'Start',
81
+ 'endlabel': 'End'
82
+ },
83
+ global: {
84
+ stubs: {
85
+ 'Step': Step
86
+ }
87
+ },
88
+ slots: {
89
+ default: `<Step status="success">Customer due diligence</Step>
90
+ <Step url="/step" status="success">Legal Preperation</Step>
91
+ <Step url="/step" current>Financial Preparation</Step>
92
+ <Step url="/step">Surveys</Step>`
93
+ }
94
+ })
95
+
96
+ expect(test.find('.bg-success').exists()).toBe(true)
97
+ expect(test.find('.current').exists()).toBe(true)
98
+ })
99
+ })
@@ -21,6 +21,12 @@ export default {
21
21
  return {
22
22
  show: this.lazy ? false : true
23
23
  }
24
+ },
25
+ watch: {
26
+
27
+ show(newVal, oldVal) {
28
+ console.log(newVal)
29
+ }
24
30
  }
25
31
  }
26
32
  </script>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="container tabs__container" ref="wrapper">
3
3
 
4
- <input type="radio" class="tab__input" v-for="(value,index) in tabLinks()" :key="index" :name="value.name" :id="value.id" :checked="index == 0? 'checked':''" />
4
+ <input type="radio" class="tab__input" v-for="(value,index) in tabLinks()" :key="index" :data-key="index" :name="value.name" :id="value.id" :checked="(index == 0 ? true:false)" />
5
5
 
6
6
  <div class="tabs__links">
7
7
  <label v-for="(value,index) in tabLinks()" :key="index" :for="value.id" class="link" v-on:click="openTab(index)">
@@ -33,13 +33,13 @@ export default {
33
33
  const tabLinks = [];
34
34
  let i = 1;
35
35
 
36
- for (const [key, value] of Object.entries(this.$slots.default)) {
37
-
36
+ for (const [key, value] of Object.entries(this.$slots.default())) {
37
+
38
38
  // Check if the value in the object is actually a tab and has the correct data
39
- if(value.componentOptions && value.componentOptions.propsData && value.componentOptions.propsData.title){
40
-
41
- let tabTitle = value.componentOptions.propsData.title;
42
-
39
+ if(value.props && value.props.title){
40
+
41
+ let tabTitle = value.props.title;
42
+
43
43
  let tab = {
44
44
  name: this.tabsID,
45
45
  id: this.tabsID+"_tab"+i++,
@@ -56,14 +56,16 @@ export default {
56
56
  },
57
57
  methods: {
58
58
  openTab: function (index) {
59
-
59
+
60
60
  let i = 0;
61
- for (const [key, value] of Object.entries(this.$slots.default)) {
62
-
63
- if(value.componentOptions && value.componentOptions.propsData && value.componentOptions.propsData.title){
64
-
61
+ for (const [key, value] of Object.entries(this.$slots.default())) {
62
+
63
+ if(value.props && value.props.title){
64
+
65
65
  if(i == index){
66
- value.componentInstance._data.show = true;
66
+
67
+ console.log(value)
68
+ value.type.data().show = true;
67
69
  }
68
70
 
69
71
  i++;