Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for additional logo in footer #3227

Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
8f83e87
added initial changes and updated tests
precious-onyenaucheya-ons Apr 22, 2024
b99e980
added initial changes and updated tests
precious-onyenaucheya-ons Apr 22, 2024
ea84dd0
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Apr 22, 2024
e3511c5
update example and visual tests
precious-onyenaucheya-ons Apr 24, 2024
219b1e2
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 24, 2024
72ff151
Update src/components/footer/_macro-options.md
precious-onyenaucheya-ons Apr 24, 2024
d26ae7c
Update src/components/footer/_macro-options.md
precious-onyenaucheya-ons Apr 24, 2024
7b06a5f
update visual test
precious-onyenaucheya-ons Apr 25, 2024
d61a36e
update example and visual test
precious-onyenaucheya-ons Apr 26, 2024
8face79
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Apr 26, 2024
a2fb140
address PR comments
precious-onyenaucheya-ons Apr 26, 2024
dbb2ec8
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Apr 29, 2024
a9d03c0
Update src/components/footer/example-footer-with-additional-logo.njk
precious-onyenaucheya-ons Apr 29, 2024
8a26c19
Update src/components/footer/_macro.spec.js
precious-onyenaucheya-ons Apr 29, 2024
8bdbf01
Update src/components/footer/_macro.spec.js
precious-onyenaucheya-ons Apr 29, 2024
2ea56fd
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 29, 2024
97c5ee6
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 29, 2024
3d4aa8b
update macro
precious-onyenaucheya-ons Apr 29, 2024
fced6c7
remove styling rom css
precious-onyenaucheya-ons Apr 29, 2024
996a2f8
update snapshot
precious-onyenaucheya-ons Apr 29, 2024
98288e2
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Apr 29, 2024
9cbbab0
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 29, 2024
695271e
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 29, 2024
dcf2e99
Update src/components/footer/_macro.spec.js
precious-onyenaucheya-ons Apr 29, 2024
81f6c7c
update snapshot
precious-onyenaucheya-ons Apr 29, 2024
d8fce77
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 30, 2024
8febfb0
Update src/components/footer/_macro-options.md
precious-onyenaucheya-ons Apr 30, 2024
ebb3ecf
Update src/components/footer/_macro-options.md
precious-onyenaucheya-ons Apr 30, 2024
ab080e2
Update src/components/footer/_macro.spec.js
precious-onyenaucheya-ons Apr 30, 2024
879d2b0
Update src/components/footer/_macro.spec.js
precious-onyenaucheya-ons Apr 30, 2024
00eb27e
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 30, 2024
9bea1c7
Update src/components/footer/example-footer-with-additional-logo.njk
precious-onyenaucheya-ons Apr 30, 2024
3464b0d
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 30, 2024
7c715a4
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 30, 2024
03d7db9
Update src/components/footer/_macro.njk
precious-onyenaucheya-ons Apr 30, 2024
6c56fd9
fix tests failure
precious-onyenaucheya-ons Apr 30, 2024
fa64722
update macro.md file
precious-onyenaucheya-ons Apr 30, 2024
76bafac
rename example file
precious-onyenaucheya-ons Apr 30, 2024
692efb7
update visual tests
precious-onyenaucheya-ons Apr 30, 2024
8aa8ef5
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons May 1, 2024
292575c
update logo
precious-onyenaucheya-ons May 8, 2024
599b27d
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons May 8, 2024
79e06b9
update css
precious-onyenaucheya-ons May 8, 2024
5781429
update css as per PR comment
precious-onyenaucheya-ons May 10, 2024
a0b4ccd
update styling
precious-onyenaucheya-ons May 10, 2024
0060979
update visual test
precious-onyenaucheya-ons May 10, 2024
529c67a
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
alessioventuriniAND May 16, 2024
34c1b60
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
alessioventuriniAND May 21, 2024
acdbff5
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
alessioventuriniAND May 31, 2024
c158709
add initial changes
precious-onyenaucheya-ons Jun 4, 2024
0cc62f7
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Jun 4, 2024
4d4ce77
update doc
precious-onyenaucheya-ons Jun 5, 2024
8bb3942
update tests
precious-onyenaucheya-ons Jun 5, 2024
fd7e0c1
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Jun 5, 2024
2bd7fb9
update visual test
precious-onyenaucheya-ons Jun 5, 2024
bb6fc5e
update visual test
precious-onyenaucheya-ons Jun 7, 2024
f083347
add example
precious-onyenaucheya-ons Jun 14, 2024
d0f7cf5
add example
precious-onyenaucheya-ons Jun 14, 2024
f315b58
add changes as per PR comments
precious-onyenaucheya-ons Jun 18, 2024
630f6e1
approve visual tests
precious-onyenaucheya-ons Jun 18, 2024
052dec6
update macro
precious-onyenaucheya-ons Jun 18, 2024
123348d
update
precious-onyenaucheya-ons Jun 21, 2024
88bf38b
update visual tests
precious-onyenaucheya-ons Jun 24, 2024
efeaa83
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Jun 24, 2024
ed44303
update visual tests
precious-onyenaucheya-ons Jun 25, 2024
7cf10a7
update tests
precious-onyenaucheya-ons Jun 25, 2024
1b34335
update css
precious-onyenaucheya-ons Jun 27, 2024
99d45cf
rename example
precious-onyenaucheya-ons Jun 28, 2024
cd9ec46
Update src/components/footer/_macro-options.md
precious-onyenaucheya-ons Jun 28, 2024
11b2593
update css
precious-onyenaucheya-ons Jul 1, 2024
23fd37c
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Jul 1, 2024
9c9fcad
update footer
precious-onyenaucheya-ons Jul 5, 2024
2613ba2
Merge branch 'main' into feature/3134-add-option-for-additional-logo-…
precious-onyenaucheya-ons Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions __snapshots__/layout/_template.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@ exports[`base page template matches the full configuration snapshot 1`] = `





<footer class="ons-footer">

Expand Down Expand Up @@ -1500,7 +1501,7 @@ exports[`base page template matches the full configuration snapshot 1`] = `

