Allow better keyboard navigation (#373)

This commit is contained in:
TAKAHASHI Shuuji 2023-01-09 04:20:05 +09:00 committed by GitHub
parent eede9682b2
commit d51f2883aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 16 deletions

View File

@ -1,10 +1,10 @@
{% if post.pk in interactions.boost %} {% if post.pk in interactions.boost %}
<a title="Unboost" class="active" hx-post="{{ post.urls.action_unboost }}" hx-swap="outerHTML"> <a title="Unboost" class="active" hx-trigger="click, keyup[key=='Enter']" hx-post="{{ post.urls.action_unboost }}" hx-swap="outerHTML" tabindex="0">
<i class="fa-solid fa-retweet"></i> <i class="fa-solid fa-retweet"></i>
<span class="like-count">{{ post.stats_with_defaults.boosts }}</span> <span class="like-count">{{ post.stats_with_defaults.boosts }}</span>
</a> </a>
{% else %} {% else %}
<a title="Boost" hx-post="{{ post.urls.action_boost }}" hx-swap="outerHTML"> <a title="Boost" hx-trigger="click, keyup[key=='Enter']" hx-post="{{ post.urls.action_boost }}" hx-swap="outerHTML" tabindex="0">
<i class="fa-solid fa-retweet"></i> <i class="fa-solid fa-retweet"></i>
<span class="like-count">{{ post.stats_with_defaults.boosts }}</span> <span class="like-count">{{ post.stats_with_defaults.boosts }}</span>
</a> </a>

View File

@ -5,15 +5,15 @@
{{ attachment.name|default:"(no description)" }} {{ attachment.name|default:"(no description)" }}
</p> </p>
<div class="buttons"> <div class="buttons">
<a class="button delete left" _="on click remove closest .uploaded-image">Remove</a> <button class="button delete left" _="on click remove closest .uploaded-image">Remove</button>
</div> </div>
</div> </div>
{% if request.htmx %} {% if request.htmx %}
<a class="button add-image" <button class="add-image"
hx-get='{% url "compose_image_upload" %}' hx-get='{% url "compose_image_upload" %}'
hx-target="this" hx-target="this"
hx-swap="outerHTML" hx-swap="outerHTML"
_="on load if length of <.uploaded-image/> > 3 then hide me"> _="on load if length of <.uploaded-image/> > 3 then hide me">
Add Image Add Image
</a> </button>
{% endif %} {% endif %}

View File

@ -1,10 +1,10 @@
{% if post.pk in interactions.like %} {% if post.pk in interactions.like %}
<a title="Unlike" class="active" hx-post="{{ post.urls.action_unlike }}" hx-swap="outerHTML" role="menuitem"> <a title="Unlike" class="active" hx-trigger="click, keyup[key=='Enter']" hx-post="{{ post.urls.action_unlike }}" hx-swap="outerHTML" role="menuitem" tabindex="0">
<i class="fa-solid fa-star"></i> <i class="fa-solid fa-star"></i>
<span class="like-count">{{ post.stats_with_defaults.likes }}</span> <span class="like-count">{{ post.stats_with_defaults.likes }}</span>
</a> </a>
{% else %} {% else %}
<a title="Like" hx-post="{{ post.urls.action_like }}" hx-swap="outerHTML" role="menuitem"> <a title="Like" hx-trigger="click, keyup[key=='Enter']" hx-post="{{ post.urls.action_like }}" hx-swap="outerHTML" role="menuitem" tabindex="0">
<i class="fa-solid fa-star"></i> <i class="fa-solid fa-star"></i>
<span class="like-count">{{ post.stats_with_defaults.likes }}</span> <span class="like-count">{{ post.stats_with_defaults.likes }}</span>
</a> </a>

View File

@ -64,7 +64,7 @@
<input type="hidden" name="visibility" value="{{ config_identity.default_post_visibility }}"> <input type="hidden" name="visibility" value="{{ config_identity.default_post_visibility }}">
<div class="buttons"> <div class="buttons">
<span id="character-counter">{{ config.post_length }}</span> <span id="character-counter">{{ config.post_length }}</span>
<span class="button toggle" _="on click toggle .enabled then toggle .hidden on #id_content_warning">CW</span> <button class="toggle" _="on click or keyup[key is 'Enter'] toggle .enabled then toggle .hidden on #id_content_warning">CW</button>
<button id="post-button">{% if config_identity.toot_mode %}Toot!{% else %}Post{% endif %}</button> <button id="post-button">{% if config_identity.toot_mode %}Toot!{% else %}Post{% endif %}</button>
</div> </div>
</form> </form>

View File

@ -28,9 +28,9 @@
{% if post.summary %} {% if post.summary %}
{% if config_identity.expand_linked_cws %} {% if config_identity.expand_linked_cws %}
<div class="summary" _="on click toggle .enabled on <.{{ post.summary_class }} .summary/> then toggle .hidden on <.{{ post.summary_class }} .content/> then halt"> <div class="summary" _="on click or keyup[key is 'Enter'] toggle .enabled on <.{{ post.summary_class }} .summary/> then toggle .hidden on <.{{ post.summary_class }} .content/> then halt" tabindex="0">
{% else %} {% else %}
<div class="summary" _="on click toggle .enabled then toggle .hidden on the next .content then halt"> <div class="summary" _="on click or keyup[key is 'Enter'] toggle .enabled then toggle .hidden on the next .content then halt" tabindex="0">
{% endif %} {% endif %}
{{ post.summary }} {{ post.summary }}
</div> </div>
@ -70,7 +70,7 @@
{% include "activities/_reply.html" %} {% include "activities/_reply.html" %}
{% include "activities/_like.html" %} {% include "activities/_like.html" %}
{% include "activities/_boost.html" %} {% include "activities/_boost.html" %}
<a title="Menu" class="menu" _="on click toggle .enabled on the next <menu/> then halt" role="menuitem" aria-haspopup="menu"> <a title="Menu" class="menu" _="on click or keyup[key is 'Enter'] toggle .enabled on the next <menu/> then halt" role="menuitem" aria-haspopup="menu" tabindex="0">
<i class="fa-solid fa-bars"></i> <i class="fa-solid fa-bars"></i>
</a> </a>
<menu> <menu>

View File

@ -25,12 +25,12 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if not post or post.attachments.count < 4 %} {% if not post or post.attachments.count < 4 %}
<a class="button add-image" <button class="add-image"
hx-get='{% url "compose_image_upload" %}' hx-get='{% url "compose_image_upload" %}'
hx-target="this" hx-target="this"
hx-swap="outerHTML"> hx-swap="outerHTML">
Add Image Add Image
</a> </button>
{% endif %} {% endif %}
</fieldset> </fieldset>
<div class="buttons"> <div class="buttons">

