@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.
Files changed (148) hide show
  1. package/dist/cjs/index-88d5cf20.js +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/{ontario-accordion_43.cjs.entry.js → ontario-accordion_44.cjs.entry.js} +738 -296
  4. package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -0
  5. package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
  6. package/dist/collection/collection-manifest.json +1 -0
  7. package/dist/collection/components/ontario-card/ontario-card-types.js +29 -2
  8. package/dist/collection/components/ontario-card/ontario-card-types.js.map +1 -1
  9. package/dist/collection/components/ontario-card/ontario-card.css +257 -31
  10. package/dist/collection/components/ontario-card/ontario-card.js +104 -80
  11. package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
  12. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +23 -13
  13. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js.map +1 -1
  14. package/dist/collection/components/ontario-header/ontario-header.js +17 -3
  15. package/dist/collection/components/ontario-header/ontario-header.js.map +1 -1
  16. package/dist/collection/components/ontario-header/service-ontario-header.css +0 -3
  17. package/dist/collection/components/ontario-header/test/ontario-header.spec.js +3 -3
  18. package/dist/collection/components/ontario-header/test/ontario-header.spec.js.map +1 -1
  19. package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js +193 -47
  20. package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js.map +1 -1
  21. package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js +16 -3
  22. package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js.map +1 -1
  23. package/dist/collection/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  24. package/dist/collection/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  25. package/dist/collection/components/ontario-search-box/ontario-search-box.css +823 -0
  26. package/dist/collection/components/ontario-search-box/ontario-search-box.js +584 -0
  27. package/dist/collection/components/ontario-search-box/ontario-search-box.js.map +1 -0
  28. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js +20 -0
  29. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js.map +1 -0
  30. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js +19 -0
  31. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js.map +1 -0
  32. package/dist/collection/components/ontario-step-indicator/ontario-step-indicator.js +5 -5
  33. package/dist/collection/components/ontario-table/ontario-table.js +5 -5
  34. package/dist/collection/components/ontario-textarea/ontario-textarea.js +3 -3
  35. package/dist/collection/i18n/global.i18n.json +172 -162
  36. package/dist/collection/utils/common/input/input.js +3 -0
  37. package/dist/collection/utils/common/input/input.js.map +1 -1
  38. package/dist/collection/utils/common/input-caption/input-caption.js +5 -3
  39. package/dist/collection/utils/common/input-caption/input-caption.js.map +1 -1
  40. package/dist/collection/utils/common/language-types.js +1 -1
  41. package/dist/collection/utils/common/language-types.js.map +1 -1
  42. package/dist/collection/utils/helper/utils-types.js +2 -0
  43. package/dist/collection/utils/helper/utils-types.js.map +1 -0
  44. package/dist/collection/utils/helper/utils.js +26 -0
  45. package/dist/collection/utils/helper/utils.js.map +1 -1
  46. package/dist/components/error-message.js +1 -324
  47. package/dist/components/error-message.js.map +1 -1
  48. package/dist/components/event-handler.js +330 -0
  49. package/dist/components/event-handler.js.map +1 -0
  50. package/dist/components/global.i18n.js +184 -173
  51. package/dist/components/global.i18n.js.map +1 -1
  52. package/dist/components/input.js +3 -0
  53. package/dist/components/input.js.map +1 -1
  54. package/dist/components/ontario-card.js +118 -66
  55. package/dist/components/ontario-card.js.map +1 -1
  56. package/dist/components/ontario-checkboxes.js +2 -1
  57. package/dist/components/ontario-checkboxes.js.map +1 -1
  58. package/dist/components/ontario-date-input.js +2 -1
  59. package/dist/components/ontario-date-input.js.map +1 -1
  60. package/dist/components/ontario-dropdown-list.js +2 -1
  61. package/dist/components/ontario-dropdown-list.js.map +1 -1
  62. package/dist/components/ontario-header.js +13 -7
  63. package/dist/components/ontario-header.js.map +1 -1
  64. package/dist/components/ontario-icon-search2.js +6 -0
  65. package/dist/components/ontario-icon-search2.js.map +1 -0
  66. package/dist/components/ontario-input.js +2 -1
  67. package/dist/components/ontario-input.js.map +1 -1
  68. package/dist/components/ontario-language-toggle2.js +180 -37
  69. package/dist/components/ontario-language-toggle2.js.map +1 -1
  70. package/dist/components/ontario-radio-buttons.js +2 -1
  71. package/dist/components/ontario-radio-buttons.js.map +1 -1
  72. package/dist/components/ontario-search-box.d.ts +11 -0
  73. package/dist/components/ontario-search-box.js +269 -0
  74. package/dist/components/ontario-search-box.js.map +1 -0
  75. package/dist/components/ontario-step-indicator.js +5 -5
  76. package/dist/components/ontario-table.js +5 -5
  77. package/dist/components/ontario-textarea.js +5 -4
  78. package/dist/components/ontario-textarea.js.map +1 -1
  79. package/dist/components/utils.js +28 -0
  80. package/dist/components/utils.js.map +1 -1
  81. package/dist/esm/index-603026f7.js +2 -2
  82. package/dist/esm/loader.js +1 -1
  83. package/dist/esm/{ontario-accordion_43.entry.js → ontario-accordion_44.entry.js} +738 -296
  84. package/dist/esm/ontario-accordion_44.entry.js.map +1 -0
  85. package/dist/esm/ontario-design-system-components.js +1 -1
  86. package/dist/ontario-design-system-components/i18n/global.i18n.json +172 -162
  87. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
  88. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js.map +1 -1
  89. package/dist/ontario-design-system-components/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
  90. package/dist/ontario-design-system-components/p-9c3a1be9.entry.js.map +1 -0
  91. package/dist/types/components/ontario-card/ontario-card-types.d.ts +4 -4
  92. package/dist/types/components/ontario-card/ontario-card.d.ts +40 -29
  93. package/dist/types/components/ontario-header/ontario-header.d.ts +13 -2
  94. package/dist/types/components/ontario-language-toggle/ontario-language-toggle.d.ts +75 -8
  95. package/dist/types/components/ontario-search-box/ontario-search-box.d.ts +180 -0
  96. package/dist/types/components.d.ts +211 -22
  97. package/dist/types/utils/common/input/input.d.ts +2 -1
  98. package/dist/types/utils/common/input-caption/input-caption.d.ts +7 -1
  99. package/dist/types/utils/common/language-types.d.ts +2 -1
  100. package/dist/types/utils/helper/utils-types.d.ts +2 -0
  101. package/dist/types/utils/helper/utils.d.ts +21 -0
  102. package/package.json +3 -3
  103. package/src/components/ontario-card/ontario-card-types.tsx +33 -4
  104. package/src/components/ontario-card/ontario-card.scss +59 -38
  105. package/src/components/ontario-card/ontario-card.tsx +98 -70
  106. package/src/components/ontario-card/readme.md +57 -27
  107. package/src/components/ontario-card/test/__snapshots__/ontario-cards.spec.tsx.snap +66 -0
  108. package/src/components/ontario-card/test/ontario-cards.spec.tsx +27 -13
  109. package/src/components/ontario-card-collection/readme.md +13 -13
  110. package/src/components/ontario-checkbox/ontario-checkboxes.scss +0 -1
  111. package/src/components/ontario-header/ontario-header.tsx +13 -4
  112. package/src/components/ontario-header/service-ontario-header.scss +0 -4
  113. package/src/components/ontario-header/test/ontario-header.spec.tsx +3 -3
  114. package/src/components/ontario-hint-text/readme.md +2 -0
  115. package/src/components/ontario-language-toggle/ontario-language-toggle.tsx +192 -45
  116. package/src/components/ontario-language-toggle/readme.md +10 -10
  117. package/src/components/ontario-language-toggle/test/__snapshots__/ontario-language-toggle.spec.tsx.snap +1 -1
  118. package/src/components/ontario-language-toggle/test/ontario-language-toggle.spec.tsx +17 -3
  119. package/src/components/ontario-radio-buttons/ontario-radio-buttons.scss +0 -1
  120. package/src/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  121. package/src/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  122. package/src/components/ontario-search-box/ontario-search-box.scss +141 -0
  123. package/src/components/ontario-search-box/ontario-search-box.tsx +341 -0
  124. package/src/components/ontario-search-box/readme.md +132 -0
  125. package/src/components/ontario-search-box/test/__snapshots__/ontario-search-box.spec.tsx.snap +35 -0
  126. package/src/components/ontario-search-box/test/ontario-search-box.e2e.ts +21 -0
  127. package/src/components/ontario-search-box/test/ontario-search-box.spec.tsx +22 -0
  128. package/src/components.d.ts +211 -22
  129. package/src/french.html +37 -0
  130. package/src/index.html +292 -38
  131. package/src/translations/global.i18n.json +172 -162
  132. package/src/utils/common/input/input.tsx +4 -1
  133. package/src/utils/common/input-caption/input-caption.tsx +9 -3
  134. package/src/utils/common/language-types.ts +2 -1
  135. package/src/utils/helper/utils-types.ts +2 -0
  136. package/src/utils/helper/utils.ts +30 -0
  137. package/www/build/ontario-design-system-components.esm.js +1 -1
  138. package/www/build/ontario-design-system-components.esm.js.map +1 -1
  139. package/www/build/{p-b61db0f6.js → p-84035ac3.js} +1 -1
  140. package/www/build/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
  141. package/www/build/p-9c3a1be9.entry.js.map +1 -0
  142. package/www/french.html +37 -0
  143. package/www/i18n/global.i18n.json +172 -162
  144. package/www/index.html +266 -38
  145. package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +0 -1
  146. package/dist/esm/ontario-accordion_43.entry.js.map +0 -1
  147. package/dist/ontario-design-system-components/p-cff41424.entry.js.map +0 -1
  148. package/www/build/p-cff41424.entry.js.map +0 -1
