@ons/design-system 72.9.1 → 72.10.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.
- package/components/button/_button.scss +10 -0
- package/components/card/_macro.njk +3 -3
- package/components/card/_macro.spec.js +109 -252
- package/components/card/_test_examples.js +56 -0
- package/components/chart/_chart.scss +74 -1
- package/components/chart/_macro.njk +64 -5
- package/components/chart/_macro.spec.js +405 -0
- package/components/chart/bar-chart.js +2 -2
- package/components/chart/boxplot.js +37 -0
- package/components/chart/chart-constants.js +13 -0
- package/components/chart/chart.js +98 -50
- package/components/chart/columnrange-chart.js +94 -0
- package/components/chart/common-chart-options.js +28 -19
- package/components/chart/example-bar-chart-with-annotations.njk +1 -1
- package/components/chart/example-bar-chart-with-point-range-and-reference-line-annotations.njk +95 -0
- package/components/chart/example-bar-with-confidence-levels.njk +71 -0
- package/components/chart/example-clustered-column-chart.njk +1 -3
- package/components/chart/example-column-chart-with-annotations.njk +1 -1
- package/components/chart/example-column-chart-with-range-annotations.njk +64 -0
- package/components/chart/example-column-chart-with-reference-line-annotations.njk +64 -0
- package/components/chart/example-column-with-confidence-levels.njk +61 -0
- package/components/chart/example-line-chart-with-annotations.njk +3 -3
- package/components/chart/example-line-chart-with-markers.njk +1 -1
- package/components/chart/example-line-chart-with-range-annotations-inside.njk +238 -0
- package/components/chart/example-line-chart-with-range-annotations-outside-left-right.njk +240 -0
- package/components/chart/example-line-chart-with-range-annotations-outside-top-bottom.njk +239 -0
- package/components/chart/example-line-chart-with-reference-line-annotations.njk +236 -0
- package/components/chart/example-scatter-chart.njk +1 -1
- package/components/chart/range-annotations-options.js +216 -0
- package/components/chart/reference-line-annotations-options.js +93 -0
- package/components/chart/scatter-chart.js +15 -0
- package/components/chart/specific-chart-options.js +1 -1
- package/components/chart/utilities.js +96 -0
- package/components/details-panel/_macro.njk +5 -1
- package/components/details-panel/_macro.spec.js +22 -0
- package/components/document-list/_document-list.scss +5 -13
- package/components/document-list/_macro.njk +14 -17
- package/components/document-list/_macro.spec.js +3 -3
- package/components/fieldset/_macro.spec.js +200 -120
- package/components/fieldset/_test_examples.js +15 -0
- package/components/header/_header.scss +11 -0
- package/components/header/_macro.njk +11 -6
- package/components/header/_macro.spec.js +113 -3
- package/components/hero/_macro.spec.js +1 -1
- package/components/icon/_macro.njk +14 -24
- package/components/language-selector/_macro.njk +6 -3
- package/components/navigation/navigation.js +57 -58
- package/components/navigation/navigation.spec.js +6 -10
- package/components/summary/_macro.njk +4 -1
- package/components/table-of-contents/_macro.njk +1 -1
- package/components/table-of-contents/_macro.spec.js +7 -0
- package/components/table-of-contents/table-of-contents.js +43 -26
- package/css/main.css +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Utility function to merge two configs together
|
|
2
|
+
export const mergeConfigs = (baseConfig, newConfig) => {
|
|
3
|
+
// If newConfig is null/undefined, return baseConfig
|
|
4
|
+
if (!newConfig) return baseConfig;
|
|
5
|
+
|
|
6
|
+
// Create a new object to store the merged result
|
|
7
|
+
const merged = { ...baseConfig };
|
|
8
|
+
|
|
9
|
+
// Iterate through all keys in newConfig
|
|
10
|
+
Object.keys(newConfig).forEach((key) => {
|
|
11
|
+
// Get values from both configs for this key
|
|
12
|
+
const baseValue = merged[key];
|
|
13
|
+
const newValue = newConfig[key];
|
|
14
|
+
|
|
15
|
+
// If both values are objects (and not null), recursively merge them
|
|
16
|
+
if (
|
|
17
|
+
baseValue &&
|
|
18
|
+
newValue &&
|
|
19
|
+
typeof baseValue === 'object' &&
|
|
20
|
+
typeof newValue === 'object' &&
|
|
21
|
+
!Array.isArray(baseValue) &&
|
|
22
|
+
!Array.isArray(newValue)
|
|
23
|
+
) {
|
|
24
|
+
merged[key] = mergeConfigs(baseValue, newValue);
|
|
25
|
+
} else {
|
|
26
|
+
// For non-objects and arrays use the new value
|
|
27
|
+
// If the new value is null/undefined, use the base value
|
|
28
|
+
merged[key] = newValue ?? baseValue;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return merged;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Helper function to process the range and reference line annotations plus any plot lines config
|
|
36
|
+
// ready to pass to the responsive rules
|
|
37
|
+
export const preparePlotLinesAndBands = (
|
|
38
|
+
annotations = undefined,
|
|
39
|
+
rangeAnnotations = undefined,
|
|
40
|
+
rangeAnnotationsOptions = undefined,
|
|
41
|
+
referenceLineAnnotationsOptions = undefined,
|
|
42
|
+
commonChartOptions,
|
|
43
|
+
chartType,
|
|
44
|
+
) => {
|
|
45
|
+
const totalPointAndRangeAnnotations = (annotations ? annotations.length : 0) + (rangeAnnotations ? rangeAnnotations.length : 0);
|
|
46
|
+
|
|
47
|
+
// Both range and reference line annotations are added to the axis objects, so we need to correctly combine them before we can pass them to the config.
|
|
48
|
+
let desktopRangeAnnotations = {};
|
|
49
|
+
let mobileRangeAnnotations = {};
|
|
50
|
+
let desktopReferenceLineAnnotations = {};
|
|
51
|
+
let mobileReferenceLineAnnotations = {};
|
|
52
|
+
let desktopAllPlotLines = {};
|
|
53
|
+
let mobileAllPlotLines = {};
|
|
54
|
+
let desktopAllPlotLinesAndBands = {};
|
|
55
|
+
let mobileAllPlotLinesAndBands = {};
|
|
56
|
+
|
|
57
|
+
// get the desktop and mobile range annotations
|
|
58
|
+
if (rangeAnnotationsOptions) {
|
|
59
|
+
desktopRangeAnnotations = rangeAnnotationsOptions.getRangeAnnotationsOptionsDesktop(chartType);
|
|
60
|
+
mobileRangeAnnotations = rangeAnnotationsOptions.getRangeAnnotationsOptionsMobile(annotations ? annotations.length : 0, chartType);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// get the desktop and mobile reference line annotations
|
|
64
|
+
if (referenceLineAnnotationsOptions) {
|
|
65
|
+
desktopReferenceLineAnnotations = referenceLineAnnotationsOptions.getReferenceLineAnnotationsOptionsDesktop();
|
|
66
|
+
mobileReferenceLineAnnotations = referenceLineAnnotationsOptions.getReferenceLineAnnotationsOptionsMobile(
|
|
67
|
+
totalPointAndRangeAnnotations,
|
|
68
|
+
chartType,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// We also need to combine the zero line (and any future plot lines) with the reference line annotations here, as otherwise
|
|
73
|
+
// it gets overridden by the reference line annotations config
|
|
74
|
+
let plotLineOptions = commonChartOptions.getPlotLines();
|
|
75
|
+
|
|
76
|
+
if (desktopReferenceLineAnnotations.yAxis !== undefined) {
|
|
77
|
+
let desktopMergedPlotLines = desktopReferenceLineAnnotations.yAxis.plotLines.concat(plotLineOptions.yAxis.plotLines);
|
|
78
|
+
let mobileMergedPlotLines = mobileReferenceLineAnnotations.yAxis.plotLines.concat(plotLineOptions.yAxis.plotLines);
|
|
79
|
+
desktopAllPlotLines = { ...desktopReferenceLineAnnotations };
|
|
80
|
+
mobileAllPlotLines = { ...mobileReferenceLineAnnotations };
|
|
81
|
+
desktopAllPlotLines.yAxis.plotLines = desktopMergedPlotLines;
|
|
82
|
+
mobileAllPlotLines.yAxis.plotLines = mobileMergedPlotLines;
|
|
83
|
+
} else {
|
|
84
|
+
desktopAllPlotLines = { ...plotLineOptions };
|
|
85
|
+
mobileAllPlotLines = { ...plotLineOptions };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// combine the desktop and mobile range and reference line annotations, along with other plot lines, ready to pass to the config
|
|
89
|
+
desktopAllPlotLinesAndBands = mergeConfigs(desktopRangeAnnotations, desktopAllPlotLines);
|
|
90
|
+
mobileAllPlotLinesAndBands = mergeConfigs(mobileRangeAnnotations, mobileAllPlotLines);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
desktopAllPlotLinesAndBands,
|
|
94
|
+
mobileAllPlotLinesAndBands,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
<div class="ons-container ons-details-panel__banner-contents">
|
|
5
5
|
<span class="ons-details-panel__info-icon ons-u-mr-2xs" aria-hidden="true">i</span>
|
|
6
6
|
<div class="ons-details-panel__banner-body">
|
|
7
|
-
|
|
7
|
+
{% set titleTag = params.headingLevel | default(2) %}
|
|
8
|
+
{% set openingTag = "<h" ~ titleTag %}
|
|
9
|
+
{% set closingTag = "</h" ~ titleTag ~ ">" %}
|
|
10
|
+
{{ openingTag | safe }}
|
|
11
|
+
class="ons-details-panel__banner-title ons-u-fs-m ons-u-mb-2xs">{{ params.title }}{{ closingTag | safe }}
|
|
8
12
|
<div class="ons-details-panel__banner-detail ons-js-details-heading">
|
|
9
13
|
<span class="ons-details-panel__banner-detail-title ons-js-corrections-details-title ons-u-mr-3xs"
|
|
10
14
|
>Show detail</span
|
|
@@ -15,6 +15,28 @@ describe('FOR: Macro: Details Panel', () => {
|
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
describe('GIVEN: Params: headingLevel', () => {
|
|
19
|
+
describe('WHEN: headingLevel is provided', () => {
|
|
20
|
+
const customParams = {
|
|
21
|
+
...EXAMPLE_DETAILS_PANEL,
|
|
22
|
+
headingLevel: 3,
|
|
23
|
+
};
|
|
24
|
+
const $ = cheerio.load(renderComponent('details-panel', customParams));
|
|
25
|
+
test('THEN: banner title uses the correct heading level', () => {
|
|
26
|
+
const bannerTitle = $('.ons-details-panel__banner-title');
|
|
27
|
+
expect(bannerTitle.prop('tagName')).toBe('H3');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('WHEN: headingLevel is not provided', () => {
|
|
32
|
+
const $ = cheerio.load(renderComponent('details-panel', EXAMPLE_DETAILS_PANEL));
|
|
33
|
+
test('THEN: banner title uses default heading level (h2)', () => {
|
|
34
|
+
const bannerTitle = $('.ons-details-panel__banner-title');
|
|
35
|
+
expect(bannerTitle.prop('tagName')).toBe('H2');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
18
40
|
describe('GIVEN: Params: detailsItems', () => {
|
|
19
41
|
describe('WHEN: detailsItems is provided', () => {
|
|
20
42
|
const $ = cheerio.load(renderComponent('details-panel', EXAMPLE_DETAILS_PANEL));
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
.ons-document-list__item-image {
|
|
41
41
|
width: 248px;
|
|
42
42
|
|
|
43
|
-
& &__image
|
|
43
|
+
& &__image {
|
|
44
44
|
&--placeholder {
|
|
45
45
|
height: 96px;
|
|
46
46
|
}
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
margin-right: 2.5rem;
|
|
51
51
|
width: 379px;
|
|
52
52
|
|
|
53
|
-
& &__image
|
|
53
|
+
& &__image {
|
|
54
54
|
&--placeholder {
|
|
55
55
|
height: 248px;
|
|
56
56
|
}
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
&__item-image & {
|
|
103
|
-
&__image
|
|
103
|
+
&__image {
|
|
104
104
|
&--placeholder {
|
|
105
105
|
height: 96px;
|
|
106
106
|
}
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
&__item-image--file & {
|
|
115
|
-
&__image
|
|
115
|
+
&__image {
|
|
116
116
|
border-color: var(--ons-color-borders);
|
|
117
117
|
|
|
118
118
|
&--placeholder {
|
|
@@ -121,20 +121,12 @@
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
&__image
|
|
124
|
+
&__image {
|
|
125
125
|
border: 2px solid transparent;
|
|
126
126
|
box-sizing: content-box;
|
|
127
127
|
display: block;
|
|
128
128
|
width: 100%;
|
|
129
129
|
|
|
130
|
-
&:focus {
|
|
131
|
-
background-color: var(--ons-color-placeholder) !important;
|
|
132
|
-
border: 2px solid var(--ons-color-borders-document-image-focus);
|
|
133
|
-
box-shadow: none;
|
|
134
|
-
outline: 4px solid var(--ons-color-focus) !important;
|
|
135
|
-
outline-offset: 0 !important;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
130
|
&--placeholder {
|
|
139
131
|
background-clip: padding-box;
|
|
140
132
|
background-color: var(--ons-color-placeholder);
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
{% macro onsDocumentList(params) %}
|
|
2
|
+
{% set titleTag = params.headingLevel | default(2) %}
|
|
3
|
+
{% set openingTag = "<h" ~ titleTag %}
|
|
4
|
+
{% set closingTag = "</h" ~ titleTag ~ ">" %}
|
|
2
5
|
<ul
|
|
3
6
|
{% if params.id %}id="{{ params.id }}"{% endif %}class="ons-document-list{{ ' ' + params.classes if params.classes else '' }}"
|
|
4
7
|
{% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ ' ' }}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
|
|
5
8
|
>
|
|
6
9
|
{% for document in params.documents %}
|
|
7
|
-
{% set titleTag = params.headingLevel | default(2) %}
|
|
8
|
-
{% set openingTag = "<h" ~ titleTag %}
|
|
9
|
-
{% set closingTag = "</h" ~ titleTag ~ ">" %}
|
|
10
10
|
{% set documentItem %}
|
|
11
11
|
{% if document.thumbnail %}
|
|
12
12
|
<div
|
|
13
13
|
class="ons-document-list__item-image{{ ' ons-document-list__item-image--file' if document.metadata.file }}"
|
|
14
14
|
aria-hidden="true"
|
|
15
15
|
>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/>
|
|
28
|
-
{% endif %}
|
|
29
|
-
</a>
|
|
16
|
+
{% if document.thumbnail.smallSrc and document.thumbnail.largeSrc %}
|
|
17
|
+
<img
|
|
18
|
+
class="ons-document-list__image"
|
|
19
|
+
srcset="{{ document.thumbnail.smallSrc }} 1x, {{ document.thumbnail.largeSrc }} 2x"
|
|
20
|
+
src="{{ document.thumbnail.smallSrc }}"
|
|
21
|
+
alt=""
|
|
22
|
+
loading="lazy"
|
|
23
|
+
/>
|
|
24
|
+
{% else %}
|
|
25
|
+
<span class="ons-document-list__image ons-document-list__image--placeholder"> </span>
|
|
26
|
+
{% endif %}
|
|
30
27
|
</div>
|
|
31
28
|
{% endif %}
|
|
32
29
|
|
|
@@ -232,12 +232,12 @@ describe('FOR: Macro: Document list', () => {
|
|
|
232
232
|
});
|
|
233
233
|
|
|
234
234
|
test('THEN: has expected srcset attribute', () => {
|
|
235
|
-
const srcset = $('.ons-document-list__image
|
|
235
|
+
const srcset = $('.ons-document-list__image').attr('srcset');
|
|
236
236
|
expect(srcset).toBe('/example-small.png 1x, /example-large.png 2x');
|
|
237
237
|
});
|
|
238
238
|
|
|
239
239
|
test('THEN: has expected src attribute', () => {
|
|
240
|
-
const src = $('.ons-document-list__image
|
|
240
|
+
const src = $('.ons-document-list__image').attr('src');
|
|
241
241
|
expect(src).toBe('/example-small.png');
|
|
242
242
|
});
|
|
243
243
|
});
|
|
@@ -249,7 +249,7 @@ describe('FOR: Macro: Document list', () => {
|
|
|
249
249
|
documents: [{ ...EXAMPLE_DOCUMENT_LIST_BASIC, thumbnail: true }],
|
|
250
250
|
}),
|
|
251
251
|
);
|
|
252
|
-
expect($('.ons-document-list__image
|
|
252
|
+
expect($('.ons-document-list__image').hasClass('ons-document-list__image--placeholder')).toBe(true);
|
|
253
253
|
});
|
|
254
254
|
});
|
|
255
255
|
});
|