View File

@ -7,7 +7,7 @@
{% include "activities/_mini_post.html" %} {% include "activities/_mini_post.html" %}
<form action="." method="POST"> <form action="." method="POST">
{% csrf_token %} {% csrf_token %}
<a class="button" onclick="history.back()">Cancel</a> <button onclick="history.back()" autofocus>Cancel</button>
<button class="delete">Delete</button> <button class="delete">Delete</button>
</form> </form>

View File

@ -23,7 +23,7 @@
{% endif %} {% endif %}
{% if request.user.admin %} {% if request.user.admin %}
<a title="Menu" class="menu button" _="on click toggle .enabled on the next <menu/> then halt" aria-haspopup="menu"> <a title="Menu" class="menu button" _="on click or keyup[key is 'Enter'] toggle .enabled on the next <menu/> then halt" aria-haspopup="menu" tabindex="0">
<i class="fa-solid fa-bars"></i> <i class="fa-solid fa-bars"></i>
</a> </a>
<menu> <menu>

View File

@ -29,7 +29,8 @@
@{{ identity.handle }} @{{ identity.handle }}
<a title="Copy handle" <a title="Copy handle"
class="copy" class="copy"
_="on click tabindex="0"
_="on click or keyup[key is 'Enter']
writeText('@{{ identity.handle }}') into the navigator's clipboard writeText('@{{ identity.handle }}') into the navigator's clipboard
then add .copied then add .copied
wait 2s wait 2s