@ons/design-system 62.1.1 → 62.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.
@@ -22,7 +22,9 @@
22
22
  {% call onsDetails({
23
23
  "id": params.definition.id,
24
24
  "classes": 'ons-u-mb-m',
25
- "title": params.definition.title
25
+ "title": params.definition.title,
26
+ "headingAttributes": params.definition.headingAttributes,
27
+ "contentAttributes": params.definition.contentAttributes
26
28
  }) %}
27
29
  {% if params.definition.content %}
28
30
  {{ params.definition.content | safe }}
@@ -35,7 +37,9 @@
35
37
  {% set questionGuidance %}
36
38
  {% from "components/panel/_macro.njk" import onsPanel %}
37
39
  {% call onsPanel({
38
- "classes": "ons-question-guidance ons-u-mb-m"
40
+ "id": params.guidance.id,
41
+ "classes": "ons-question-guidance ons-u-mb-m",
42
+ "attributes": params.guidance.attributes
39
43
  }) %}
40
44
  {% if params.guidance.content %}
41
45
  {{ params.guidance.content | safe }}
@@ -65,6 +69,30 @@
65
69
  class="ons-question ons-u-mb-l{% if params.classes %} {{ params.classes }}{% endif %}"
66
70
  {% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
67
71
  >
72
+ {% set additionalContent %}
73
+ {% if params.warning %}
74
+ {% from "components/panel/_macro.njk" import onsPanel %}
75
+ {% call onsPanel({
76
+ "id": params.warning.id,
77
+ "type": "warn"
78
+ }) %}
79
+ <p>{{ params.warning.body }}</p>
80
+ {% endcall %}
81
+ {% endif %}
82
+
83
+ {% if params.instruction %}
84
+ {{- instHtml | safe -}}
85
+ {% endif %}
86
+
87
+ {% if params.definition %}
88
+ {{- questionDefinition | safe -}}
89
+ {% endif %}
90
+
91
+ {% if params.guidance %}
92
+ {{- questionGuidance | safe -}}
93
+ {% endif %}
94
+ {% endset %}
95
+
68
96
  {% if params.legendIsQuestionTitle %}
69
97
  {% from "components/fieldset/_macro.njk" import onsFieldset %}
70
98
 
@@ -78,6 +106,7 @@
78
106
  "legendClasses": params.legendClasses,
79
107
  "legendTitleClasses": params.legendTitleClasses
80
108
  }) %}
109
+ {{- additionalContent | safe -}}
81
110
  {{ content }}
82
111
  {% endcall %}
83
112
  </div>
@@ -91,17 +120,7 @@
91
120
  {{- descHtml | safe -}}
92
121
  {% endif %}
93
122
 
94
- {% if params.instruction %}
95
- {{- instHtml | safe -}}
96
- {% endif %}
97
-
98
- {% if params.definition %}
99
- {{- questionDefinition | safe -}}
100
- {% endif %}
101
-
102
- {% if params.guidance %}
103
- {{- questionGuidance | safe -}}
104
- {% endif %}
123
+ {{- additionalContent | safe -}}
105
124
 
106
125
  <div class="ons-question__answer ons-u-mb-m">
107
126
  {{ caller() if caller }}
@@ -113,7 +132,9 @@
113
132
  {% call onsDetails({
114
133
  "id": params.justification.id,
115
134
  "classes": 'ons-u-mb-m',
116
- "title": params.justification.title | default('Why we ask this question')
135
+ "title": params.justification.title | default('Why we ask this question'),
136
+ "headingAttributes": params.justification.headingAttributes,
137
+ "contentAttributes": params.justification.contentAttributes
117
138
  }) %}
118
139
  {{ params.justification.content | safe }}
119
140
  {% endcall %}
@@ -11,6 +11,14 @@ const EXAMPLE_QUESTION_BASIC = {
11
11
  description: 'Question description',
12
12
  };
13
13
 
