A11y improvements and style tweaks

- Use button element instead of anchors, fixes keyboard navigation and
other issues
- Disable search input until it's open, prevents being able to write
inside it while it's closed
- Use :root instead of html in CSS
- Add minimal size for separator between home button and other links
This commit is contained in:
daudix
2024-07-16 23:41:53 +03:00
parent 354b4050af
commit e8cc17a4a0
7 changed files with 35 additions and 20 deletions

View File

@ -22,9 +22,9 @@
<h2>{{ macros_translate::translate(key="comments", default="Comments", language_strings=language_strings) }}</h2>
<p>{{ macros_translate::translate(key="comments_description", default="You can comment on this blog post by publicly replying to this post using a Mastodon or other ActivityPub/Fediverse account. Known non-private replies are displayed below.", language_strings=language_strings) }}</p>
<div class="dialog-buttons">
<a id="load-comments" class="inline-button" onclick="loadComments()" onkeypress="loadComments()" tabindex="0">
<button id="load-comments" class="inline-button" onclick="loadComments()">
{{- macros_translate::translate(key="load_comments", default="Load Comments", language_strings=language_strings) -}}
</a>
</button>
<a class="inline-button colored external" href="https://{{ host }}/@{{ username }}/{{ id }}">
{{- macros_translate::translate(key="open_post", default="Open Post", language_strings=language_strings) -}}
</a>

View File

@ -35,12 +35,12 @@
{%- endfor -%}
{%- if config.build_search_index %}
<li id="search">
<a onclick="toggleSearch()" onkeypress="toggleSearch()" tabindex="0">
<button onclick="toggleSearch()">
<i class="icon"></i>
<span class="hidden">
{{- macros_translate::translate(key="search", default="Search", language_strings=language_strings) -}}
</span>
</a>
</button>
</li>
{%- endif %}
{%- if config.languages | length > 0 %}
@ -59,7 +59,10 @@
</ul>
</nav>
<div id="search-container">
<input id="search-bar" type="search" placeholder="{{ macros_translate::translate(key='search_for', default='Search for…', language_strings=language_strings) }}">
<label for="search-bar" class="hidden">
{{- macros_translate::translate(key="search", default="Search", language_strings=language_strings) -}}
</label>
<input id="search-bar" placeholder="{{ macros_translate::translate(key='search_for', default='Search for…', language_strings=language_strings) }}" disabled type="search">
<div id="search-results"></div>
</div>
</header>

View File

@ -191,7 +191,9 @@
function toggleSearch() {
var searchContainer = document.getElementById("search-container");
var searchBar = document.getElementById("search-bar");
searchContainer.classList.toggle("active");
searchBar.toggleAttribute("disabled");
}
if (document.readyState === "complete" ||