@ons/design-system 72.1.1 → 72.2.0

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.
@@ -10,6 +10,53 @@
10
10
  background-color: var(--ons-color-hero-bg-dark);
11
11
  }
12
12
 
13
+ &--navy-blue {
14
+ background-color: var(--ons-color-navy-blue);
15
+ &::before {
16
+ content: '';
17
+ background-color: var(--ons-color-navy-blue-light);
18
+ border-radius: 0 0 50% 50%;
19
+ inset: 0;
20
+ left: -40%;
21
+ position: absolute;
22
+ width: 150%;
23
+ @include mq(l) {
24
+ border-radius: 0 0 300% 150%;
25
+ left: 0;
26
+ width: 100%;
27
+ }
28
+ }
29
+ }
30
+
31
+ &--grey {
32
+ background-color: var(--ons-color-grey-10);
33
+ &::before {
34
+ content: '';
35
+ background-color: var(--ons-color-banner-bg);
36
+ border-radius: 0 0 50% 50%;
37
+ inset: 0;
38
+ left: -40%;
39
+ position: absolute;
40
+ width: 150%;
41
+ @include mq(l) {
42
+ border-radius: 0 0 300% 150%;
43
+ left: 0;
44
+ width: 100%;
45
+ }
46
+ }
47
+ }
48
+ &__badge {
49
+ @include mq(xs, l) {
50
+ margin-top: 2.5rem;
51
+ margin-bottom: 1rem;
52
+ }
53
+ }
54
+
55
+ &--topic {
56
+ color: var(--ons-color-branded);
57
+ @extend .ons-u-mb-no;
58
+ }
59
+
13
60
  &__container {
14
61
  align-items: center;
15
62
  display: flex;
@@ -25,10 +72,6 @@
25
72
  height: 100%;
26
73
  }
27
74
 
28
- &__text {
29
- padding-bottom: 1rem;
30
- }
31
-
32
75
  &__pre-title {
33
76
  margin-bottom: 0.5rem;
34
77
 
@@ -44,6 +87,10 @@
44
87
  z-index: 5;
45
88
  }
46
89
 
90
+ &__details:has(.ons-breadcrumbs) {
91
+ padding-top: 1rem;
92
+ }
93
+
47
94
  &--dark & {
48
95
  &__details {
49
96
  color: var(--ons-color-text-inverse) !important;
@@ -62,4 +109,235 @@
62
109
  }
63
110
  }
64
111
  }