14
+ const EXAMPLE_QUESTION_WARNING = {
15
+ ...EXAMPLE_QUESTION_BASIC,
16
+ warning: {
17
+ id: 'warning-id',
18
+ body: 'Warning content',
19
+ },
20
+ };
21
+
14
22
  const EXAMPLE_QUESTION_DEFINITION = {
15
23
  ...EXAMPLE_QUESTION_BASIC,
16
24
  definition: {
@@ -70,6 +78,7 @@ const EXAMPLE_QUESTION_DESCRIPTION_FIRST = {
70
78
  describe('macro: question', () => {
71
79
  describe.each([
72
80
  ['with basic parameters', EXAMPLE_QUESTION_BASIC],
81
+ ['with warning', EXAMPLE_QUESTION_WARNING],
73
82
  ['with definition', EXAMPLE_QUESTION_DEFINITION],
74
83
  ['with guidance', EXAMPLE_QUESTION_GUIDANCE],
75
84
  ['with justification', EXAMPLE_QUESTION_JUSTIFICATION],
@@ -80,6 +89,7 @@ describe('macro: question', () => {
80
89
  [
81
90
  'with all options combined',
82
91
  {
92
+ ...EXAMPLE_QUESTION_WARNING,
83
93
  ...EXAMPLE_QUESTION_DEFINITION,
84
94
  ...EXAMPLE_QUESTION_GUIDANCE,
85
95
  ...EXAMPLE_QUESTION_JUSTIFICATION,
@@ -162,6 +172,24 @@ describe('macro: question', () => {
162
172
  });
163
173
  });
164
174
 
175
+ describe('mode: with warning', () => {
176
+ it('outputs the expected panel', () => {
177
+ const faker = templateFaker();
178
+ const panelSpy = faker.spy('panel');
179
+
180
+ faker.renderComponent('question', EXAMPLE_QUESTION_WARNING);
181
+
182
+ expect(panelSpy.occurrences[0]).toHaveProperty('id', 'warning-id');
183
+ expect(panelSpy.occurrences[0]).toHaveProperty('type', 'warn');
184
+ });
185
+
186
+ it('outputs the expected panel content', () => {
187
+ const $ = cheerio.load(renderComponent('question', EXAMPLE_QUESTION_WARNING));
188
+
189
+ expect($('.ons-panel__body > p').text()).toBe('Warning content');
190
+ });
191
+ });
192
+
165
193
  describe('mode: with definition', () => {
166
194
  it('outputs the expected details', () => {
167
195
  const faker = templateFaker();
@@ -4,9 +4,7 @@ layout: ~
4
4
  ---
5
5
  {% extends "layout/_template.njk" %}
6
6
  {% from "components/question/_macro.njk" import onsQuestion %}
7
- {% from "components/details/_macro.njk" import onsDetails %}
8
7
  {% from "components/input/_macro.njk" import onsInput %}
9
- {% from "components/button/_macro.njk" import onsButton %}
10
8
 
11
9
  {% set pageConfig = {
12
10
  "header": {
@@ -4,10 +4,7 @@ layout: ~
4
4
  ---
5
5
  {% extends "layout/_template.njk" %}
6
6
  {% from "components/question/_macro.njk" import onsQuestion %}
7
- {% from "components/details/_macro.njk" import onsDetails %}
8
- {% from "components/panel/_macro.njk" import onsPanel %}
9
7
  {% from "components/radios/_macro.njk" import onsRadios %}
10
- {% from "components/button/_macro.njk" import onsButton %}
11
8
 
12
9
  {% set pageConfig = {
13
10
  "header": {
@@ -65,34 +62,34 @@ layout: ~
65
62
  }) %}
66
63
 
67
64
  {{ onsRadios({
68
- "id": "number-of-employees",
69
- "name": "number-of-employees",
70
- "legend": questionTitle,
71
- "legendClasses": "ons-u-vh",
72
- "radios": [
73
- {
74
- "id": "number-of-employees-1-9",
75
- "label": {
76
- "text": "1 – 9 employees"
77
- },
78
- "value": "1-9"
79
- },
80
- {
81
- "id": "number-of-employees-10-49",
82
- "label": {
83
- "text": "10 – 49 employees"
65
+ "id": "number-of-employees",
66
+ "name": "number-of-employees",
67
+ "legend": questionTitle,
68
+ "legendClasses": "ons-u-vh",
69
+ "radios": [
70
+ {
71
+ "id": "number-of-employees-1-9",
72
+ "label": {
73
+ "text": "1 – 9 employees"
74
+ },
75
+ "value": "1-9"
84
76
  },
85
- "value": "10-49"
86
- },
87
- {
88
- "id": "number-of-employees-50-100",
89
- "label": {
90
- "text": "50 – 100+ employees",
91
- "description": "Include multi-corporations"
77
+ {
78
+ "id": "number-of-employees-10-49",
79
+ "label": {
80
+ "text": "10 – 49 employees"
81
+ },
82
+ "value": "10-49"
92
83
  },
93
- "value": "50-100"
94
- }
95
- ]
84
+ {
85
+ "id": "number-of-employees-50-100",
86
+ "label": {
87
+ "text": "50 – 100+ employees",
88
+ "description": "Include multi-corporations"
89
+ },
90
+ "value": "50-100"
91
+ }
92
+ ]
96
93
  }) }}
97
94
 
98
95
  {% endcall %}
@@ -6,9 +6,6 @@ layout: ~
6
6
 
7
7
  {% extends "layout/_template.njk" %}
8
8
  {% from "components/question/_macro.njk" import onsQuestion %}
9
- {% from "components/details/_macro.njk" import onsDetails %}
10
- {% from "components/input/_macro.njk" import onsInput %}
11
- {% from "components/button/_macro.njk" import onsButton %}
12
9
 
13
10
  {% set pageConfig = {
14
11
  "header": {
@@ -4,9 +4,7 @@ layout: ~
4
4
  ---
5
5
  {% extends "layout/_template.njk" %}
6
6
  {% from "components/question/_macro.njk" import onsQuestion %}
7
- {% from "components/details/_macro.njk" import onsDetails %}
8
7
  {% from "components/input/_macro.njk" import onsInput %}
9
- {% from "components/button/_macro.njk" import onsButton %}
10
8
 
11
9
  {% set pageConfig = {
12
10
  "header": {
@@ -12,7 +12,7 @@
12
12
  <div class="{{ className }}">
13
13
  {% for summary in params.summaries %}
14
14
  {% if summary.summaryTitle %}
15
- <h2 class="ons-summary__title ons-u-mb-m">{{ summary.summaryTitle }}</h2>
15
+ <h2 class="ons-summary__title ons-u-mb-m{{ " ons-u-mt-m" if loop.index > 1 else "" }}">{{ summary.summaryTitle }}</h2>
16
16
  {% set titleSize = "3" %}
17
17
  {% endif %}
18
18
  {% for group in summary.groups %}
@@ -7,7 +7,8 @@
7
7
  {
8
8
  "id": "ukis",
9
9
  "title": 'UKIS',
10
- "content": '<h3>Aim of this survey</h3>
10
+ "content": '<h2 class="ons-u-d-no@m">UKIS</h2>
11
+ <h3>Aim of this survey</h3>
11
12
  <p class="ons-u-fs-r">The aim of the UK Innovation Survey (UKIS) is to collect data from businesses about various aspects of their innovation related activities. Using this data we can measure the level, types and trends in innovation.</p>
12
13
  <h3>How we’ll use this data</h3>
13
14
  <p class="ons-u-fs-r">The UKIS data is a major source of evidence to inform government policy. It is used to promote innovation activities among businesses to boost economic growth. It is an important contribution to the European-wide Community Innovation Survey (CIS). The CIS is used for international benchmarking and comparison purposes.</p>
@@ -16,14 +17,16 @@
16
17
  {
17
18
  "id": "vacancy-survey",
18
19
  "title": 'Vacancy survey',
19
- "content": '<h3>Purpose</h3>
20
+ "content": '<h2 class="ons-u-d-no@m">Vacancy survey</h2>
21
+ <h3>Purpose</h3>
20
22
  <p class="ons-u-fs-r">The Vacancy Survey is a regular survey of businesses, which provides an accurate and comprehensive measure of the total number of vacancies across the economy and fills a gap in the information available regarding the demand for labour. Before the Vacancy Survey was introduced, the only information available nationally about vacancies was from records of vacancies notified to Job Centres by employers. This provided only a partial picture, possibly less than half of all vacancies, because employers are under no obligation to notify vacancies to Job Centres. This business based survey has a more complete coverage and is included in the monthly ONS Labour Market Statistical Bulletin.</p>
21
23
  <p>You can <a href="https://www.ons.gov.uk/surveys/informationforbusinesses/businesssurveys/vacancysurvey">find more information on the Vacancy Survey on the ONS website</a>.</p>'
22
24
  },
23
25
  {
24
26
  "id": "monthly-business-survey",
25
27
  "title": 'Monthly Business Survey',
26
- "content": '<h3>Aim of this survey</h3>
28
+ "content": '<h2 class="ons-u-d-no@m">Monthly Business Survey</h2>
29
+ <h3>Aim of this survey</h3>
27
30
  <p class="ons-u-fs-r">The Monthly Business Survey (MBS) collects monthly information on employment of businesses in Great Britain. Your response contributes to Labour Market Statistics.</p>
28
31
  <h4>What you need to know</h4>
29
32
  <p class="ons-u-fs-r">To complete the survey, you will need the following information to answer the survey questions:</p>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ons/design-system",
3
3
  "description": "ONS Design System built CSS, JS, and Nunjucks templates",
4
- "version": "62.1.1",
4
+ "version": "62.2.1",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "author": {