focus arrow keys for scrolling

This commit is contained in:
cupcakearmy 2019-09-06 22:45:56 +02:00
parent 9324a3905a
commit 6f94029999
4 changed files with 14 additions and 2 deletions

View File

@ -6,7 +6,7 @@ get_header();
$tags = get_tags( [ 'orderby' => 'count', 'order' => 'desc' ] );
?>
<div id="home">
<div id="home" data-focusme>
<a id="lights" href="javascript:void(0);" onclick="window.toggleLights();">
<img src="<?= get_template_directory_uri() . '/vendor/icons/contrast.svg' ?>" alt="lights"/>
</a>

View File

@ -1,4 +1,5 @@
;((window) => {
// Lights
const key = 'nicco.io:blog:lights'
const CSS = 'body, .wp-block-image img, .thumbnail img {filter: invert(1);} '
const style = window.document.createElement('style')
@ -19,4 +20,11 @@
if (isDark()) off()
window.toggleLights = () => isDark() ? on() : off()
// Focus scrolling
document.addEventListener('DOMContentLoaded', ()=> {
const toFocus = document.querySelector('[data-focusme]')
toFocus.tabIndex = '1'
toFocus.focus({preventScroll: true})
})
})(window)

View File

@ -43,7 +43,7 @@ $dates = getDates();
<div class="alt-font">previous</div>
</a>
<div class="flex item grow" id="main">
<div class="flex item grow" id="main" data-focusme>
<div class="flex container vertical middle">
<!-- Title -->

View File

@ -25,6 +25,10 @@ Theme URI: https://github.com/cupcakearmy/liquet
scroll-behavior: smooth;
}
*[tabindex]:focus {
outline: none;
}
html, body {
padding: 0;
margin: 0;