docbrown/app/javascript/packs/heroBannerClose.js
fille du chaos bef1c4a1e0
Migrate initializeDrawerSliders and initializeHeroBannerClose to Webpack (#19324)
* feat: tests for tag page sidebar drawers on mobile

* feat: tests for hero area/banner on home feed

* refactor: move ui interaction initialisers to packs

* remove old filter select implementation
2023-04-17 10:55:02 +01:00

17 lines
676 B
JavaScript

const initializeHeroBannerClose = () => {
const bannerWrapper = document.getElementById('hero-html-wrapper');
const closeIcon = document.getElementById('js-hero-banner__x');
// Currently js-hero-banner__x button icon ID needs to be written into the abstract html
// In the future this could be extracted so the implementer doesn't need to worry about it.
if (bannerWrapper && closeIcon) {
closeIcon.setAttribute('aria-label', 'Close campaign banner');
closeIcon.addEventListener('click', () => {
localStorage.setItem('exited_hero', bannerWrapper.dataset.name);
bannerWrapper.style.display = 'none';
});
}
};
initializeHeroBannerClose();