Improved focus outlines when using keyboard navigation

This commit is contained in:
squidfunk 2021-04-18 18:42:02 +02:00
parent 4247e3b440
commit 564c1dad43
14 changed files with 27 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.dcbf0b87.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/main.7c7fd32f.min.css' | url }}">
{% if config.theme.palette %} {% if config.theme.palette %}
{% set palette = config.theme.palette %} {% set palette = config.theme.palette %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.ef6f36e2.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/palette.ef6f36e2.min.css' | url }}">

View File

@ -164,6 +164,12 @@ kbd {
&:hover { &:hover {
color: var(--md-accent-fg-color); color: var(--md-accent-fg-color);
} }
// Text link on keyboard focus
&.focus-visible {
outline-color: var(--md-accent-fg-color);
outline-offset: px2rem(4px);
}
} }
// Code block // Code block

View File

@ -92,6 +92,7 @@
// Tab label on focus // Tab label on focus
&:focus + label { &:focus + label {
outline-style: auto; outline-style: auto;
outline-color: var(--md-accent-fg-color);
} }
// Hide outline for pointer devices // Hide outline for pointer devices

View File

@ -140,9 +140,10 @@ body {
display: block; display: block;
} }
// Option label on focus // Show outline for pointer devices
&.focus-visible + label { &.focus-visible + label {
outline-style: auto; outline-style: auto;
outline-color: var(--md-accent-fg-color);
} }
} }
@ -158,6 +159,7 @@ body {
font-size: px2rem(12.8px); font-size: px2rem(12.8px);
background-color: var(--md-default-fg-color); background-color: var(--md-default-fg-color);
border-radius: px2rem(2px); border-radius: px2rem(2px);
outline-color: var(--md-accent-fg-color);
transform: translateY(px2rem(8px)); transform: translateY(px2rem(8px));
opacity: 0; opacity: 0;

View File

@ -41,6 +41,8 @@
height: px2em(24px); height: px2em(24px);
color: var(--md-default-fg-color--lightest); color: var(--md-default-fg-color--lightest);
border-radius: px2rem(2px); border-radius: px2rem(2px);
outline-color: var(--md-accent-fg-color);
outline-offset: px2rem(2px);
cursor: pointer; cursor: pointer;
transition: color 250ms; transition: color 250ms;

View File

@ -45,6 +45,7 @@
display: flex; display: flex;
padding-top: px2rem(28px); padding-top: px2rem(28px);
padding-bottom: px2rem(8px); padding-bottom: px2rem(8px);
outline-color: var(--md-accent-fg-color);
transition: opacity 250ms; transition: opacity 250ms;
// [tablet +]: Adjust width to 50/50 // [tablet +]: Adjust width to 50/50

View File

@ -63,11 +63,6 @@
box-shadow 250ms; box-shadow 250ms;
} }
// Link or button on focus
.focus-visible {
outline-color: currentColor;
}
// Header wrapper // Header wrapper
&__inner { &__inner {
display: flex; display: flex;
@ -83,6 +78,7 @@
padding: px2rem(8px); padding: px2rem(8px);
color: currentColor; color: currentColor;
vertical-align: middle; vertical-align: middle;
outline-color: var(--md-accent-fg-color);
cursor: pointer; cursor: pointer;
transition: opacity 250ms; transition: opacity 250ms;

View File

@ -125,6 +125,12 @@
color: var(--md-accent-fg-color); color: var(--md-accent-fg-color);
} }
// Navigation link on keyboard focus
&.focus-visible {
outline-color: var(--md-accent-fg-color);
outline-offset: px2rem(4px);
}
// Navigation link to table of contents // Navigation link to table of contents
.md-nav--primary &[for="__toc"] { .md-nav--primary &[for="__toc"] {
display: none; display: none;

View File

@ -72,6 +72,7 @@
font-size: px2rem(13px); font-size: px2rem(13px);
line-height: 1.2; line-height: 1.2;
white-space: nowrap; white-space: nowrap;
outline-color: var(--md-accent-fg-color);
// Hack: promote to own layer to reduce jitter // Hack: promote to own layer to reduce jitter
backface-visibility: hidden; backface-visibility: hidden;
transition: opacity 250ms; transition: opacity 250ms;

View File

@ -76,6 +76,8 @@
display: block; display: block;
margin-top: px2rem(16px); margin-top: px2rem(16px);
font-size: px2rem(14px); font-size: px2rem(14px);
outline-color: var(--md-accent-fg-color);
outline-offset: px2rem(4px);
// Hack: save a repaint when tabs are appearing on scrolling up // Hack: save a repaint when tabs are appearing on scrolling up
backface-visibility: hidden; backface-visibility: hidden;
opacity: 0.7; opacity: 0.7;