@onsvisual/svelte-components 0.1.21 → 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>;
@@ -29,7 +29,7 @@
29
29
  if (mounted) {
30
30
  const url = page?.url || document.location;
31
31
  lang = url.host.startsWith("cy") ? "cy" : "en";
32
- baseurl = `//${url.host}`;
32
+ baseurl = lang === "cy" ? "//cy.ons.gov.uk" : "//www.ons.gov.uk";
33
33
  path = url.pathname;
34
34
  }
35
35
  }
@@ -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 = `//${url.host}`;
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 == "cy" && texts[text] ? texts[text] : text);
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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",