@ons/design-system 72.1.2 → 72.2.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 (31) hide show
  1. package/components/address-input/_macro.spec.js +0 -1
  2. package/components/address-input/autosuggest.address.spec.js +0 -1
  3. package/components/autosuggest/autosuggest.spec.js +0 -2
  4. package/components/button/_button.scss +3 -2
  5. package/components/char-check-limit/_macro.spec.js +50 -58
  6. package/components/description-list/_macro.njk +7 -1
  7. package/components/description-list/_macro.spec.js +4 -1
  8. package/components/description-list/example-inline-description-list.njk +2 -1
  9. package/components/document-list/_macro.spec.js +298 -347
  10. package/components/header/_macro.spec.js +0 -1
  11. package/components/header/example-header-external-with-navigation-and-search.njk +0 -1
  12. package/components/hero/_hero.scss +45 -4
  13. package/components/hero/_macro.njk +49 -10
  14. package/components/hero/_macro.spec.js +84 -1
  15. package/components/hero/example-hero-grey.njk +78 -0
  16. package/components/icon/_macro.njk +146 -0
  17. package/components/list/_list.scss +3 -0
  18. package/components/list/_macro.njk +12 -18
  19. package/components/list/_macro.spec.js +11 -7
  20. package/components/message-list/_macro.njk +10 -3
  21. package/components/message-list/_macro.spec.js +72 -14
  22. package/components/message-list/_message-list.scss +1 -1
  23. package/components/navigation/_macro.njk +0 -1
  24. package/components/navigation/_macro.spec.js +0 -1
  25. package/components/panel/_macro.njk +1 -1
  26. package/components/panel/_macro.spec.js +15 -1
  27. package/css/main.css +1 -1
  28. package/package.json +1 -1
  29. package/scss/base/_typography.scss +1 -1
  30. package/scss/helpers/_mq.scss +1 -1
  31. package/scss/vars/_colors.scss +1 -0
