Skip to content

Commit 4203960

Browse files
committed
[WIP] hack together component and pop it all over the page
1 parent f7056dc commit 4203960

32 files changed

Lines changed: 1159 additions & 4 deletions

packages/govuk-frontend-review/src/views/examples/template-custom/index.njk

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
44
{% from "govuk/components/skip-link/macro.njk" import govukSkipLink %}
55
{% from "govuk/components/header/macro.njk" import govukHeader %}
6+
{% from "govuk/components/language-switcher/macro.njk" import govukLanguageSwitcher %}
67
{% from "govuk/components/phase-banner/macro.njk" import govukPhaseBanner %}
78
{% from "govuk/components/footer/macro.njk" import govukFooter %}
89

@@ -15,6 +16,39 @@
1516
{% set bodyClasses = 'app-body-class' %}
1617
{% set containerClasses = "app-width-container--wide" %}
1718
{% set assetUrl = 'https://govuk-frontend-review.herokuapp.com/assets' %}
19+
{% set languageSwitcherItems = [
20+
{
21+
code: "fr",
22+
text: "Francais",
23+
href: "#fr"
24+
},
25+
{
26+
code: "en",
27+
text: "English",
28+
href: "#en"
29+
},
30+
{
31+
code: "cy",
32+
text: "Cymraeg",
33+
href: "#cy"
34+
}
35+
] %}
36+
{% set headerLanguageSwitcherHtml %}
37+
{{ govukLanguageSwitcher({
38+
currentLanguage: "fr",
39+
showIcon: true,
40+
collapseOnMobile: false,
41+
items: languageSwitcherItems
42+
}) }}
43+
{% endset %}
44+
{% set footerLanguageSwitcherHtml %}
45+
{{ govukLanguageSwitcher({
46+
currentLanguage: "fr",
47+
showIcon: true,
48+
collapseOnMobile: false,
49+
items: languageSwitcherItems
50+
}) }}
51+
{% endset %}
1852

1953
{% block pageTitle %}GOV.UK - Le meilleur endroit pour trouver des services gouvernementaux et de l'information{% endblock %}
2054