112
+ &--navy-blue & {
113
+ &__details {
114
+ color: var(--ons-color-text-inverse);
115
+ padding: 2rem 0 6rem;
116
+ @include mq(l) {
117
+ padding: 4rem 0;
118
+ }
119
+ }
120
+
121
+ &__circle-1 {
122
+ @include mq(l) {
123
+ background-color: var(--ons-color-spring-green);
124
+ border-radius: 50%;
125
+ height: 59px;
126
+ position: absolute;
127
+ right: 289px;
128
+ top: -11px;
129
+ width: 59px;
130
+ }
131
+ }
132
+
133
+ &__circle-2 {
134
+ @include mq(l) {
135
+ background-color: var(--ons-color-white);
136
+ border-radius: 50%;
137
+ position: absolute;
138
+ height: 30px;
139
+ right: 193px;
140
+ top: 11px;
141
+ width: 30px;
142
+ }
143
+ }
144
+
145
+ &__circle-3 {
146
+ @include mq(l) {
147
+ height: 60px;
148
+ right: 112px;
149
+ top: 25px;
150
+ width: 60px;
151
+ background-color: var(--ons-color-white);
152
+ border-radius: 50%;
153
+ position: absolute;
154
+ }
155
+ }
156
+
157
+ &__circle-4 {
158
+ @include mq(l) {
159
+ background-color: var(--ons-color-white);
160
+ border-radius: 50%;
161
+ height: 60px;
162
+ position: absolute;
163
+ right: 208px;
164
+ top: 80px;
165
+ width: 60px;
166
+ }
167
+
168
+ &::before {
169
+ @include mq(l) {
170
+ background-color: var(--ons-color-ocean-blue);
171
+ border-radius: 50%;
172
+ content: '';
173
+ height: 100%;
174
+ left: 0;
175
+ opacity: 0.4;
176
+ position: absolute;
177
+ top: 0;
178
+ width: 100%;
179
+ }
180
+ }
181
+ }
182
+
183
+ &__circle-5 {
184
+ @include mq(l) {
185
+ background-color: var(--ons-color-white);
186
+ border-radius: 50%;
187
+ height: 14px;
188
+ position: absolute;
189
+ right: 222px;
190
+ top: 187px;
191
+ width: 14px;
192
+ }
193
+
194
+ &::before {
195
+ @include mq(l) {
196
+ background-color: var(--ons-color-sky-blue);
197
+ border-radius: 50%;
198
+ content: '';
199
+ height: 100%;
200
+ left: 0;
201
+ opacity: 0.7;
202
+ position: absolute;
203
+ top: 0;
204
+ width: 100%;
205
+ }
206
+ }
207
+ }
208
+
209
+ &__circle-6 {
210
+ @include mq(l) {
211
+ background-color: var(--ons-color-spring-green);
212
+ border-radius: 50%;
213
+ height: 15px;
214
+ position: absolute;
215
+ right: 135px;
216
+ top: 188px;
217
+ width: 15px;
218
+ }
219
+ }
220
+
221
+ &__circle-7 {
222
+ @include mq(l) {
223
+ background-color: var(--ons-color-white);
224
+ border-radius: 50%;
225
+ height: 60px;
226
+ position: absolute;
227
+ right: 24px;
228
+ bottom: 92px;
229
+ width: 60px;
230
+ }
231
+
232
+ &::before {
233
+ @include mq(l) {
234
+ background-color: var(--ons-color-night-blue);
235
+ border-radius: 50%;
236
+ content: '';
237
+ height: 100%;
238
+ left: 0;
239
+ opacity: 0.7;
240
+ position: absolute;
241
+ top: 0;
242
+ width: 100%;
243
+ }
244
+ }
245
+ }
246
+
247
+ &__circle-8 {
248
+ @include mq(l) {
249
+ background-color: var(--ons-color-white);
250
+ border-radius: 50%;
251
+ bottom: 70px;
252
+ height: 15px;
253
+ position: absolute;
254
+ right: 275px;
255
+ width: 15px;
256
+ }
257
+ }
258
+
259
+ &__circle-9 {
260
+ background-color: var(--ons-color-spring-green);
261
+ border-radius: 50%;
262
+ bottom: 28px;
263
+ position: absolute;
264
+ right: 15px;
265
+ width: 40px;
266
+ height: 40px;
267
+ @include mq(l) {
268
+ bottom: 40px;
269
+ height: 30px;
270
+ position: absolute;
271
+ right: 215px;
272
+ width: 30px;
273
+ }
274
+ }
275
+
276
+ &__circle-10 {
277
+ @include mq(l) {
278
+ background-color: var(--ons-color-white);
279
+ border-radius: 50%;
280
+ bottom: 63px;
281
+ height: 15px;
282
+ position: absolute;
283
+ right: 120px;
284
+ width: 15px;
285
+ }
286
+
287
+ &::before {
288
+ @include mq(l) {
289
+ background-color: var(--ons-color-aqua-teal);
290
+ border-radius: 50%;
291
+ content: '';
292
+ height: 100%;
293
+ left: 0;
294
+ opacity: 0.4;
295
+ position: absolute;
296
+ top: 0;
297
+ width: 100%;
298
+ }
299
+ }
300
+ }
301
+
302
+ &__circle-11 {
303
+ background-color: var(--ons-color-sky-blue);
304
+ border-radius: 50%;
305
+ height: 14px;
306
+ width: 14px;
307
+ position: absolute;
308
+ bottom: -7px;
309
+ right: 50px;
310
+ @include mq(l) {
311
+ bottom: 33px;
312
+ height: 30px;
313
+ position: absolute;
314
+ right: 75px;
315
+ width: 30px;
316
+ }
317
+ }
318
+
319
+ &__circle-12 {
320
+ @include mq(l) {
321
+ background-color: var(--ons-color-night-blue);
322
+ border-radius: 50%;
323
+ bottom: -35px;
324
+ height: 59px;
325
+ position: absolute;
326
+ right: 125px;
327
+ width: 59px;
328
+ }
329
+ }
330
+ }
331
+
332
+ &__title-container {
333
+ @include mq(l) {
334
+ display: grid;
335
+ align-items: start;
336
+ justify-content: space-between;
337
+
338
+ &.ons-hero__title-badge {
339
+ grid-template-columns: 1fr auto;
340
+ }
341
+ }
342
+ }
65
343
  }
@@ -6,18 +6,50 @@
6
6
  <section
7
7
  class="ons-hero ons-grid--gutterless{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-hero--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-hero--{{ params.variants }}{% endif %}"
8
8
  >
9
+ {% if params.variants == 'navy-blue' %}
10
+ <div class="ons-hero__circles" aria-hidden="true">
11
+ {% for i in range(1, 13) %}
12
+ <div class="ons-hero__circle-{{ i }}"></div>
13
+ {% endfor %}
14
+ </div>
15
+ {% endif %}
9
16
  <div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}">
10
17
  <div class="ons-hero__details ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