@@ -10,6 +10,7 @@ const EXAMPLE_MESSAGE_LIST_MINIMAL = {
10
10
  fromLabel: 'From',
11
11
  dateLabel: 'Date',
12
12
  hiddenReadLabel: 'Read the message',
13
+ bodyLabel: 'Body',
13
14
  messages: [
14
15
  {
15
16
  id: 'message1',
@@ -39,7 +40,47 @@ const EXAMPLE_MESSAGE_LIST = {
39
40
  ...EXAMPLE_MESSAGE_LIST_MINIMAL,
40
41
  ariaLabel: 'Message list for ONS Business Surveys',
41
42
  ariaLabelMetaData: 'Message information',
42
- ariaLabelMsg: 'Message preview',
43
+ };
44
+
45
+ const EXAMPLE_MESSAGE_LIST_WITH_DEPRECATED_ARIALABELMSG_PARAM = {
46
+ unreadText: 'New',
47
+ fromLabel: 'From',
48
+ dateLabel: 'Date',
49
+ hiddenReadLabel: 'Read the message',
50
+ ariaLabelMsg: 'Aria Label Msg Preview',
51
+ messages: [
52
+ {
53
+ id: 'message1',
54
+ unread: true,
55
+ subject: {
56
+ url: 'https://example.com/message/1',
57
+ text: 'Example message subject',
58
+ },
59
+ fromText: 'Example Sender 1',
60
+ dateText: 'Tue 4 Jul 2020 at 7:47',
61
+ body: 'An example message.',
62
+ },
63
+ ],
64
+ };
65
+
66
+ const EXAMPLE_MESSAGE_LIST_WIHTOUT_BODYLABEL_PARAM = {
67
+ unreadText: 'New',
68
+ fromLabel: 'From',
69
+ dateLabel: 'Date',
70
+ hiddenReadLabel: 'Read the message',
71
+ messages: [
72
+ {
73
+ id: 'message1',
74
+ unread: true,
75
+ subject: {
76
+ url: 'https://example.com/message/1',
77
+ text: 'Example message subject',
78
+ },
79
+ fromText: 'Example Sender 1',
80
+ dateText: 'Tue 4 Jul 2020 at 7:47',
81
+ body: 'An example message.',
82
+ },
83
+ ],
43
84
  };
44
85
 
45
86
  describe('macro: message-list', () => {
@@ -74,18 +115,6 @@ describe('macro: message-list', () => {
74
115
  expect($('.ons-message-item__metadata:first').attr('aria-label')).toBe('Message information');
75
116
  });
76
117
 
77
- it('has `aria-label` attribute on `.ons-message-item__body` with the correct default value', () => {
78
- const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
79
-
80
- expect($('.ons-message-item__body:first').attr('aria-label')).toBe('Message text');
81
- });
82
-
83
- it('has `aria-label` attribute on `.ons-message-item__body` using the provided value', () => {
84
- const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST));
85
-
86
- expect($('.ons-message-item__body:first').attr('aria-label')).toBe('Message preview');
87
- });
88
-
89
118
  it('has `unreadText` for unread messages', () => {
90
119
  const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST));
91
120
 
@@ -110,6 +139,35 @@ describe('macro: message-list', () => {
110
139
  expect($('.ons-message-item__link:first').text()).toContain('Read the message: ');
111
140
  });
112
141
 
142
+ it('has visually hidden label `bodyLabel` when only `bodyLabel` is provided`', () => {
143
+ const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
144
+
145
+ expect($('.ons-message-item__metadata-term--body:first').text().trim()).toBe('Body:');
146
+ });
147
+
148
+ it('has visually hidden label `bodyLabel` when both `bodyLabel` and `ariaLabelMsg` are provided`', () => {
149
+ const $ = cheerio.load(
150
+ renderComponent('message-list', {
151
+ ...EXAMPLE_MESSAGE_LIST_MINIMAL,
152
+ ariaLabelMsg: 'Aria Label Msg Preview',
153
+ }),
154
+ );
155
+
156
+ expect($('.ons-message-item__metadata-term--body:first').text().trim()).toBe('Body:');
157
+ });
158
+
159
+ it('has visually hidden deprecated label `ariaLabelMsg` when only `ariaLabelMsg` is provided', () => {
160
+ const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_WITH_DEPRECATED_ARIALABELMSG_PARAM));
161
+
162
+ expect($('.ons-message-item__metadata-term--body:first').text().trim()).toBe('Aria Label Msg Preview:');
163
+ });
164
+
165
+ it('has the defualt text for visually hidden label `bodyLabel` when both `bodyLabel` and `ariaLabelMsg` are not provided', () => {
166
+ const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_WIHTOUT_BODYLABEL_PARAM));
167
+
168
+ expect($('.ons-message-item__metadata-term--body:first').text().trim()).toBe('Message text:');
169
+ });
170
+
113
171
  it('has message as expected', () => {
114
172
  const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
115
173
 
@@ -119,7 +177,7 @@ describe('macro: message-list', () => {
119
177
  expect($message2.find('.ons-message-item__subject').attr('id')).toBe('message2');
120
178
  expect($message2.find('.ons-message-item__metadata-value--from').text().trim()).toBe('Example Sender 2');
121
179
  expect($message2.find('.ons-message-item__metadata-value--date').text().trim()).toBe('Mon 1 Oct 2019 at 9:52');
122
- expect($message2.find('.ons-message-item__body').text().trim()).toBe('Another example message.');
180
+ expect($message2.find('.ons-message-item__metadata-value--body').text().trim()).toBe('Another example message.');
123
181
  expect($message2.find('.ons-message-item__link a').attr('href')).toBe('https://example.com/message/2');
124
182
  });
125
183
 
@@ -5,7 +5,7 @@
5
5
  .ons-message-item {
6
6
  list-style: none;
7
7
  margin-bottom: 2rem;
8
- padding-bottom: 1.5rem;
8
+ padding-bottom: 0.5rem;
9
9
 
10
10
  &:not(:last-child) {
11
11
  border-bottom: 1px solid var(--ons-color-borders);
@@ -32,7 +32,6 @@
32
32
  "ariaYouHaveSelected":params.siteSearchAutosuggest.ariaYouHaveSelected,
33
33
  "minChars": params.siteSearchAutosuggest.minChars,
34
34
  "ariaMinChars": params.siteSearchAutosuggest.ariaMinChars,
35
- "ariaResultsLabel": params.siteSearchAutosuggest.ariaResultsLabel,
36
35
  "ariaOneResult": params.siteSearchAutosuggest.ariaOneResult,
37
36
  "ariaNResults": params.siteSearchAutosuggest.ariaNResults,
38
37
  "ariaLimitedResults": params.siteSearchAutosuggest.ariaLimitedResults,
@@ -75,7 +75,6 @@ const SITE_SEARCH_AUTOSUGGEST = {
75
75
  "Use up and down keys to navigate results once you've typed more than two characters. Use the enter key to select a result. Touch device users, explore by touch or with swipe gestures.",
76
76
  ariaYouHaveSelected: 'You have selected',
77
77
  ariaMinChars: 'Enter 3 or more characters for results.',
78
- ariaResultsLabel: 'Search results',
79
78
  ariaOneResult: 'There is one result available.',
80
79
  ariaNResults: 'There are {n} results available.',
81
80
  ariaLimitedResults: 'Results have been limited to 10 results. Type more characters to improve your search',
@@ -50,7 +50,7 @@
50
50
  <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Announcement: ") }}</span>
51
51
  {% endif %}
52
52
 
53
- {% if params.title %}
53
+ {% if params.title and (params.variant not in ['bare', 'warn', 'warn-branded', 'announcement'] ) %}
54
54
  {% if params.variant == 'error' %}
55
55
  {% set defaultTitleTag = "h" ~ 2 %}
56
56
  {% else %}
@@ -32,7 +32,7 @@ describe('macro: panel', () => {
32
32
  expect(results).toHaveNoViolations();
33
33
  });
34
34
 
35
- it('has correct class', () => {
35
+ it('has correct panel variant class', () => {
36
36
  const $ = cheerio.load(
37
37
  renderComponent('panel', {
38
38
  ...EXAMPLE_PANEL_BASIC,
@@ -173,6 +173,20 @@ describe('macro: panel', () => {
173
173
  });
174
174
  });
175
175
 
176
+ describe.each(['bare', 'warn', 'warn-branded', 'announcement'])('mode: %s', (panelVariant) => {
177
+ it('does not render a title when `title` is provided', () => {
178
+ const $ = cheerio.load(
179
+ renderComponent('panel', {
180
+ ...EXAMPLE_PANEL_BASIC,
181
+ title: 'Panel title',
182
+ variant: panelVariant,
183
+ }),
184
+ );
185
+
186
+ expect($('.ons-panel__title').length).toBe(0);
187
+ });
188
+ });
189
+
176
190
  describe.each([
177
191
  ['error', 'h2'],
178
192
  ['success', 'div'],