add base styles and scripts
This commit is contained in:
@@ -11,23 +11,30 @@
|
||||
@php(wp_body_open())
|
||||
|
||||
<div id="app">
|
||||
<a class="sr-only focus:not-sr-only" href="#main">
|
||||
{{ __('Skip to content') }}
|
||||
<a class="visually-hidden" href="#main">
|
||||
{{ __('Skip to content', 'sage') }}
|
||||
</a>
|
||||
|
||||
@include('sections.header')
|
||||
<div class="wrapper section-has-angle section-has-angle-bottom">
|
||||
|
||||
<main id="main" class="main">
|
||||
@yield('content')
|
||||
</main>
|
||||
@include('sections.header.header')
|
||||
|
||||
@hasSection('sidebar')
|
||||
<aside class="sidebar">
|
||||
@yield('sidebar')
|
||||
</aside>
|
||||
@endif
|
||||
<main id="main" class="main">
|
||||
@yield('content')
|
||||
</main>
|
||||
|
||||
@include('sections.footer')
|
||||
@hasSection('sidebar')
|
||||
<aside class="sidebar">
|
||||
@yield('sidebar')
|
||||
</aside>
|
||||
@endif
|
||||
|
||||
<div class="last-slice angle-slice-wrap bottom">
|
||||
<div class="angle-slice small bottom right"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('sections.footer.footer')
|
||||
</div>
|
||||
|
||||
@php(do_action('get_footer'))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export default function Footer() {
|
||||
const body = document.querySelector("body");
|
||||
const footer = document.querySelector(".js-footer");
|
||||
const links = footer.querySelectorAll("a");
|
||||
const currentURL = location.protocol + '//' + location.host + location.pathname;
|
||||
|
||||
links.forEach(link => {
|
||||
const hash = link.hash;
|
||||
const href = link.href;
|
||||
|
||||
link.addEventListener("click", () => {
|
||||
if(href.includes(currentURL)) {
|
||||
body.classList.remove("menu-open");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
export default function Header() {
|
||||
const body = document.querySelector("body");
|
||||
const wrapper = document.querySelector(".wrapper");
|
||||
const menuToggle = document.querySelector(".js-menu-toggle");
|
||||
const menuClose = document.querySelector(".js-menu-close");
|
||||
|
||||
menuToggle.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
body.classList.toggle("menu-open");
|
||||
|
||||
if(menuToggle.ariaExpanded == 'true') {
|
||||
menuToggle.ariaExpanded = 'false';
|
||||
} else {
|
||||
menuToggle.ariaExpanded = 'true';
|
||||
}
|
||||
|
||||
console.log(menuToggle.ariaExpanded);
|
||||
|
||||
});
|
||||
|
||||
menuClose.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
body.classList.remove("menu-open");
|
||||
menuToggle.ariaExpanded = 'false';
|
||||
|
||||
console.log(menuToggle.ariaExpanded);
|
||||
});
|
||||
|
||||
document.addEventListener("keyup", function (event) {
|
||||
if (event.key === "Escape") {
|
||||
body.classList.remove("menu-open");
|
||||
menuToggle.ariaExpanded = 'false';
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("scroll", () => {
|
||||
const scrolled = document.scrollingElement.scrollTop;
|
||||
const position = body.offsetTop;
|
||||
const header = document.querySelector(".site-header");
|
||||
|
||||
if (scrolled > position + header.offsetHeight) {
|
||||
body.classList.add("scrolled");
|
||||
} else {
|
||||
body.classList.remove("scrolled");
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.addEventListener("click", (e) => {
|
||||
const target = e.target;
|
||||
|
||||
if(!menuToggle.contains(target) && body.classList.contains("menu-open")) {
|
||||
body.classList.remove("menu-open");
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user