<header class="fixed-header">
<div class="site-header container">
<div class="container__content">
<a href="#main-content" class="skip-to-content">Skip to main content</a>
<img src="/assets/images/england-football-logo.svg" alt="England Football logo" class="logo" /></a>
</div>
<button class="hamburger" aria-controls="main-nav" aria-haspopup="true" aria-expanded="false">Open
navigation</button>
<nav role="navigation" class="site-navigation" id="main-nav">
<ul>
<li class="site-navigation__level1">
<button class="site-navigation__main-tab" aria-controls="teams" aria-haspopup="true" aria-expanded="false" role="menu">England
Teams</button>
<div class="site-navigation__level2-wrapper" id="teams">
<ul class="site-navigation__level2">
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-1" id="accordion-button-1" tabindex="-1">Three Lions</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-1" role="region" aria-labelledby="accordion-button-1" hidden="">
<li><a href="/" data-attr="true">Home</a></li>
<li><a href="/">Squad</a></li>
<li><a href="/">Fixtures & Results</a></li>
<li><a href="/" class="link-external">England Supports Travel Club</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-2" id="accordion-button-2" tabindex="-1">Lionesses</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-2" role="region" aria-labelledby="accordion-button-2" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Squad</a></li>
<li><a href="/">Fixtures & Results</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-3" id="accordion-button-3" tabindex="-1">Youth</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-3" role="region" aria-labelledby="accordion-button-3" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Men's U21</a></li>
<li><a href="/">Women's U23</a></li>
<li><a href="/">Fixtures & Results</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-4" id="accordion-button-4" tabindex="-1">Para</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-4" role="region" aria-labelledby="accordion-button-4" hidden="">
<li><a href="/">Home</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-9" id="accordion-button-9" tabindex="-1">Play</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-9" role="region" aria-labelledby="accordion-button-9" hidden="">
<li><a href="/">Home</a></li>
</ul>
</li>
<li class="site-navigation__promos">
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Tickets</a>
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">England Store</a>
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Interactive Timeline</a>
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">My England Football</a>
</li>
</ul>
</div>
</li>
<li class="site-navigation__level1">
<button class="site-navigation__main-tab" aria-controls="play" aria-haspopup="true" aria-expanded="false" role="menu">Play
& Participate</button>
<div class="site-navigation__level2-wrapper" id="play">
<ul class="site-navigation__level2">
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-5" id="accordion-button-5" tabindex="-1">Play</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-5" role="region" aria-labelledby="accordion-button-5" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Adult</a></li>
<li><a href="/">Kids</a></li>
<li><a href="/">Women & Girls</a></li>
<li><a href="/">Disability</a></li>
<li><a href="/" class="link-external">England Supports Travel Club</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-6" id="accordion-button-6" tabindex="-1">Learn</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-6" role="region" aria-labelledby="accordion-button-6" hidden="">
<li><a href="/" class="link-external">The Bootroom</a></li>
<li><a href="/" class="link-external">Courses</a></li>
<li><a href="/" class="link-external">Session Plans</a></li>
<li><a href="/" class="link-external">Coach Community</a></li>
<li><a href="/" class="link-external">Safeguarding</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-7" id="accordion-button-7" tabindex="-1">Volunteer</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-7" role="region" aria-labelledby="accordion-button-7" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/" class="link-external">Safeguarding</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false" aria-controls="accordion-section-8" id="accordion-button-8" tabindex="-1">Explore</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-8" role="region" aria-labelledby="accordion-button-8" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Helpful Apps & Websites</a></li>
<li><a href="/">Respect</a></li>
<li><a href="/">Grassroots Awards</a></li>
<li><a href="/">County FAs</a></li>
<li><a href="/">COVID-19 Guidane</a></li>
<li><a href="/">The Football Foundation</a></li>
</ul>
</li>
<li class="site-navigation__promos">
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Find Football</a>
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Platform for Football</a>
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Matchday app</a>
<a href="/" class="site-navigation__promo" style="background-image: url(/assets/example-content/nav-promo-store.jpg)">My England Football</a>
</li>
</ul>
</div>
</li>
</ul>
<div class="site-navigation__mobile-prompt">
Please select either England Teams or Play & Participate for navigation options
</div>
</nav>
<div class="container__content b2c-nav-container">
<div class="site-signin">
<a href="#"><span class="mob-only">Sign in/Up</span><span class="desktop-only">Sign in</span></a>
<span class="desktop-only">or</span>
<a class="site-register" href="#">Register Now</a>
</div>
</div>
</div>
</header>
No notes defined.
{
"signedIn": false
}
const ACCORDION_TRIGGER_REF = '.accordion-trigger';
const handleClick = (target, accordion) => {
// Check if the current toggle is expanded.
const isDisabled = target.getAttribute('aria-disabled') === 'true';
if (isDisabled) {
return;
}
const isExpanded = target.getAttribute('aria-expanded') === 'true';
const active = accordion.querySelector(
`${ACCORDION_TRIGGER_REF}[aria-expanded="true"]`
);
// without allowMultiple, close the open accordion
if (active && active !== target) {
// Set the expanded state on the triggering element
active.setAttribute('aria-expanded', 'false');
// Hide the accordion sections, using aria-controls to specify the desired section
document
.getElementById(active.getAttribute('aria-controls'))
.setAttribute('hidden', '');
}
if (!isExpanded) {
// Set the expanded state on the triggering element
target.setAttribute('aria-expanded', 'true');
// Hide the accordion sections, using aria-controls to specify the desired section
document
.getElementById(target.getAttribute('aria-controls'))
.removeAttribute('hidden');
} else {
// Set the expanded state on the triggering element
target.setAttribute('aria-expanded', 'false');
// Hide the accordion sections, using aria-controls to specify the desired section
document
.getElementById(target.getAttribute('aria-controls'))
.setAttribute('hidden', '');
}
};
export const disableAccordion = accordion => {
const allItems = accordion.querySelectorAll(ACCORDION_TRIGGER_REF);
allItems.forEach(element => {
element.setAttribute('aria-disabled', 'true');
element.setAttribute('aria-expanded', 'true');
document
.getElementById(element.getAttribute('aria-controls'))
.removeAttribute('hidden');
});
};
export const enableAccordion = accordion => {
const allItems = accordion.querySelectorAll(ACCORDION_TRIGGER_REF);
allItems.forEach(element => {
element.setAttribute('aria-disabled', 'false');
element.setAttribute('aria-expanded', 'false');
document
.getElementById(element.getAttribute('aria-controls'))
.setAttribute('hidden', '');
});
allItems.forEach(trigger =>
trigger.addEventListener('click', ({ target }) =>
handleClick(target, accordion)
)
);
};
import debounce from 'lodash.debounce';
import { enableAccordion, disableAccordion } from './accordion';
import showSignedInNav from './signed-in-navigation';
const MOBILE_BREAKPOINT = 800;
const KEYCODE_MAP = {
RETURN: 13,
SPACE: 32,
};
const ACCOUNT_API = '/account/IsUserLoggedIn/';
const createMenuAccordion = parentElement => {
if (window.innerWidth >= MOBILE_BREAKPOINT) {
disableAccordion(parentElement);
return;
}
enableAccordion(parentElement);
window.addEventListener(
'resize',
debounce(() => {
if (window.innerWidth >= MOBILE_BREAKPOINT) {
disableAccordion(parentElement);
return;
}
enableAccordion(parentElement);
}, 250)
);
};
const closeNavTab = ({ listenerElement, trigger, body }) => {
if (trigger) {
trigger.setAttribute('aria-expanded', 'false');
} else {
const allTabs = document.querySelectorAll('.site-navigation__main-tab');
allTabs.forEach(tab => tab.setAttribute('aria-expanded', 'false'));
}
body.classList.remove('navigation-open');
body.classList.remove('navigation-open--main');
listenerElement.removeEventListener('mouseout', closeNavTab);
listenerElement.removeEventListener('focusout', closeNavTab);
};
const openNavTab = (event, navigation, body) => {
const { target } = event;
if (!target.classList.contains('site-navigation__main-tab')) {
return;
}
event.preventDefault();
// Grab anything that's already open
const openItems = navigation.querySelector(
'.site-navigation__main-tab[aria-expanded=true]'
);
// open the current tab
target.setAttribute('aria-expanded', 'true');
body.classList.add('navigation-open');
body.classList.add('navigation-open--main');
document.querySelector('.site-header').classList.add('nav-active');
if (event.type === 'mouseover') {
// when we opened the tab with a mouseover, we should close it on mouseleave
target.parentElement.addEventListener(
'mouseleave',
({ target: listenerElement }) =>
closeNavTab({ listenerElement, target, body })
);
return;
}
if (openItems) {
openItems.setAttribute('aria-expanded', 'false');
}
// If there are no open items, then remove the navigation-open class
const isAllTabsClosed = !navigation.querySelector(
'.site-navigation__main-tab[aria-expanded=true]'
);
if (isAllTabsClosed) {
document.querySelector('.site-header').classList.remove('nav-active');
}
};
const handleKeydown = (event, parentElement, body) => {
if (![KEYCODE_MAP.SPACE, KEYCODE_MAP.RETURN].includes(event.keyCode)) {
return;
}
openNavTab(event, parentElement, body);
};
const hamburgerMenu = () => {
const hamburger = document.querySelector('[aria-controls="main-nav"]');
if (!hamburger.offsetParent) {
hamburger.setAttribute('aria-expanded', 'true');
return;
}
hamburger.addEventListener('click', ({ target }) => {
const currentValue = target.getAttribute('aria-expanded');
document.querySelector('body').classList.toggle('navigation-open');
document.querySelector('body').classList.toggle('navigation-open--main');
const allMenu = document.querySelectorAll('.site-navigation__main-tab');
allMenu.forEach(tab => tab.setAttribute('aria-expanded', 'false'));
target.setAttribute('aria-expanded', currentValue !== 'true');
if (document.querySelector('.site-navigation__main-tab.active') === null) {
document.querySelector('.site-header').classList.remove('nav-active');
} else if (document.querySelector('a[data-attr=true]')) {
document
.querySelector('.site-header')
.querySelector('a[data-attr=true]')
.closest('.site-navigation__level1')
.querySelector('.site-navigation__main-tab')
.setAttribute('aria-expanded', 'true');
} else if (
document.querySelectorAll('div[data-brand]').length &&
(document
.querySelectorAll('div[data-brand]')[0]
.getAttribute('data-brand') === 'mens' ||
document
.querySelectorAll('div[data-brand]')[0]
.getAttribute('data-brand') === 'womens')
) {
document
.querySelector('.site-navigation__level1:first-child')
.querySelector('.site-navigation__main-tab')
.setAttribute('aria-expanded', 'true');
}
/* else {
document
.querySelector('.site-navigation__level1:last-child')
.querySelector('.site-navigation__main-tab')
.setAttribute('aria-expanded', 'true');
} */
});
};
const initFixedHeader = () => {
const { body } = document;
let { pageYOffset: prevScrollPos } = window;
const headerEle = document.querySelector('.fixed-header');
const { offsetHeight: headerEleHeight } = headerEle;
let isScrolling = false;
const minScrollDistance = window.innerWidth <= MOBILE_BREAKPOINT ? 10 : 20;
setTimeout(() => {
body.style.marginTop = `${headerEleHeight}px`; // default body margin
}, 500);
window.addEventListener(
'scroll',
() => {
// If there's already a scroll being calculated, we don't
// need to do anything
if (isScrolling) {
return;
}
isScrolling = true;
setTimeout(() => {
const { pageYOffset: currentScrollPos } = window;
// const { offsetHeight: headerEleHeight } = headerEle;
// set the body top padding in order to keep empty space
// of equal height of the header element.
body.style.marginTop = `${headerEleHeight}px`;
// at the top or scroll position is smaller than height of header element.
if (currentScrollPos <= 0 || currentScrollPos <= headerEleHeight) {
headerEle.style.top = 0;
isScrolling = false;
return;
}
if (currentScrollPos > prevScrollPos + minScrollDistance) {
// scroll down
headerEle.style.top = `-${headerEleHeight}px`;
} else if (currentScrollPos < prevScrollPos - minScrollDistance) {
// scroll up
headerEle.style.top = 0;
}
prevScrollPos = currentScrollPos;
isScrolling = false;
}, 100);
},
{ passive: true }
);
};
const highlightNavLinks = parentElement => {
if (parentElement.querySelector('a[data-attr=true]')) {
parentElement.querySelector('a[data-attr=true]').classList.add('active');
parentElement
.querySelector('a[data-attr=true]')
.closest('.site-navigation__level1')
.querySelector('.site-navigation__main-tab')
.classList.add('active');
if (window.innerWidth < MOBILE_BREAKPOINT) {
document.querySelector('.site-header').classList.add('nav-active');
parentElement
.querySelector('a[data-attr=true]')
.closest('.site-navigation__level1')
.querySelector('.site-navigation__main-tab')
.setAttribute('aria-expanded', 'true');
parentElement
.querySelector('a[data-attr=true]')
.closest('.site-navigation__level3')
.removeAttribute('hidden');
parentElement
.querySelector('a[data-attr=true]')
.closest('.site-navigation__level3')
.closest('li')
.querySelector('button')
.setAttribute('aria-expanded', 'true');
}
} else if (
document.querySelectorAll('div[data-brand]').length &&
(document
.querySelectorAll('div[data-brand]')[0]
.getAttribute('data-brand') === 'mens' ||
document
.querySelectorAll('div[data-brand]')[0]
.getAttribute('data-brand') === 'womens')
) {
document
.querySelector('.site-navigation__level1:first-child')
.querySelector('.site-navigation__main-tab')
.classList.add('active');
if (window.innerWidth < MOBILE_BREAKPOINT) {
document.querySelector('.site-header').classList.add('nav-active');
document
.querySelector('.site-navigation__level1:first-child')
.querySelector('.site-navigation__main-tab')
.setAttribute('aria-expanded', 'true');
}
}
/* else {
document
.querySelector('.site-navigation__level1:last-child')
.querySelector('.site-navigation__main-tab')
.classList.add('active');
if (window.innerWidth < MOBILE_BREAKPOINT) {
document.querySelector('.site-header').classList.add('nav-active');
document
.querySelector('.site-navigation__level1:last-child')
.querySelector('.site-navigation__main-tab')
.setAttribute('aria-expanded', 'true');
}
} */
};
const userSignInAnalytics = (loginStatus, { fanCode, userStatus }) => {
// eslint-disable-next-line no-undef
const pageName = dataLayerPageName;
// eslint-disable-next-line no-undef
const pageUrl = dataLayerPageUrl;
// eslint-disable-next-line no-undef
const pageType = dataLayerPageType;
const isLogin = loginStatus;
// eslint-disable-next-line no-undef
const loginWith = dataLayerLoginType;
const status = userStatus;
window.dataLayer.push({
page_name: pageName,
page_url: pageUrl,
page_type: pageType,
loginStatus: isLogin,
logintype: loginWith,
loginId: fanCode,
userStatus: status,
});
};
export default async parentElement => {
const { isAuthenticated, ...userDetails } = await fetch(ACCOUNT_API)
.then(response => response.json())
.catch(error => {
console.error('Error fetched membership status', error);
return {};
});
if (isAuthenticated) {
showSignedInNav(userDetails, MOBILE_BREAKPOINT);
userSignInAnalytics('yes', userDetails);
} else {
userSignInAnalytics('no', userDetails);
}
hamburgerMenu();
createMenuAccordion(parentElement);
const body = document.querySelector('body');
if (window.innerWidth >= MOBILE_BREAKPOINT) {
parentElement.addEventListener('mouseover', event =>
openNavTab(event, parentElement, body)
);
} else {
parentElement.addEventListener('click', event =>
openNavTab(event, parentElement, body)
);
}
// eslint-disable-next-line no-param-reassign
parentElement.tabIndex = -1;
parentElement
.querySelectorAll('.site-navigation__main-tab')
.forEach(tab =>
tab.addEventListener('keydown', event =>
handleKeydown(event, parentElement, body)
)
);
initFixedHeader();
highlightNavLinks(parentElement);
};
/* stylelint-disable no-descending-specificity */
.accordion-section {
transition: transform 0.5s ease-in-out;
&[hidden] {
transform: translateX(-100%);
}
}
@media screen and (max-width: $mq-medium) {
.accordion-trigger {
width: 100%;
&::after {
content: '';
background: url('./assets/images/chevron.svg');
background-repeat: no-repeat;
float: right;
height: 1.7rem;
width: 1rem;
transform: rotate(90deg);
margin-top: 0.85rem;
}
}
.accordion-trigger[aria-expanded='true'] {
&::after {
transform: rotate(270deg);
}
}
.navigation-open {
overflow: hidden;
padding-top: 5.6rem;
.site-header {
position: fixed;
width: 100%;
height: 100vh;
top: 0;
overflow-y: auto;
-webkit-backdrop-filter: blur(16px);
backdrop-filter: blur(16px);
background: rgba(255, 255, 255, 0.9);
&.nav-active {
background: none;
.site-navigation__mobile-prompt {
display: none;
}
}
& > .container__content {
background-color: $white;
&::before {
content: '';
width: 100%;
display: inline-block;
position: absolute;
height: 1.6rem;
top: 0;
z-index: 10;
background-color: $white;
left: 0;
}
}
}
}
}
.navigation-open--b2c .hamburger {
display: none;
}
.navigation-open--main [aria-controls='myaccount-nav'] {
display: none;
}
.fixed-header {
background-color: $white;
border-bottom: 1px solid $grey-light;
left: 0;
top: 0;
transition: all 0.4s ease-in-out 0s;
width: 100%;
z-index: 100;
position: fixed;
}
.site-header {
padding: $spacing-m 0;
position: relative;
z-index: 10;
background: $white;
.site-signin {
font-family: $text-font-ef;
letter-spacing: 0.02em;
font-size: 1.4rem;
line-height: 1.4rem;
color: $color-interface-light;
background-color: $white;
box-sizing: border-box;
border-radius: 7rem;
position: absolute;
top: 1.6rem;
left: 1.6rem;
text-decoration: none;
& > a {
font-family: $text-font-ef;
letter-spacing: 0.02em;
font-size: 1.4rem;
line-height: 1.4rem;
color: $color-interface-light;
text-transform: capitalize;
text-decoration: none;
}
}
.site-myaccount {
font-family: $text-font-ef;
background-color: $white;
border: none;
position: absolute;
top: 1.6rem;
left: 1.6rem;
font-size: 0;
&::after {
content: attr(data-username);
color: $white;
font-size: 1.6rem;
background-color: $crest-blue;
border-radius: 7rem;
width: 3.4rem;
height: 3.4rem;
display: inline-block;
line-height: 3.4rem;
text-align: center;
}
}
.site-mobile-myaccount {
color: $white;
background-color: $blue;
padding: 0.8rem 1.4rem;
}
.mob-only {
font-size: 0;
&::after {
content: '';
background: url('./assets/images/sign-in-icon.svg');
width: 2.4rem;
height: 2.4rem;
display: inline-block;
position: relative;
top: 0.4rem;
}
}
.desktop-only,
.site-register {
display: none;
}
.site-myaccount-menus {
background: rgba(245, 245, 245, 0.8);
background-blend-mode: hard-light;
box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.5);
-webkit-backdrop-filter: blur(81px);
backdrop-filter: blur(81px);
border-radius: 0;
position: absolute;
width: 100%;
height: 100vh;
z-index: 10;
padding: 0.8rem 2rem 3.4rem 2rem;
display: none;
margin-top: 1rem;
left: 0;
p {
color: $color-interface-light;
text-align: left;
padding-bottom: 1.6rem;
border-bottom: 1px solid rgba(91, 104, 133, 0.1);
}
.site-navigation__level3 {
text-align: left;
margin-top: 2.4rem;
border-bottom: 1px solid rgba(91, 104, 133, 0.1);
padding-bottom: 1.4rem;
}
}
[aria-controls='myaccount-nav'][aria-expanded='true']
+ .site-myaccount-menus {
display: block;
}
.logo {
max-width: 9rem;
margin: auto;
}
.hamburger,
.site-myaccount-nav--close {
color: transparent;
background: url('./assets/images/icon-menu.svg') no-repeat center;
border: none;
position: absolute;
right: $spacing-m;
top: $spacing-m;
width: 2rem;
&[aria-expanded='true'] {
background-image: url('./assets/images/icon-close.svg');
}
}
.site-myaccount-nav--close {
background-color: white;
padding: 0.6rem;
&[aria-expanded='false'] {
display: none;
}
}
@media screen and (min-width: $mq-medium) {
display: grid;
grid-template-columns: 25rem auto 25rem;
overflow: initial;
padding-bottom: 0;
.site-navigation {
width: 100%;
& > ul {
width: 100%;
max-width: initial;
& > li.site-navigation__level1 {
width: 100%;
}
}
}
.hamburger,
.site-mobile-signin,
.site-mobile-myaccount,
.site-myaccount-nav--close,
.mob-only {
display: none;
}
.desktop-only,
.site-register {
display: initial;
}
.site-myaccount,
.site-signin {
border: none;
display: block;
float: right;
position: relative;
top: 0.8rem;
left: 0.2rem;
}
.site-myaccount {
font-size: 1.6rem;
color: $crest-blue;
font-weight: 500;
&::after {
margin-left: 1rem;
}
}
.site-signin {
font-family: $text-font-ef;
letter-spacing: 0.02em;
font-size: 1.6rem;
line-height: 2.4rem;
display: block;
color: $color-interface-light;
float: right;
padding: 0.8rem 1.8rem;
padding-right: 3.8rem;
& > a {
font-family: $text-font-ef;
letter-spacing: 0.02em;
font-size: 1.6rem;
line-height: 1.4rem;
text-transform: capitalize;
text-decoration: underline;
&:hover {
text-decoration: underline;
color: $blue;
}
}
&::after {
content: '';
background: url('./assets/images/sign-in-icon.svg');
width: 2.4rem;
height: 2.4rem;
display: inline-block;
position: absolute;
top: 0.6rem;
right: 0;
}
}
.site-myaccount-menus {
background: #f8f8f8;
background-blend-mode: hard-light;
box-shadow: 0 34px 34px rgba(0, 0, 0, 0.25),
inset 0 1px 3px rgba(255, 255, 255, 0.5);
-webkit-backdrop-filter: blur(81px);
backdrop-filter: blur(81px);
border-radius: 12px;
right: 1.5rem;
left: auto;
width: auto;
height: auto;
min-width: 35.4rem;
min-height: 20.8rem;
top: 5.6rem;
padding: 0.8rem 2rem 3.4rem 2rem;
&::after,
&::before {
content: '';
border-width: 4.2rem;
border-style: solid;
border-color: transparent transparent #f7f7f7 transparent;
position: absolute;
top: -5.4rem;
right: 0.5rem;
}
&::before {
width: 100%;
border: transparent;
height: 60px;
}
}
.logo {
max-width: 15.4rem;
margin: 0;
}
}
@media screen and (min-width: $mq-large) {
grid-template-columns: 25% auto 25%;
}
}
.link-external {
&::after {
background-image: url('./assets/images/icon-external link.svg');
content: '';
display: inline-block;
height: $spacing-s;
margin-left: $spacing-s;
width: $spacing-s;
}
}
.site-navigation {
background-color: $white;
margin: auto;
// FUNCTIONAL STYLES
// These styles are needed to create the show / hide interaction
.hamburger[aria-expanded='false'] + & {
display: none;
}
&__main-tab[aria-expanded='false'] + &__level2-wrapper {
display: none;
}
// LAYOUT styles
& > ul {
display: flex;
justify-content: space-around;
margin: auto;
max-width: 34rem;
> li {
margin-left: 2.2rem;
margin-right: 0;
& > button {
text-align: left;
width: 100%;
position: relative;
margin-bottom: 12px;
&::before {
content: '';
border-bottom: $spacing-xs solid transparent;
width: 14rem;
display: block;
position: absolute;
}
&[aria-expanded='true'] {
&::before {
border-bottom: $spacing-xs solid $grey;
}
}
&.active {
&::before {
border-bottom: $spacing-xs solid $red;
}
}
}
&:first-child {
margin-right: 2.2rem;
margin-left: 0;
& > button {
text-align: right;
&::before {
content: '';
border-bottom: $spacing-xs solid transparent;
width: 11.4rem;
display: block;
left: initial;
right: 0;
position: absolute;
}
&[aria-expanded='true'] {
&::before {
border-bottom: $spacing-xs solid $grey;
}
}
&.active {
&::before {
border-bottom: $spacing-xs solid $red;
}
}
}
}
}
}
&__level2-wrapper {
-webkit-backdrop-filter: blur(16px);
backdrop-filter: blur(16px);
background: rgba(255, 255, 255, 0.9);
border-radius: 0 0 1.2rem 1.2rem;
height: auto;
left: 50%;
position: absolute;
max-width: 144rem;
padding: $spacing-m $spacing-xl;
transform: translateX(-50%);
width: 100%;
z-index: 10;
}
&__level2 {
> li:not(:last-of-type) {
border-bottom: 1px solid $color-borders;
}
}
// LINK STYLES
button {
background: none;
border: none;
&:not([aria-disabled]) {
cursor: pointer;
}
}
&__main-tab {
color: $color-interface-light;
font-family: $text-font-ef;
font-size: 1.8rem;
font-style: italic;
font-weight: bold;
margin-bottom: $spacing-xs;
padding: $spacing-m 0;
text-transform: uppercase;
white-space: nowrap;
&[aria-expanded='true'] {
color: $blue;
position: relative;
margin-bottom: 12px;
&::before {
content: '';
border-bottom: $spacing-xs solid $grey;
width: 14rem;
display: block;
position: absolute;
left: 0;
bottom: 0;
}
}
&.active {
color: $blue;
position: relative;
margin-bottom: 12px;
&::before {
bottom: 0;
}
}
}
&__section-heading {
color: $red;
font-family: $text-font-ef;
font-size: 2.4rem;
font-style: italic;
font-weight: bold;
padding: $spacing-l 0;
text-align: left;
text-transform: uppercase;
.site-navigation__level1:first-of-type & {
color: $crest-blue;
}
}
&__level3 {
.active:not(:hover) {
color: $color-interface;
text-decoration: underline;
font-weight: bold;
}
li:last-child {
padding-bottom: 2.4rem;
}
a {
color: $color-interface-light;
display: block;
font-family: $text-font-ef;
font-size: 1.8rem;
padding: 1rem 0.8rem;
text-decoration: none;
&:hover {
color: $red;
text-decoration: underline;
}
&.link-external {
border: 2px solid transparent;
display: inline-block;
padding: 1rem 0.8rem;
}
}
}
// PROMOS
&__promos {
padding: $spacing-xxl 0;
}
&__promo {
align-items: flex-end;
background-size: cover;
border-radius: $spacing-s;
color: $white;
display: flex;
font-family: $text-font-ef;
font-size: 2.4rem;
font-style: italic;
font-weight: bold;
height: 12rem;
justify-content: flex-start;
margin: $spacing-m 0;
padding: $spacing-xs $spacing-m;
text-decoration: none;
width: 100%;
}
&__mobile-prompt {
font-family: $text-font2;
font-style: italic;
font-size: 1.6rem;
line-height: 2rem;
margin: 0 auto;
text-align: center;
width: 25.5rem;
margin-top: 7.3rem;
color: $color-interface-light;
position: absolute;
left: calc(50% - 12.75rem);
&::before {
content: '';
background: url('./assets/images/arrow-up-icon.svg') no-repeat center
center;
width: 3rem;
height: 3rem;
display: inline-block;
position: absolute;
top: -5rem;
left: calc(50% - 1.5rem);
}
}
@media screen and (min-width: $mq-medium) {
$nav-column-width: 26.2rem;
&__main-tab {
margin-bottom: 16px;
}
&__level2 {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin: auto;
max-width: 130rem;
> li {
position: relative;
flex: 1;
}
> li:not(:last-of-type) {
border-bottom: none;
}
> li:not(:first-of-type):not(.site-navigation__promos)::before {
content: '';
display: block;
width: 1px;
background: $color-borders;
opacity: 0.5;
position: absolute;
top: 4rem;
bottom: 0;
}
}
&__section-heading,
&__level3 {
text-align: center;
width: 100%;
}
& &__promos {
display: flex;
flex-basis: 100%;
grid-template-columns: repeat(4, $nav-column-width);
justify-content: center;
max-width: 105rem;
padding: 5rem 0;
}
&__promo {
max-width: 24.4rem;
margin: auto;
}
&__mobile-prompt {
display: none;
}
}
&.hide {
display: none;
}
}
/* eslint-enable no-descending-specificity */
// TODO: Hide my account when Nav is open
const closeMyAccountMenu = ({ listenerElement }) => {
const body = document.querySelector('body');
const controls = listenerElement.parentElement.querySelectorAll(
'[aria-controls="myaccount-nav"]'
);
controls.forEach(button => {
button.setAttribute('aria-expanded', 'false');
});
body.classList.remove('navigation-open');
listenerElement.removeEventListener('mouseout', closeMyAccountMenu);
};
// my account menu open option
const openMyAccountMenu = event => {
const { target } = event;
if (!target.classList.contains('site-myaccount-nav')) {
return;
}
const controls = target.parentElement.querySelectorAll(
'[aria-controls="myaccount-nav"]'
);
controls.forEach(button => {
button.setAttribute('aria-expanded', 'true');
});
// open the current tab
// when we opened the tab with a mouseover, we should close it on mouseleave
target.parentElement.addEventListener(
'mouseleave',
({ target: listenerElement }) => closeMyAccountMenu({ listenerElement })
);
};
const toggleMyAccountMenu = event => {
const { target } = event;
const controls = target.parentElement.querySelectorAll(
'[aria-controls="myaccount-nav"]'
);
const current = target.getAttribute('aria-expanded');
const body = document.querySelector('body');
body.classList.toggle('navigation-open');
body.classList.toggle('navigation-open--b2c');
controls.forEach(button => {
button.setAttribute('aria-expanded', current !== 'true');
});
};
export default ({ myAccountUrl, signOutUrl, userName }, MOBILE_BREAKPOINT) => {
const markup = `<button class="site-myaccount-nav site-myaccount" aria-controls="myaccount-nav" aria-haspopup="true"
aria-expanded="false" data-username="${userName}">My Account</button>
<button class="site-myaccount-nav--close" aria-controls="myaccount-nav" aria-haspopup="true"
aria-expanded="false">Close</button>
<nav role="navigation" class="site-myaccount-menus" id="myaccount-nav">
<ul>
<li>
<p class="site-navigation__section-heading">ACCOUNT DETAILS</p>
<ul class="site-navigation__level3">
<li><a href="${myAccountUrl}" target="_blank" class="link-external">My Account</a></li>
<li><a href="${signOutUrl}">Logout</a></li>
</ul>
</li>
</ul>
</nav>`;
const container = document.createElement('div');
const b2cNavContainer = document.querySelector('.b2c-nav-container');
// We make the contents of the container be the result of the function
container.innerHTML = markup;
// Append the created markup to the DOM
b2cNavContainer.replaceChild(
container,
b2cNavContainer.querySelector('.site-signin')
);
if (window.innerWidth >= MOBILE_BREAKPOINT) {
b2cNavContainer
.querySelector('[aria-controls="myaccount-nav"]')
.addEventListener('mouseover', event => {
openMyAccountMenu(event);
});
} else {
const controls = b2cNavContainer.querySelectorAll(
'[aria-controls="myaccount-nav"]'
);
controls.forEach(button => {
button.addEventListener('click', event => {
toggleMyAccountMenu(event);
});
});
}
};
<header class="fixed-header">
<div class="site-header container">
<div class="container__content">
<a href="#main-content" class="skip-to-content">Skip to main content</a>
<img src="/assets/images/england-football-logo.svg" alt="England Football logo" class="logo" /></a>
</div>
<button class="hamburger" aria-controls="main-nav" aria-haspopup="true" aria-expanded="false">Open
navigation</button>
<nav role="navigation" class="site-navigation" id="main-nav">
<ul>
<li class="site-navigation__level1">
<button class="site-navigation__main-tab" aria-controls="teams" aria-haspopup="true" aria-expanded="false"
role="menu">England
Teams</button>
<div class="site-navigation__level2-wrapper" id="teams">
<ul class="site-navigation__level2">
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-1" id="accordion-button-1" tabindex="-1">Three Lions</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-1" role="region"
aria-labelledby="accordion-button-1" hidden="">
<li><a href="/" data-attr="true">Home</a></li>
<li><a href="/">Squad</a></li>
<li><a href="/">Fixtures & Results</a></li>
<li><a href="/" class="link-external">England Supports Travel Club</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-2" id="accordion-button-2" tabindex="-1">Lionesses</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-2" role="region"
aria-labelledby="accordion-button-2" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Squad</a></li>
<li><a href="/">Fixtures & Results</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-3" id="accordion-button-3" tabindex="-1">Youth</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-3" role="region"
aria-labelledby="accordion-button-3" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Men's U21</a></li>
<li><a href="/">Women's U23</a></li>
<li><a href="/">Fixtures & Results</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-4" id="accordion-button-4" tabindex="-1">Para</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-4" role="region"
aria-labelledby="accordion-button-4" hidden="">
<li><a href="/">Home</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-9" id="accordion-button-9" tabindex="-1">Play</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-9" role="region"
aria-labelledby="accordion-button-9" hidden="">
<li><a href="/">Home</a></li>
</ul>
</li>
<li class="site-navigation__promos">
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Tickets</a>
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">England Store</a>
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Interactive Timeline</a>
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">My England Football</a>
</li>
</ul>
</div>
</li>
<li class="site-navigation__level1">
<button class="site-navigation__main-tab" aria-controls="play" aria-haspopup="true" aria-expanded="false"
role="menu">Play
& Participate</button>
<div class="site-navigation__level2-wrapper" id="play">
<ul class="site-navigation__level2">
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-5" id="accordion-button-5" tabindex="-1">Play</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-5" role="region"
aria-labelledby="accordion-button-5" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Adult</a></li>
<li><a href="/">Kids</a></li>
<li><a href="/">Women & Girls</a></li>
<li><a href="/">Disability</a></li>
<li><a href="/" class="link-external">England Supports Travel Club</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-6" id="accordion-button-6" tabindex="-1">Learn</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-6" role="region"
aria-labelledby="accordion-button-6" hidden="">
<li><a href="/" class="link-external">The Bootroom</a></li>
<li><a href="/" class="link-external">Courses</a></li>
<li><a href="/" class="link-external">Session Plans</a></li>
<li><a href="/" class="link-external">Coach Community</a></li>
<li><a href="/" class="link-external">Safeguarding</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-7" id="accordion-button-7" tabindex="-1">Volunteer</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-7" role="region"
aria-labelledby="accordion-button-7" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/" class="link-external">Safeguarding</a></li>
</ul>
</li>
<li>
<button class="site-navigation__section-heading accordion-trigger" aria-expanded="false"
aria-controls="accordion-section-8" id="accordion-button-8" tabindex="-1">Explore</button>
<ul class="site-navigation__level3 accordion-section" id="accordion-section-8" role="region"
aria-labelledby="accordion-button-8" hidden="">
<li><a href="/">Home</a></li>
<li><a href="/">Helpful Apps & Websites</a></li>
<li><a href="/">Respect</a></li>
<li><a href="/">Grassroots Awards</a></li>
<li><a href="/">County FAs</a></li>
<li><a href="/">COVID-19 Guidane</a></li>
<li><a href="/">The Football Foundation</a></li>
</ul>
</li>
<li class="site-navigation__promos">
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Find Football</a>
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Platform for Football</a>
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">Matchday app</a>
<a href="/" class="site-navigation__promo"
style="background-image: url(/assets/example-content/nav-promo-store.jpg)">My England Football</a>
</li>
</ul>
</div>
</li>
</ul>
<div class="site-navigation__mobile-prompt">
Please select either England Teams or Play & Participate for navigation options
</div>
</nav>
<div class="container__content b2c-nav-container">
<div class="site-signin">
<a href="#"><span class="mob-only">Sign in/Up</span><span class="desktop-only">Sign in</span></a>
<span class="desktop-only">or</span>
<a class="site-register" href="#">Register Now</a>
</div>
</div>
</div>
</header>