@communitiesuk/svelte-component-library 0.1.17
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/README.md +188 -0
- package/dist/assets/css/govuk-frontend.min.css +2 -0
- package/dist/assets/css/govuk-frontend.min.css.map +1 -0
- package/dist/assets/fonts/bold-affa96571d-v2.woff +0 -0
- package/dist/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
- package/dist/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
- package/dist/assets/fonts/light-f591b13f7d-v2.woff +0 -0
- package/dist/assets/govuk_publishing_components/images/icon-autocomplete-search-suggestion.svg +4 -0
- package/dist/assets/govuk_publishing_components/images/icon-close.svg +1 -0
- package/dist/assets/images/favicon.ico +0 -0
- package/dist/assets/images/favicon.svg +1 -0
- package/dist/assets/images/govuk-crest-2x.png +0 -0
- package/dist/assets/images/govuk-crest.png +0 -0
- package/dist/assets/images/govuk-crest.svg +1 -0
- package/dist/assets/images/govuk-icon-180.png +0 -0
- package/dist/assets/images/govuk-icon-192.png +0 -0
- package/dist/assets/images/govuk-icon-512.png +0 -0
- package/dist/assets/images/govuk-icon-mask.svg +1 -0
- package/dist/assets/images/govuk-opengraph-image.png +0 -0
- package/dist/assets/images/homepage-illustration.svg +1 -0
- package/dist/assets/images/homepage.svg +44 -0
- package/dist/assets/images/masthead-illustration.svg +123 -0
- package/dist/assets/images/oflog_crest_black.png +0 -0
- package/dist/assets/images/oflog_crest_white.png +0 -0
- package/dist/assets/images/undraw_approved-wireframe_odf4.svg +1 -0
- package/dist/assets/images/undraw_collaborators_rgw4.svg +1 -0
- package/dist/assets/images/undraw_content-creator_vuqg.svg +1 -0
- package/dist/assets/images/undraw_online-media_opxh.svg +1 -0
- package/dist/assets/images/undraw_pull-request_zlsu.svg +1 -0
- package/dist/assets/images/undraw_reviewed-docs_g0cg.svg +1 -0
- package/dist/components/FilterPanel/codeBlocks.d.ts +3 -0
- package/dist/components/FilterPanel/codeBlocks.js +418 -0
- package/dist/components/content/InsetText.svelte +21 -0
- package/dist/components/content/InsetText.svelte.d.ts +7 -0
- package/dist/components/content/WarningText.svelte +27 -0
- package/dist/components/content/WarningText.svelte.d.ts +8 -0
- package/dist/components/data-vis/axis/Axis.svelte +51 -0
- package/dist/components/data-vis/axis/Axis.svelte.d.ts +33 -0
- package/dist/components/data-vis/axis/Ticks.svelte +113 -0
- package/dist/components/data-vis/axis/Ticks.svelte.d.ts +33 -0
- package/dist/components/data-vis/line-chart/Line.svelte +150 -0
- package/dist/components/data-vis/line-chart/Line.svelte.d.ts +85 -0
- package/dist/components/data-vis/line-chart/LineChart.svelte +249 -0
- package/dist/components/data-vis/line-chart/LineChart.svelte.d.ts +73 -0
- package/dist/components/data-vis/line-chart/Lines.svelte +138 -0
- package/dist/components/data-vis/line-chart/Lines.svelte.d.ts +57 -0
- package/dist/components/data-vis/line-chart/Marker.svelte +61 -0
- package/dist/components/data-vis/line-chart/Marker.svelte.d.ts +37 -0
- package/dist/components/data-vis/line-chart/SeriesLabel.svelte +67 -0
- package/dist/components/data-vis/line-chart/SeriesLabel.svelte.d.ts +43 -0
- package/dist/components/data-vis/line-chart/ValueLabel.svelte +50 -0
- package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +25 -0
- package/dist/components/data-vis/map/Map.svelte +392 -0
- package/dist/components/data-vis/map/Map.svelte.d.ts +47 -0
- package/dist/components/data-vis/map/MapLegend.svelte +41 -0
- package/dist/components/data-vis/map/MapLegend.svelte.d.ts +15 -0
- package/dist/components/data-vis/map/NonStandardControls.svelte +42 -0
- package/dist/components/data-vis/map/NonStandardControls.svelte.d.ts +13 -0
- package/dist/components/data-vis/map/Tooltip.svelte +41 -0
- package/dist/components/data-vis/map/Tooltip.svelte.d.ts +19 -0
- package/dist/components/data-vis/map/colorbrewer.d.ts +337 -0
- package/dist/components/data-vis/map/colorbrewer.js +1523 -0
- package/dist/components/data-vis/map/colors.d.ts +13 -0
- package/dist/components/data-vis/map/colors.js +65 -0
- package/dist/components/data-vis/map/dataJoin.d.ts +2 -0
- package/dist/components/data-vis/map/dataJoin.js +27 -0
- package/dist/components/data-vis/map/fullTopo.json +1 -0
- package/dist/components/data-vis/map/jenks.d.ts +1 -0
- package/dist/components/data-vis/map/jenks.js +51 -0
- package/dist/components/data-vis/map/lad2023.json +1 -0
- package/dist/components/data-vis/map/mapUtils.d.ts +5 -0
- package/dist/components/data-vis/map/mapUtils.js +86 -0
- package/dist/components/data-vis/map/topo.json +1 -0
- package/dist/components/data-vis/table/Table.svelte +247 -0
- package/dist/components/data-vis/table/Table.svelte.d.ts +19 -0
- package/dist/components/layout/Breadcrumbs.svelte +191 -0
- package/dist/components/layout/Breadcrumbs.svelte.d.ts +24 -0
- package/dist/components/layout/Footer.svelte +171 -0
- package/dist/components/layout/Footer.svelte.d.ts +30 -0
- package/dist/components/layout/Header.svelte +43 -0
- package/dist/components/layout/Header.svelte.d.ts +7 -0
- package/dist/components/layout/InternalHeader.svelte +628 -0
- package/dist/components/layout/InternalHeader.svelte.d.ts +15 -0
- package/dist/components/layout/PhaseBanner.svelte +28 -0
- package/dist/components/layout/PhaseBanner.svelte.d.ts +9 -0
- package/dist/components/layout/ServiceNavigation.svelte +143 -0
- package/dist/components/layout/ServiceNavigation.svelte.d.ts +13 -0
- package/dist/components/layout/SideNavigation.svelte +345 -0
- package/dist/components/layout/SideNavigation.svelte.d.ts +25 -0
- package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte +91 -0
- package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte.d.ts +15 -0
- package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte +233 -0
- package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte.d.ts +27 -0
- package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte +70 -0
- package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte.d.ts +11 -0
- package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte +276 -0
- package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte.d.ts +22 -0
- package/dist/components/ui/Accordion.svelte +244 -0
- package/dist/components/ui/Accordion.svelte.d.ts +23 -0
- package/dist/components/ui/Breadcrumbs.svelte +198 -0
- package/dist/components/ui/Breadcrumbs.svelte.d.ts +24 -0
- package/dist/components/ui/Button.svelte +96 -0
- package/dist/components/ui/Button.svelte.d.ts +17 -0
- package/dist/components/ui/CheckBox.svelte +198 -0
- package/dist/components/ui/CheckBox.svelte.d.ts +27 -0
- package/dist/components/ui/ContentsList.svelte +1117 -0
- package/dist/components/ui/ContentsList.svelte.d.ts +25 -0
- package/dist/components/ui/DateInput.svelte +255 -0
- package/dist/components/ui/DateInput.svelte.d.ts +59 -0
- package/dist/components/ui/Details.svelte +12 -0
- package/dist/components/ui/Details.svelte.d.ts +13 -0
- package/dist/components/ui/FilterPanel.svelte +588 -0
- package/dist/components/ui/FilterPanel.svelte.d.ts +74 -0
- package/dist/components/ui/Footer.svelte +171 -0
- package/dist/components/ui/Footer.svelte.d.ts +30 -0
- package/dist/components/ui/Header.svelte +43 -0
- package/dist/components/ui/Header.svelte.d.ts +7 -0
- package/dist/components/ui/Masthead.svelte +267 -0
- package/dist/components/ui/Masthead.svelte.d.ts +12 -0
- package/dist/components/ui/NavigationExample.svelte +117 -0
- package/dist/components/ui/NavigationExample.svelte.d.ts +3 -0
- package/dist/components/ui/NotificationBanner.svelte +93 -0
- package/dist/components/ui/NotificationBanner.svelte.d.ts +15 -0
- package/dist/components/ui/Radios.svelte +176 -0
- package/dist/components/ui/Radios.svelte.d.ts +28 -0
- package/dist/components/ui/RelatedContent.svelte +596 -0
- package/dist/components/ui/RelatedContent.svelte.d.ts +29 -0
- package/dist/components/ui/Search.svelte +499 -0
- package/dist/components/ui/Search.svelte.d.ts +32 -0
- package/dist/components/ui/SearchAutocomplete.svelte +655 -0
- package/dist/components/ui/SearchAutocomplete.svelte.d.ts +37 -0
- package/dist/components/ui/Select.svelte +116 -0
- package/dist/components/ui/Select.svelte.d.ts +22 -0
- package/dist/components/ui/ServiceNavigation.svelte +143 -0
- package/dist/components/ui/ServiceNavigation.svelte.d.ts +13 -0
- package/dist/components/ui/SideNavigation.svelte +346 -0
- package/dist/components/ui/SideNavigation.svelte.d.ts +25 -0
- package/dist/components/ui/Tabs.svelte +306 -0
- package/dist/components/ui/Tabs.svelte.d.ts +18 -0
- package/dist/components/ui/WhatsNew.svelte +155 -0
- package/dist/components/ui/WhatsNew.svelte.d.ts +29 -0
- package/dist/config.d.ts +51 -0
- package/dist/config.js +44 -0
- package/dist/icons/DoubleChevronButton.svelte +62 -0
- package/dist/icons/DoubleChevronButton.svelte.d.ts +13 -0
- package/dist/icons/IconSearch.svelte +42 -0
- package/dist/icons/IconSearch.svelte.d.ts +6 -0
- package/dist/icons/SingleChevronButtonWithLabel.svelte +132 -0
- package/dist/icons/SingleChevronButtonWithLabel.svelte.d.ts +19 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +45 -0
- package/dist/main.css +1 -0
- package/dist/package-wrapping/BaseInformation.svelte +82 -0
- package/dist/package-wrapping/BaseInformation.svelte.d.ts +15 -0
- package/dist/package-wrapping/BaseNameAndStatus.svelte +108 -0
- package/dist/package-wrapping/BaseNameAndStatus.svelte.d.ts +10 -0
- package/dist/package-wrapping/CodeBlock.svelte +62 -0
- package/dist/package-wrapping/CodeBlock.svelte.d.ts +12 -0
- package/dist/package-wrapping/ComponentDemo.svelte +114 -0
- package/dist/package-wrapping/ComponentDemo.svelte.d.ts +25 -0
- package/dist/package-wrapping/ComponentDemoTEMP.svelte +305 -0
- package/dist/package-wrapping/ComponentDemoTEMP.svelte.d.ts +21 -0
- package/dist/package-wrapping/ComponentDetails.svelte +123 -0
- package/dist/package-wrapping/ComponentDetails.svelte.d.ts +13 -0
- package/dist/package-wrapping/DividerLine.svelte +21 -0
- package/dist/package-wrapping/DividerLine.svelte.d.ts +17 -0
- package/dist/package-wrapping/InputForParameter.svelte +205 -0
- package/dist/package-wrapping/InputForParameter.svelte.d.ts +13 -0
- package/dist/package-wrapping/InputForParameterUpdated.svelte +222 -0
- package/dist/package-wrapping/InputForParameterUpdated.svelte.d.ts +17 -0
- package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte +203 -0
- package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte.d.ts +17 -0
- package/dist/package-wrapping/ListOfComponentStatuses.svelte +19 -0
- package/dist/package-wrapping/ListOfComponentStatuses.svelte.d.ts +11 -0
- package/dist/package-wrapping/OverlayAndComponentContainer.svelte +426 -0
- package/dist/package-wrapping/OverlayAndComponentContainer.svelte.d.ts +33 -0
- package/dist/package-wrapping/ParametersSection.svelte +235 -0
- package/dist/package-wrapping/ParametersSection.svelte.d.ts +19 -0
- package/dist/package-wrapping/ParsingErrorToastsContainer.svelte +50 -0
- package/dist/package-wrapping/ParsingErrorToastsContainer.svelte.d.ts +15 -0
- package/dist/package-wrapping/Pill.svelte +54 -0
- package/dist/package-wrapping/Pill.svelte.d.ts +25 -0
- package/dist/package-wrapping/PlaygroundDetails.svelte +106 -0
- package/dist/package-wrapping/PlaygroundDetails.svelte.d.ts +13 -0
- package/dist/package-wrapping/ScreenSizeRadio.svelte +24 -0
- package/dist/package-wrapping/ScreenSizeRadio.svelte.d.ts +11 -0
- package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte +23 -0
- package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte.d.ts +11 -0
- package/dist/package-wrapping/SidebarContainer.svelte +103 -0
- package/dist/package-wrapping/SidebarContainer.svelte.d.ts +23 -0
- package/dist/package-wrapping/WrapperDetailsUpdate.svelte +40 -0
- package/dist/package-wrapping/WrapperDetailsUpdate.svelte.d.ts +15 -0
- package/dist/package-wrapping/templates/Template.svelte +100 -0
- package/dist/package-wrapping/templates/Template.svelte.d.ts +25 -0
- package/dist/templates/ComponentPageTemplate.svelte +1 -0
- package/dist/templates/ComponentPageTemplate.svelte.d.ts +26 -0
- package/dist/utils/data-transformations/convertCSV.d.ts +2 -0
- package/dist/utils/data-transformations/convertCSV.js +22 -0
- package/dist/utils/data-transformations/getValueFromParametersArray.d.ts +1 -0
- package/dist/utils/data-transformations/getValueFromParametersArray.js +9 -0
- package/dist/utils/layoutNavHelpers.d.ts +70 -0
- package/dist/utils/layoutNavHelpers.js +129 -0
- package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.js +21 -0
- package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.js +12 -0
- package/dist/utils/package-wrapping-specific/createParametersObject.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/createParametersObject.js +29 -0
- package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.js +14 -0
- package/dist/utils/package-wrapping-specific/trackVisibleParameters.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/trackVisibleParameters.js +29 -0
- package/dist/utils/syntax-highlighting/shikiHighlight.d.ts +7 -0
- package/dist/utils/syntax-highlighting/shikiHighlight.js +76 -0
- package/dist/utils/text-string-conversion/textStringConversion.d.ts +9 -0
- package/dist/utils/text-string-conversion/textStringConversion.js +86 -0
- package/package.json +113 -0
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Type definitions
|
|
3
|
+
export interface InternalLink {
|
|
4
|
+
title: string;
|
|
5
|
+
base_path: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ExternalLink {
|
|
10
|
+
title: string;
|
|
11
|
+
url: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RelatedContentSection {
|
|
16
|
+
type: "main" | "subheading" | "other";
|
|
17
|
+
id: string; // Unique ID for keys and state
|
|
18
|
+
title?: string; // For the main H2 heading (type 'main' only)
|
|
19
|
+
subheading?: string; // For H3 subheadings (type 'subheading' or 'other')
|
|
20
|
+
links: (InternalLink | ExternalLink)[];
|
|
21
|
+
linkStyle?: "normal" | "other"; // Default determined by type if undefined
|
|
22
|
+
truncateThreshold?: number; // Per-section override
|
|
23
|
+
disableTruncation?: boolean; // Disable truncation for this section
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Define component props
|
|
27
|
+
let {
|
|
28
|
+
sections = [] as RelatedContentSection[],
|
|
29
|
+
headingLevel = 2 as 1 | 2 | 3 | 4 | 5 | 6, // Main heading level (used by first 'main' section)
|
|
30
|
+
listTruncateThreshold = 5, // Default threshold, can be overridden per section
|
|
31
|
+
disableGa4 = false,
|
|
32
|
+
} = $props<{
|
|
33
|
+
sections?: RelatedContentSection[];
|
|
34
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
35
|
+
listTruncateThreshold?: number; // Default threshold
|
|
36
|
+
disableGa4?: boolean;
|
|
37
|
+
}>();
|
|
38
|
+
|
|
39
|
+
// Helper to check if a link is external
|
|
40
|
+
function isExternalLink(
|
|
41
|
+
link: InternalLink | ExternalLink,
|
|
42
|
+
): link is ExternalLink {
|
|
43
|
+
return "url" in link;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// State to track expanded sections, keyed by section.id
|
|
47
|
+
let sectionExpandedState = $state<Record<string, boolean>>({});
|
|
48
|
+
|
|
49
|
+
$effect(() => {
|
|
50
|
+
// Initialize state when sections change
|
|
51
|
+
const initialState: Record<string, boolean> = {};
|
|
52
|
+
for (const section of sections) {
|
|
53
|
+
initialState[section.id] = false;
|
|
54
|
+
}
|
|
55
|
+
sectionExpandedState = initialState;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Helper function to toggle section expansion by ID
|
|
59
|
+
function toggleSection(sectionId: string) {
|
|
60
|
+
if (sectionId in sectionExpandedState) {
|
|
61
|
+
sectionExpandedState[sectionId] = !sectionExpandedState[sectionId];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Add browser check for JavaScript support
|
|
66
|
+
import { browser } from "$app/environment";
|
|
67
|
+
|
|
68
|
+
// Track if JavaScript is supported
|
|
69
|
+
let hasJavaScript = $state(false);
|
|
70
|
+
|
|
71
|
+
// Set JavaScript support flag on mount
|
|
72
|
+
$effect(() => {
|
|
73
|
+
if (browser) {
|
|
74
|
+
hasJavaScript = true;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const mainSection = $derived(sections.find((s) => s.type === "main"));
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<!-- Define snippets outside the script tag, in the markup area -->
|
|
82
|
+
{#snippet linkListItem(
|
|
83
|
+
link,
|
|
84
|
+
index,
|
|
85
|
+
totalItems,
|
|
86
|
+
sectionName,
|
|
87
|
+
isOther = false,
|
|
88
|
+
sectionIndex,
|
|
89
|
+
)}
|
|
90
|
+
{@const isExternal = isExternalLink(link)}
|
|
91
|
+
{@const href = isExternal ? link.url : link.base_path}
|
|
92
|
+
{@const langAttr = link.locale}
|
|
93
|
+
{@const ga4LinkData = !disableGa4
|
|
94
|
+
? JSON.stringify({
|
|
95
|
+
event_name: "navigation",
|
|
96
|
+
type: "related content",
|
|
97
|
+
index_section: (sectionIndex + 1).toString(), // Use dynamic section index
|
|
98
|
+
index_link: (index + 1).toString(),
|
|
99
|
+
index_section_count: sections.length.toString(), // Total number of sections
|
|
100
|
+
index_total: totalItems.toString(),
|
|
101
|
+
section: sectionName, // Use subheading or main title as section name
|
|
102
|
+
...(isExternal && { external: "true" }),
|
|
103
|
+
})
|
|
104
|
+
: undefined}
|
|
105
|
+
|
|
106
|
+
<li class="gem-c-related-navigation__link">
|
|
107
|
+
<a
|
|
108
|
+
{href}
|
|
109
|
+
class="govuk-link govuk-link gem-c-related-navigation__section-link {isOther
|
|
110
|
+
? 'govuk-link gem-c-related-navigation__section-link--other'
|
|
111
|
+
: ''}"
|
|
112
|
+
target={isExternal ? "_blank" : undefined}
|
|
113
|
+
rel={isExternal ? "noopener noreferrer external" : undefined}
|
|
114
|
+
data-ga4-link={ga4LinkData}
|
|
115
|
+
lang={langAttr}
|
|
116
|
+
>
|
|
117
|
+
{link.title}
|
|
118
|
+
</a>
|
|
119
|
+
</li>
|
|
120
|
+
{/snippet}
|
|
121
|
+
|
|
122
|
+
{#snippet toggleControl(items, sectionId, threshold)}
|
|
123
|
+
{@const numHidden = items.length - threshold}
|
|
124
|
+
{#if numHidden > 0}
|
|
125
|
+
<li
|
|
126
|
+
class="gem-c-related-navigation__link toggle-wrap"
|
|
127
|
+
data-module="ga4-event-tracker"
|
|
128
|
+
>
|
|
129
|
+
<a
|
|
130
|
+
class="gem-c-related-navigation__toggle"
|
|
131
|
+
data-controls={`toggle_${sectionId}`}
|
|
132
|
+
data-expanded={sectionExpandedState[sectionId]}
|
|
133
|
+
data-toggled-text="Show {numHidden} more"
|
|
134
|
+
data-ga4-event={JSON.stringify({
|
|
135
|
+
event_name: "select_content",
|
|
136
|
+
type: "related content",
|
|
137
|
+
})}
|
|
138
|
+
href={"#"}
|
|
139
|
+
role="button"
|
|
140
|
+
aria-controls={`toggle_${sectionId}`}
|
|
141
|
+
aria-expanded={sectionExpandedState[sectionId]}
|
|
142
|
+
onclick={(event) => {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
toggleSection(sectionId);
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
{sectionExpandedState[sectionId]
|
|
148
|
+
? "Show fewer"
|
|
149
|
+
: `Show ${numHidden} more`}
|
|
150
|
+
</a>
|
|
151
|
+
</li>
|
|
152
|
+
{/if}
|
|
153
|
+
{/snippet}
|
|
154
|
+
|
|
155
|
+
{#snippet truncatedItemsList(
|
|
156
|
+
items,
|
|
157
|
+
sectionId,
|
|
158
|
+
sectionName,
|
|
159
|
+
isOther = false,
|
|
160
|
+
threshold,
|
|
161
|
+
sectionIndex,
|
|
162
|
+
)}
|
|
163
|
+
{@const truncatedItems = items.slice(threshold)}
|
|
164
|
+
{#if truncatedItems.length > 0}
|
|
165
|
+
<li
|
|
166
|
+
class="gem-c-related-navigation__link gem-c-related-navigation__link--truncated-links"
|
|
167
|
+
>
|
|
168
|
+
<span
|
|
169
|
+
id={`toggle_${sectionId}`}
|
|
170
|
+
class="gem-c-related-navigation__toggle-more {sectionExpandedState[
|
|
171
|
+
sectionId
|
|
172
|
+
]
|
|
173
|
+
? ''
|
|
174
|
+
: 'js-hidden'}"
|
|
175
|
+
aria-live="polite"
|
|
176
|
+
role="region"
|
|
177
|
+
>
|
|
178
|
+
{#each truncatedItems as link, i (isExternalLink(link) ? link.url : link.base_path)}
|
|
179
|
+
{@const isExternal = isExternalLink(link)}
|
|
180
|
+
{@const href = isExternal ? link.url : link.base_path}
|
|
181
|
+
{@const langAttr = link.locale}
|
|
182
|
+
{@const itemClass = isOther
|
|
183
|
+
? "govuk-link govuk-link gem-c-related-navigation__section-link govuk-link gem-c-related-navigation__section-link--other-truncated"
|
|
184
|
+
: "govuk-link govuk-link gem-c-related-navigation__section-link gem-c-related-navigation__section-link--inline"}
|
|
185
|
+
{@const ga4LinkData = !disableGa4
|
|
186
|
+
? JSON.stringify({
|
|
187
|
+
event_name: "navigation",
|
|
188
|
+
type: "related content",
|
|
189
|
+
index_section: (sectionIndex + 1).toString(),
|
|
190
|
+
index_link: (threshold + i + 1).toString(), // Adjust index based on threshold
|
|
191
|
+
index_section_count: sections.length.toString(),
|
|
192
|
+
index_total: items.length.toString(),
|
|
193
|
+
section: sectionName,
|
|
194
|
+
...(isExternal && { external: "true" }),
|
|
195
|
+
})
|
|
196
|
+
: undefined}
|
|
197
|
+
<a
|
|
198
|
+
{href}
|
|
199
|
+
class={itemClass}
|
|
200
|
+
target={isExternal ? "_blank" : undefined}
|
|
201
|
+
rel={isExternal ? "noopener noreferrer external" : undefined}
|
|
202
|
+
data-ga4-link={ga4LinkData}
|
|
203
|
+
lang={langAttr}>{link.title}</a
|
|
204
|
+
>
|
|
205
|
+
{#if i < truncatedItems.length - 1}{i === truncatedItems.length - 2
|
|
206
|
+
? ", and "
|
|
207
|
+
: ", "}{/if}
|
|
208
|
+
{/each}
|
|
209
|
+
</span>
|
|
210
|
+
</li>
|
|
211
|
+
{/if}
|
|
212
|
+
{/snippet}
|
|
213
|
+
|
|
214
|
+
{#snippet sectionHeading(id, text, isOther = false)}
|
|
215
|
+
<h3
|
|
216
|
+
{id}
|
|
217
|
+
class="gem-c-related-navigation__sub-heading {isOther
|
|
218
|
+
? 'gem-c-related-navigation__sub-heading--other'
|
|
219
|
+
: ''}"
|
|
220
|
+
data-track-count={!isOther ? "sidebarRelatedItemSection" : undefined}
|
|
221
|
+
>
|
|
222
|
+
{text}
|
|
223
|
+
</h3>
|
|
224
|
+
{/snippet}
|
|
225
|
+
|
|
226
|
+
<div
|
|
227
|
+
data-module="ga4-link-tracker"
|
|
228
|
+
class="gem-c-related-navigation govuk-!-display-none-print {hasJavaScript
|
|
229
|
+
? 'govuk-frontend-supported'
|
|
230
|
+
: ''}"
|
|
231
|
+
role="complementary"
|
|
232
|
+
>
|
|
233
|
+
{#if mainSection && mainSection.title}
|
|
234
|
+
<svelte:element
|
|
235
|
+
this={`h${headingLevel}`}
|
|
236
|
+
id={`related-nav-${mainSection.id}`}
|
|
237
|
+
class="gem-c-related-navigation__main-heading"
|
|
238
|
+
>
|
|
239
|
+
{mainSection.title}
|
|
240
|
+
</svelte:element>
|
|
241
|
+
{/if}
|
|
242
|
+
|
|
243
|
+
{#each sections as section, sectionIndex (section.id)}
|
|
244
|
+
{@const sectionLinks = section.links ?? []}
|
|
245
|
+
{@const threshold = section.truncateThreshold ?? listTruncateThreshold}
|
|
246
|
+
{@const isTruncatable =
|
|
247
|
+
!section.disableTruncation && sectionLinks.length > threshold}
|
|
248
|
+
{@const defaultLinkStyle =
|
|
249
|
+
section.type === "main" || section.type === "other" ? "other" : "normal"}
|
|
250
|
+
{@const useOtherStyle = (section.linkStyle ?? defaultLinkStyle) === "other"}
|
|
251
|
+
{@const sectionTitle =
|
|
252
|
+
section.subheading ?? mainSection?.title ?? "Related content"}
|
|
253
|
+
|
|
254
|
+
{#if sectionLinks.length > 0}
|
|
255
|
+
<nav
|
|
256
|
+
class="gem-c-related-navigation__nav-section"
|
|
257
|
+
aria-labelledby={section.type !== "main"
|
|
258
|
+
? `related-nav-heading-${section.id}`
|
|
259
|
+
: undefined}
|
|
260
|
+
data-module={isTruncatable ? "gem-toggle" : undefined}
|
|
261
|
+
>
|
|
262
|
+
{#if section.type === "subheading" || section.type === "other"}
|
|
263
|
+
{@render sectionHeading(
|
|
264
|
+
`related-nav-heading-${section.id}`,
|
|
265
|
+
section.subheading ?? "",
|
|
266
|
+
section.type === "other",
|
|
267
|
+
)}
|
|
268
|
+
{/if}
|
|
269
|
+
|
|
270
|
+
<ul class="gem-c-related-navigation__link-list">
|
|
271
|
+
{#each sectionLinks.slice(0, isTruncatable ? threshold : sectionLinks.length) as link, i}
|
|
272
|
+
{@render linkListItem(
|
|
273
|
+
link,
|
|
274
|
+
i,
|
|
275
|
+
sectionLinks.length,
|
|
276
|
+
sectionTitle,
|
|
277
|
+
useOtherStyle,
|
|
278
|
+
sectionIndex,
|
|
279
|
+
)}
|
|
280
|
+
{/each}
|
|
281
|
+
{#if isTruncatable && hasJavaScript}
|
|
282
|
+
{@render toggleControl(sectionLinks, section.id, threshold)}
|
|
283
|
+
{@render truncatedItemsList(
|
|
284
|
+
sectionLinks,
|
|
285
|
+
section.id,
|
|
286
|
+
sectionTitle,
|
|
287
|
+
useOtherStyle,
|
|
288
|
+
threshold,
|
|
289
|
+
sectionIndex,
|
|
290
|
+
)}
|
|
291
|
+
{/if}
|
|
292
|
+
</ul>
|
|
293
|
+
</nav>
|
|
294
|
+
{/if}
|
|
295
|
+
{/each}
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
<style>
|
|
299
|
+
.gem-c-related-navigation {
|
|
300
|
+
border-top: 2px solid #1d70b8;
|
|
301
|
+
margin-bottom: 60px;
|
|
302
|
+
color: #0b0c0c;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@media print {
|
|
306
|
+
.gem-c-related-navigation {
|
|
307
|
+
color: #000;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.gem-c-related-navigation__main-heading {
|
|
312
|
+
margin-top: 15px;
|
|
313
|
+
margin-bottom: 10px;
|
|
314
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
315
|
+
-webkit-font-smoothing: antialiased;
|
|
316
|
+
-moz-osx-font-smoothing: grayscale;
|
|
317
|
+
font-weight: 700;
|
|
318
|
+
font-size: 1.1875rem;
|
|
319
|
+
line-height: 1.3157894737;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@media print {
|
|
323
|
+
.gem-c-related-navigation__main-heading {
|
|
324
|
+
font-family: sans-serif;
|
|
325
|
+
font-size: 14pt;
|
|
326
|
+
line-height: 1.15;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.gem-c-related-navigation__sub-heading {
|
|
331
|
+
border-top: 1px solid #b1b4b6;
|
|
332
|
+
margin: 0;
|
|
333
|
+
padding-top: 15px;
|
|
334
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
335
|
+
-webkit-font-smoothing: antialiased;
|
|
336
|
+
-moz-osx-font-smoothing: grayscale;
|
|
337
|
+
font-weight: 400;
|
|
338
|
+
font-size: 1rem;
|
|
339
|
+
line-height: 1.25;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
@media print {
|
|
343
|
+
.gem-c-related-navigation__sub-heading {
|
|
344
|
+
font-family: sans-serif;
|
|
345
|
+
font-size: 14pt;
|
|
346
|
+
line-height: 1.2;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.gem-c-related-navigation__sub-heading--footer {
|
|
351
|
+
border-top: 0;
|
|
352
|
+
padding-top: 0;
|
|
353
|
+
margin-top: 15px;
|
|
354
|
+
margin-bottom: 10px;
|
|
355
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
356
|
+
-webkit-font-smoothing: antialiased;
|
|
357
|
+
-moz-osx-font-smoothing: grayscale;
|
|
358
|
+
font-weight: 700;
|
|
359
|
+
font-size: 1.1875rem;
|
|
360
|
+
line-height: 1.3157894737;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
@media print {
|
|
364
|
+
.gem-c-related-navigation__sub-heading--footer {
|
|
365
|
+
font-family: sans-serif;
|
|
366
|
+
font-size: 14pt;
|
|
367
|
+
line-height: 1.15;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.gem-c-related-navigation__main-heading
|
|
372
|
+
+ .gem-c-related-navigation__sub-heading {
|
|
373
|
+
border-top: 0;
|
|
374
|
+
padding-top: 0;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.gem-c-related-navigation__sub-heading--other {
|
|
378
|
+
border-top: 0;
|
|
379
|
+
padding-top: 0;
|
|
380
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
381
|
+
-webkit-font-smoothing: antialiased;
|
|
382
|
+
-moz-osx-font-smoothing: grayscale;
|
|
383
|
+
font-weight: 700;
|
|
384
|
+
font-size: 1.1875rem;
|
|
385
|
+
line-height: 1.3157894737;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
@media print {
|
|
389
|
+
.gem-c-related-navigation__sub-heading--other {
|
|
390
|
+
font-family: sans-serif;
|
|
391
|
+
font-size: 14pt;
|
|
392
|
+
line-height: 1.15;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.gem-c-related-navigation__nav-section {
|
|
397
|
+
margin-bottom: 30px;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.gem-c-related-navigation__link {
|
|
401
|
+
list-style-type: none;
|
|
402
|
+
margin-top: 15px;
|
|
403
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
404
|
+
-webkit-font-smoothing: antialiased;
|
|
405
|
+
-moz-osx-font-smoothing: grayscale;
|
|
406
|
+
font-weight: 400;
|
|
407
|
+
font-size: 1rem;
|
|
408
|
+
line-height: 1.45;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
@media print {
|
|
412
|
+
.gem-c-related-navigation__link {
|
|
413
|
+
font-family: sans-serif;
|
|
414
|
+
font-size: 14pt;
|
|
415
|
+
line-height: 1.45;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
@media (min-width: 40.0625em) {
|
|
420
|
+
.gem-c-related-navigation__link {
|
|
421
|
+
line-height: 1.28;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.gem-c-related-navigation__link:focus,
|
|
426
|
+
.gem-c-related-navigation__link:active:focus,
|
|
427
|
+
.gem-c-related-navigation__link:link:focus,
|
|
428
|
+
.gem-c-related-navigation__link:visited:focus {
|
|
429
|
+
outline: 3px solid rgba(0, 0, 0, 0);
|
|
430
|
+
background-color: #fd0;
|
|
431
|
+
box-shadow:
|
|
432
|
+
0 -2px #fd0,
|
|
433
|
+
0 4px #0b0c0c;
|
|
434
|
+
text-decoration: none;
|
|
435
|
+
-webkit-box-decoration-break: clone;
|
|
436
|
+
box-decoration-break: clone;
|
|
437
|
+
color: #0b0c0c !important;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.gem-c-related-navigation__link--truncated-links {
|
|
441
|
+
margin-top: 10px;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.gem-c-related-navigation__toggle {
|
|
445
|
+
display: none;
|
|
446
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
447
|
+
-webkit-font-smoothing: antialiased;
|
|
448
|
+
-moz-osx-font-smoothing: grayscale;
|
|
449
|
+
text-decoration: underline;
|
|
450
|
+
text-decoration-thickness: max(1px, 0.0625rem);
|
|
451
|
+
text-underline-offset: 0.1578em;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
@media print {
|
|
455
|
+
.gem-c-related-navigation__toggle {
|
|
456
|
+
font-family: sans-serif;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.gem-c-related-navigation__toggle:hover {
|
|
461
|
+
text-decoration-thickness: max(3px, 0.1875rem, 0.12em);
|
|
462
|
+
-webkit-text-decoration-skip-ink: none;
|
|
463
|
+
text-decoration-skip-ink: none;
|
|
464
|
+
-webkit-text-decoration-skip: none;
|
|
465
|
+
text-decoration-skip: none;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.gem-c-related-navigation__toggle:focus {
|
|
469
|
+
outline: 3px solid rgba(0, 0, 0, 0);
|
|
470
|
+
color: #0b0c0c;
|
|
471
|
+
background-color: #fd0;
|
|
472
|
+
box-shadow:
|
|
473
|
+
0 -2px #fd0,
|
|
474
|
+
0 4px #0b0c0c;
|
|
475
|
+
text-decoration: none;
|
|
476
|
+
-webkit-box-decoration-break: clone;
|
|
477
|
+
box-decoration-break: clone;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.gem-c-related-navigation__toggle:link {
|
|
481
|
+
color: #1d70b8;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.gem-c-related-navigation__toggle:visited {
|
|
485
|
+
color: #1d70b8;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.gem-c-related-navigation__toggle:hover {
|
|
489
|
+
color: #003078;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.gem-c-related-navigation__toggle:active {
|
|
493
|
+
color: #0b0c0c;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.gem-c-related-navigation__toggle:focus {
|
|
497
|
+
color: #0b0c0c;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.govuk-frontend-supported .gem-c-related-navigation__toggle {
|
|
501
|
+
display: inline-block;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.gem-c-related-navigation__section-link {
|
|
505
|
+
font-weight: bold;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.gem-c-related-navigation__section-link:focus,
|
|
509
|
+
.gem-c-related-navigation__section-link:active:focus,
|
|
510
|
+
.gem-c-related-navigation__section-link:link:focus,
|
|
511
|
+
.gem-c-related-navigation__section-link:visited:focus {
|
|
512
|
+
outline: 3px solid rgba(0, 0, 0, 0);
|
|
513
|
+
background-color: #fd0;
|
|
514
|
+
box-shadow:
|
|
515
|
+
0 -2px #fd0,
|
|
516
|
+
0 4px #0b0c0c;
|
|
517
|
+
text-decoration: none;
|
|
518
|
+
-webkit-box-decoration-break: clone;
|
|
519
|
+
box-decoration-break: clone;
|
|
520
|
+
color: #0b0c0c !important;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.gem-c-related-navigation__section-link--other {
|
|
524
|
+
font-weight: normal;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.gem-c-related-navigation__section-link--other:focus,
|
|
528
|
+
.gem-c-related-navigation__section-link--other:active:focus,
|
|
529
|
+
.gem-c-related-navigation__section-link--other:link:focus,
|
|
530
|
+
.gem-c-related-navigation__section-link--other:visited:focus {
|
|
531
|
+
outline: 3px solid rgba(0, 0, 0, 0);
|
|
532
|
+
background-color: #fd0;
|
|
533
|
+
box-shadow:
|
|
534
|
+
0 -2px #fd0,
|
|
535
|
+
0 4px #0b0c0c;
|
|
536
|
+
text-decoration: none;
|
|
537
|
+
-webkit-box-decoration-break: clone;
|
|
538
|
+
box-decoration-break: clone;
|
|
539
|
+
color: #0b0c0c !important;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.gem-c-related-navigation__section-link--footer:focus,
|
|
543
|
+
.gem-c-related-navigation__section-link--footer:active:focus,
|
|
544
|
+
.gem-c-related-navigation__section-link--footer:link:focus,
|
|
545
|
+
.gem-c-related-navigation__section-link--footer:visited:focus {
|
|
546
|
+
outline: 3px solid rgba(0, 0, 0, 0);
|
|
547
|
+
background-color: #fd0;
|
|
548
|
+
box-shadow:
|
|
549
|
+
0 -2px #fd0,
|
|
550
|
+
0 4px #0b0c0c;
|
|
551
|
+
text-decoration: none;
|
|
552
|
+
-webkit-box-decoration-break: clone;
|
|
553
|
+
box-decoration-break: clone;
|
|
554
|
+
color: #0b0c0c !important;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.gem-c-related-navigation__section-link--inline {
|
|
558
|
+
line-height: 1.45;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.gem-c-related-navigation__link-list {
|
|
562
|
+
padding: 0;
|
|
563
|
+
margin: 0;
|
|
564
|
+
list-style: none;
|
|
565
|
+
margin-bottom: 1.25em;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
@media (min-width: 40.0625em) {
|
|
569
|
+
.gem-c-related-navigation__toggle-more
|
|
570
|
+
.gem-c-related-navigation__section-link {
|
|
571
|
+
line-height: 1.45;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.govuk-frontend-supported .gem-c-related-navigation__toggle-more.js-hidden {
|
|
576
|
+
display: none;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/* Add new rules to override govuk-link default font weight */
|
|
580
|
+
a.govuk-link.gem-c-related-navigation__section-link {
|
|
581
|
+
font-weight: bold;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
a.govuk-link.gem-c-related-navigation__section-link--other {
|
|
585
|
+
font-weight: normal;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/* New rules for truncated links with the --other modifiers */
|
|
589
|
+
a.govuk-link.gem-c-related-navigation__section-link--other-truncated {
|
|
590
|
+
line-height: 1.45;
|
|
591
|
+
font-weight: normal;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface InternalLink {
|
|
2
|
+
title: string;
|
|
3
|
+
base_path: string;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface ExternalLink {
|
|
7
|
+
title: string;
|
|
8
|
+
url: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface RelatedContentSection {
|
|
12
|
+
type: "main" | "subheading" | "other";
|
|
13
|
+
id: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
subheading?: string;
|
|
16
|
+
links: (InternalLink | ExternalLink)[];
|
|
17
|
+
linkStyle?: "normal" | "other";
|
|
18
|
+
truncateThreshold?: number;
|
|
19
|
+
disableTruncation?: boolean;
|
|
20
|
+
}
|
|
21
|
+
type $$ComponentProps = {
|
|
22
|
+
sections?: RelatedContentSection[];
|
|
23
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
24
|
+
listTruncateThreshold?: number;
|
|
25
|
+
disableGa4?: boolean;
|
|
26
|
+
};
|
|
27
|
+
declare const RelatedContent: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
28
|
+
type RelatedContent = ReturnType<typeof RelatedContent>;
|
|
29
|
+
export default RelatedContent;
|