@ons/design-system 61.0.1 → 61.0.3
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/components/access-code/_macro.njk +1 -1
- package/components/card/_card.scss +6 -0
- package/components/pagination/_macro.njk +18 -27
- package/components/pagination/_macro.spec.js +19 -24
- package/components/section-navigation/_macro.njk +1 -1
- package/components/section-navigation/_macro.spec.js +6 -0
- package/components/summary/_macro.njk +2 -2
- package/components/summary/_summary.scss +3 -12
- package/css/main.css +2 -2
- package/package.json +1 -1
- package/scss/base/_global.scss +1 -0
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
text-decoration-thickness: 3px;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
&__title {
|
|
9
|
+
// This is to allow the focus state for multi lined title links to render the focus style correctly.
|
|
10
|
+
// This should be corrected when the typography scale is improved.
|
|
11
|
+
line-height: 1.65 !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
@include mq(m) {
|
|
9
15
|
margin: 0;
|
|
10
16
|
.ons-grid__col & {
|
|
@@ -8,22 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
{% set totalPages = params.pages | length %}
|
|
10
10
|
{% set position = "Page " + currentPageIndex + " of " + totalPages %}
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
{% set middlePageCount = 5 %}
|
|
14
|
-
{% set middlePagesEachSide = (middlePageCount - 1) / 2 %}
|
|
15
|
-
|
|
16
|
-
{% if (currentPageIndex - middlePagesEachSide) <= 1 %}
|
|
17
|
-
{% set middlePagesStart = 1 %}
|
|
18
|
-
{% set middlePagesEnd = middlePageCount - 1 %}
|
|
19
|
-
{% elif (currentPageIndex + middlePagesEachSide) >= totalPages %}
|
|
20
|
-
{% set middlePagesStart = totalPages - middlePageCount + 1 %}
|
|
21
|
-
{% set middlePagesEnd = totalPages %}
|
|
22
|
-
{% else %}
|
|
23
|
-
{% set middlePagesStart = currentPageIndex - middlePagesEachSide %}
|
|
24
|
-
{% set middlePagesEnd = currentPageIndex + middlePagesEachSide %}
|
|
25
|
-
{% endif %}
|
|
26
|
-
|
|
11
|
+
{% set lastPage = params.pages | last %}
|
|
12
|
+
{% set firstPage = params.pages | first %}
|
|
27
13
|
|
|
28
14
|
<nav class="ons-pagination {{ params.classes }}{% if params.hideRangeIndicator %} ons-pagination--no-indicator{% endif %}" aria-label="Pagination ({{ position }})">
|
|
29
15
|
<div class="ons-pagination__position">{{ position }}</div>
|
|
@@ -34,17 +20,23 @@
|
|
|
34
20
|
<a href="{{ params.pages[prevPageIndex].url }}" class="ons-pagination__link" rel="prev" aria-label="Go to the previous page (Page {{ currentPageIndex - 1 }})">{{ params.previous }}</a>
|
|
35
21
|
</li>
|
|
36
22
|
{% endif %}
|
|
37
|
-
{% if currentPageIndex >
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</li>
|
|
23
|
+
{% if currentPageIndex > 2 %}
|
|
24
|
+
<li class="ons-pagination__item{% if firstPage.current == true %} ons-pagination__item--current{% endif %}">
|
|
25
|
+
<a href="{{ firstPage.url }}" class="ons-pagination__link" aria-label="Go to the first page (Page 1)">1</a>
|
|
26
|
+
</li>
|
|
42
27
|
{% endif %}
|
|
43
28
|
{% if currentPageIndex > 4 %}
|
|
44
29
|
<li class="ons-pagination__item ons-pagination__item--gap">…</li>
|
|
45
30
|
{% endif %}
|
|
46
31
|
{% for page in params.pages %}
|
|
47
|
-
{%
|
|
32
|
+
{% set showPage = false %}
|
|
33
|
+
{# Show the current, next and previous page
|
|
34
|
+
Show page 2 if the current page index is within the first 4 pages
|
|
35
|
+
Show the penultimate page if the current page index is within the last 4 pages #}
|
|
36
|
+
{% if (loop.index == currentPageIndex) or (loop.index == currentPageIndex + 1) or (loop.index == currentPageIndex - 1) or (loop.index == 2 and currentPageIndex <= 4) or ((loop.index == totalPages - 1) and (currentPageIndex > totalPages - 4)) %}
|
|
37
|
+
{% set showPage = true %}
|
|
38
|
+
{% endif %}
|
|
39
|
+
{% if showPage == true %}
|
|
48
40
|
<li class="ons-pagination__item{% if page.current == true %} ons-pagination__item--current{% endif %}">
|
|
49
41
|
<a href="{{ page.url }}" class="ons-pagination__link"
|
|
50
42
|
{%- if page.current -%}
|
|
@@ -65,11 +57,10 @@
|
|
|
65
57
|
{% if currentPageIndex < totalPages - 3 %}
|
|
66
58
|
<li class="ons-pagination__item ons-pagination__item--gap">…</li>
|
|
67
59
|
{% endif %}
|
|
68
|
-
{% if currentPageIndex < totalPages -
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</li>
|
|
60
|
+
{% if currentPageIndex < totalPages - 1 %}
|
|
61
|
+
<li class="ons-pagination__item{% if lastPage.current == true %} ons-pagination__item--current{% endif %}">
|
|
62
|
+
<a href="{{ lastPage.url }}" class="ons-pagination__link" aria-label="Go to the last page (Page {{ totalPages }})">{{ totalPages }}</a>
|
|
63
|
+
</li>
|
|
73
64
|
{% endif %}
|
|
74
65
|
{% if totalPages > 1 and totalPages != currentPageIndex %}
|
|
75
66
|
<li class="ons-pagination__item ons-pagination__item--next">
|
|
@@ -251,16 +251,15 @@ describe('macro: pagination', () => {
|
|
|
251
251
|
).toBe('Page 2 of 6');
|
|
252
252
|
});
|
|
253
253
|
|
|
254
|
-
it('has
|
|
255
|
-
expect($('li').length).toBe(
|
|
254
|
+
it('has 7 list items ("Previous page", "1", "2", "3", "...", "6", "Next page")', () => {
|
|
255
|
+
expect($('li').length).toBe(7);
|
|
256
256
|
assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Go to the previous page (Page 1)', 'Previous page');
|
|
257
257
|
assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to page 1', '1');
|
|
258
258
|
assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Current page (Page 2 of 6)', '2');
|
|
259
259
|
assertIsNextPage($('.ons-pagination__item:nth-child(4)'), '/page/3', 'Go to page 3', '3');
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
assertIsNextPage($('.ons-pagination__item:nth-child(8)'), '/page/3', 'Go to the next page (Page 3)', 'Next page');
|
|
260
|
+
assertIsGap($('.ons-pagination__item:nth-child(5)'));
|
|
261
|
+
assertIsOtherPage($('.ons-pagination__item:nth-child(6)'), '/page/6', 'Go to the last page (Page 6)', '6');
|
|
262
|
+
assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/3', 'Go to the next page (Page 3)', 'Next page');
|
|
264
263
|
});
|
|
265
264
|
});
|
|
266
265
|
|
|
@@ -301,19 +300,17 @@ describe('macro: pagination', () => {
|
|
|
301
300
|
).toBe('Page 5 of 11');
|
|
302
301
|
});
|
|
303
302
|
|
|
304
|
-
it('has a
|
|
305
|
-
expect($('li').length).toBe(
|
|
303
|
+
it('has a 9 list items ("Previous page", "1", "...", "4", "5", "6", "...", "11", "Next page")', () => {
|
|
304
|
+
expect($('li').length).toBe(9);
|
|
306
305
|
assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/4', 'Go to the previous page (Page 4)', 'Previous page');
|
|
307
306
|
assertIsOtherPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to the first page (Page 1)', '1');
|
|
308
307
|
assertIsGap($('.ons-pagination__item:nth-child(3)'));
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
assertIsOtherPage($('.ons-pagination__item:nth-child(8)'), '/page/
|
|
314
|
-
|
|
315
|
-
assertIsOtherPage($('.ons-pagination__item:nth-child(10)'), '/page/11', 'Go to the last page (Page 11)', '11');
|
|
316
|
-
assertIsNextPage($('.ons-pagination__item:nth-child(11)'), '/page/6', 'Go to the next page (Page 6)', 'Next page');
|
|
308
|
+
assertIsPreviousPage($('.ons-pagination__item:nth-child(4)'), '/page/4', 'Go to page 4', '4');
|
|
309
|
+
assertIsCurrentPage($('.ons-pagination__item:nth-child(5)'), '/page/5', 'Current page (Page 5 of 11)', '5');
|
|
310
|
+
assertIsNextPage($('.ons-pagination__item:nth-child(6)'), '/page/6', 'Go to page 6', '6');
|
|
311
|
+
assertIsGap($('.ons-pagination__item:nth-child(7)'));
|
|
312
|
+
assertIsOtherPage($('.ons-pagination__item:nth-child(8)'), '/page/11', 'Go to the last page (Page 11)', '11');
|
|
313
|
+
assertIsNextPage($('.ons-pagination__item:nth-child(9)'), '/page/6', 'Go to the next page (Page 6)', 'Next page');
|
|
317
314
|
});
|
|
318
315
|
});
|
|
319
316
|
|
|
@@ -354,17 +351,15 @@ describe('macro: pagination', () => {
|
|
|
354
351
|
).toBe('Page 10 of 11');
|
|
355
352
|
});
|
|
356
353
|
|
|
357
|
-
it('has a
|
|
358
|
-
expect($('li').length).toBe(
|
|
354
|
+
it('has a 7 list items ("Previous page", "1", "...", "9", "10", "11", "Next page")', () => {
|
|
355
|
+
expect($('li').length).toBe(7);
|
|
359
356
|
assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/9', 'Go to the previous page (Page 9)', 'Previous page');
|
|
360
357
|
assertIsOtherPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to the first page (Page 1)', '1');
|
|
361
358
|
assertIsGap($('.ons-pagination__item:nth-child(3)'));
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
assertIsNextPage($('.ons-pagination__item:nth-child(8)'), '/page/11', 'Go to page 11', '11');
|
|
367
|
-
assertIsNextPage($('.ons-pagination__item:nth-child(9)'), '/page/11', 'Go to the next page (Page 11)', 'Next page');
|
|
359
|
+
assertIsPreviousPage($('.ons-pagination__item:nth-child(4)'), '/page/9', 'Go to page 9', '9');
|
|
360
|
+
assertIsCurrentPage($('.ons-pagination__item:nth-child(5)'), '/page/10', 'Current page (Page 10 of 11)', '10');
|
|
361
|
+
assertIsNextPage($('.ons-pagination__item:nth-child(6)'), '/page/11', 'Go to page 11', '11');
|
|
362
|
+
assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/11', 'Go to the next page (Page 11)', 'Next page');
|
|
368
363
|
});
|
|
369
364
|
});
|
|
370
365
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% macro onsSectionNavigation(params) %}
|
|
2
|
-
<nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %}"{% if params.id %} id="{{ params.id }}"{% endif %} aria-label="{{ params.ariaLabel | default("Section menu") }}">
|
|
2
|
+
<nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %}{% if params.classes %} {{ params.classes }}{% endif %}"{% if params.id %} id="{{ params.id }}"{% endif %} aria-label="{{ params.ariaLabel | default("Section menu") }}">
|
|
3
3
|
<ul class="ons-section-nav__list">
|
|
4
4
|
{% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
|
|
5
5
|
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title|lower) %}
|
|
@@ -91,6 +91,12 @@ describe('macro: section-navigation', () => {
|
|
|
91
91
|
expect($('.ons-section-nav').attr('id')).toBe('section-menu');
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
+
it('has the provided custom `classes`', () => {
|
|
95
|
+
const $ = cheerio.load(renderComponent('section-navigation', { ...EXAMPLE_SECTION_NAVIGATION, classes: 'custom-class' }));
|
|
96
|
+
|
|
97
|
+
expect($('.ons-section-nav').hasClass('custom-class')).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
94
100
|
it('has the provided `ariaLabel` parameter', () => {
|
|
95
101
|
const $ = cheerio.load(
|
|
96
102
|
renderComponent('section-navigation', {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
{% for rowItem in row.rowItems %}
|
|
40
40
|
<dl class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}"{% if rowItem.id %} id="{{ rowItem.id }}"{% endif %}>
|
|
41
|
-
<dt class="ons-summary__item-title
|
|
41
|
+
<dt class="ons-summary__item-title"
|
|
42
42
|
{% if rowItem.rowTitleAttributes %}{% for attribute, value in (rowItem.rowTitleAttributes.items() if rowItem.rowTitleAttributes is mapping and rowItem.rowTitleAttributes.items else rowItem.rowTitleAttributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
|
|
43
43
|
>
|
|
44
44
|
{% if rowItem.iconType %}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
</dt>
|
|
64
64
|
{% if rowItem.valueList %}
|
|
65
65
|
<dd
|
|
66
|
-
class="ons-summary__values"
|
|
66
|
+
class="ons-summary__values{% if not rowItem.actions %} ons-summary__values--2{% endif %}"
|
|
67
67
|
{% if rowItem.attributes %}{% for attribute, value in (rowItem.attributes.items() if rowItem.attributes is mapping and rowItem.attributes.items else rowItem.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
|
|
68
68
|
>
|
|
69
69
|
{% if rowItem.valueList | length == 1 %}
|
|
@@ -178,7 +178,7 @@ $hub-row-spacing: 1.3rem;
|
|
|
178
178
|
&__item-title,
|
|
179
179
|
&__values,
|
|
180
180
|
&__actions {
|
|
181
|
-
flex:
|
|
181
|
+
flex: 5 1 33%;
|
|
182
182
|
padding-top: $summary-row-spacing;
|
|
183
183
|
vertical-align: top;
|
|
184
184
|
|
|
@@ -196,13 +196,8 @@ $hub-row-spacing: 1.3rem;
|
|
|
196
196
|
align-self: flex-start;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
&
|
|
200
|
-
|
|
201
|
-
flex: 7.3;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
&__item-title--2 {
|
|
205
|
-
flex: 4.5;
|
|
199
|
+
&__values--2 {
|
|
200
|
+
flex: 10.5 1 66%;
|
|
206
201
|
}
|
|
207
202
|
|
|
208
203
|
&--hub & {
|
|
@@ -211,10 +206,6 @@ $hub-row-spacing: 1.3rem;
|
|
|
211
206
|
&__actions {
|
|
212
207
|
padding-top: $hub-row-spacing;
|
|
213
208
|
}
|
|
214
|
-
|
|
215
|
-
&__actions {
|
|
216
|
-
flex: 6;
|
|
217
|
-
}
|
|
218
209
|
}
|
|
219
210
|
}
|
|
220
211
|
}
|