</div>

<div class="ons-grid ons-grid--flex ons-grid--vertical-top ons-grid--between">
<div class="ons-grid ons-grid--vertical-top ons-grid--between">
<div class="ons-grid__col">

<!-- Legal -->
Expand Down Expand Up @@ -1594,9 +1595,15 @@ exports[`base page template matches the full configuration snapshot 1`] = `

</div>



<a class="ons-footer__poweredBy-link" href="https://www.ons.gov.uk/">
<div class="ons-footer__poweredby-logo ons-u-mb-m">




<div class="ons-footer__logo ons-u-mb-m">

<a class="ons-footer__logo-link" href="https://www.ons.gov.uk/">

<svg class="ons-icon--logo" xmlns="http://www.w3.org/2000/svg" width="197" height="19" viewBox="33 2 552 60" aria-labelledby="ons-logo-en-footer-alt" role="img">
<title id="ons-logo-en-footer-alt">Office for National Statistics</title>
Expand Down Expand Up @@ -1637,14 +1644,13 @@ exports[`base page template matches the full configuration snapshot 1`] = `
</g>
</svg>

</div>
</a>

</a>
</div>
</div>

</div>


</div>
</div>
</footer>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions src/components/footer/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
vertical-align: middle;
}

&__poweredBy-link {
&:focus {
.ons-icon--logo {
@extend %a-focus;
}
}
&__extra-logo svg,
img {
max-height: 30px;
width: auto;
}

&__logo {
gap: 1rem;
}

.ons-icon--logo,
Expand Down
25 changes: 24 additions & 1 deletion src/components/footer/_macro-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| cols | array`<FooterCol>` | false | An array of objects for each of the 3 allowed [footer columns](#footercol) |
| rows | array`<FooterRow>` | false | An array for the first [footer row](#footerrow) |
| legal | array`<LegalRow>` | false | An array of for the [row of legal links](#legalrow) |
| poweredBy | HTML | false | Any HTML to render an image for example embedded `<svg>` or `<img>` to override the default ONS logo |
| footerLogo | object`<FooterLogo>` | false | Settings for a [footer logo](#footerLogo) in the footer to override the default ONS logo. |
| lang | string | false | Set the ISO language code for current page to display the correct language ONS logo. Defaults to “en”. |
| newTabWarning | string | false | Leading line of text to warn users that all footer links will open a new tab |
| OGLLink | object`<OGLLink>` | false | An object containing settings for the [Open Government Licence content](#ogllink). Set to “true” to display the default values for English and Welsh |
Expand Down Expand Up @@ -50,3 +50,26 @@
| Name | Type | Required | Description |
| --------- | ----------------------------------------------------------- | -------- | --------------------------- |
| itemsList | array`<ListItem>` [_(ref)_](/foundations/typography/#lists) | true | A list of links for the row |

## FooterLogo

| Name | Type | Required | Description |
| ------- | ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| classes | string | false | Classes to be added. |
| logos | Object`<Logos>` | false | Allows for up to two logos to be used in the footer. |
| display | string | false | Allowed values are 'split' or 'default'. The 'split' display positions the additional logo on the opposite side of the page, while the 'default' display places the logos next to each other. |

## Logos

| Name | Type | Required | Description |
| ------- | -------------- | -------- | --------------------------------- |
| classes | string | false | Classes to be added. |
| logo1 | object`<Logo>` | false | First Logo. Defaults to ONS logo. |
| logo2 | object`<Logo>` | false | Second Logo |

## Logo

| Name | Type | Required | Description |
| --------- | -------------- | -------- | --------------------------------------------------------------------------------------- |
| logoImage | HTML or string | false | Any HTML to render an image for example embedded `<svg>` or `<img>`. |
| logoUrl | string | false | Wraps the extra logo in a link. Set the URL for the HTML `href` attribute for the link. |
39 changes: 27 additions & 12 deletions src/components/footer/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
{% set lang = 'en' %}
{% endif %}

{% set extraLogo = params.footerLogo.logos.logo2 %}
{% set onsLogo %}
{% if params.lang == 'cy' %}
{{-
onsIcon({
"iconType": 'ons-logo-cy',
"iconType": 'ons-logo-stacked-cy' if extraLogo else 'ons-logo-cy',
"altText": 'Swyddfa Ystadegau Gwladol',
"altTextId": 'ons-logo-cy-footer-alt'
})
-}}
{% else %}
{{-
onsIcon({
"iconType": 'ons-logo-en',
"iconType": 'ons-logo-stacked-en' if extraLogo else 'ons-logo-en' ,
"altText": 'Office for National Statistics',
"altTextId": 'ons-logo-en-footer-alt'
})
Expand Down Expand Up @@ -111,7 +112,7 @@
{% endif %}
</div>

<div class="ons-grid ons-grid--flex ons-grid--vertical-top ons-grid--between">
<div class="ons-grid{% if params.crest %} ons-grid--flex{% endif %} ons-grid--vertical-top ons-grid--between">
<div class="ons-grid__col">
{% if params.legal %}
<!-- Legal -->
Expand Down Expand Up @@ -156,13 +157,30 @@
{% endif %}
</div>
{% endif %}
{% if not params.poweredBy %}
<a class="ons-footer__poweredBy-link" {% if lang == "cy" %}href="https://cy.ons.gov.uk/"{% else %}href="https://www.ons.gov.uk/"{% endif %}>
<div class="ons-footer__poweredby-logo ons-u-mb-m">
{{ onsLogo | safe }}
</div>
</a>

{% if not params.footerLogo.logos.logo1 %}
{% set logo1 = {
'logoUrl': 'https://cy.ons.gov.uk/' if lang == 'cy' else 'https://www.ons.gov.uk/',
'logoImage': onsLogo | safe
} %}
{% set logos = [logo1, params.footerLogo.logos.logo2] %}
{% else %}
{% set logos = [params.footerLogo.logos.logo1, params.footerLogo.logos.logo2] %}
{% endif %}

<div class="ons-footer__logo ons-u-mb-m{% if extraLogo %} ons-footer__extra-logo ons-grid--flex ons-grid--vertical-center{% if params.footerLogo.display == 'split' %} ons-grid--between{% endif %}{% endif %}">
{% for logo in logos %}
{%-if logo.logoUrl %}
<a class="ons-footer__logo-link{% if extraLogo and loop.index == 1 %} ons-u-mr-s{% endif %}" href="{{ logo.logoUrl }}">
{% endif -%}

{{ logo.logoImage | safe }}

{%-if logo.logoUrl %}
</a>
{% endif -%}
{% endfor %}
</div>
</div>
{% if params.crest %}
<!-- Crest -->
Expand All @@ -175,9 +193,6 @@
</div>
{% endif %}
</div>
{% if params.poweredBy %}
{{ params.poweredBy | safe }}
{% endif %}
{% if params.copyrightDeclaration %}
<!-- Copyright -->
<div class="ons-grid ons-grid--flex ons-grid--vertical-bottom ons-grid--between">
Expand Down
98 changes: 80 additions & 18 deletions src/components/footer/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ describe('macro: footer', () => {
});
});

describe('poweredBy logo', () => {
describe('default poweredBy logo', () => {
describe('Footer logo', () => {
describe('default footer logo', () => {
describe.each([
[
'the `lang` parameter is not provided',
Expand Down Expand Up @@ -387,7 +387,7 @@ describe('macro: footer', () => {
});
});
});
describe('provided poweredBy logo', () => {
describe('provided footer logo', () => {
describe.each([
[
'the `lang` parameter is "cy"',
Expand Down Expand Up @@ -415,54 +415,74 @@ describe('macro: footer', () => {
it('has the Welsh lang link when the default Welsh lang ons icon is present', () => {
const $ = cheerio.load(renderComponent('footer', { lang: 'cy' }));

expect($('.ons-footer__poweredBy-link').attr('href')).toBe('https://cy.ons.gov.uk/');
expect($('.ons-footer__logo-link').attr('href')).toBe('https://cy.ons.gov.uk/');
});
it('has the English lang link when the default English lang ons icon is present', () => {
const $ = cheerio.load(renderComponent('footer', { lang: 'en' }));

expect($('.ons-footer__poweredBy-link').attr('href')).toBe('https://www.ons.gov.uk/');
expect($('.ons-footer__logo-link').attr('href')).toBe('https://www.ons.gov.uk/');
});
});
describe('provided poweredBy logo', () => {
describe('provided footer logo', () => {
describe.each([
[
'the `poweredBy` and `OGLLink` parameters are provided',
'the `footerLogo` and `OGLLink` parameters are provided',
{
poweredBy: '<img src="logo.svg" class="custom-logo" alt="logo">',
footerLogo: {
logos: {
logo1: { logoImage: '<img src="logo.svg" class="custom-logo" alt="logo">' },
},
},
OGLLink: EXAMPLE_OGL_LINK_PARAM,
},
],
[
'the `poweredBy` and `legal` parameters are provided',
'the `footerLogo` and `legal` parameters are provided',
{
poweredBy: '<img src="logo.svg" class="custom-logo" alt="logo">',
footerLogo: {
logos: {
logo1: { logoImage: '<img src="logo.svg" class="custom-logo" alt="logo">' },
},
},
legal: EXAMPLE_LEGAL_PARAM,
},
],
[
'the `poweredBy` and `crest` parameters are provided',
'the `footerLogo` and `crest` parameters are provided',
{
poweredBy: '<img src="logo.svg" class="custom-logo" alt="logo">',
footerLogo: {
logos: {
logo1: { logoImage: '<img src="logo.svg" class="custom-logo" alt="logo">' },
},
},
crest: true,
},
],
[
'the `poweredBy`, `legal` and `crest` parameters are provided',
'the `footerLogo`, `legal` and `crest` parameters are provided',
{
poweredBy: '<img src="logo.svg" class="custom-logo" alt="logo">',
footerLogo: {
logos: {
logo1: { logoImage: '<img src="logo.svg" class="custom-logo" alt="logo">' },
},
},
legal: EXAMPLE_LEGAL_PARAM,
crest: true,
},
],
[
'the `poweredBy` parameter is provided but the `legal` and `crest` parameters are not provided',
'the `footerLogo` parameter is provided but the `legal` and `crest` parameters are not provided',
{
poweredBy: '<img src="logo.svg" class="custom-logo" alt="logo">',
footerLogo: {
logos: {
logo1: { logoImage: '<img src="logo.svg" class="custom-logo" alt="logo">' },
},
},
},
],
])('where %s', (_, poweredByParams) => {
])('where %s', (_, footerLogoParams) => {
const params = {
...poweredByParams,
...footerLogoParams,
};

it('passes jest-axe checks', async () => {
Expand All @@ -478,6 +498,48 @@ describe('macro: footer', () => {
expect($('.custom-logo').length).toBe(1);
});
});

it('has the extra footer logo image and link', () => {
const $ = cheerio.load(
renderComponent('footer', {
footerLogo: {
logos: {
logo1: { logoImage: '<img src="logo.svg" class="custom-logo" alt="logo">' },
logo2: {
logoUrl: '#0',
logoImage: '<img src="a-logo.svg">',
},
},
},
legal: EXAMPLE_LEGAL_PARAM,
crest: true,
}),
);

expect($('.ons-footer__logo-link').attr('href')).toBe('#0');
expect($('.ons-footer__logo-link > img').attr('src')).toBe('a-logo.svg');
});

it('has the correct class applied for opposite display of logos', () => {
const $ = cheerio.load(
renderComponent('footer', {
footerLogo: {
logos: {
logo1: { logoImage: '<img src="logo.svg" class="custom-logo" alt="logo">' },
logo2: {
logoUrl: '#0',
logoImage: '<img src="a-logo.svg">',
},
},
display: 'split',
},
legal: EXAMPLE_LEGAL_PARAM,
crest: true,
}),
);

expect($('.ons-footer__logo').attr('class')).toContain('ons-grid--between');
});
});
});

Expand Down
Loading
Loading