11
- <header>
12
- <h1 class="ons-hero__title ons-u-fs-3xl">{{ params.title }}</h1>
13
- {% if params.subtitle %}
14
- <h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
15
- {% endif %}
16
- </header>
17
-
18
- {% if params.text %}
19
- <p class="ons-hero__text">{{ params.text | safe }}</p>
18
+ {% if params.breadcrumbs %}
19
+ {% from "components/breadcrumbs/_macro.njk" import onsBreadcrumbs %}
20
+ {{
21
+ onsBreadcrumbs({
22
+ "itemsList": params.breadcrumbs.itemsList,
23
+ "ariaLabel": params.breadcrumbs.ariaLabel,
24
+ "id": params.breadcrumbs.id,
25
+ "classes": 'ons-u-pt-no' ~ (' ' + params.breadcrumbs.classes if params.breadcrumbs.classes else '')
26
+ })
27
+ }}
20
28
  {% endif %}
29
+ {% if params.topic %}
30
+ <h2 class="ons-hero--topic">{{ params.topic | safe }}</h2>
31
+ {% endif %}
32
+ <div class="ons-hero__title-container {% if params.officialStatisticsBadge %}ons-hero__title-badge{% endif %}">
33
+ <header>
34
+ <h1 class="ons-hero__title ons-u-fs-3xl">{{ params.title }}</h1>
35
+ {% if params.subtitle %}
36
+ <h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
37
+ {% endif %}
38
+ </header>
39
+ {% if params.officialStatisticsBadge == true %}
40
+ {% from "components/icon/_macro.njk" import onsIcon %}
41
+ <div class="ons-hero__badge">
42
+ {{-
43
+ onsIcon({
44
+ "iconType": 'official-statistics'
45
+ })
46
+ -}}
47
+ </div>
48
+ {% endif %}
49
+ {% if params.text %}
50
+ <p class="ons-hero__text">{{ params.text | safe }}</p>
51
+ {% endif %}
52
+ </div>
21
53
 
22
54
  {% if params.button %}
23
55
  {% from "components/button/_macro.njk" import onsButton %}
@@ -27,7 +59,7 @@
27
59
  {% endif %}
28
60
  {{
29
61
  onsButton({
30
- "classes": btnClasses,
62
+ "classes": 'ons-u-mt-s' + btnClasses,
31
63
  "type": 'button',
32
64
  "text": params.button.text,
33
65
  "url": params.button.url
@@ -37,7 +69,21 @@
37
69
  {% if caller %}
38
70
  <div class="ons-hero__additional-content">{{- caller() -}}</div>
39
71
  {% endif %}
72
+
73
+ {% if params.descriptionList %}
74
+ {% from "components/description-list/_macro.njk" import onsDescriptionList %}
75
+ {{
76
+ onsDescriptionList({
77
+ "classes": "ons-u-mb-no",
78
+ "variant": 'inline',
79
+ "termCol": params.descriptionList.termCol,
80
+ "descriptionCol": params.descriptionList.descriptionCol,
81
+ "itemsList": params.descriptionList.itemsList
82
+ })
83
+ }}
84
+ {% endif %}
40
85
  </div>
86
+
41
87
  {% if params.html %}
42
88
  <div class="ons-hero__additional-html">{{- params.html | safe -}}</div>
43
89
  {% endif %}
@@ -78,7 +78,7 @@ describe('macro: hero', () => {
78
78
 
79
79
  faker.renderComponent('hero', { ...EXAMPLE_HERO, variants: 'dark' });
80
80
 
81
- expect(buttonSpy.occurrences[0]).toHaveProperty('classes', ' ons-btn--ghost');
81
+ expect(buttonSpy.occurrences[0]).toHaveProperty('classes', 'ons-u-mt-s ons-btn--ghost');
82
82
  });
83
83
 
84
84
  it('calls with content', () => {
@@ -87,4 +87,92 @@ describe('macro: hero', () => {
87
87
  const content = $('.ons-hero__additional-content').text().trim();
88
88
  expect(content).toEqual(expect.stringContaining('Example content...'));
89
89
  });
90
+
91
+ it('renders circles when variant is `navy blue`', () => {
92
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'navy-blue' }));
93
+ expect($('.ons-hero--navy-blue .ons-hero__circles').length).toBe(1);
94
+ });
95
+
96
+ it('outputs the correct topic when set', () => {
97
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, topic: 'Topic Text' }));
98
+
99
+ const content = $('.ons-hero--topic').text().trim();
100
+ expect(content).toBe('Topic Text');
101
+ });
102
+
103
+ it('outputs the official statistics badge when officialStatisticsBadge is set to true', () => {
104
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, officialStatisticsBadge: true }));
105
+
106
+ expect($('.ons-hero__badge').length).toBe(1);
107
+ expect($('.ons-hero__badge svg title').text().trim()).toBe('Offical Statistics Badge');
108
+ });
109
+
110
+ it('renders curved gradient when variant is `grey`', () => {
111
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'grey' }));
112
+ expect($('.ons-hero--grey').length).toBe(1);
113
+ });
114
+
115
+ it('outputs the correct breadcrumbs', () => {
116
+ const $ = cheerio.load(
117
+ renderComponent('hero', {
118
+ ...EXAMPLE_HERO,
119
+ variants: 'grey',
120
+ breadcrumbs: {
121
+ ariaLabel: 'Breadcrumbs',
122
+ itemsList: [
123
+ {
124
+ url: '/breadcrumb-1',
125
+ text: 'Breadcrumbs 1',
126
+ },
127
+ {
128
+ url: '/breadcrumb-2',
129
+ text: 'Breadcrumbs 2',
130
+ },
131
+ ],
132
+ },
133
+ }),
134
+ );
135
+
136
+ const breadcrumbs = $('.ons-breadcrumbs__link');
137
+ expect($(breadcrumbs).length).toBe(2);
138
+ expect($(breadcrumbs[0]).attr('href')).toBe('/breadcrumb-1');
139
+ expect($(breadcrumbs[0]).text().trim()).toBe('Breadcrumbs 1');
140
+ expect($(breadcrumbs[1]).attr('href')).toBe('/breadcrumb-2');
141
+ expect($(breadcrumbs[1]).text().trim()).toBe('Breadcrumbs 2');
142
+ });
143
+
144
+ it('outputs the correct description list value', () => {
145
+ const $ = cheerio.load(
146
+ renderComponent('hero', {
147
+ ...EXAMPLE_HERO,
148
+ variants: 'grey',
149
+ descriptionList: {
150
+ termCol: '4',
151
+ descriptionCol: '8',
152
+ itemsList: [
153
+ {
154
+ term: 'term1:',
155
+ descriptions: [
156
+ {
157
+ description: 'description1',
158
+ },
159
+ ],
160
+ },
161
+ {
162
+ term: 'term2:',
163
+ descriptions: [
164
+ {
165
+ description: 'description2',
166
+ },
167
+ ],
168
+ },
169
+ ],
170
+ },
171
+ }),
172
+ );
173
+
174
+ const descriptionText = $('.ons-description-list__value');
175
+ expect($(descriptionText[0]).text().trim()).toBe('description1');
176
+ expect($(descriptionText[1]).text().trim()).toBe('description2');
177
+ });
90
178
  });
