@nationalarchives/frontend 0.1.41 → 0.1.42
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/nationalarchives/all.css +1 -1
- package/nationalarchives/all.css.map +1 -1
- package/nationalarchives/all.js +1 -1
- package/nationalarchives/all.js.map +1 -1
- package/nationalarchives/all.mjs +18 -0
- package/nationalarchives/analytics.js +2 -0
- package/nationalarchives/analytics.js.map +1 -0
- package/nationalarchives/analytics.mjs +238 -0
- package/nationalarchives/components/_index.scss +3 -1
- package/nationalarchives/components/breadcrumbs/analytics.js +17 -0
- package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +3 -1
- package/nationalarchives/components/breadcrumbs/fixtures.json +69 -6
- package/nationalarchives/components/breadcrumbs/macro-options.json +12 -6
- package/nationalarchives/components/breadcrumbs/template.njk +11 -4
- package/nationalarchives/components/button/_index.scss +1 -0
- package/nationalarchives/components/button/button.css +1 -1
- package/nationalarchives/components/button/button.css.map +1 -1
- package/nationalarchives/components/button/button.scss +2 -1
- package/nationalarchives/components/button/fixtures.json +5 -10
- package/nationalarchives/components/button/template.njk +2 -2
- package/nationalarchives/components/card/card.css.map +1 -1
- package/nationalarchives/components/card/fixtures.json +17 -34
- package/nationalarchives/components/checkboxes/analytics.js +25 -0
- package/nationalarchives/components/checkboxes/checkboxes.css +1 -1
- package/nationalarchives/components/checkboxes/checkboxes.css.map +1 -1
- package/nationalarchives/components/checkboxes/checkboxes.njk +12 -0
- package/nationalarchives/components/checkboxes/checkboxes.scss +1 -0
- package/nationalarchives/components/checkboxes/fixtures.json +6 -12
- package/nationalarchives/components/checkboxes/template.njk +10 -7
- package/nationalarchives/components/compound-filters/compound-filters.css +1 -1
- package/nationalarchives/components/compound-filters/compound-filters.css.map +1 -1
- package/nationalarchives/components/compound-filters/compound-filters.scss +2 -0
- package/nationalarchives/components/compound-filters/fixtures.json +1 -2
- package/nationalarchives/components/compound-filters/template.njk +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.css.map +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.js +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.js.map +1 -1
- package/nationalarchives/components/cookie-banner/fixtures.json +10 -20
- package/nationalarchives/components/date-input/date-input.css +1 -1
- package/nationalarchives/components/date-input/date-input.css.map +1 -1
- package/nationalarchives/components/date-input/fixtures.json +5 -10
- package/nationalarchives/components/date-input/template.njk +9 -9
- package/nationalarchives/components/date-search/date-search.css +1 -1
- package/nationalarchives/components/date-search/date-search.css.map +1 -1
- package/nationalarchives/components/date-search/date-search.njk +7 -0
- package/nationalarchives/components/date-search/fixtures.json +6 -12
- package/nationalarchives/components/date-search/template.njk +6 -7
- package/nationalarchives/components/error-summary/_index.scss +1 -0
- package/nationalarchives/components/error-summary/error-summary.css +1 -0
- package/nationalarchives/components/error-summary/error-summary.css.map +1 -0
- package/nationalarchives/components/error-summary/error-summary.js +2 -0
- package/nationalarchives/components/error-summary/error-summary.js.map +1 -0
- package/nationalarchives/components/error-summary/error-summary.mjs +51 -0
- package/nationalarchives/components/error-summary/error-summary.scss +39 -0
- package/nationalarchives/components/error-summary/error-summary.stories.js +59 -0
- package/nationalarchives/components/error-summary/fixtures.json +24 -0
- package/nationalarchives/components/error-summary/macro-options.json +52 -0
- package/nationalarchives/components/error-summary/macro.njk +3 -0
- package/nationalarchives/components/error-summary/template.njk +15 -0
- package/nationalarchives/components/featured-records/featured-records.css.map +1 -1
- package/nationalarchives/components/featured-records/fixtures.json +2 -4
- package/nationalarchives/components/footer/fixtures.json +2 -4
- package/nationalarchives/components/footer/footer.css.map +1 -1
- package/nationalarchives/components/gallery/gallery.css.map +1 -1
- package/nationalarchives/components/global-header/analytics.js +23 -0
- package/nationalarchives/components/global-header/fixtures.json +1 -2
- package/nationalarchives/components/global-header/global-header.css +1 -1
- package/nationalarchives/components/global-header/global-header.css.map +1 -1
- package/nationalarchives/components/global-header/global-header.stories.js +32 -20
- package/nationalarchives/components/grid/fixtures.json +13 -26
- package/nationalarchives/components/header/analytics.js +23 -0
- package/nationalarchives/components/header/fixtures.json +1 -2
- package/nationalarchives/components/header/header.css.map +1 -1
- package/nationalarchives/components/hero/analytics.js +26 -0
- package/nationalarchives/components/hero/fixtures.json +12 -24
- package/nationalarchives/components/hero/hero.css.map +1 -1
- package/nationalarchives/components/index-grid/fixtures.json +8 -16
- package/nationalarchives/components/index-grid/index-grid.css +1 -1
- package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
- package/nationalarchives/components/message/fixtures.json +1 -2
- package/nationalarchives/components/message/message.css.map +1 -1
- package/nationalarchives/components/message/phase-banner.stories.js +1 -1
- package/nationalarchives/components/pagination/fixtures.json +1 -2
- package/nationalarchives/components/phase-banner/fixtures.json +4 -8
- package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
- package/nationalarchives/components/picture/analytics.js +34 -0
- package/nationalarchives/components/picture/fixtures.json +5 -10
- package/nationalarchives/components/picture/picture.css.map +1 -1
- package/nationalarchives/components/quick-filters/_index.scss +1 -0
- package/nationalarchives/components/quick-filters/fixtures.json +51 -0
- package/nationalarchives/components/{filters → quick-filters}/macro-options.json +2 -2
- package/nationalarchives/components/quick-filters/macro.njk +3 -0
- package/nationalarchives/components/quick-filters/quick-filters.css +1 -0
- package/nationalarchives/components/quick-filters/quick-filters.css.map +1 -0
- package/nationalarchives/components/{filters/filters.scss → quick-filters/quick-filters.scss} +10 -8
- package/nationalarchives/components/{filters/filters.stories.js → quick-filters/quick-filters.stories.js} +2 -2
- package/nationalarchives/components/quick-filters/template.njk +8 -0
- package/nationalarchives/components/radios/analytics.js +25 -0
- package/nationalarchives/components/radios/fixtures.json +6 -12
- package/nationalarchives/components/radios/radios.css +1 -1
- package/nationalarchives/components/radios/radios.css.map +1 -1
- package/nationalarchives/components/radios/radios.njk +12 -0
- package/nationalarchives/components/radios/template.njk +6 -13
- package/nationalarchives/components/search-field/analytics.js +22 -0
- package/nationalarchives/components/search-field/fixtures.json +3 -6
- package/nationalarchives/components/search-field/search-field.css +1 -1
- package/nationalarchives/components/search-field/search-field.css.map +1 -1
- package/nationalarchives/components/search-field/search-field.scss +7 -2
- package/nationalarchives/components/search-field/template.njk +4 -4
- package/nationalarchives/components/search-filters/_index.scss +1 -0
- package/nationalarchives/components/search-filters/fixtures.json +16 -0
- package/nationalarchives/components/search-filters/macro-options.json +39 -0
- package/nationalarchives/components/search-filters/macro.njk +3 -0
- package/nationalarchives/components/search-filters/search-filters.css +1 -0
- package/nationalarchives/components/search-filters/search-filters.css.map +1 -0
- package/nationalarchives/components/search-filters/search-filters.js +2 -0
- package/nationalarchives/components/search-filters/search-filters.js.map +1 -0
- package/nationalarchives/components/search-filters/search-filters.mjs +67 -0
- package/nationalarchives/components/search-filters/search-filters.scss +163 -0
- package/nationalarchives/components/search-filters/search-filters.stories.js +207 -0
- package/nationalarchives/components/search-filters/template.njk +107 -0
- package/nationalarchives/components/select/fixtures.json +6 -12
- package/nationalarchives/components/select/select.css +1 -1
- package/nationalarchives/components/select/select.css.map +1 -1
- package/nationalarchives/components/select/select.scss +1 -1
- package/nationalarchives/components/select/template.njk +4 -4
- package/nationalarchives/components/sensitive-image/fixtures.json +3 -6
- package/nationalarchives/components/skip-link/fixtures.json +1 -2
- package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
- package/nationalarchives/components/tabs/fixtures.json +1 -2
- package/nationalarchives/components/tabs/tabs.css.map +1 -1
- package/nationalarchives/components/text-input/analytics.js +23 -0
- package/nationalarchives/components/text-input/fixtures.json +6 -12
- package/nationalarchives/components/text-input/template.njk +6 -10
- package/nationalarchives/components/text-input/text-input.css +1 -1
- package/nationalarchives/components/text-input/text-input.css.map +1 -1
- package/nationalarchives/components/text-input/text-input.njk +10 -0
- package/nationalarchives/components/text-input/text-input.scss +1 -1
- package/nationalarchives/components/textarea/analytics.js +23 -0
- package/nationalarchives/components/textarea/fixtures.json +6 -12
- package/nationalarchives/components/textarea/template.njk +5 -5
- package/nationalarchives/components/textarea/textarea.css +1 -1
- package/nationalarchives/components/textarea/textarea.css.map +1 -1
- package/nationalarchives/components/textarea/textarea.scss +1 -1
- package/nationalarchives/global-header-package.css +1 -1
- package/nationalarchives/global-header-package.css.map +1 -1
- package/nationalarchives/lib/analytics-helpers.mjs +63 -0
- package/nationalarchives/lib/cookies.mjs +59 -35
- package/nationalarchives/prototype-kit.css +1 -1
- package/nationalarchives/prototype-kit.css.map +1 -1
- package/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js +28 -6
- package/nationalarchives/stories/utilities/forms/forms.mdx +6 -6
- package/nationalarchives/tests/analytics.test.js +11 -0
- package/nationalarchives/tests/cookies.test.js +21 -0
- package/nationalarchives/tests/uuid.test.js +0 -6
- package/nationalarchives/tools/_a11y.scss +2 -2
- package/nationalarchives/tools/_colour.scss +23 -14
- package/nationalarchives/utilities/_forms.scss +6 -0
- package/nationalarchives/utilities/_typography.scss +2 -0
- package/nationalarchives/variables/_colour.scss +2 -0
- package/nationalarchives/variables/_forms.scss +1 -1
- package/package.json +2 -2
- package/nationalarchives/components/filters/_index.scss +0 -1
- package/nationalarchives/components/filters/filters.css +0 -1
- package/nationalarchives/components/filters/filters.css.map +0 -1
- package/nationalarchives/components/filters/fixtures.json +0 -51
- package/nationalarchives/components/filters/macro.njk +0 -3
- package/nationalarchives/components/filters/template.njk +0 -8
@@ -0,0 +1,67 @@
|
|
1
|
+
export class SearchFilters {
|
2
|
+
constructor($module) {
|
3
|
+
this.$module = $module;
|
4
|
+
|
5
|
+
if (!this.$module) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
|
9
|
+
this.$module.classList.add("tna-search-filters--js-enabled");
|
10
|
+
|
11
|
+
Array.from(
|
12
|
+
this.$module.querySelectorAll(".tna-search-filters__fieldset"),
|
13
|
+
).forEach(($fieldset) => {
|
14
|
+
// const type = $fieldset.dataset.type;
|
15
|
+
const $toggle = $fieldset.querySelector(
|
16
|
+
".tna-search-filters__item-toggle",
|
17
|
+
);
|
18
|
+
const $headingInner = $fieldset.querySelector(
|
19
|
+
".tna-search-filters__heading-inner",
|
20
|
+
);
|
21
|
+
const $item = $fieldset.querySelector(".tna-search-filters__item");
|
22
|
+
|
23
|
+
if (!$toggle || !$headingInner || !$item) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
|
27
|
+
$toggle.removeAttribute("hidden");
|
28
|
+
$headingInner.remove();
|
29
|
+
|
30
|
+
this.syncItem($toggle, $item);
|
31
|
+
|
32
|
+
$toggle.addEventListener("click", () => {
|
33
|
+
this.toggleItem($toggle, $item);
|
34
|
+
});
|
35
|
+
|
36
|
+
// if (type === "multiple") {
|
37
|
+
// const $count = $toggle.querySelector(
|
38
|
+
// ".tna-search-filters__item-toggle-info",
|
39
|
+
// );
|
40
|
+
// if ($count) {
|
41
|
+
// $item.addEventListener("change", () => {
|
42
|
+
// const selected = Array.from(
|
43
|
+
// $item.querySelectorAll('input[type="checkbox"]:checked'),
|
44
|
+
// ).length;
|
45
|
+
// $count.innerText = selected ? `(${selected} selected)` : "";
|
46
|
+
// });
|
47
|
+
// }
|
48
|
+
// }
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
toggleItem($toggle, $item) {
|
53
|
+
$toggle.setAttribute(
|
54
|
+
"aria-expanded",
|
55
|
+
$toggle.getAttribute("aria-expanded") == "false",
|
56
|
+
);
|
57
|
+
this.syncItem($toggle, $item);
|
58
|
+
}
|
59
|
+
|
60
|
+
syncItem($toggle, $item) {
|
61
|
+
if ($toggle.getAttribute("aria-expanded") == "true") {
|
62
|
+
$item.removeAttribute("hidden");
|
63
|
+
} else {
|
64
|
+
$item.setAttribute("hidden", true);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
@@ -0,0 +1,163 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
3
|
+
@use "../../tools/colour";
|
4
|
+
@use "../../tools/media";
|
5
|
+
@use "../../tools/spacing";
|
6
|
+
@use "../../tools/typography";
|
7
|
+
|
8
|
+
.tna-search-filters {
|
9
|
+
@include spacing.space-above;
|
10
|
+
|
11
|
+
&__title {
|
12
|
+
}
|
13
|
+
|
14
|
+
&__update {
|
15
|
+
display: block;
|
16
|
+
}
|
17
|
+
|
18
|
+
.tna-heading-s {
|
19
|
+
margin: 0;
|
20
|
+
padding: 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
&__fieldset {
|
24
|
+
border: none;
|
25
|
+
}
|
26
|
+
|
27
|
+
&__legend {
|
28
|
+
width: 100%;
|
29
|
+
}
|
30
|
+
|
31
|
+
&__heading-inner,
|
32
|
+
&__item-toggle {
|
33
|
+
padding: 0.5rem 0.75rem;
|
34
|
+
|
35
|
+
@include colour.colour-border("keyline", 1px, solid);
|
36
|
+
border-bottom-width: 0;
|
37
|
+
}
|
38
|
+
|
39
|
+
&__heading-inner {
|
40
|
+
margin-top: 1rem;
|
41
|
+
padding: 0.5rem 0.75rem;
|
42
|
+
}
|
43
|
+
|
44
|
+
&__item-toggle {
|
45
|
+
width: 100%;
|
46
|
+
margin: 0;
|
47
|
+
padding-right: 2.5rem;
|
48
|
+
|
49
|
+
display: block;
|
50
|
+
|
51
|
+
position: relative;
|
52
|
+
|
53
|
+
color: inherit;
|
54
|
+
font-family: inherit;
|
55
|
+
font-size: inherit;
|
56
|
+
font-weight: inherit;
|
57
|
+
line-height: inherit;
|
58
|
+
text-align: inherit;
|
59
|
+
|
60
|
+
background: none;
|
61
|
+
|
62
|
+
cursor: pointer;
|
63
|
+
|
64
|
+
&::before {
|
65
|
+
width: 0;
|
66
|
+
height: 0;
|
67
|
+
|
68
|
+
position: absolute;
|
69
|
+
right: 0.5rem;
|
70
|
+
top: calc(50% - #{math.div(math.sqrt(3), 4)}rem);
|
71
|
+
|
72
|
+
@include colour.colour-border(
|
73
|
+
"font-base",
|
74
|
+
#{math.div(math.sqrt(3), 2)}rem
|
75
|
+
);
|
76
|
+
border-right: 0.5rem transparent solid;
|
77
|
+
border-bottom-width: 0;
|
78
|
+
border-left: 0.5rem transparent solid;
|
79
|
+
|
80
|
+
content: "";
|
81
|
+
}
|
82
|
+
|
83
|
+
&:hover,
|
84
|
+
&:active {
|
85
|
+
@include typography.interacted-text-decoration;
|
86
|
+
|
87
|
+
background: none;
|
88
|
+
}
|
89
|
+
|
90
|
+
&[aria-expanded="true"] {
|
91
|
+
&::before {
|
92
|
+
border-top-width: 0;
|
93
|
+
border-bottom-width: #{math.div(math.sqrt(3), 2)}rem;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
&__item-toggle-label {
|
99
|
+
}
|
100
|
+
|
101
|
+
&__item-toggle-info {
|
102
|
+
display: block;
|
103
|
+
|
104
|
+
@include typography.main-font-weight;
|
105
|
+
@include typography.relative-font-size(14);
|
106
|
+
}
|
107
|
+
|
108
|
+
&__item {
|
109
|
+
padding: 0.75rem;
|
110
|
+
|
111
|
+
@include colour.colour-background("background-tint");
|
112
|
+
|
113
|
+
@include colour.colour-border("keyline", 1px);
|
114
|
+
border-width: 0 1px 1px;
|
115
|
+
}
|
116
|
+
|
117
|
+
&__hint {
|
118
|
+
margin-bottom: 0.5rem;
|
119
|
+
|
120
|
+
@include typography.relative-font-size(16);
|
121
|
+
@include colour.colour-font("font-light");
|
122
|
+
}
|
123
|
+
|
124
|
+
&__inline-fields {
|
125
|
+
display: flex;
|
126
|
+
flex-wrap: wrap;
|
127
|
+
gap: 0.5rem 2rem;
|
128
|
+
}
|
129
|
+
|
130
|
+
&__label {
|
131
|
+
display: block;
|
132
|
+
}
|
133
|
+
|
134
|
+
&__footer {
|
135
|
+
padding: 0.75rem;
|
136
|
+
|
137
|
+
display: none;
|
138
|
+
|
139
|
+
@include colour.colour-border("keyline", 1px);
|
140
|
+
}
|
141
|
+
|
142
|
+
&--js-enabled &__title {
|
143
|
+
margin-bottom: 1rem;
|
144
|
+
}
|
145
|
+
|
146
|
+
&--js-enabled &__footer {
|
147
|
+
display: block;
|
148
|
+
}
|
149
|
+
|
150
|
+
&--js-enabled &__item {
|
151
|
+
border-bottom: none;
|
152
|
+
}
|
153
|
+
|
154
|
+
&--js-enabled &__update-item {
|
155
|
+
display: none;
|
156
|
+
}
|
157
|
+
|
158
|
+
&__fieldset[data-type="multiple"] &__item {
|
159
|
+
max-height: 15rem;
|
160
|
+
|
161
|
+
overflow: auto;
|
162
|
+
}
|
163
|
+
}
|
@@ -0,0 +1,207 @@
|
|
1
|
+
import Filters from "./template.njk";
|
2
|
+
import macroOptions from "./macro-options.json";
|
3
|
+
|
4
|
+
const argTypes = {
|
5
|
+
title: { control: "text" },
|
6
|
+
rootHeadingLevel: { control: { type: "number", min: 1, max: 6 } },
|
7
|
+
formId: { control: "text" },
|
8
|
+
items: { control: "object" },
|
9
|
+
classes: { control: "text" },
|
10
|
+
attributes: { control: "object" },
|
11
|
+
};
|
12
|
+
|
13
|
+
Object.keys(argTypes).forEach((argType) => {
|
14
|
+
argTypes[argType].description = macroOptions.find(
|
15
|
+
(option) => option.name === argType,
|
16
|
+
)?.description;
|
17
|
+
});
|
18
|
+
|
19
|
+
export default {
|
20
|
+
title: "Components/Search filters",
|
21
|
+
argTypes,
|
22
|
+
};
|
23
|
+
|
24
|
+
const Template = ({
|
25
|
+
title,
|
26
|
+
rootHeadingLevel,
|
27
|
+
formId,
|
28
|
+
items,
|
29
|
+
classes,
|
30
|
+
attributes,
|
31
|
+
}) =>
|
32
|
+
Filters({
|
33
|
+
params: {
|
34
|
+
title,
|
35
|
+
rootHeadingLevel,
|
36
|
+
formId,
|
37
|
+
items,
|
38
|
+
classes,
|
39
|
+
attributes,
|
40
|
+
},
|
41
|
+
});
|
42
|
+
|
43
|
+
export const Standard = Template.bind({});
|
44
|
+
Standard.args = {
|
45
|
+
title: "Filters",
|
46
|
+
rootHeadingLevel: 2,
|
47
|
+
formId: "test-form",
|
48
|
+
items: [
|
49
|
+
{
|
50
|
+
type: "text",
|
51
|
+
label: "Refine",
|
52
|
+
id: "refine1",
|
53
|
+
name: "refine1",
|
54
|
+
// open: true,
|
55
|
+
hint: "Search within the current results",
|
56
|
+
},
|
57
|
+
// {
|
58
|
+
// type: "single",
|
59
|
+
// label: "Type",
|
60
|
+
// id: "type1",
|
61
|
+
// name: "type1",
|
62
|
+
// small: true,
|
63
|
+
// // open: true,
|
64
|
+
// hint: "You can only select one.",
|
65
|
+
// items: [
|
66
|
+
// {
|
67
|
+
// text: "Audio",
|
68
|
+
// value: "audio",
|
69
|
+
// },
|
70
|
+
// {
|
71
|
+
// text: "Image",
|
72
|
+
// value: "image",
|
73
|
+
// },
|
74
|
+
// {
|
75
|
+
// text: "Video",
|
76
|
+
// value: "video",
|
77
|
+
// },
|
78
|
+
// ],
|
79
|
+
// },
|
80
|
+
{
|
81
|
+
type: "multiple",
|
82
|
+
label: "Category",
|
83
|
+
id: "categories1",
|
84
|
+
name: "categories1",
|
85
|
+
small: true,
|
86
|
+
// open: true,
|
87
|
+
hint: "The category of the record",
|
88
|
+
// count: 2,
|
89
|
+
seeMoreText: "See all 29 categories",
|
90
|
+
seeMoreUrl: "#",
|
91
|
+
items: [
|
92
|
+
{
|
93
|
+
text: "Alpha",
|
94
|
+
value: "alpha",
|
95
|
+
},
|
96
|
+
{
|
97
|
+
text: "Beta",
|
98
|
+
value: "beta",
|
99
|
+
// checked: true,
|
100
|
+
},
|
101
|
+
{
|
102
|
+
text: "Gamma",
|
103
|
+
value: "gamma",
|
104
|
+
},
|
105
|
+
],
|
106
|
+
},
|
107
|
+
{
|
108
|
+
type: "date",
|
109
|
+
label: "Opening date",
|
110
|
+
id: "date1",
|
111
|
+
name: "date1",
|
112
|
+
hint: "The earliest opening date of the record",
|
113
|
+
},
|
114
|
+
{
|
115
|
+
type: "daterange",
|
116
|
+
label: "Covering date",
|
117
|
+
id: "dates",
|
118
|
+
hint: "The earliest and/or latest covering date of the record",
|
119
|
+
// open: true,
|
120
|
+
from: {
|
121
|
+
label: "From",
|
122
|
+
id: "date2",
|
123
|
+
name: "date2",
|
124
|
+
},
|
125
|
+
to: {
|
126
|
+
label: "To",
|
127
|
+
id: "date3",
|
128
|
+
name: "date3",
|
129
|
+
},
|
130
|
+
},
|
131
|
+
],
|
132
|
+
classes: "tna-search-filters--demo",
|
133
|
+
};
|
134
|
+
|
135
|
+
export const OpenedAndPrepopulated = Template.bind({});
|
136
|
+
OpenedAndPrepopulated.args = {
|
137
|
+
title: "Filters",
|
138
|
+
rootHeadingLevel: 2,
|
139
|
+
formId: "test-form",
|
140
|
+
items: [
|
141
|
+
{
|
142
|
+
type: "text",
|
143
|
+
label: "Refine",
|
144
|
+
id: "refine1",
|
145
|
+
name: "refine1",
|
146
|
+
open: true,
|
147
|
+
hint: "Search within the current results",
|
148
|
+
value: "iceberg",
|
149
|
+
},
|
150
|
+
{
|
151
|
+
type: "multiple",
|
152
|
+
label: "Category",
|
153
|
+
id: "categories1",
|
154
|
+
name: "categories1",
|
155
|
+
small: true,
|
156
|
+
open: true,
|
157
|
+
hint: "The category of the record",
|
158
|
+
seeMoreText: "See all 29 categories",
|
159
|
+
seeMoreUrl: "#",
|
160
|
+
items: [
|
161
|
+
{
|
162
|
+
text: "Alpha",
|
163
|
+
value: "alpha",
|
164
|
+
},
|
165
|
+
{
|
166
|
+
text: "Beta",
|
167
|
+
value: "beta",
|
168
|
+
checked: true,
|
169
|
+
},
|
170
|
+
{
|
171
|
+
text: "Gamma",
|
172
|
+
value: "gamma",
|
173
|
+
checked: true,
|
174
|
+
},
|
175
|
+
],
|
176
|
+
},
|
177
|
+
{
|
178
|
+
type: "date",
|
179
|
+
label: "Opening date",
|
180
|
+
id: "date1",
|
181
|
+
name: "date1",
|
182
|
+
hint: "The earliest opening date of the record",
|
183
|
+
open: true,
|
184
|
+
value: "1969-07-16",
|
185
|
+
},
|
186
|
+
{
|
187
|
+
type: "daterange",
|
188
|
+
label: "Covering date",
|
189
|
+
id: "dates",
|
190
|
+
hint: "The earliest and/or latest covering date of the record",
|
191
|
+
open: true,
|
192
|
+
from: {
|
193
|
+
label: "From",
|
194
|
+
id: "date2",
|
195
|
+
name: "date2",
|
196
|
+
value: "1912-04-14",
|
197
|
+
},
|
198
|
+
to: {
|
199
|
+
label: "To",
|
200
|
+
id: "date3",
|
201
|
+
name: "date3",
|
202
|
+
value: "1912-04-15",
|
203
|
+
},
|
204
|
+
},
|
205
|
+
],
|
206
|
+
classes: "tna-search-filters--demo",
|
207
|
+
};
|
@@ -0,0 +1,107 @@
|
|
1
|
+
{% from "nationalarchives/components/button/macro.njk" import tnaButton %}
|
2
|
+
{% from "nationalarchives/components/checkboxes/checkboxes.njk" import tnaCheckboxesElement %}
|
3
|
+
{% from "nationalarchives/components/date-search/date-search.njk" import tnaDateSearchElement %}
|
4
|
+
{% from "nationalarchives/components/radios/radios.njk" import tnaRadiosElement %}
|
5
|
+
{% from "nationalarchives/components/text-input/text-input.njk" import tnaTextInputElement %}
|
6
|
+
|
7
|
+
{%- set containerClasses = [params.classes] if params.classes else [] -%}
|
8
|
+
<div class="tna-search-filters {{ containerClasses | join(' ') }}" data-module="tna-search-filters"{% for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
9
|
+
<h{{ params.rootHeadingLevel }} class="tna-heading-m tna-search-filters__title">
|
10
|
+
{{ params.title }}
|
11
|
+
</h{{ params.rootHeadingLevel }}>
|
12
|
+
{%- for filter in params.items %}
|
13
|
+
<fieldset class="tna-search-filters__fieldset" {%- if filter.hint and (filter.type == 'single' or filter.type == 'multiple' or filter.type == 'daterange') %} aria-describedby="{{ filter.id }}-hint"{% endif %} data-type="{{ filter.type }}">
|
14
|
+
<legend class="tna-search-filters__legend">
|
15
|
+
<h{{ params.rootHeadingLevel + 1 }} class="tna-heading-s">
|
16
|
+
<div class="tna-search-filters__heading-inner">
|
17
|
+
{% if filter.type == 'single' or filter.type == 'multiple' or filter.type == 'daterange' %}
|
18
|
+
{{ filter.label }}
|
19
|
+
{% else %}
|
20
|
+
<label for="{{ filter.id }}">
|
21
|
+
{{ filter.label }}
|
22
|
+
</label>
|
23
|
+
{% endif %}
|
24
|
+
</div>
|
25
|
+
<button class="tna-search-filters__item-toggle" aria-controls="{{ filter.id }}-wrapper" aria-expanded="{{ filter.open or false }}" hidden>
|
26
|
+
{% if filter.type == 'single' or filter.type == 'multiple' or filter.type == 'daterange' %}
|
27
|
+
<span class="tna-search-filters__item-toggle-label">
|
28
|
+
{{ filter.label }}
|
29
|
+
</span>
|
30
|
+
{% else %}
|
31
|
+
<label class="tna-search-filters__item-toggle-label" for="{{ filter.id }}">
|
32
|
+
{{ filter.label }}
|
33
|
+
</label>
|
34
|
+
{% endif %}
|
35
|
+
{% if filter.count %}
|
36
|
+
<span class="tna-search-filters__item-toggle-info">({{ filter.count }} selected)</span>
|
37
|
+
{% else %}
|
38
|
+
<span class="tna-search-filters__item-toggle-info"></span>
|
39
|
+
{% endif %}
|
40
|
+
</button>
|
41
|
+
</h{{ params.rootHeadingLevel + 1 }}>
|
42
|
+
</legend>
|
43
|
+
<div id="{{ filter.id }}-wrapper" class="tna-search-filters__item">
|
44
|
+
{%- if filter.hint %}
|
45
|
+
<p id="{{ filter.id }}-hint" class="tna-search-filters__hint">
|
46
|
+
{{ filter.hint }}
|
47
|
+
</p>
|
48
|
+
{%- endif %}
|
49
|
+
{% if filter.type == 'single' %}
|
50
|
+
{{ tnaRadiosElement(filter, { form: params.formId }) }}
|
51
|
+
{% elif filter.type == 'multiple' %}
|
52
|
+
{{ tnaCheckboxesElement(filter, { form: params.formId }) }}
|
53
|
+
<div class="tna-button-group tna-button-group--small tna-!--margin-top-xs">
|
54
|
+
{{ tnaButton({
|
55
|
+
text: filter.seeMoreText or 'See more',
|
56
|
+
href: filter.seeMoreUrl,
|
57
|
+
plain: true
|
58
|
+
}) }}
|
59
|
+
</div>
|
60
|
+
{% elif filter.type == 'text' %}
|
61
|
+
{{ tnaTextInputElement(filter, { form: params.formId }) }}
|
62
|
+
{% elif filter.type == 'date' %}
|
63
|
+
{{ tnaDateSearchElement(filter, { form: params.formId }) }}
|
64
|
+
{% elif filter.type == 'daterange' %}
|
65
|
+
<div class="tna-search-filters__inline-fields">
|
66
|
+
<label class="tna-search-filters__label">
|
67
|
+
{{ filter.from.label }}
|
68
|
+
{{ tnaDateSearchElement(filter.from, { form: params.formId }) }}
|
69
|
+
</label>
|
70
|
+
<label class="tna-search-filters__label">
|
71
|
+
{{ filter.to.label }}
|
72
|
+
{{ tnaDateSearchElement(filter.to, { form: params.formId }) }}
|
73
|
+
</label>
|
74
|
+
</div>
|
75
|
+
{% endif %}
|
76
|
+
<div class="tna-button-group tna-button-group--small tna-search-filters__update-item tna-!--margin-top-s">
|
77
|
+
{{ tnaButton({
|
78
|
+
text: 'Update',
|
79
|
+
buttonElement: true,
|
80
|
+
buttonType: 'submit',
|
81
|
+
attributes: {
|
82
|
+
form: params.formId
|
83
|
+
}
|
84
|
+
}) }}
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
</fieldset>
|
88
|
+
{%- endfor %}
|
89
|
+
<div class="tna-search-filters__footer">
|
90
|
+
<div class="tna-button-group tna-button-group--small">
|
91
|
+
{{ tnaButton({
|
92
|
+
text: 'Update',
|
93
|
+
buttonElement: true,
|
94
|
+
buttonType: 'submit',
|
95
|
+
classes: 'tna-search-filters__update',
|
96
|
+
attributes: {
|
97
|
+
form: params.formId
|
98
|
+
}
|
99
|
+
}) }}
|
100
|
+
{{ tnaButton({
|
101
|
+
text: 'Clear all filters',
|
102
|
+
href: '#',
|
103
|
+
plain: true
|
104
|
+
}) }}
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
</div>
|
@@ -24,8 +24,7 @@
|
|
24
24
|
}
|
25
25
|
]
|
26
26
|
},
|
27
|
-
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"
|
28
|
-
"hidden": false
|
27
|
+
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"sort\">Sort by</label></h4></div><select class=\"tna-select \" name=\"sort\" id=\"sort\"><option value=\"relevance\">Relevance</option><option value=\"date\">Date</option><option value=\"title\">Title</option></select></div>"
|
29
28
|
},
|
30
29
|
{
|
31
30
|
"name": "select with a preselected value",
|
@@ -51,8 +50,7 @@
|
|
51
50
|
],
|
52
51
|
"selected": "date"
|
53
52
|
},
|
54
|
-
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"
|
55
|
-
"hidden": false
|
53
|
+
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"sort\">Sort by</label></h4></div><select class=\"tna-select \" name=\"sort\" id=\"sort\"><option value=\"relevance\">Relevance</option><option value=\"date\" selected>Date</option><option value=\"title\">Title</option></select></div>"
|
56
54
|
},
|
57
55
|
{
|
58
56
|
"name": "select with a hint",
|
@@ -78,8 +76,7 @@
|
|
78
76
|
}
|
79
77
|
]
|
80
78
|
},
|
81
|
-
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"
|
82
|
-
"hidden": false
|
79
|
+
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"sort\">Sort by</label></h4><p id=\"sort-hint\" class=\"tna-form__hint\">Select a field to sort by.</p></div><select class=\"tna-select \" name=\"sort\" id=\"sort\" aria-describedby=\"sort-hint\"><option value=\"relevance\">Relevance</option><option value=\"date\">Date</option><option value=\"title\">Title</option></select></div>"
|
83
80
|
},
|
84
81
|
{
|
85
82
|
"name": "select with an error",
|
@@ -107,8 +104,7 @@
|
|
107
104
|
}
|
108
105
|
]
|
109
106
|
},
|
110
|
-
"html": "<div class=\"tna-form__group tna-form__group--error \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"
|
111
|
-
"hidden": false
|
107
|
+
"html": "<div class=\"tna-form__group tna-form__group--error \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"sort\">Sort by</label></h4><p id=\"sort-error\" class=\"tna-form__error-message\"><span class=\"tna-!--visually-hidden\">Error:</span> You must select a field to sort by</p></div><select class=\"tna-select \" name=\"sort\" id=\"sort\"><option value=\"relevance\">Relevance</option><option value=\"date\">Date</option><option value=\"title\">Title</option></select></div>"
|
112
108
|
},
|
113
109
|
{
|
114
110
|
"name": "inline select",
|
@@ -134,8 +130,7 @@
|
|
134
130
|
],
|
135
131
|
"inline": true
|
136
132
|
},
|
137
|
-
"html": "<div class=\"tna-form__group tna-form__group--inline\"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"
|
138
|
-
"hidden": false
|
133
|
+
"html": "<div class=\"tna-form__group tna-form__group--inline\"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"sort\">Sort by</label></h4></div><select class=\"tna-select \" name=\"sort\" id=\"sort\"><option value=\"relevance\">Relevance</option><option value=\"date\">Date</option><option value=\"title\">Title</option></select></div>"
|
139
134
|
},
|
140
135
|
{
|
141
136
|
"name": "select size",
|
@@ -161,8 +156,7 @@
|
|
161
156
|
],
|
162
157
|
"size": "xl"
|
163
158
|
},
|
164
|
-
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"
|
165
|
-
"hidden": false
|
159
|
+
"html": "<div class=\"tna-form__group \"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"sort\">Sort by</label></h4></div><select class=\"tna-select tna-select--xl \" name=\"sort\" id=\"sort\"><option value=\"relevance\">Relevance</option><option value=\"date\">Date</option><option value=\"title\">Title</option></select></div>"
|
166
160
|
}
|
167
161
|
]
|
168
162
|
}
|
@@ -1 +1 @@
|
|
1
|
-
.tna-select{--page-background: #f4f4f4;--background-tint: #e4e4e4;--font-base: #343338;--font-dark: rgb(0, 0, 0);--font-light: rgb(0 0 0/0.58);--icon-light: rgb(52 51 56/0.45);--link: #0062a8;--link-visited: #4c2c92;--focus-outline: rgb(0, 176, 255);--keyline: rgb(38 38 42/0.25);--keyline-dark: #26262a;--input-foreground: rgb(0, 0, 0);--input-background: rgb(255, 255, 255);--input-border: rgb(0, 0, 0);--
|
1
|
+
.tna-select{--page-background: #f4f4f4;--background-tint: #e4e4e4;--font-base: #343338;--font-dark: rgb(0, 0, 0);--font-light: rgb(0 0 0/0.58);--icon-light: rgb(52 51 56/0.45);--link: #0062a8;--link-visited: #4c2c92;--focus-outline: rgb(0, 176, 255);--keyline: rgb(38 38 42/0.25);--keyline-dark: #26262a;--input-foreground: rgb(0, 0, 0);--input-background: rgb(255, 255, 255);--input-border: rgb(0, 0, 0);--button-text: rgb(255, 255, 255);--button-background: rgb(0, 0, 0);--button-hover-text: rgb(0, 0, 0);--button-hover-background: rgb(255, 255, 255);--contrast-background: #1e1e1e;--contrast-font-base: rgb(255, 255, 255);--contrast-font-dark: rgb(255, 255, 255);--contrast-font-light: rgb(255 255 255/0.7);--contrast-icon-light: rgb(255 255 255/0.45);--contrast-link: rgb(255, 255, 255);--contrast-link-visited: rgb(255, 255, 255);--contrast-keyline: rgb(255 255 255/0.5);--contrast-keyline-dark: rgb(255 255 255/0.8);--contrast-button-text: rgb(0, 0, 0);--contrast-button-background: rgb(255, 255, 255);--contrast-button-hover-text: rgb(255, 255, 255);--contrast-button-hover-background: rgb(0, 0, 0);--accent-background: #111;--accent-background-light: #ededed;--accent-font-base: rgb(255, 255, 255);--accent-font-dark: rgb(255, 255, 255);--accent-font-light: rgb(255 255 255/0.7);--accent-icon-light: rgb(255 255 255/0.45);--accent-link: rgb(255, 255, 255);--accent-link-visited: #b9f;--accent-keyline: rgb(255 255 255/0.5);--accent-keyline-dark: rgb(255 255 255/0.8);--button-accent-text: rgb(0, 0, 0);--button-accent-background: rgb(140, 150, 148)}@media(prefers-contrast: more){.tna-select{--page-background: rgb(255, 255, 255);--background-tint: #e4e4e4;--font-base: rgb(0, 0, 0);--font-dark: rgb(0, 0, 0);--font-light: rgb(0, 0, 0);--icon-light: rgb(0 0 0/0.75);--link: #34d;--link-visited: #848;--focus-outline: rgb(253, 63, 3);--keyline: rgb(0, 0, 0);--keyline-dark: rgb(0, 0, 0);--input-foreground: rgb(0, 0, 0);--input-background: rgb(255, 255, 255);--input-border: rgb(0, 0, 0);--button-text: rgb(255, 255, 255);--button-background: rgb(0, 0, 0);--button-hover-text: rgb(0, 0, 0);--button-hover-background: rgb(255, 255, 255);--contrast-background: #f4f4f4;--contrast-font-base: rgb(0, 0, 0);--contrast-font-dark: rgb(0, 0, 0);--contrast-font-light: rgb(0, 0, 0);--contrast-icon-light: rgb(255 255 255/0.45);--contrast-link: #34d;--contrast-link-visited: #848;--contrast-keyline: rgb(0, 0, 0);--contrast-keyline-dark: rgb(0, 0, 0);--contrast-button-text: rgb(255, 255, 255);--contrast-button-background: rgb(0, 0, 0);--contrast-button-hover-text: rgb(0, 0, 0);--contrast-button-hover-background: rgb(255, 255, 255);--accent-background: #111;--accent-background-light: #ededed;--accent-font-base: rgb(255, 255, 255);--accent-font-dark: rgb(255, 255, 255);--accent-font-light: rgb(255 255 255/0.7);--accent-icon-light: rgb(255 255 255/0.45);--accent-link: rgb(255, 255, 255);--accent-link-visited: #b9f;--accent-keyline: rgb(255 255 255/0.5);--accent-keyline-dark: rgb(255 255 255/0.8);--button-accent-text: rgb(0, 0, 0);--button-accent-background: rgb(140, 150, 148)}}.tna-template--high-contrast-theme .tna-select{--page-background: rgb(255, 255, 255);--background-tint: #e4e4e4;--font-base: rgb(0, 0, 0);--font-dark: rgb(0, 0, 0);--font-light: rgb(0, 0, 0);--icon-light: rgb(0 0 0/0.75);--link: #34d;--link-visited: #848;--focus-outline: rgb(253, 63, 3);--keyline: rgb(0, 0, 0);--keyline-dark: rgb(0, 0, 0);--input-foreground: rgb(0, 0, 0);--input-background: rgb(255, 255, 255);--input-border: rgb(0, 0, 0);--button-text: rgb(255, 255, 255);--button-background: rgb(0, 0, 0);--button-hover-text: rgb(0, 0, 0);--button-hover-background: rgb(255, 255, 255);--contrast-background: #f4f4f4;--contrast-font-base: rgb(0, 0, 0);--contrast-font-dark: rgb(0, 0, 0);--contrast-font-light: rgb(0, 0, 0);--contrast-icon-light: rgb(255 255 255/0.45);--contrast-link: #34d;--contrast-link-visited: #848;--contrast-keyline: rgb(0, 0, 0);--contrast-keyline-dark: rgb(0, 0, 0);--contrast-button-text: rgb(255, 255, 255);--contrast-button-background: rgb(0, 0, 0);--contrast-button-hover-text: rgb(0, 0, 0);--contrast-button-hover-background: rgb(255, 255, 255);--accent-background: #111;--accent-background-light: #ededed;--accent-font-base: rgb(255, 255, 255);--accent-font-dark: rgb(255, 255, 255);--accent-font-light: rgb(255 255 255/0.7);--accent-icon-light: rgb(255 255 255/0.45);--accent-link: rgb(255, 255, 255);--accent-link-visited: #b9f;--accent-keyline: rgb(255 255 255/0.5);--accent-keyline-dark: rgb(255 255 255/0.8);--button-accent-text: rgb(0, 0, 0);--button-accent-background: rgb(140, 150, 148)}.tna-select{max-width:100%;height:calc(2rem + 6px);padding:0 1rem 0 .5rem;display:block;color:#000;color:var(--input-foreground);font-size:inherit;line-height:2rem;background-color:#fff;background-color:var(--input-background);border:2px #000 solid;border:2px var(--input-border) solid;border-radius:.1px}.tna-select--styled{padding:0 2.5rem 0 .75rem;appearance:none;background-image:url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjUwMHB4IiBoZWlnaHQ9IjUwMHB4IiB2aWV3Qm94PSIwIDAgNTAwIDUwMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgNTAwIDUwMCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBvbHlnb24gcG9pbnRzPSIyNTAsNDAwIDUwLDEwMCA0NTAsMTAwIiBmaWxsPSIjMDAwIi8+PC9zdmc+");background-position:center right .5rem;background-size:.75rem .75rem;background-repeat:no-repeat}.tna-form__group--error .tna-select{border-color:#c00;border-color:var(--form-error)}.tna-select--s{width:10rem}.tna-select--m{width:20rem}.tna-select--l{width:40rem}.tna-select--xl{width:80rem}/*# sourceMappingURL=select.css.map */
|