@ongov/ontario-design-system-component-library 4.3.1-alpha.1 → 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} +339 -78
- 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 +252 -34
- package/dist/collection/components/ontario-card/ontario-card.js +102 -78
- 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/service-ontario-header.css +0 -3
- 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/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/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/input.js +3 -0
- package/dist/components/input.js.map +1 -1
- package/dist/components/ontario-card.js +116 -64
- 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 +2 -4
- 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-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/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} +339 -78
- 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/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-abe58ec9.entry.js → p-9c3a1be9.entry.js} +1925 -1728
- 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-search-box/ontario-search-box.d.ts +180 -0
- package/dist/types/components.d.ts +199 -16
- 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/package.json +2 -2
- package/src/components/ontario-card/ontario-card-types.tsx +33 -4
- package/src/components/ontario-card/ontario-card.scss +54 -40
- package/src/components/ontario-card/ontario-card.tsx +94 -68
- 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/service-ontario-header.scss +0 -4
- package/src/components/ontario-hint-text/readme.md +2 -0
- 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 +199 -16
- package/src/index.html +287 -52
- package/src/utils/common/input/input.tsx +4 -1
- package/src/utils/common/input-caption/input-caption.tsx +9 -3
- 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-fdc9ab6d.js → p-84035ac3.js} +1 -1
- package/www/build/{p-abe58ec9.entry.js → p-9c3a1be9.entry.js} +1925 -1728
- package/www/build/p-9c3a1be9.entry.js.map +1 -0
- package/www/index.html +261 -52
- 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-abe58ec9.entry.js.map +0 -1
- package/www/build/p-abe58ec9.entry.js.map +0 -1
|
@@ -1,9 +1,38 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const HeaderTypes = ['default', 'light', 'dark'] as const;
|
|
1
|
+
export const Layouts = ['vertical', 'horizontal'] as const;
|
|
3
2
|
export const HorizontalImagePositionTypes = ['left', 'right'] as const;
|
|
4
3
|
export const HorizontalImageSizeTypes = ['one-fourth', 'one-third'] as const;
|
|
5
4
|
|
|
6
|
-
export type
|
|
7
|
-
export type HeaderType = (typeof HeaderTypes)[number];
|
|
5
|
+
export type Layout = (typeof Layouts)[number];
|
|
8
6
|
export type HorizontalImagePositionType = (typeof HorizontalImagePositionTypes)[number];
|
|
9
7
|
export type HorizontalImageSizeType = (typeof HorizontalImageSizeTypes)[number];
|
|
8
|
+
|
|
9
|
+
export const HeaderColours = [
|
|
10
|
+
'dark-accent',
|
|
11
|
+
'light-accent',
|
|
12
|
+
'light-gold',
|
|
13
|
+
'light-yellow',
|
|
14
|
+
'light-taupe',
|
|
15
|
+
'light-green',
|
|
16
|
+
'light-lime',
|
|
17
|
+
'light-teal',
|
|
18
|
+
'light-sky',
|
|
19
|
+
'light-blue',
|
|
20
|
+
'light-purple',
|
|
21
|
+
'light-orange',
|
|
22
|
+
'light-red',
|
|
23
|
+
'light-magenta',
|
|
24
|
+
'gold',
|
|
25
|
+
'yellow',
|
|
26
|
+
'taupe',
|
|
27
|
+
'green',
|
|
28
|
+
'lime',
|
|
29
|
+
'teal',
|
|
30
|
+
'sky',
|
|
31
|
+
'blue',
|
|
32
|
+
'purple',
|
|
33
|
+
'orange',
|
|
34
|
+
'red',
|
|
35
|
+
'magenta',
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export type HeaderColour = (typeof HeaderColours)[number];
|
|
@@ -47,16 +47,11 @@
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.ontario-card__header-type--dark.ontario-card__description-false {
|
|
51
|
-
background-color: colours.$ontario-colour-black;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.ontario-card__header-type--light.ontario-card__description-false {
|
|
55
|
-
background-color: colours.$ontario-greyscale-5;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
50
|
.ontario-card--image-true {
|
|
59
51
|
margin-top: spacing.$spacing-2 * -1;
|
|
52
|
+
@at-root .ontario-card__card-type--horizontal & {
|
|
53
|
+
margin-top: spacing.$spacing-0;
|
|
54
|
+
}
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
.ontario-card__card-type--horizontal {
|
|
@@ -72,6 +67,10 @@
|
|
|
72
67
|
position: relative;
|
|
73
68
|
}
|
|
74
69
|
|
|
70
|
+
.ontario-card__heading {
|
|
71
|
+
border-radius: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
75
74
|
a {
|
|
76
75
|
&:focus-within {
|
|
77
76
|
box-shadow: none;
|
|
@@ -100,30 +99,18 @@
|
|
|
100
99
|
padding: (spacing.$spacing-5 - spacing.$spacing-1) spacing.$spacing-5 spacing.$spacing-2 spacing.$spacing-5;
|
|
101
100
|
transition: text-decoration 0.3s ease-in-out;
|
|
102
101
|
background-color: colours.$ontario-colour-white;
|
|
102
|
+
max-width: none;
|
|
103
103
|
|
|
104
104
|
.ontario-card:hover & {
|
|
105
105
|
text-decoration-line: underline;
|
|
106
106
|
text-decoration-color: colours.$ontario-colour-black;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.ontario-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
border-radius: globalVariables.$global-radius globalVariables.$global-radius 0 0;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.ontario-card__header-type--dark & {
|
|
118
|
-
background-color: colours.$ontario-colour-black;
|
|
119
|
-
padding-top: spacing.$spacing-4;
|
|
120
|
-
padding-bottom: spacing.$spacing-4;
|
|
121
|
-
border-radius: globalVariables.$global-radius globalVariables.$global-radius 0 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.ontario-card__header-type--dark:hover & {
|
|
125
|
-
text-decoration-line: underline;
|
|
126
|
-
text-decoration-color: colours.$ontario-colour-white;
|
|
109
|
+
.ontario-card--image-true & {
|
|
110
|
+
border-radius: 0;
|
|
111
|
+
@at-root .ontario-card__card-type--horizontal & {
|
|
112
|
+
border-radius: 0 globalVariables.$global-radius 0 0;
|
|
113
|
+
}
|
|
127
114
|
}
|
|
128
115
|
|
|
129
116
|
a {
|
|
@@ -131,10 +118,6 @@
|
|
|
131
118
|
text-decoration: none;
|
|
132
119
|
outline: none;
|
|
133
120
|
|
|
134
|
-
.ontario-card__header-type--dark & {
|
|
135
|
-
color: colours.$ontario-colour-white;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
121
|
&::after {
|
|
139
122
|
content: '';
|
|
140
123
|
position: absolute;
|
|
@@ -160,6 +143,47 @@
|
|
|
160
143
|
}
|
|
161
144
|
}
|
|
162
145
|
|
|
146
|
+
// ontario-card's header colour options
|
|
147
|
+
|
|
148
|
+
$ontario-card-heading-colours: (
|
|
149
|
+
'light-accent': colours.$ontario-greyscale-5,
|
|
150
|
+
'dark-accent': colours.$ontario-colour-black,
|
|
151
|
+
'light-gold': colours.$ontario-colour-light-gold,
|
|
152
|
+
'light-yellow': colours.$ontario-colour-light-yellow,
|
|
153
|
+
'light-taupe': colours.$ontario-colour-light-taupe,
|
|
154
|
+
'light-green': colours.$ontario-colour-light-green,
|
|
155
|
+
'light-lime': colours.$ontario-colour-light-lime,
|
|
156
|
+
'light-teal': colours.$ontario-colour-light-teal,
|
|
157
|
+
'light-sky': colours.$ontario-colour-light-sky,
|
|
158
|
+
'light-purple': colours.$ontario-colour-light-purple,
|
|
159
|
+
'light-orange': colours.$ontario-colour-light-orange,
|
|
160
|
+
'light-red': colours.$ontario-colour-light-red,
|
|
161
|
+
'light-magenta': colours.$ontario-colour-light-magenta,
|
|
162
|
+
'gold': colours.$ontario-colour-gold,
|
|
163
|
+
'yellow': colours.$ontario-colour-yellow,
|
|
164
|
+
'taupe': colours.$ontario-colour-taupe,
|
|
165
|
+
'green': colours.$ontario-colour-green,
|
|
166
|
+
'lime': colours.$ontario-colour-lime,
|
|
167
|
+
'teal': colours.$ontario-colour-teal,
|
|
168
|
+
'sky': colours.$ontario-colour-sky,
|
|
169
|
+
'purple': colours.$ontario-colour-purple,
|
|
170
|
+
'orange': colours.$ontario-colour-orange,
|
|
171
|
+
'red': colours.$ontario-colour-red,
|
|
172
|
+
'magenta': colours.$ontario-colour-magenta,
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
@each $colour-name, $colour-value in $ontario-card-heading-colours {
|
|
176
|
+
.ontario-card__background--#{$colour-name} {
|
|
177
|
+
background-color: $colour-value;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.ontario-card__heading--#{$colour-name} {
|
|
181
|
+
background-color: $colour-value;
|
|
182
|
+
padding-top: spacing.$spacing-4;
|
|
183
|
+
padding-bottom: spacing.$spacing-4;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
163
187
|
.ontario-card__text-container {
|
|
164
188
|
.ontario-card__card-type--horizontal & {
|
|
165
189
|
width: 66.6%;
|
|
@@ -189,18 +213,8 @@
|
|
|
189
213
|
margin-bottom: spacing.$spacing-0;
|
|
190
214
|
}
|
|
191
215
|
|
|
192
|
-
.ontario-card__header-type--light &,
|
|
193
|
-
.ontario-card__header-type--dark & {
|
|
194
|
-
padding-top: spacing.$spacing-4;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
216
|
@media screen and (max-width: breakpoints.$medium-breakpoint) {
|
|
198
217
|
padding: spacing.$spacing-2 spacing.$spacing-4 spacing.$spacing-5 spacing.$spacing-4;
|
|
199
|
-
|
|
200
|
-
.ontario-card__header-type--light &,
|
|
201
|
-
.ontario-card__header-type--dark & {
|
|
202
|
-
padding-top: spacing.$spacing-4;
|
|
203
|
-
}
|
|
204
218
|
}
|
|
205
219
|
}
|
|
206
220
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Component, Prop, Element, h, State, Watch } from '@stencil/core';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
57
|
+
* The layout oritnetation of the card.
|
|
57
58
|
*
|
|
58
|
-
* If no type is passed, it will default to '
|
|
59
|
+
* If no type is passed, it will default to 'vertical'.
|
|
59
60
|
*
|
|
60
61
|
*/
|
|
61
|
-
@Prop()
|
|
62
|
+
@Prop() layout?: Layout = 'vertical';
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
|
-
*
|
|
65
|
+
* Set the card's header colour.
|
|
65
66
|
*
|
|
66
|
-
*
|
|
67
|
+
* This is optional.
|
|
67
68
|
*/
|
|
68
|
-
@Prop()
|
|
69
|
+
@Prop() headerColour?: HeaderColour;
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
* The position of the image when the card-type is set to 'horizontal'.
|
|
@@ -113,114 +114,139 @@ export class OntarioCard {
|
|
|
113
114
|
|
|
114
115
|
/**
|
|
115
116
|
* Mutable variable, for internal use only.
|
|
116
|
-
* Set the card's
|
|
117
|
-
*/
|
|
118
|
-
@State() private cardTypeState: string;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Mutable variable, for internal use only.
|
|
122
|
-
* Set the card's header type depending on validation result.
|
|
117
|
+
* Set the card's layout depending on validation result.
|
|
123
118
|
*/
|
|
124
|
-
@State() private
|
|
119
|
+
@State() private layoutState: string;
|
|
125
120
|
|
|
126
121
|
/**
|
|
127
|
-
* Watch for changes to the `
|
|
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 `
|
|
130
|
-
* If a match is found in one of the array values then `
|
|
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('
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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 `
|
|
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 `
|
|
146
|
-
* If a match is found in one of the array values then `
|
|
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('
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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 `
|
|
160
|
-
* @returns default type (basic).
|
|
159
|
+
* Print the invalid `layout` prop warning message.
|
|
161
160
|
*/
|
|
162
|
-
private
|
|
161
|
+
private warnDefaultLayout() {
|
|
163
162
|
const message = new ConsoleMessageClass();
|
|
164
163
|
message
|
|
165
164
|
.addDesignSystemTag()
|
|
166
|
-
.addMonospaceText('
|
|
165
|
+
.addMonospaceText(' layout ')
|
|
167
166
|
.addRegularText('on')
|
|
168
167
|
.addMonospaceText(' <ontario-card> ')
|
|
169
|
-
.addRegularText('was set to an invalid
|
|
170
|
-
.addMonospaceText(
|
|
171
|
-
.addRegularText('are supported. The default
|
|
172
|
-
.addMonospaceText('
|
|
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 `
|
|
180
|
-
* @returns default type (default).
|
|
177
|
+
* Print the invalid `headerColour` prop warning message.
|
|
181
178
|
*/
|
|
182
|
-
private
|
|
179
|
+
private warnDefaultHeaderColour() {
|
|
183
180
|
const message = new ConsoleMessageClass();
|
|
184
181
|
message
|
|
185
182
|
.addDesignSystemTag()
|
|
186
|
-
.addMonospaceText(' header-
|
|
183
|
+
.addMonospaceText(' header-colour ')
|
|
187
184
|
.addRegularText('on')
|
|
188
185
|
.addMonospaceText(' <ontario-card> ')
|
|
189
|
-
.addRegularText('was set to an invalid
|
|
190
|
-
.addMonospaceText(
|
|
191
|
-
.addRegularText('are supported.
|
|
192
|
-
.
|
|
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
|
-
*
|
|
194
|
+
* Returns the top level classes of the card.
|
|
195
|
+
*
|
|
196
|
+
* @returns {string}
|
|
200
197
|
*/
|
|
201
|
-
private
|
|
198
|
+
private getCardClasses(): string {
|
|
202
199
|
const baseClass =
|
|
203
|
-
this.
|
|
204
|
-
? `ontario-card ontario-card__card-type
|
|
205
|
-
: `ontario-card ontario-
|
|
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}`;
|
|
206
203
|
|
|
207
204
|
const descriptionClass = this.description ? '' : ' ontario-card__description-false';
|
|
208
205
|
|
|
209
|
-
|
|
206
|
+
const backgroundClass =
|
|
207
|
+
this.headerColour && !this.description ? `ontario-card__background--${this.headerColour}` : '';
|
|
208
|
+
|
|
209
|
+
return `${baseClass} ${descriptionClass} ${backgroundClass}`.trim();
|
|
210
|
+
}
|
|
211
|
+
|
|
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();
|
|
210
226
|
}
|
|
211
227
|
|
|
212
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Returns the url that the card links to.
|
|
230
|
+
*
|
|
231
|
+
* @returns {string}
|
|
232
|
+
*/
|
|
233
|
+
private getHref(): string {
|
|
213
234
|
return this.cardLink ? this.cardLink : '#';
|
|
214
235
|
}
|
|
215
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Component life cycle hook.
|
|
239
|
+
*
|
|
240
|
+
* https://stenciljs.com/docs/component-lifecycle#connectedcallback
|
|
241
|
+
*/
|
|
216
242
|
componentWillLoad() {
|
|
217
|
-
this.
|
|
218
|
-
this.
|
|
243
|
+
this.validateLayout();
|
|
244
|
+
this.validateHeaderColour();
|
|
219
245
|
}
|
|
220
246
|
|
|
221
247
|
render() {
|
|
222
248
|
return (
|
|
223
|
-
<li class={this.
|
|
249
|
+
<li class={this.getCardClasses()}>
|
|
224
250
|
{this.image && (
|
|
225
251
|
<div class="ontario-card__image-container">
|
|
226
252
|
<a href={this.getHref()} aria-label={this.ariaLabelText}>
|
|
@@ -229,7 +255,7 @@ export class OntarioCard {
|
|
|
229
255
|
</div>
|
|
230
256
|
)}
|
|
231
257
|
<div class={`ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`}>
|
|
232
|
-
<h2 class=
|
|
258
|
+
<h2 class={this.getCardHeadingClasses()}>
|
|
233
259
|
<a href={this.getHref()} aria-label={this.ariaLabelText}>
|
|
234
260
|
{this.label}
|
|
235
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.
|
|
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 `
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
50
|
+
layout="horizontal"
|
|
54
51
|
label="Card Title"
|
|
55
|
-
image="https://picsum.photos/
|
|
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
|
-
|
|
62
|
+
layout="horizontal"
|
|
66
63
|
label="Card Title"
|
|
67
|
-
image="https://picsum.photos/
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
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`
|
|
81
|
-
| `cardLink` | `card-link` | Action link for when the card is clicked. This is optional. | `string \| undefined`
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
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
|
+
`;
|