@ongov/ontario-design-system-component-library 4.3.0 → 5.0.0-alpha.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/dist/cjs/index-88d5cf20.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{ontario-accordion_43.cjs.entry.js → ontario-accordion_44.cjs.entry.js} +738 -296
- package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -0
- package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/ontario-card/ontario-card-types.js +29 -2
- package/dist/collection/components/ontario-card/ontario-card-types.js.map +1 -1
- package/dist/collection/components/ontario-card/ontario-card.css +257 -31
- package/dist/collection/components/ontario-card/ontario-card.js +104 -80
- package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
- package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +23 -13
- package/dist/collection/components/ontario-card/test/ontario-cards.spec.js.map +1 -1
- package/dist/collection/components/ontario-header/ontario-header.js +17 -3
- package/dist/collection/components/ontario-header/ontario-header.js.map +1 -1
- package/dist/collection/components/ontario-header/service-ontario-header.css +0 -3
- package/dist/collection/components/ontario-header/test/ontario-header.spec.js +3 -3
- package/dist/collection/components/ontario-header/test/ontario-header.spec.js.map +1 -1
- package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js +193 -47
- package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js.map +1 -1
- package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js +16 -3
- package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js.map +1 -1
- package/dist/collection/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
- package/dist/collection/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.css +823 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.js +584 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.js.map +1 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js +20 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js.map +1 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js +19 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js.map +1 -0
- package/dist/collection/components/ontario-step-indicator/ontario-step-indicator.js +5 -5
- package/dist/collection/components/ontario-table/ontario-table.js +5 -5
- package/dist/collection/components/ontario-textarea/ontario-textarea.js +3 -3
- package/dist/collection/i18n/global.i18n.json +172 -162
- package/dist/collection/utils/common/input/input.js +3 -0
- package/dist/collection/utils/common/input/input.js.map +1 -1
- package/dist/collection/utils/common/input-caption/input-caption.js +5 -3
- package/dist/collection/utils/common/input-caption/input-caption.js.map +1 -1
- package/dist/collection/utils/common/language-types.js +1 -1
- package/dist/collection/utils/common/language-types.js.map +1 -1
- package/dist/collection/utils/helper/utils-types.js +2 -0
- package/dist/collection/utils/helper/utils-types.js.map +1 -0
- package/dist/collection/utils/helper/utils.js +26 -0
- package/dist/collection/utils/helper/utils.js.map +1 -1
- package/dist/components/error-message.js +1 -324
- package/dist/components/error-message.js.map +1 -1
- package/dist/components/event-handler.js +330 -0
- package/dist/components/event-handler.js.map +1 -0
- package/dist/components/global.i18n.js +184 -173
- package/dist/components/global.i18n.js.map +1 -1
- package/dist/components/input.js +3 -0
- package/dist/components/input.js.map +1 -1
- package/dist/components/ontario-card.js +118 -66
- package/dist/components/ontario-card.js.map +1 -1
- package/dist/components/ontario-checkboxes.js +2 -1
- package/dist/components/ontario-checkboxes.js.map +1 -1
- package/dist/components/ontario-date-input.js +2 -1
- package/dist/components/ontario-date-input.js.map +1 -1
- package/dist/components/ontario-dropdown-list.js +2 -1
- package/dist/components/ontario-dropdown-list.js.map +1 -1
- package/dist/components/ontario-header.js +13 -7
- package/dist/components/ontario-header.js.map +1 -1
- package/dist/components/ontario-icon-search2.js +6 -0
- package/dist/components/ontario-icon-search2.js.map +1 -0
- package/dist/components/ontario-input.js +2 -1
- package/dist/components/ontario-input.js.map +1 -1
- package/dist/components/ontario-language-toggle2.js +180 -37
- package/dist/components/ontario-language-toggle2.js.map +1 -1
- package/dist/components/ontario-radio-buttons.js +2 -1
- package/dist/components/ontario-radio-buttons.js.map +1 -1
- package/dist/components/ontario-search-box.d.ts +11 -0
- package/dist/components/ontario-search-box.js +269 -0
- package/dist/components/ontario-search-box.js.map +1 -0
- package/dist/components/ontario-step-indicator.js +5 -5
- package/dist/components/ontario-table.js +5 -5
- package/dist/components/ontario-textarea.js +5 -4
- package/dist/components/ontario-textarea.js.map +1 -1
- package/dist/components/utils.js +28 -0
- package/dist/components/utils.js.map +1 -1
- package/dist/esm/index-603026f7.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{ontario-accordion_43.entry.js → ontario-accordion_44.entry.js} +738 -296
- package/dist/esm/ontario-accordion_44.entry.js.map +1 -0
- package/dist/esm/ontario-design-system-components.js +1 -1
- package/dist/ontario-design-system-components/i18n/global.i18n.json +172 -162
- package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
- package/dist/ontario-design-system-components/ontario-design-system-components.esm.js.map +1 -1
- package/dist/ontario-design-system-components/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
- package/dist/ontario-design-system-components/p-9c3a1be9.entry.js.map +1 -0
- package/dist/types/components/ontario-card/ontario-card-types.d.ts +4 -4
- package/dist/types/components/ontario-card/ontario-card.d.ts +40 -29
- package/dist/types/components/ontario-header/ontario-header.d.ts +13 -2
- package/dist/types/components/ontario-language-toggle/ontario-language-toggle.d.ts +75 -8
- package/dist/types/components/ontario-search-box/ontario-search-box.d.ts +180 -0
- package/dist/types/components.d.ts +211 -22
- package/dist/types/utils/common/input/input.d.ts +2 -1
- package/dist/types/utils/common/input-caption/input-caption.d.ts +7 -1
- package/dist/types/utils/common/language-types.d.ts +2 -1
- package/dist/types/utils/helper/utils-types.d.ts +2 -0
- package/dist/types/utils/helper/utils.d.ts +21 -0
- package/package.json +3 -3
- package/src/components/ontario-card/ontario-card-types.tsx +33 -4
- package/src/components/ontario-card/ontario-card.scss +59 -38
- package/src/components/ontario-card/ontario-card.tsx +98 -70
- package/src/components/ontario-card/readme.md +57 -27
- package/src/components/ontario-card/test/__snapshots__/ontario-cards.spec.tsx.snap +66 -0
- package/src/components/ontario-card/test/ontario-cards.spec.tsx +27 -13
- package/src/components/ontario-card-collection/readme.md +13 -13
- package/src/components/ontario-checkbox/ontario-checkboxes.scss +0 -1
- package/src/components/ontario-header/ontario-header.tsx +13 -4
- package/src/components/ontario-header/service-ontario-header.scss +0 -4
- package/src/components/ontario-header/test/ontario-header.spec.tsx +3 -3
- package/src/components/ontario-hint-text/readme.md +2 -0
- package/src/components/ontario-language-toggle/ontario-language-toggle.tsx +192 -45
- package/src/components/ontario-language-toggle/readme.md +10 -10
- package/src/components/ontario-language-toggle/test/__snapshots__/ontario-language-toggle.spec.tsx.snap +1 -1
- package/src/components/ontario-language-toggle/test/ontario-language-toggle.spec.tsx +17 -3
- package/src/components/ontario-radio-buttons/ontario-radio-buttons.scss +0 -1
- package/src/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
- package/src/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
- package/src/components/ontario-search-box/ontario-search-box.scss +141 -0
- package/src/components/ontario-search-box/ontario-search-box.tsx +341 -0
- package/src/components/ontario-search-box/readme.md +132 -0
- package/src/components/ontario-search-box/test/__snapshots__/ontario-search-box.spec.tsx.snap +35 -0
- package/src/components/ontario-search-box/test/ontario-search-box.e2e.ts +21 -0
- package/src/components/ontario-search-box/test/ontario-search-box.spec.tsx +22 -0
- package/src/components.d.ts +211 -22
- package/src/french.html +37 -0
- package/src/index.html +292 -38
- package/src/translations/global.i18n.json +172 -162
- package/src/utils/common/input/input.tsx +4 -1
- package/src/utils/common/input-caption/input-caption.tsx +9 -3
- package/src/utils/common/language-types.ts +2 -1
- package/src/utils/helper/utils-types.ts +2 -0
- package/src/utils/helper/utils.ts +30 -0
- package/www/build/ontario-design-system-components.esm.js +1 -1
- package/www/build/ontario-design-system-components.esm.js.map +1 -1
- package/www/build/{p-b61db0f6.js → p-84035ac3.js} +1 -1
- package/www/build/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
- package/www/build/p-9c3a1be9.entry.js.map +1 -0
- package/www/french.html +37 -0
- package/www/i18n/global.i18n.json +172 -162
- package/www/index.html +266 -38
- package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +0 -1
- package/dist/esm/ontario-accordion_43.entry.js.map +0 -1
- package/dist/ontario-design-system-components/p-cff41424.entry.js.map +0 -1
- package/www/build/p-cff41424.entry.js.map +0 -1
|
@@ -1,109 +1,135 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import {
|
|
2
|
+
import { HeaderColours, Layouts } from './ontario-card-types';
|
|
3
3
|
import { validateValueAgainstArray } from '../../utils/validation/validation-functions';
|
|
4
4
|
import { ConsoleMessageClass } from '../../utils/console-message/console-message';
|
|
5
|
+
import { printArray } from '../../utils/helper/utils';
|
|
5
6
|
export class OntarioCard {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.label = undefined;
|
|
8
9
|
this.image = undefined;
|
|
9
10
|
this.description = undefined;
|
|
10
11
|
this.cardLink = undefined;
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
12
|
+
this.layout = 'vertical';
|
|
13
|
+
this.headerColour = undefined;
|
|
13
14
|
this.horizontalImagePositionType = 'left';
|
|
14
15
|
this.horizontalImageSizeType = 'one-third';
|
|
15
16
|
this.ariaLabelText = undefined;
|
|
16
|
-
this.
|
|
17
|
-
this.headerTypeState = undefined;
|
|
17
|
+
this.layoutState = undefined;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Watch for changes to the `
|
|
20
|
+
* Watch for changes to the `layout` property for validation purposes.
|
|
21
21
|
*
|
|
22
|
-
* If the user input doesn't match one of the array values then `
|
|
23
|
-
* If a match is found in one of the array values then `
|
|
22
|
+
* If the user input doesn't match one of the array values then `layout` will be set to its default (`vertical`).
|
|
23
|
+
* If a match is found in one of the array values then `layoutState` will be set to the matching array key value.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
validateLayout() {
|
|
26
|
+
if (this.layout) {
|
|
27
|
+
const isValid = validateValueAgainstArray(this.layout, Layouts);
|
|
28
|
+
if (isValid) {
|
|
29
|
+
this.layoutState = this.layout;
|
|
30
|
+
} else {
|
|
31
|
+
this.warnDefaultLayout();
|
|
32
|
+
this.layoutState = 'vertical';
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
|
-
* Watch for changes to the `
|
|
37
|
+
* Watch for changes to the `headerColour` property for validation purposes.
|
|
35
38
|
*
|
|
36
|
-
* If the user input doesn't match one of the array values then `
|
|
37
|
-
* If a match is found in one of the array values then `
|
|
39
|
+
* If the user input doesn't match one of the array values then `headerColour` will be kept empty ('').
|
|
40
|
+
* If a match is found in one of the array values then `headerColour` will be set to the matching array key value.
|
|
38
41
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
validateHeaderColour() {
|
|
43
|
+
if (this.headerColour) {
|
|
44
|
+
const isValid = validateValueAgainstArray(this.headerColour, HeaderColours);
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
this.warnDefaultHeaderColour();
|
|
47
|
+
this.headerColour = '';
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
|
-
* Print the invalid `
|
|
49
|
-
* @returns default type (basic).
|
|
52
|
+
* Print the invalid `layout` prop warning message.
|
|
50
53
|
*/
|
|
51
|
-
|
|
54
|
+
warnDefaultLayout() {
|
|
52
55
|
const message = new ConsoleMessageClass();
|
|
53
56
|
message
|
|
54
57
|
.addDesignSystemTag()
|
|
55
|
-
.addMonospaceText('
|
|
58
|
+
.addMonospaceText(' layout ')
|
|
56
59
|
.addRegularText('on')
|
|
57
60
|
.addMonospaceText(' <ontario-card> ')
|
|
58
|
-
.addRegularText('was set to an invalid
|
|
59
|
-
.addMonospaceText(
|
|
60
|
-
.addRegularText('are supported. The default
|
|
61
|
-
.addMonospaceText('
|
|
61
|
+
.addRegularText('was set to an invalid layout; only ')
|
|
62
|
+
.addMonospaceText(printArray([...Layouts]))
|
|
63
|
+
.addRegularText(' are supported. The default layout')
|
|
64
|
+
.addMonospaceText(' vertical ')
|
|
62
65
|
.addRegularText('is assumed.')
|
|
63
66
|
.printMessage();
|
|
64
|
-
return 'basic';
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
67
|
-
* Print the invalid `
|
|
68
|
-
* @returns default type (default).
|
|
69
|
+
* Print the invalid `headerColour` prop warning message.
|
|
69
70
|
*/
|
|
70
|
-
|
|
71
|
+
warnDefaultHeaderColour() {
|
|
71
72
|
const message = new ConsoleMessageClass();
|
|
72
73
|
message
|
|
73
74
|
.addDesignSystemTag()
|
|
74
|
-
.addMonospaceText(' header-
|
|
75
|
+
.addMonospaceText(' header-colour ')
|
|
75
76
|
.addRegularText('on')
|
|
76
77
|
.addMonospaceText(' <ontario-card> ')
|
|
77
|
-
.addRegularText('was set to an invalid
|
|
78
|
-
.addMonospaceText(
|
|
79
|
-
.addRegularText('are supported.
|
|
80
|
-
.
|
|
81
|
-
.addRegularText('is assumed.')
|
|
78
|
+
.addRegularText('was set to an invalid colour; only ')
|
|
79
|
+
.addMonospaceText(printArray([...HeaderColours]))
|
|
80
|
+
.addRegularText(' are supported. ')
|
|
81
|
+
.addRegularText('No colour is assumed as the default.')
|
|
82
82
|
.printMessage();
|
|
83
|
-
return 'default';
|
|
84
83
|
}
|
|
85
84
|
/**
|
|
86
|
-
*
|
|
85
|
+
* Returns the top level classes of the card.
|
|
86
|
+
*
|
|
87
|
+
* @returns {string}
|
|
87
88
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
getCardClasses() {
|
|
90
|
+
const baseClass =
|
|
91
|
+
this.layoutState === 'horizontal'
|
|
92
|
+
? `ontario-card ontario-card__card-type--${this.layoutState} ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`
|
|
93
|
+
: `ontario-card ontario-card__card-type--basic ontario-card--position-${this.layoutState}`;
|
|
94
|
+
const descriptionClass = this.description ? '' : ' ontario-card__description-false';
|
|
95
|
+
const backgroundClass =
|
|
96
|
+
this.headerColour && !this.description ? `ontario-card__background--${this.headerColour}` : '';
|
|
97
|
+
return `${baseClass} ${descriptionClass} ${backgroundClass}`.trim();
|
|
95
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns the heading classes of the card.
|
|
101
|
+
*
|
|
102
|
+
* @returns {string}
|
|
103
|
+
*/
|
|
104
|
+
getCardHeadingClasses() {
|
|
105
|
+
const baseClass = 'ontario-card__heading';
|
|
106
|
+
const backgroundClass =
|
|
107
|
+
this.headerColour && validateValueAgainstArray(this.headerColour, HeaderColours)
|
|
108
|
+
? `ontario-card__heading--${this.headerColour}`
|
|
109
|
+
: '';
|
|
110
|
+
return `${baseClass} ${backgroundClass}`.trim();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns the url that the card links to.
|
|
114
|
+
*
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
96
117
|
getHref() {
|
|
97
118
|
return this.cardLink ? this.cardLink : '#';
|
|
98
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Component life cycle hook.
|
|
122
|
+
*
|
|
123
|
+
* https://stenciljs.com/docs/component-lifecycle#connectedcallback
|
|
124
|
+
*/
|
|
99
125
|
componentWillLoad() {
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
126
|
+
this.validateLayout();
|
|
127
|
+
this.validateHeaderColour();
|
|
102
128
|
}
|
|
103
129
|
render() {
|
|
104
130
|
return h(
|
|
105
131
|
'li',
|
|
106
|
-
{ key: '
|
|
132
|
+
{ key: 'e63b893390ea13ee21a2d47f7ef6c9b403c4d044', class: this.getCardClasses() },
|
|
107
133
|
this.image &&
|
|
108
134
|
h(
|
|
109
135
|
'div',
|
|
@@ -117,16 +143,16 @@ export class OntarioCard {
|
|
|
117
143
|
h(
|
|
118
144
|
'div',
|
|
119
145
|
{
|
|
120
|
-
key: '
|
|
146
|
+
key: 'b6f0a2218840a76baf9c803c3f155733a00ee029',
|
|
121
147
|
class: `ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`,
|
|
122
148
|
},
|
|
123
149
|
h(
|
|
124
150
|
'h2',
|
|
125
|
-
{ key: '
|
|
151
|
+
{ key: '063dc227db00f3faecec029dc82f5478910b65be', class: this.getCardHeadingClasses() },
|
|
126
152
|
h(
|
|
127
153
|
'a',
|
|
128
154
|
{
|
|
129
|
-
'key': '
|
|
155
|
+
'key': 'debb40036a708ad1a1852a85fa35db2d5f1e23cc',
|
|
130
156
|
'href': this.getHref(),
|
|
131
157
|
'aria-label': this.ariaLabelText,
|
|
132
158
|
},
|
|
@@ -228,53 +254,52 @@ export class OntarioCard {
|
|
|
228
254
|
attribute: 'card-link',
|
|
229
255
|
reflect: false,
|
|
230
256
|
},
|
|
231
|
-
|
|
257
|
+
layout: {
|
|
232
258
|
type: 'string',
|
|
233
259
|
mutable: false,
|
|
234
260
|
complexType: {
|
|
235
|
-
original: '
|
|
236
|
-
resolved: '"
|
|
261
|
+
original: 'Layout',
|
|
262
|
+
resolved: '"horizontal" | "vertical" | undefined',
|
|
237
263
|
references: {
|
|
238
|
-
|
|
264
|
+
Layout: {
|
|
239
265
|
location: 'import',
|
|
240
266
|
path: './ontario-card-types',
|
|
241
|
-
id: 'src/components/ontario-card/ontario-card-types.tsx::
|
|
267
|
+
id: 'src/components/ontario-card/ontario-card-types.tsx::Layout',
|
|
242
268
|
},
|
|
243
269
|
},
|
|
244
270
|
},
|
|
245
271
|
required: false,
|
|
246
|
-
optional:
|
|
272
|
+
optional: true,
|
|
247
273
|
docs: {
|
|
248
274
|
tags: [],
|
|
249
|
-
text: "The
|
|
275
|
+
text: "The layout oritnetation of the card.\n\nIf no type is passed, it will default to 'vertical'.",
|
|
250
276
|
},
|
|
251
|
-
attribute: '
|
|
277
|
+
attribute: 'layout',
|
|
252
278
|
reflect: false,
|
|
253
|
-
defaultValue: "'
|
|
279
|
+
defaultValue: "'vertical'",
|
|
254
280
|
},
|
|
255
|
-
|
|
281
|
+
headerColour: {
|
|
256
282
|
type: 'string',
|
|
257
283
|
mutable: false,
|
|
258
284
|
complexType: {
|
|
259
|
-
original: '
|
|
260
|
-
resolved: '
|
|
285
|
+
original: 'HeaderColour',
|
|
286
|
+
resolved: 'string | undefined',
|
|
261
287
|
references: {
|
|
262
|
-
|
|
288
|
+
HeaderColour: {
|
|
263
289
|
location: 'import',
|
|
264
290
|
path: './ontario-card-types',
|
|
265
|
-
id: 'src/components/ontario-card/ontario-card-types.tsx::
|
|
291
|
+
id: 'src/components/ontario-card/ontario-card-types.tsx::HeaderColour',
|
|
266
292
|
},
|
|
267
293
|
},
|
|
268
294
|
},
|
|
269
295
|
required: false,
|
|
270
|
-
optional:
|
|
296
|
+
optional: true,
|
|
271
297
|
docs: {
|
|
272
298
|
tags: [],
|
|
273
|
-
text: "
|
|
299
|
+
text: "Set the card's header colour.\n\nThis is optional.",
|
|
274
300
|
},
|
|
275
|
-
attribute: 'header-
|
|
301
|
+
attribute: 'header-colour',
|
|
276
302
|
reflect: false,
|
|
277
|
-
defaultValue: "'default'",
|
|
278
303
|
},
|
|
279
304
|
horizontalImagePositionType: {
|
|
280
305
|
type: 'string',
|
|
@@ -355,8 +380,7 @@ export class OntarioCard {
|
|
|
355
380
|
}
|
|
356
381
|
static get states() {
|
|
357
382
|
return {
|
|
358
|
-
|
|
359
|
-
headerTypeState: {},
|
|
383
|
+
layoutState: {},
|
|
360
384
|
};
|
|
361
385
|
}
|
|
362
386
|
static get elementRef() {
|
|
@@ -365,12 +389,12 @@ export class OntarioCard {
|
|
|
365
389
|
static get watchers() {
|
|
366
390
|
return [
|
|
367
391
|
{
|
|
368
|
-
propName: '
|
|
369
|
-
methodName: '
|
|
392
|
+
propName: 'layout',
|
|
393
|
+
methodName: 'validateLayout',
|
|
370
394
|
},
|
|
371
395
|
{
|
|
372
|
-
propName: '
|
|
373
|
-
methodName: '
|
|
396
|
+
propName: 'headerColour',
|
|
397
|
+
methodName: 'validateHeaderColour',
|
|
374
398
|
},
|
|
375
399
|
];
|
|
376
400
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ontario-card.js","sourceRoot":"","sources":["../../../src/components/ontario-card/ontario-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAEN,SAAS,EAET,WAAW,GAGX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAOlF,MAAM,OAAO,WAAW;;;;;;wBA2CM,OAAO;0BAOH,SAAS;2CAkB0B,MAAM;uCAkBd,WAAW;;;;;IAsBvE;;;;;OAKG;IAEH,gBAAgB;QACf,MAAM,OAAO,GAAG,yBAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACpE,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC;QACpC,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACjD,CAAC;IACF,CAAC;IAED;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import { Component, Prop, Element, h, State, Watch } from '@stencil/core';\nimport {\n\tCardType,\n\tCardTypes,\n\tHeaderType,\n\tHeaderTypes,\n\tHorizontalImagePositionType,\n\tHorizontalImageSizeType,\n} from './ontario-card-types';\nimport { validateValueAgainstArray } from '../../utils/validation/validation-functions';\nimport { ConsoleMessageClass } from '../../utils/console-message/console-message';\n\n@Component({\n\ttag: 'ontario-card',\n\tstyleUrl: 'ontario-card.scss',\n\tshadow: true,\n})\nexport class OntarioCard {\n\t@Element() host: HTMLElement;\n\n\t/**\n\t * Text to be displayed within the header.\n\t *\n\t * @example\n\t *\t<ontario-card\n\t *\t\theader-type=\"dark\"\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\tdescription=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t */\n\t@Prop() label: string;\n\n\t/**\n\t * Image to be displayed within the card image container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() image?: string;\n\n\t/**\n\t * Text to be displayed within the card description container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() description?: string;\n\n\t/**\n\t * Action link for when the card is clicked.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() cardLink?: string;\n\n\t/**\n\t * The type of card to render.\n\t *\n\t * If no type is passed, it will default to 'basic'.\n\t *\n\t */\n\t@Prop() cardType: CardType = 'basic';\n\n\t/**\n\t * The type of header to render.\n\t *\n\t * If no type is passed, it will default to 'default'.\n\t */\n\t@Prop() headerType: HeaderType = 'default';\n\n\t/**\n\t * The position of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImagePositionType?: HorizontalImagePositionType = 'left';\n\n\t/**\n\t * The size of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImageSizeType?: HorizontalImageSizeType = 'one-third';\n\n\t/**\n\t * Provides more context as to what the card interaction is doing. This should only be used for accessibility purposes, if the card interaction requires more * * description than what the text provides.\n\t *\n\t * This is optional.\n\t *\n\t */\n\t@Prop() ariaLabelText?: string;\n\n\t/**\n\t * Mutable variable, for internal use only.\n\t * Set the card's type depending on validation result.\n\t */\n\t@State() private cardTypeState: string;\n\n\t/**\n\t * Mutable variable, for internal use only.\n\t * Set the card's header type depending on validation result.\n\t */\n\t@State() private headerTypeState: string;\n\n\t/**\n\t * Watch for changes to the `cardType` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `cardType` will be set to its default (`basic`).\n\t * If a match is found in one of the array values then `cardType` will be set to the matching array key value.\n\t */\n\t@Watch('cardType')\n\tvalidateCardType() {\n\t\tconst isValid = validateValueAgainstArray(this.cardType, CardTypes);\n\t\tif (isValid) {\n\t\t\tthis.cardTypeState = this.cardType;\n\t\t} else {\n\t\t\tthis.cardTypeState = this.warnDefaultCardType();\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `headerType` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `headerType` will be set to its default (`default`).\n\t * If a match is found in one of the array values then `headerType` will be set to the matching array key value.\n\t */\n\t@Watch('headerType')\n\tvalidateHeaderType() {\n\t\tconst isValid = validateValueAgainstArray(this.headerType, HeaderTypes);\n\t\tif (isValid) {\n\t\t\tthis.headerTypeState = this.headerType;\n\t\t} else {\n\t\t\tthis.headerTypeState = this.warnDefaultHeaderType();\n\t\t}\n\t}\n\n\t/**\n\t * Print the invalid `cardType` prop warning message.\n\t * @returns default type (basic).\n\t */\n\tprivate warnDefaultCardType(): CardType {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' card-type ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid type; only')\n\t\t\t.addMonospaceText(' basic, image, label, horizontal ')\n\t\t\t.addRegularText('are supported. The default type')\n\t\t\t.addMonospaceText(' basic ')\n\t\t\t.addRegularText('is assumed.')\n\t\t\t.printMessage();\n\t\treturn 'basic';\n\t}\n\n\t/**\n\t * Print the invalid `headerType` prop warning message.\n\t * @returns default type (default).\n\t */\n\tprivate warnDefaultHeaderType(): HeaderType {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' header-type ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid type; only')\n\t\t\t.addMonospaceText(' default, light, dark')\n\t\t\t.addRegularText('are supported. The default type')\n\t\t\t.addMonospaceText(' default ')\n\t\t\t.addRegularText('is assumed.')\n\t\t\t.printMessage();\n\t\treturn 'default';\n\t}\n\n\t/**\n\t * @returns the classes of the ontario cards based off the `cardType` and `headerType`.\n\t */\n\tprivate getClass() {\n\t\tif (this.cardTypeState === 'horizontal') {\n\t\t\treturn `ontario-card ontario-card__card-type--horizontal ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`;\n\t\t} else {\n\t\t\t// Return other classes when cardTypeState is not 'horizontal'\n\t\t\treturn `ontario-card ontario-card__header-type--${this.headerTypeState} ontario-card__card-type--${this.cardTypeState}`;\n\t\t}\n\t}\n\n\tprivate getHref() {\n\t\treturn this.cardLink ? this.cardLink : '#';\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateCardType();\n\t\tthis.validateHeaderType();\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<li class={this.getClass()}>\n\t\t\t\t{this.image && (\n\t\t\t\t\t<div class=\"ontario-card__image-container\">\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t<img class=\"ontario-card__image\" src={this.image} />\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<div class={`ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`}>\n\t\t\t\t\t<h2 class=\"ontario-card__heading\">\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</h2>\n\t\t\t\t\t{this.description && (\n\t\t\t\t\t\t<div class=\"ontario-card__description\">\n\t\t\t\t\t\t\t<p>{this.description}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"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,EAAE,gBAAc,IAAI,CAAC,aAAa,IACrD,IAAI,CAAC,KAAK,CACR,CACA;gBACJ,IAAI,CAAC,WAAW,IAAI,CACpB,WAAK,KAAK,EAAC,2BAA2B;oBACrC,aAAI,IAAI,CAAC,WAAW,CAAK,CACpB,CACN,CACI,CACF,CACL,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import { Component, Prop, Element, h, State, Watch } from '@stencil/core';\nimport {\n\tHeaderColour,\n\tHeaderColours,\n\tHorizontalImagePositionType,\n\tHorizontalImageSizeType,\n\tLayout,\n\tLayouts,\n} from './ontario-card-types';\nimport { validateValueAgainstArray } from '../../utils/validation/validation-functions';\nimport { ConsoleMessageClass } from '../../utils/console-message/console-message';\nimport { printArray } from '../../utils/helper/utils';\n\n@Component({\n\ttag: 'ontario-card',\n\tstyleUrl: 'ontario-card.scss',\n\tshadow: true,\n})\nexport class OntarioCard {\n\t@Element() host: HTMLElement;\n\n\t/**\n\t * Text to be displayed within the header.\n\t *\n\t * @example\n\t *\t<ontario-card\n\t *\t\theader-type=\"dark\"\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\tdescription=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t */\n\t@Prop() label: string;\n\n\t/**\n\t * Image to be displayed within the card image container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() image?: string;\n\n\t/**\n\t * Text to be displayed within the card description container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() description?: string;\n\n\t/**\n\t * Action link for when the card is clicked.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() cardLink?: string;\n\n\t/**\n\t * The layout oritnetation of the card.\n\t *\n\t * If no type is passed, it will default to 'vertical'.\n\t *\n\t */\n\t@Prop() layout?: Layout = 'vertical';\n\n\t/**\n\t * Set the card's header colour.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() headerColour?: HeaderColour;\n\n\t/**\n\t * The position of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImagePositionType?: HorizontalImagePositionType = 'left';\n\n\t/**\n\t * The size of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImageSizeType?: HorizontalImageSizeType = 'one-third';\n\n\t/**\n\t * Provides more context as to what the card interaction is doing. This should only be used for accessibility purposes, if the card interaction requires more * * description than what the text provides.\n\t *\n\t * This is optional.\n\t *\n\t */\n\t@Prop() ariaLabelText?: string;\n\n\t/**\n\t * Mutable variable, for internal use only.\n\t * Set the card's layout depending on validation result.\n\t */\n\t@State() private layoutState: string;\n\n\t/**\n\t * Watch for changes to the `layout` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `layout` will be set to its default (`vertical`).\n\t * If a match is found in one of the array values then `layoutState` will be set to the matching array key value.\n\t */\n\t@Watch('layout')\n\tvalidateLayout() {\n\t\tif (this.layout) {\n\t\t\tconst isValid = validateValueAgainstArray(this.layout, Layouts);\n\t\t\tif (isValid) {\n\t\t\t\tthis.layoutState = this.layout;\n\t\t\t} else {\n\t\t\t\tthis.warnDefaultLayout();\n\t\t\t\tthis.layoutState = 'vertical';\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `headerColour` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `headerColour` will be kept empty ('').\n\t * If a match is found in one of the array values then `headerColour` will be set to the matching array key value.\n\t */\n\t@Watch('headerColour')\n\tvalidateHeaderColour() {\n\t\tif (this.headerColour) {\n\t\t\tconst isValid = validateValueAgainstArray(this.headerColour, HeaderColours);\n\n\t\t\tif (!isValid) {\n\t\t\t\tthis.warnDefaultHeaderColour();\n\t\t\t\tthis.headerColour = '';\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Print the invalid `layout` prop warning message.\n\t */\n\tprivate warnDefaultLayout() {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' layout ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid layout; only ')\n\t\t\t.addMonospaceText(printArray([...Layouts]))\n\t\t\t.addRegularText(' are supported. The default layout')\n\t\t\t.addMonospaceText(' vertical ')\n\t\t\t.addRegularText('is assumed.')\n\t\t\t.printMessage();\n\t}\n\n\t/**\n\t * Print the invalid `headerColour` prop warning message.\n\t */\n\tprivate warnDefaultHeaderColour() {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' header-colour ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid colour; only ')\n\t\t\t.addMonospaceText(printArray([...HeaderColours]))\n\t\t\t.addRegularText(' are supported. ')\n\t\t\t.addRegularText('No colour is assumed as the default.')\n\t\t\t.printMessage();\n\t}\n\n\t/**\n\t * Returns the top level classes of the card.\n\t *\n\t * @returns {string}\n\t */\n\tprivate getCardClasses(): string {\n\t\tconst baseClass =\n\t\t\tthis.layoutState === 'horizontal'\n\t\t\t\t? `ontario-card ontario-card__card-type--${this.layoutState} ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`\n\t\t\t\t: `ontario-card ontario-card__card-type--basic ontario-card--position-${this.layoutState}`;\n\n\t\tconst descriptionClass = this.description ? '' : ' ontario-card__description-false';\n\n\t\tconst backgroundClass =\n\t\t\tthis.headerColour && !this.description ? `ontario-card__background--${this.headerColour}` : '';\n\n\t\treturn `${baseClass} ${descriptionClass} ${backgroundClass}`.trim();\n\t}\n\n\t/**\n\t * Returns the heading classes of the card.\n\t *\n\t * @returns {string}\n\t */\n\tprivate getCardHeadingClasses(): string {\n\t\tconst baseClass = 'ontario-card__heading';\n\n\t\tconst backgroundClass =\n\t\t\tthis.headerColour && validateValueAgainstArray(this.headerColour, HeaderColours)\n\t\t\t\t? `ontario-card__heading--${this.headerColour}`\n\t\t\t\t: '';\n\n\t\treturn `${baseClass} ${backgroundClass}`.trim();\n\t}\n\n\t/**\n\t * Returns the url that the card links to.\n\t *\n\t * @returns {string}\n\t */\n\tprivate getHref(): string {\n\t\treturn this.cardLink ? this.cardLink : '#';\n\t}\n\n\t/**\n\t * Component life cycle hook.\n\t *\n\t * https://stenciljs.com/docs/component-lifecycle#connectedcallback\n\t */\n\tcomponentWillLoad() {\n\t\tthis.validateLayout();\n\t\tthis.validateHeaderColour();\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<li class={this.getCardClasses()}>\n\t\t\t\t{this.image && (\n\t\t\t\t\t<div class=\"ontario-card__image-container\">\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t<img class=\"ontario-card__image\" src={this.image} />\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<div class={`ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`}>\n\t\t\t\t\t<h2 class={this.getCardHeadingClasses()}>\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</h2>\n\t\t\t\t\t{this.description && (\n\t\t\t\t\t\t<div class=\"ontario-card__description\">\n\t\t\t\t\t\t\t<p>{this.description}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -6,19 +6,29 @@ describe('ontario-card', () => {
|
|
|
6
6
|
components: [OntarioCard],
|
|
7
7
|
html: `<ontario-card></ontario-card>`,
|
|
8
8
|
});
|
|
9
|
-
expect(page.root).
|
|
10
|
-
<ontario-card>
|
|
11
|
-
<mock:shadow-root>
|
|
12
|
-
<li class="ontario-card ontario-card__card-type--basic ontario-card__header-type--default">
|
|
13
|
-
<div class="ontario-card__text-container">
|
|
14
|
-
<h2 class="ontario-card__heading">
|
|
15
|
-
<a href="#"></a>
|
|
16
|
-
</h2>
|
|
17
|
-
</div>
|
|
18
|
-
</li>
|
|
19
|
-
</mock:shadow-root>
|
|
20
|
-
</ontario-card>
|
|
21
|
-
`);
|
|
9
|
+
expect(page.root).toMatchSnapshot();
|
|
22
10
|
});
|
|
11
|
+
it('should render a label', async () => {
|
|
12
|
+
const page = await newSpecPage({
|
|
13
|
+
components: [OntarioCard],
|
|
14
|
+
html: `<ontario-card label="Card Title 1"></ontario-card>`,
|
|
15
|
+
});
|
|
16
|
+
expect(page.root).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
it('should render a header colour on the label', async () => {
|
|
19
|
+
const page = await newSpecPage({
|
|
20
|
+
components: [OntarioCard],
|
|
21
|
+
html: `<ontario-card label="Card Title 1" header-colour="sky"></ontario-card>`,
|
|
22
|
+
});
|
|
23
|
+
expect(page.root).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
it('should render a description', async () => {
|
|
26
|
+
const page = await newSpecPage({
|
|
27
|
+
components: [OntarioCard],
|
|
28
|
+
html: `<ontario-card description="Lorem ipsum"></ontario-card>`,
|
|
29
|
+
});
|
|
30
|
+
expect(page.root).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
// Don't think we can test images unless we point to a local path
|
|
23
33
|
});
|
|
24
34
|
//# sourceMappingURL=ontario-cards.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ontario-cards.spec.js","sourceRoot":"","sources":["../../../../src/components/ontario-card/test/ontario-cards.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,+BAA+B;SACrC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"ontario-cards.spec.js","sourceRoot":"","sources":["../../../../src/components/ontario-card/test/ontario-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AEH,iEAAiE;AAClE,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { OntarioCard } from '../ontario-card';\n\ndescribe('ontario-card', () => {\n\tit('renders', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\tit('should render a label', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card label=\"Card Title 1\"></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\tit('should render a header colour on the label', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card label=\"Card Title 1\" header-colour=\"sky\"></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\tit('should render a description', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card description=\"Lorem ipsum\"></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\t// Don't think we can test images unless we point to a local path\n});\n"]}
|
|
@@ -111,10 +111,19 @@ export class OntarioHeader {
|
|
|
111
111
|
if (this.menuToggle) this.menuToggle = !this.menuToggle;
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
* This listens for the `setAppLanguage` event sent from the
|
|
114
|
+
* This listens for the `setAppLanguage` event sent from the language toggle when it is is connected to the DOM.
|
|
115
|
+
* It is used for the initial language when the input component loads.
|
|
115
116
|
*/
|
|
116
117
|
handleSetAppLanguage(event) {
|
|
117
118
|
this.language = validateLanguage(event);
|
|
119
|
+
this.parseMenuItems();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* This listens for the `headerLanguageToggled` event sent from the language toggle when it is is connected to the DOM.
|
|
123
|
+
* It is used for changing the component language after the language toggle has been activated.
|
|
124
|
+
*/
|
|
125
|
+
handleLanguageToggle(event) {
|
|
126
|
+
this.handleSetAppLanguage(event.detail.newLanguage);
|
|
118
127
|
}
|
|
119
128
|
/**
|
|
120
129
|
* Call to Ontario Menu API to fetch linksets to populate header component
|
|
@@ -407,7 +416,6 @@ export class OntarioHeader {
|
|
|
407
416
|
: _b.englishLink,
|
|
408
417
|
size: 'default',
|
|
409
418
|
customLanguageToggle: this.customLanguageToggle,
|
|
410
|
-
language: this.language,
|
|
411
419
|
}),
|
|
412
420
|
h(
|
|
413
421
|
'button',
|
|
@@ -539,7 +547,6 @@ export class OntarioHeader {
|
|
|
539
547
|
? void 0
|
|
540
548
|
: _e.englishLink,
|
|
541
549
|
customLanguageToggle: this.customLanguageToggle,
|
|
542
|
-
language: this.language,
|
|
543
550
|
}),
|
|
544
551
|
),
|
|
545
552
|
),
|
|
@@ -1044,6 +1051,13 @@ export class OntarioHeader {
|
|
|
1044
1051
|
capture: false,
|
|
1045
1052
|
passive: false,
|
|
1046
1053
|
},
|
|
1054
|
+
{
|
|
1055
|
+
name: 'headerLanguageToggled',
|
|
1056
|
+
method: 'handleLanguageToggle',
|
|
1057
|
+
target: 'window',
|
|
1058
|
+
capture: false,
|
|
1059
|
+
passive: false,
|
|
1060
|
+
},
|
|
1047
1061
|
];
|
|
1048
1062
|
}
|
|
1049
1063
|
}
|