@@ -60,6 +94,7 @@
6094
{{ govukHeader({
6195
serviceName: "Nom du service",
6296
containerClasses: containerClasses,
97+
secondaryHtml: headerLanguageSwitcherHtml,
6398
navigation: [
6499
{
65100
href: '#1',
@@ -106,9 +141,18 @@
106141

107142
{% block containerStart %}
108143
<!-- block:containerStart -->
109-
{{ govukBackLink({
110-
href: "/"
111-
}) }}
144+
<div style="display: flex; justify-content: space-between; align-items: start; gap: 20px;">
145+
{{ govukBackLink({
146+
href: "/"
147+
}) }}
148+
{{ govukLanguageSwitcher({
149+
classes: "govuk-language-switcher--right-align",
150+
currentLanguage: "fr",
151+
showIcon: true,
152+
collapseOnMobile: false,
153+
items: languageSwitcherItems
154+
}) }}
155+
</div>
112156
<!-- endblock:containerStart -->
113157
{% endblock %}
114158

@@ -120,6 +164,15 @@
120164

121165
{% block content %}
122166
<!-- block:content -->
167+
{{ govukLanguageSwitcher({
168+
currentLanguage: "fr",
169+
showIcon: true,
170+
collapseOnMobile: true,
171+
items: languageSwitcherItems
172+
}) }}
173+
174+
<h1 class="govuk-heading-l">Exemples de placement du selecteur de langue</h1>
175+
<p class="govuk-body">Cette page montre le composant language-switcher dans l'en-tete, sous l'en-tete, a cote du lien retour, en haut du contenu principal et dans le pied de page.</p>
123176
{{ super() }}
124177
<!-- endblock:content -->
125178
{% endblock %}
@@ -140,6 +193,7 @@
140193
{{ govukFooter({
141194
containerClasses: "app-width-container--wide",
142195
"meta": {
196+
"html": footerLanguageSwitcherHtml,
143197
"items": [
144198
{
145199
"href": "#1",

packages/govuk-frontend/src/govuk/all.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export { Checkboxes } from './components/checkboxes/checkboxes.mjs'
66
export { ErrorSummary } from './components/error-summary/error-summary.mjs'
77
export { ExitThisPage } from './components/exit-this-page/exit-this-page.mjs'
88
export { FileUpload } from './components/file-upload/file-upload.mjs'
9+
export { LanguageSwitcher } from './components/language-switcher/language-switcher.mjs'
910
export { NotificationBanner } from './components/notification-banner/notification-banner.mjs'
1011
export { PasswordInput } from './components/password-input/password-input.mjs'
1112
export { Radios } from './components/radios/radios.mjs'

packages/govuk-frontend/src/govuk/all.puppeteer.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe('GOV.UK Frontend', () => {
7373
'ErrorSummary',
7474
'ExitThisPage',
7575
'FileUpload',
76+
'LanguageSwitcher',
7677
'NotificationBanner',
7778
'PasswordInput',
7879
'Radios',

packages/govuk-frontend/src/govuk/components/_index.import.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
@import "input";
1919
@import "inset-text";
2020
@import "label";
21+
@import "language-switcher";
2122
@import "notification-banner";
2223
@import "pagination";
2324
@import "panel";
@@ -31,6 +32,7 @@
3132
@import "table";
3233
@import "tabs";
3334
@import "tag";
35+
@import "test-service-navigation";
3436
@import "task-list";
3537
@import "textarea";
3638
@import "warning-text";

packages/govuk-frontend/src/govuk/components/_index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
@use "input";
1919
@use "inset-text";
2020
@use "label";
21+
@use "language-switcher";
2122
@use "notification-banner";
2223
@use "pagination";
2324
@use "panel";
@@ -31,6 +32,7 @@
3132
@use "table";
3233
@use "tabs";
3334
@use "tag";
35+
@use "test-service-navigation";
3436
@use "task-list";
3537
@use "textarea";
3638
@use "warning-text";

packages/govuk-frontend/src/govuk/components/header/_mixin.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
padding: 0 base.govuk-spacing(3);
1818
}
1919

20+
.govuk-header__container--with-secondary {
21+
display: flex;
22+
align-items: center;
23+
justify-content: space-between;
24+
gap: base.govuk-spacing(3);
25+
}
26+
2027
.govuk-header__logo {
2128
box-sizing: border-box;
2229

@@ -25,6 +32,29 @@
2532
padding-bottom: 14px - $logo-bottom-margin;
2633
}
2734

35+
.govuk-header__secondary {
36+
margin-left: auto;
37+
}
38+
39+
.govuk-header__secondary .govuk-language-switcher {
40+
margin: 0;
41+
color: base.govuk-colour("white");
42+
}
43+
44+
.govuk-header__secondary .govuk-language-switcher__link {
45+
@include base.govuk-link-style-inverse;
46+
}
47+
48+
.govuk-header__secondary .govuk-language-switcher__toggle {
49+
margin: 0;
50+
color: inherit;
51+
}
52+
53+
.govuk-header__secondary .govuk-language-switcher-right,
54+
.govuk-header__secondary .govuk-language-switcher--right-align {
55+
margin: 0;
56+
}
57+
2858
.govuk-header__homepage-link {
2959
// Avoid using the `base.govuk-link-common` mixin because the links in the
3060
// header get a special treatment, because:

packages/govuk-frontend/src/govuk/components/header/header.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ params:
1111
type: string
1212
required: false
1313
description: Classes for the container, useful if you want to make the header fixed width.
14+
- name: secondaryHtml
15+
type: string
16+
required: false
17+
description: HTML rendered inside the header container after the logo block.
1418
- name: classes
1519
type: string
1620
required: false

packages/govuk-frontend/src/govuk/components/header/template.njk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% from "../../macros/logo.njk" import govukLogo -%}
33

44
<div class="govuk-header {%- if params.classes %} {{ params.classes }}{% endif %}" {{- govukAttributes(params.attributes) }}>
5-
<div class="govuk-header__container {{ params.containerClasses | default("govuk-width-container", true) }}">
5+
<div class="govuk-header__container {{ params.containerClasses | default("govuk-width-container", true) }}{%- if params.secondaryHtml %} govuk-header__container--with-secondary{% endif %}">
66
<div class="govuk-header__logo">
77
<a href="{{ params.homepageUrl | default("//gov.uk", true) }}" class="govuk-header__homepage-link">
88
{{ govukLogo({
@@ -16,5 +16,10 @@
1616
{% endif %}
1717
</a>
1818
</div>
19+
{% if params.secondaryHtml %}
20+
<div class="govuk-header__secondary">
21+
{{ params.secondaryHtml | safe | trim | indent(8) }}
22+
</div>
23+
{% endif %}
1924
</div>
2025
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Language switcher
2+
3+
Use the language switcher component to let users move between equivalent pages in different languages.
4+
5+
It renders a list of language options and can collapse to a button on small viewports.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "language-switcher";

0 commit comments

Comments
 (0)