@@ -0,0 +1,78 @@
1
+ ---
2
+ 'fullWidth': true
3
+ ---
4
+
5
+ {% from "components/hero/_macro.njk" import onsHero %}
6
+ {{
7
+ onsHero({
8
+ "variants": 'grey',
9
+ "detailsColumns": '12',
10
+ "officialStatisticsBadge": true,
11
+ "topic": 'Statistical article',
12
+ "title": 'Retail sales rise amid summer discounts and sporting events, according to a first estimate',
13
+ "text": 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id mattis ligula, nec sollicitudin arcu. Donec non tristique tellus. Donec eget malesuada lorem.',
14
+ "breadcrumbs": {
15
+ "ariaLabel": 'Breadcrumbs',
16
+ "itemsList": [
17
+ {
18
+ "url": '/',
19
+ "text": 'Home'
20
+ },
21
+ {
22
+ "url": '/',
23
+ "text": 'Business, industry and trade'
24
+ },
25
+ {
26
+ "url": '/',
27
+ "text": 'Retail industry'
28
+ }
29
+ ]
30
+ },
31
+ "descriptionList": {
32
+ "termCol": "5",
33
+ "descriptionCol": "7",
34
+ "itemsList": [
35
+ {
36
+ "term": "Release date:",
37
+ "descriptions": [
38
+ {
39
+ "description": "16 August 2024"
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ "term": "Edition:",
45
+ "descriptions": [
46
+ {
47
+ "description": "Latest"
48
+ }
49
+ ]
50
+ },
51
+ {
52
+ "term": "Contact:",
53
+ "descriptions": [
54
+ {
55
+ "description": "Retail Sales team"
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ "term": "Next release:",
61
+ "descriptions": [
62
+ {
63
+ "description": "20 September 2024"
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "term": "Releases:",
69
+ "descriptions": [
70
+ {
71
+ "description": "View previous releases"
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ }
77
+ })
78
+ }}
@@ -0,0 +1,14 @@
1
+ ---
2
+ 'fullWidth': true
3
+ ---
4
+
5
+ {% from "components/hero/_macro.njk" import onsHero %}
6
+ {{
7
+ onsHero({
8
+ "title": 'Welcome to the ONS Beta',
9
+ "text": 'Thank you for participating in our beta test. This limited preview of the ONS website focuses on our
10
+ new design and navigation for the retail insutry section. Please be aware that greyed-out links indicate sections still under development.
11
+ The active links will take you through the journey to test the new design features.',
12
+ "variants": 'navy-blue'
13
+ })
14
+ }}