@@ -1,14 +1,15 @@
1
1
  import { Component, Prop, Element, h, State, Watch } from '@stencil/core';
2
2
  import {
3
- CardType,
4
- CardTypes,
5
- HeaderType,
6
- HeaderTypes,
3
+ HeaderColour,
4
+ HeaderColours,
7
5
  HorizontalImagePositionType,
8
6
  HorizontalImageSizeType,
7
+ Layout,
8
+ Layouts,
9
9
  } from './ontario-card-types';
10
10
  import { validateValueAgainstArray } from '../../utils/validation/validation-functions';
11
11
  import { ConsoleMessageClass } from '../../utils/console-message/console-message';
12
+ import { printArray } from '../../utils/helper/utils';
12
13
 
13
14
  @Component({
14
15
  tag: 'ontario-card',
@@ -53,19 +54,19 @@ export class OntarioCard {
53
54
  @Prop() cardLink?: string;
54
55
 
55
56
  /**
56
- * The type of card to render.
57
+ * The layout oritnetation of the card.
57
58
  *
58
- * If no type is passed, it will default to 'basic'.
59
+ * If no type is passed, it will default to 'vertical'.
59
60
  *
60
61
  */
61
- @Prop() cardType: CardType = 'basic';
62
+ @Prop() layout?: Layout = 'vertical';
62
63
 
63
64
  /**
64
- * The type of header to render.
65
+ * Set the card's header colour.
65
66
  *
66
- * If no type is passed, it will default to 'default'.
67
+ * This is optional.
67
68
  */
68
- @Prop() headerType: HeaderType = 'default';
69
+ @Prop() headerColour?: HeaderColour;
69
70
 
70
71
  /**
71
72
  * The position of the image when the card-type is set to 'horizontal'.
@@ -113,112 +114,139 @@ export class OntarioCard {
113
114
 
114
115
  /**
115
116
  * Mutable variable, for internal use only.
116
- * Set the card's type depending on validation result.
117
+ * Set the card's layout depending on validation result.
117
118
  */
118
- @State() private cardTypeState: string;
119
+ @State() private layoutState: string;
119
120
 
120
121
  /**
121
- * Mutable variable, for internal use only.
122
- * Set the card's header type depending on validation result.
123
- */
124
- @State() private headerTypeState: string;
125
-
126
- /**
127
- * Watch for changes to the `cardType` property for validation purposes.
122
+ * Watch for changes to the `layout` property for validation purposes.
128
123
  *
129
- * If the user input doesn't match one of the array values then `cardType` will be set to its default (`basic`).
130
- * If a match is found in one of the array values then `cardType` will be set to the matching array key value.
124
+ * If the user input doesn't match one of the array values then `layout` will be set to its default (`vertical`).
125
+ * If a match is found in one of the array values then `layoutState` will be set to the matching array key value.
131
126
  */
132
- @Watch('cardType')
133
- validateCardType() {
134
- const isValid = validateValueAgainstArray(this.cardType, CardTypes);
135
- if (isValid) {
136
- this.cardTypeState = this.cardType;
137
- } else {
138
- this.cardTypeState = this.warnDefaultCardType();
127
+ @Watch('layout')
128
+ validateLayout() {
129
+ if (this.layout) {
130
+ const isValid = validateValueAgainstArray(this.layout, Layouts);
131
+ if (isValid) {
132
+ this.layoutState = this.layout;
133
+ } else {
134
+ this.warnDefaultLayout();
135
+ this.layoutState = 'vertical';
136
+ }
139
137
  }
140
138
  }
141
139
 
142
140
  /**
143
- * Watch for changes to the `headerType` property for validation purposes.
141
+ * Watch for changes to the `headerColour` property for validation purposes.
144
142
  *
145
- * If the user input doesn't match one of the array values then `headerType` will be set to its default (`default`).
146
- * If a match is found in one of the array values then `headerType` will be set to the matching array key value.
143
+ * If the user input doesn't match one of the array values then `headerColour` will be kept empty ('').
144
+ * If a match is found in one of the array values then `headerColour` will be set to the matching array key value.
147
145
  */
148
- @Watch('headerType')
149
- validateHeaderType() {
150
- const isValid = validateValueAgainstArray(this.headerType, HeaderTypes);
151
- if (isValid) {
152
- this.headerTypeState = this.headerType;
153
- } else {
154
- this.headerTypeState = this.warnDefaultHeaderType();
146
+ @Watch('headerColour')
147
+ validateHeaderColour() {
148
+ if (this.headerColour) {
149
+ const isValid = validateValueAgainstArray(this.headerColour, HeaderColours);
150
+
151
+ if (!isValid) {
152
+ this.warnDefaultHeaderColour();
153
+ this.headerColour = '';
154
+ }
155
155
  }
156
156
  }
157
157
 
158
158
  /**
159
- * Print the invalid `cardType` prop warning message.
160
- * @returns default type (basic).
159
+ * Print the invalid `layout` prop warning message.
161
160
  */
162
- private warnDefaultCardType(): CardType {
161
+ private warnDefaultLayout() {
163
162
  const message = new ConsoleMessageClass();
164
163
  message
165
164
  .addDesignSystemTag()
166
- .addMonospaceText(' card-type ')
165
+ .addMonospaceText(' layout ')
167
166
  .addRegularText('on')
168
167
  .addMonospaceText(' <ontario-card> ')
169
- .addRegularText('was set to an invalid type; only')
170
- .addMonospaceText(' basic, image, label, horizontal ')
171
- .addRegularText('are supported. The default type')
172
- .addMonospaceText(' basic ')
168
+ .addRegularText('was set to an invalid layout; only ')
169
+ .addMonospaceText(printArray([...Layouts]))
170
+ .addRegularText(' are supported. The default layout')
171
+ .addMonospaceText(' vertical ')
173
172
  .addRegularText('is assumed.')
174
173
  .printMessage();
175
- return 'basic';
176
174
  }
177
175
 
178
176
  /**
179
- * Print the invalid `headerType` prop warning message.
180
- * @returns default type (default).
177
+ * Print the invalid `headerColour` prop warning message.
181
178
  */
182
- private warnDefaultHeaderType(): HeaderType {
179
+ private warnDefaultHeaderColour() {
183
180
  const message = new ConsoleMessageClass();
184
181
  message
185
182
  .addDesignSystemTag()
186
- .addMonospaceText(' header-type ')
183
+ .addMonospaceText(' header-colour ')
187
184
  .addRegularText('on')
188
185
  .addMonospaceText(' <ontario-card> ')
189
- .addRegularText('was set to an invalid type; only')
190
- .addMonospaceText(' default, light, dark')
191
- .addRegularText('are supported. The default type')
192
- .addMonospaceText(' default ')
193
- .addRegularText('is assumed.')
186
+ .addRegularText('was set to an invalid colour; only ')
187
+ .addMonospaceText(printArray([...HeaderColours]))
188
+ .addRegularText(' are supported. ')
189
+ .addRegularText('No colour is assumed as the default.')
194
190
  .printMessage();
195
- return 'default';
196
191
  }
197
192
 
198
193
  /**
199
- * @returns the classes of the ontario cards based off the `cardType` and `headerType`.
194
+ * Returns the top level classes of the card.
195
+ *
196
+ * @returns {string}
200
197
  */
201
- private getClass() {
202
- if (this.cardTypeState === 'horizontal') {
203
- return `ontario-card ontario-card__card-type--horizontal ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`;
204
- } else {
205
- // Return other classes when cardTypeState is not 'horizontal'
206
- return `ontario-card ontario-card__header-type--${this.headerTypeState} ontario-card__card-type--${this.cardTypeState}`;
207
- }
198
+ private getCardClasses(): string {
199
+ const baseClass =
200
+ this.layoutState === 'horizontal'
201
+ ? `ontario-card ontario-card__card-type--${this.layoutState} ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`
202
+ : `ontario-card ontario-card__card-type--basic ontario-card--position-${this.layoutState}`;
203
+
204
+ const descriptionClass = this.description ? '' : ' ontario-card__description-false';
205
+
206
+ const backgroundClass =
207
+ this.headerColour && !this.description ? `ontario-card__background--${this.headerColour}` : '';
208
+
209
+ return `${baseClass} ${descriptionClass} ${backgroundClass}`.trim();
208
210
  }
209
211
 
210
- private getHref() {
212
+ /**
213
+ * Returns the heading classes of the card.
214
+ *
215
+ * @returns {string}
216
+ */
217
+ private getCardHeadingClasses(): string {
218
+ const baseClass = 'ontario-card__heading';
219
+
220
+ const backgroundClass =
221
+ this.headerColour && validateValueAgainstArray(this.headerColour, HeaderColours)
222
+ ? `ontario-card__heading--${this.headerColour}`
223
+ : '';
224
+
225
+ return `${baseClass} ${backgroundClass}`.trim();
226
+ }
227
+
228
+ /**
229
+ * Returns the url that the card links to.
230
+ *
231
+ * @returns {string}
232
+ */
233
+ private getHref(): string {
211
234
  return this.cardLink ? this.cardLink : '#';
212
235
  }
213
236
 
237
+ /**
238
+ * Component life cycle hook.
239
+ *
240
+ * https://stenciljs.com/docs/component-lifecycle#connectedcallback
241
+ */
214
242
  componentWillLoad() {
215
- this.validateCardType();
216
- this.validateHeaderType();
243
+ this.validateLayout();
244
+ this.validateHeaderColour();
217
245
  }
218
246
 
219
247
  render() {
220
248
  return (
221
- <li class={this.getClass()}>
249
+ <li class={this.getCardClasses()}>
222
250
  {this.image && (
223
251
  <div class="ontario-card__image-container">
224
252
  <a href={this.getHref()} aria-label={this.ariaLabelText}>
@@ -227,7 +255,7 @@ export class OntarioCard {
227
255
  </div>
228
256
  )}
229
257
  <div class={`ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`}>
230
- <h2 class="ontario-card__heading">
258
+ <h2 class={this.getCardHeadingClasses()}>
231
259
  <a href={this.getHref()} aria-label={this.ariaLabelText}>
232
260
  {this.label}
233
261
  </a>
@@ -14,7 +14,7 @@ Once the component package has been installed (see Ontario Design System Compone
14
14
 
15
15
  ## Examples
16
16
 
17
- Example of a bare-bones `ontario-card` component where the `label` and `description` for the card is provided. The default card type will be `basic`, and default header type will be `default`.
17
+ Example of a bare-bones `ontario-card` component where the `label` and `description` for the card is provided.
18
18
 
19
19
  ```html
20
20
  <ontario-card label="Card Title" description="Lorem Ipsum Lorem Ipsum"></ontario-card>
@@ -22,14 +22,13 @@ Example of a bare-bones `ontario-card` component where the `label` and `descript
22
22
 
23
23
  <OntarioCard label="Card Title" description="Lorem Ipsum Lorem Ipsum"></OntarioCard>
24
24
 
25
- Example of an `ontario-card` component with an image, which includes the `cardType`, `headerType`, `image`, `label` and `description` properties.
25
+ Example of an `ontario-card` component with an image, which includes the `headerColour`, `image`, `label` and `description` properties.
26
26
 
27
27
  ```html
28
28
  <ontario-card
29
- card-type="image"
30
- header-type="light"
31
29
  label="Card Title"
32
- image="https://picsum.photos/200/300"
30
+ header-colour="sky"
31
+ image="https://picsum.photos/300/225"
33
32
  description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
34
33
  >
35
34
  </ontario-card>
@@ -37,22 +36,20 @@ Example of an `ontario-card` component with an image, which includes the `cardTy
37
36
 
38
37
  <div>
39
38
  <OntarioCard
40
- card-type="image"
41
- header-type="light"
42
39
  label="Card Title"
43
- image="https://picsum.photos/200/300"
40
+ headerColour="sky"
41
+ image="https://picsum.photos/300/225"
44
42
  description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
45
43
  ></OntarioCard>
46
44
  </div>
47
45
 
48
- This is another example of an `ontario-card` component, where the user is passing in the horizontal card-type. This will
49
- require more properties, including the `horizontalImagePositionType` and the `horizontalImageSizeType`.
46
+ This is another example of an `ontario-card` component with a horizontal layout containing an image. This will require more properties, including the `horizontalImagePositionType` and the `horizontalImageSizeType`.
50
47
 
51
48
  ```html
52
49
  <ontario-card
53
- card-type="horizontal"
50
+ layout="horizontal"
54
51
  label="Card Title"
55
- image="https://picsum.photos/200/300"
52
+ image="https://picsum.photos/300/225"
56
53
  horizontal-image-position-type="left"
57
54
  horizontal-image-size-type="one-fourth"
58
55
  description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
@@ -62,30 +59,63 @@ require more properties, including the `horizontalImagePositionType` and the `ho
62
59
 
63
60
  <div>
64
61
  <OntarioCard
65
- card-type="horizontal"
62
+ layout="horizontal"
66
63
  label="Card Title"
67
- image="https://picsum.photos/200/300"
68
- horizontal-image-position-type="left"
69
- horizontal-image-size-type="one-fourth"
64
+ image="https://picsum.photos/300/225"
65
+ horizontalImagePositionType="left"
66
+ horizontalImageSizeType="one-fourth"
70
67
  description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
71
68
  ></OntarioCard>
72
69
  </div>
73
70
 
71
+ ## Custom property types
72
+
73
+ ### headerColour
74
+
75
+ The `header-colour` property supports a wide range of values, including:
76
+
77
+ - `dark-accent`
78
+ - `light-accent`
79
+ - `light-gold`
80
+ - `light-yellow`
81
+ - `light-taupe`
82
+ - `light-green`
83
+ - `light-lime`
84
+ - `light-teal`
85
+ - `light-sky`
86
+ - `light-blue`
87
+ - `light-purple`
88
+ - `light-orange`
89
+ - `light-red`
90
+ - `light-magenta`
91
+ - `gold`
92
+ - `yellow`
93
+ - `taupe`
94
+ - `green`
95
+ - `lime`
96
+ - `teal`
97
+ - `sky`
98
+ - `blue`
99
+ - `purple`
100
+ - `orange`
101
+ - `red`
102
+ - `magenta`
103
+
74
104
  <!-- Auto Generated Below -->
75
105
 
76
106
  ## Properties
77
107
 
78
- | Property | Attribute | Description | Type | Default |
79
- | ----------------------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | ------------- |
80
- | `ariaLabelText` | `aria-label-text` | 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. This is optional. | `string \| undefined` | `undefined` |
81
- | `cardLink` | `card-link` | Action link for when the card is clicked. This is optional. | `string \| undefined` | `undefined` |
82
- | `cardType` | `card-type` | The type of card to render. If no type is passed, it will default to 'basic'. | `"basic" \| "horizontal" \| "image" \| "title"` | `'basic'` |
83
- | `description` | `description` | Text to be displayed within the card description container. This is optional. | `string \| undefined` | `undefined` |
84
- | `headerType` | `header-type` | The type of header to render. If no type is passed, it will default to 'default'. | `"dark" \| "default" \| "light"` | `'default'` |
85
- | `horizontalImagePositionType` | `horizontal-image-position-type` | The position of the image when the card-type is set to 'horizontal'. This prop is only necessry when the card-type is set to 'horizontal'. | `"left" \| "right" \| undefined` | `'left'` |
86
- | `horizontalImageSizeType` | `horizontal-image-size-type` | The size of the image when the card-type is set to 'horizontal'. This prop is only necessry when the card-type is set to 'horizontal'. | `"one-fourth" \| "one-third" \| undefined` | `'one-third'` |
87
- | `image` | `image` | Image to be displayed within the card image container. This is optional. | `string \| undefined` | `undefined` |
88
- | `label` | `label` | Text to be displayed within the header. | `string` | `undefined` |
108
+ | Property | Attribute | Description | Type | Default |
109
+ | ----------------------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ------------- |
110
+ | `ariaLabelText` | `aria-label-text` | 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. This is optional. | `string \| undefined` | `undefined` |
111
+ | `cardLink` | `card-link` | Action link for when the card is clicked. This is optional. | `string \| undefined` | `undefined` |
112
+ | `description` | `description` | Text to be displayed within the card description container. This is optional. | `string \| undefined` | `undefined` |
113
+ | `headerColour` | `header-colour` | Set the card's header colour. This is optional. | `string \| undefined` | `undefined` |
114
+ | `horizontalImagePositionType` | `horizontal-image-position-type` | The position of the image when the card-type is set to 'horizontal'. This prop is only necessry when the card-type is set to 'horizontal'. | `"left" \| "right" \| undefined` | `'left'` |
115
+ | `horizontalImageSizeType` | `horizontal-image-size-type` | The size of the image when the card-type is set to 'horizontal'. This prop is only necessry when the card-type is set to 'horizontal'. | `"one-fourth" \| "one-third" \| undefined` | `'one-third'` |
116
+ | `image` | `image` | Image to be displayed within the card image container. This is optional. | `string \| undefined` | `undefined` |
117
+ | `label` | `label` | Text to be displayed within the header. | `string` | `undefined` |
118
+ | `layout` | `layout` | The layout oritnetation of the card. If no type is passed, it will default to 'vertical'. | `"horizontal" \| "vertical" \| undefined` | `'vertical'` |
89
119
 
90
120
  ---
91
121
 
@@ -0,0 +1,66 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ontario-card renders 1`] = `
4
+ <ontario-card>
5
+ <mock:shadow-root>
6
+ <li class="ontario-card ontario-card--position-vertical ontario-card__card-type--basic ontario-card__description-false">
7
+ <div class="ontario-card__text-container">
8
+ <h2 class="ontario-card__heading">
9
+ <a href="#"></a>
10
+ </h2>
11
+ </div>
12
+ </li>
13
+ </mock:shadow-root>
14
+ </ontario-card>
15
+ `;
16
+
17
+ exports[`ontario-card should render a description 1`] = `
18
+ <ontario-card description="Lorem ipsum">
19
+ <mock:shadow-root>
20
+ <li class="ontario-card ontario-card--position-vertical ontario-card__card-type--basic">
21
+ <div class="ontario-card__text-container">
22
+ <h2 class="ontario-card__heading">
23
+ <a href="#"></a>
24
+ </h2>
25
+ <div class="ontario-card__description">
26
+ <p>
27
+ Lorem ipsum
28
+ </p>
29
+ </div>
30
+ </div>
31
+ </li>
32
+ </mock:shadow-root>
33
+ </ontario-card>
34
+ `;
35
+
36
+ exports[`ontario-card should render a header colour on the label 1`] = `
37
+ <ontario-card header-colour="sky" label="Card Title 1">
38
+ <mock:shadow-root>
39
+ <li class="ontario-card ontario-card--position-vertical ontario-card__background--sky ontario-card__card-type--basic ontario-card__description-false">
40
+ <div class="ontario-card__text-container">
41
+ <h2 class="ontario-card__heading ontario-card__heading--sky">
42
+ <a href="#">
43
+ Card Title 1
44
+ </a>
45
+ </h2>
46
+ </div>
47
+ </li>
48
+ </mock:shadow-root>
49
+ </ontario-card>
50
+ `;
51
+
52
+ exports[`ontario-card should render a label 1`] = `
53
+ <ontario-card label="Card Title 1">
54
+ <mock:shadow-root>
55
+ <li class="ontario-card ontario-card--position-vertical ontario-card__card-type--basic ontario-card__description-false">
56
+ <div class="ontario-card__text-container">
57
+ <h2 class="ontario-card__heading">
58
+ <a href="#">
59
+ Card Title 1
60
+ </a>
61
+ </h2>
62
+ </div>
63
+ </li>
64
+ </mock:shadow-root>
65
+ </ontario-card>
66
+ `;
@@ -7,18 +7,32 @@ describe('ontario-card', () => {
7
7
  components: [OntarioCard],
8
8
  html: `<ontario-card></ontario-card>`,
9
9
  });
10
- expect(page.root).toEqualHtml(`
11
- <ontario-card>
12
- <mock:shadow-root>
13
- <li class="ontario-card ontario-card__card-type--basic ontario-card__header-type--default">
14
- <div class="ontario-card__text-container">
15
- <h2 class="ontario-card__heading">
16
- <a href="#"></a>
17
- </h2>
18
- </div>
19
- </li>
20
- </mock:shadow-root>
21
- </ontario-card>
22
- `);
10
+ expect(page.root).toMatchSnapshot();
23
11
  });
12
+
13
+ it('should render a label', async () => {
14
+ const page = await newSpecPage({
15
+ components: [OntarioCard],
16
+ html: `<ontario-card label="Card Title 1"></ontario-card>`,
17
+ });
18
+ expect(page.root).toMatchSnapshot();
19
+ });
20
+
21
+ it('should render a header colour on the label', async () => {
22
+ const page = await newSpecPage({
23
+ components: [OntarioCard],
24
+ html: `<ontario-card label="Card Title 1" header-colour="sky"></ontario-card>`,
25
+ });
26
+ expect(page.root).toMatchSnapshot();
27
+ });
28
+
29
+ it('should render a description', async () => {
30
+ const page = await newSpecPage({
31
+ components: [OntarioCard],
32
+ html: `<ontario-card description="Lorem ipsum"></ontario-card>`,
33
+ });
34
+ expect(page.root).toMatchSnapshot();
35
+ });
36
+
37
+ // Don't think we can test images unless we point to a local path
24
38
  });
@@ -20,9 +20,9 @@ Example of a bare-bones `ontario-card-collection` component, with a `cardsPerRow
20
20
  ```html
21
21
  <ontario-card-collection cards-per-row="2">
22
22
  <ontario-card
23
- card-type="horizontal"
23
+ layout="horizontal"
24
24
  label="Card Title 1"
25
- image="https://picsum.photos/200/300"
25
+ image="https://picsum.photos/300/225"
26
26
  card-link="https://google.ca"
27
27
  horizontal-image-position-type="left"
28
28
  horizontal-image-size-type="one-fourth"
@@ -30,9 +30,9 @@ Example of a bare-bones `ontario-card-collection` component, with a `cardsPerRow
30
30
  >
31
31
  </ontario-card>
32
32
  <ontario-card
33
- card-type="horizontal"
33
+ layout="horizontal"
34
34
  label="Card Title 2"
35
- image="https://picsum.photos/200/300"
35
+ image="https://picsum.photos/300/225"
36
36
  horizontal-image-position-type="left"
37
37
  horizontal-image-size-type="one-fourth"
38
38
  description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
@@ -43,21 +43,21 @@ Example of a bare-bones `ontario-card-collection` component, with a `cardsPerRow
43
43
 
44
44
  <OntarioCardCollection cards-per-row="2">
45
45
  <OntarioCard
46
- card-type="horizontal"
46
+ layout="horizontal"
47
47
  label="Card Title 1"
48
- image="https://picsum.photos/200/300"
49
- card-link="https://google.ca"
50
- horizontal-image-position-type="left"
51
- horizontal-image-size-type="one-fourth"
48
+ image="https://picsum.photos/300/225"
49
+ cardLink="https://google.ca"
50
+ horizontalImagePositionType="left"
51
+ horizontalImageSizeType="one-fourth"
52
52
  description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
53
53
  >
54
54
  </OntarioCard>
55
55
  <OntarioCard
56
- card-type="horizontal"
56
+ layout="horizontal"
57
57
  label="Card Title 2"
58
- image="https://picsum.photos/200/300"
59
- horizontal-image-position-type="left"
60
- horizontal-image-size-type="one-fourth"
58
+ image="https://picsum.photos/300/225"
59
+ horizontalImagePositionType="left"
60
+ horizontalImageSizeType="one-fourth"
61
61
  description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
62
62
  >
63
63
  </OntarioCard>
@@ -16,7 +16,6 @@ $ontario-checkboxes-size: globalFunctions.px-to-rem(28);
16
16
  $ontario-checkboxes-size-mobile: globalFunctions.px-to-rem(32);
17
17
  $ontario-checkbox-border-size: globalFunctions.px-to-rem(2);
18
18
  $ontario-checkbox-box-shadow-outline: globalFunctions.px-to-rem(4);
19
- $ontario-input-border-width: 0.125rem;
20
19
 
21
20
  :host {
22
21
  --checkbox-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M0 2.667C0 1.194 1.194 0 2.667 0h18.667C22.806 0 24 1.194 24 2.667v18.667C24 22.806 22.806 24 21.333 24H2.667C1.194 24 0 22.806 0 21.333V2.667z' fill='%231a1a1a'/%3E%3Cpath d='M2.667 12.616l6.667 6.718 12-12.092-1.88-1.908L9.333 15.53l-4.787-4.8-1.88 1.894z' fill='%23fff'/%3E%3C/svg%3E");
@@ -250,11 +250,22 @@ export class OntarioHeader {
250
250
  }
251
251
 
252
252
  /**
253
- * This listens for the `setAppLanguage` event sent from the test language toggler when it is is connected to the DOM. It is used for the initial language when the input component loads.
253
+ * This listens for the `setAppLanguage` event sent from the language toggle when it is is connected to the DOM.
254
+ * It is used for the initial language when the input component loads.
254
255
  */
255
256
  @Listen('setAppLanguage', { target: 'window' })
256
- handleSetAppLanguage(event: CustomEvent<Language>) {
257
+ handleSetAppLanguage(event: CustomEvent<Language> | Language) {
257
258
  this.language = validateLanguage(event);
259
+ this.parseMenuItems();
260
+ }
261
+
262
+ /**
263
+ * This listens for the `headerLanguageToggled` event sent from the language toggle when it is is connected to the DOM.
264
+ * It is used for changing the component language after the language toggle has been activated.
265
+ */
266
+ @Listen('headerLanguageToggled', { target: 'window' })
267
+ handleLanguageToggle(event: CustomEvent<{ oldLanguage: Language; newLanguage: Language }>) {
268
+ this.handleSetAppLanguage(event.detail.newLanguage);
258
269
  }
259
270
 
260
271
  /**
@@ -573,7 +584,6 @@ export class OntarioHeader {
573
584
  url={this.language === 'en' ? this.languageState?.frenchLink : this.languageState?.englishLink}
574
585
  size="default"
575
586
  customLanguageToggle={this.customLanguageToggle}
576
- language={this.language}
577
587
  ></ontario-language-toggle>
578
588
  <button
579
589
  class="ontario-header__search-toggler ontario-header-button ontario-header-button--without-outline ontario-hide-for-large"
@@ -674,7 +684,6 @@ export class OntarioHeader {
674
684
  size="small"
675
685
  url={this.language === 'en' ? this.languageState?.frenchLink : this.languageState?.englishLink}
676
686
  customLanguageToggle={this.customLanguageToggle}
677
- language={this.language}
678
687
  ></ontario-language-toggle>
679
688
  </div>
680
689
  </div>
@@ -57,10 +57,6 @@
57
57
 
58
58
  .ontario-service-subheader .ontario-header-button {
59
59
  display: flex;
60
-
61
- &:last-of-type {
62
- display: none;
63
- }
64
60
  }
65
61
 
66
62
  .ontario-service-subheader .ontario-header-button {
@@ -87,7 +87,7 @@ describe('ontario-header', () => {
87
87
  </a>
88
88
  </div>
89
89
  <div class="ontario-application-header__lang-toggle ontario-columns ontario-small-6">
90
- <ontario-language-toggle language="en" size="small" url="/fr"></ontario-language-toggle>
90
+ <ontario-language-toggle size="small" url="/fr"></ontario-language-toggle>
91
91
  </div>
92
92
  </div>
93
93
  </header>
@@ -370,7 +370,7 @@ describe('ontario-header', () => {
370
370
  </button>
371
371
  </form>
372
372
  <div class="ontario-columns ontario-header__nav-right-container ontario-large-3 ontario-medium-8 ontario-small-10">
373
- <ontario-language-toggle language="en" size="default" url="/fr"></ontario-language-toggle>
373
+ <ontario-language-toggle size="default" url="/fr"></ontario-language-toggle>
374
374
  <button aria-controls="ontario-search-form-container" class="ontario-header-button ontario-header-button--without-outline ontario-header__search-toggler ontario-hide-for-large" id="ontario-header-search-toggler">
375
375
  <span class="ontario-header__icon-container"></span>
376
376
  <span class="ontario-show ontario-show-for-medium">
@@ -532,7 +532,7 @@ describe('ontario-header', () => {
532
532
  </a>
533
533
  </div>
534
534
  <div class="ontario-application-header__lang-toggle ontario-columns ontario-small-6">
535
- <ontario-language-toggle language="en" size="small" url="/fr"></ontario-language-toggle>
535
+ <ontario-language-toggle size="small" url="/fr"></ontario-language-toggle>
536
536
  </div>
537
537
  </div>
538
538
  </header>