@onsvisual/svelte-components 0.1.20 → 0.1.22
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.
|
@@ -7,6 +7,7 @@ export default class Header extends SvelteComponentTyped<{
|
|
|
7
7
|
title?: string;
|
|
8
8
|
compact?: boolean;
|
|
9
9
|
titleHref?: string;
|
|
10
|
+
bilingual?: boolean;
|
|
10
11
|
}, {
|
|
11
12
|
[evt: string]: CustomEvent<any>;
|
|
12
13
|
}, {
|
|
@@ -24,6 +25,7 @@ declare const __propDef: {
|
|
|
24
25
|
title?: string;
|
|
25
26
|
compact?: boolean;
|
|
26
27
|
titleHref?: string;
|
|
28
|
+
bilingual?: boolean;
|
|
27
29
|
};
|
|
28
30
|
events: {
|
|
29
31
|
[evt: string]: CustomEvent<any>;
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
setContext("cols", cols);
|
|
96
96
|
</script>
|
|
97
97
|
|
|
98
|
-
<figure aria-label="{caption}"
|
|
98
|
+
<figure aria-label="{caption}">
|
|
99
99
|
<Container
|
|
100
100
|
id="{id}"
|
|
101
101
|
cls="{cls}"
|
|
@@ -109,7 +109,12 @@
|
|
|
109
109
|
{#if title}
|
|
110
110
|
<h2 class="section-title" class:ons-u-vh="{hideTitle}">{title}</h2>
|
|
111
111
|
{/if}
|
|
112
|
-
<div
|
|
112
|
+
<div
|
|
113
|
+
class="grid {gridClass}"
|
|
114
|
+
style:grid-gap="{gridGap}"
|
|
115
|
+
style:min-height="{rowHeight}"
|
|
116
|
+
bind:clientWidth="{w}"
|
|
117
|
+
>
|
|
113
118
|
<slot />
|
|
114
119
|
</div>
|
|
115
120
|
</Container>
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
* @type {object}
|
|
31
31
|
*/
|
|
32
32
|
export let themeOverrides = null;
|
|
33
|
+
/**
|
|
34
|
+
* Set to true to include an English/Welsh language link
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
37
|
+
export let bilingual = false;
|
|
33
38
|
|
|
34
39
|
let lang = "en";
|
|
35
40
|
let baseurl = "//www.ons.gov.uk";
|
|
@@ -41,11 +46,8 @@
|
|
|
41
46
|
if (mounted) {
|
|
42
47
|
const url = page?.url || document.location;
|
|
43
48
|
lang = url.host.startsWith("cy") ? "cy" : "en";
|
|
44
|
-
baseurl =
|
|
45
|
-
baseother =
|
|
46
|
-
lang === "en"
|
|
47
|
-
? `//cy.${url.host.replace("www.", "")}`
|
|
48
|
-
: `//www.${url.host.replace("cy.", "")}`;
|
|
49
|
+
baseurl = lang === "cy" ? "//cy.ons.gov.uk" : "//www.ons.gov.uk";
|
|
50
|
+
baseother = lang === "cy" ? "//www.ons.gov.uk" : "//cy.ons.gov.uk";
|
|
49
51
|
path = url.pathname;
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -257,7 +259,7 @@
|
|
|
257
259
|
"Search for a keyword(s) or time series ID": "Chwilio am allweddair neu ID cyfres amser",
|
|
258
260
|
};
|
|
259
261
|
|
|
260
|
-
const i18n = (text) => (lang
|
|
262
|
+
const i18n = (text) => (lang === "cy" && texts[text] ? texts[text] : text);
|
|
261
263
|
|
|
262
264
|
function toggle_sm(e, i) {
|
|
263
265
|
if (window.matchMedia("(max-width:767px)").matches) {
|
|
@@ -308,11 +310,11 @@
|
|
|
308
310
|
<div
|
|
309
311
|
class="col col--lg-two-thirds col--md-two-thirds hide--sm print--hide language--js__container"
|
|
310
312
|
>
|
|
311
|
-
<div class="language">
|
|
312
|
-
{#if lang == "en"}
|
|
313
|
+
<div class="language" style:min-height="20px">
|
|
314
|
+
{#if bilingual && lang == "en"}
|
|
313
315
|
<span>English (EN) | </span>
|
|
314
316
|
<a href="{baseother}{path}" class="language__link" lang="cy">Cymraeg (CY)</a>
|
|
315
|
-
{:else}
|
|
317
|
+
{:else if bilingual}
|
|
316
318
|
<a href="{baseother}{path}" class="language__link" lang="en">English (EN)</a>
|
|
317
319
|
<span> | Cymraeg (EN)</span>
|
|
318
320
|
{/if}
|