Skip to content

Commit 7b6bdab

Browse files
committed
v2: mark-as-... spinners. #318
1 parent a31b788 commit 7b6bdab

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

src/reader/_app/v2/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ def mark_as():
7373

7474
if request.headers.get('hx-request') == 'true':
7575
return render_block(
76-
'v2/entries.html', 'entry_form', entry=reader.get_entry(entry)
76+
'v2/entries.html',
77+
'entry_form',
78+
entry=reader.get_entry(entry),
79+
next=request.form['next'],
7780
)
7881

79-
print(request.form['next'])
8082
return redirect(request.form['next'], code=303)

src/reader/_app/v2/static/style.css

+10
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@
1515
.nav.controls .nav-link.active {
1616
color: var(--bs-navbar-active-color);
1717
}
18+
19+
.htmx-indicator {
20+
display: none;
21+
}
22+
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator {
23+
display: inline-block;
24+
}
25+
.htmx-request .label, .htmx-request.label {
26+
display: none;
27+
}

src/reader/_app/v2/templates/v2/entries.html

+32-10
Original file line numberDiff line numberDiff line change
@@ -95,48 +95,74 @@ <h2 class="h5 mb-1" style="font-size: 1.125rem">
9595
</p>
9696
{% endif %}
9797

98-
{% set next = loop.index if not loop.last else loop.index - 1 -%}
98+
{% set next_index = loop.index if not loop.last else loop.index - 1 -%}
99+
{% set next = url_for('.entries', **request.args) + '#entry-' + (next_index|string) %}
99100
<form action="{{ url_for('.mark_as') }}" method="post"
100-
hx-post="{{ url_for('.mark_as') }}"
101+
hx-target="closest form"
102+
101103
class="my-2">
102104
{#- TODO: aria stuff #}
103105
{% block entry_form scoped %}
104106

105107
<button type="submit" name="read"
106108
value="{{ 'false' if entry.read else 'true' }}"
109+
hx-post="{{ url_for('.mark_as') }}"
110+
hx-disabled-elt="this"
107111
class="btn btn-outline-secondary btn-sm{% if entry.read %} active{% endif %}"
108112
{% if entry.read -%}
109113
aria-pressed="true"
110114
{% endif -%}
111115
style="width: 4rem">
112-
<i class="bi {{
116+
117+
<i class="label bi {{
113118
'bi-check-circle-fill' if entry.read is true else 'bi-check-lg'
114119
}}"></i>
120+
121+
<div class="spinner-border htmx-indicator" role="status" style="width: 0.875rem; height: 0.875rem;">
122+
<span class="visually-hidden">loading...</span>
123+
</div>
124+
115125
</button>
116126

117127
<div class="btn-group" role="group" aria-label="importance">
118128
<button type="submit" name="important"
119129
value="{{ 'none' if entry.important is true else 'true' }}"
130+
hx-post="{{ url_for('.mark_as') }}"
131+
hx-disabled-elt="this, next button"
120132
class="btn btn-outline-secondary btn-sm {% if entry.important is true %} active{% endif %}"
121133
{% if entry.important is true -%}
122134
aria-pressed="true"
123135
{% endif -%}
124136
style="width: 2rem">
125-
<i class="bi {{
137+
138+
<i class="label bi {{
126139
'bi-star-fill' if entry.important is true else 'bi-star'
127140
}}"></i>
141+
142+
<div class="spinner-border htmx-indicator" role="status" style="width: 0.875rem; height: 0.875rem;">
143+
<span class="visually-hidden">loading...</span>
144+
</div>
145+
128146
</button>
129147

130148
<button type="submit" name="important"
131149
value="{{ 'none' if entry.important is false else 'false' }}"
150+
hx-post="{{ url_for('.mark_as') }}"
151+
hx-disabled-elt="this, previous button"
132152
class="btn btn-outline-secondary btn-sm {% if entry.important is false %} active{% endif %}"
133153
{% if entry.important is false -%}
134154
aria-pressed="true"
135155
{% endif -%}
136156
style="width: 2rem">
137-
<i class="bi {{
157+
158+
<i class="label bi {{
138159
'bi-arrow-down-circle-fill' if entry.important is false else 'bi-arrow-down'
139160
}}"></i>
161+
162+
<div class="spinner-border htmx-indicator" role="status" style="width: 0.875rem; height: 0.875rem;">
163+
<span class="visually-hidden">loading...</span>
164+
</div>
165+
140166
</button>
141167
</div>
142168

@@ -152,11 +178,7 @@ <h2 class="h5 mb-1" style="font-size: 1.125rem">
152178

153179
<input type="hidden" name="feed-url" value="{{ entry.feed_url }}">
154180
<input type="hidden" name="entry-id" value="{{ entry.id }}">
155-
156-
{% if next -%}
157-
<input type="hidden" name="next"
158-
value="{{ url_for('.entries', **request.args) }}#entry-{{ next }}">
159-
{%- endif %}
181+
<input type="hidden" name="next" value="{{ next }}">
160182

161183
{% endblock %}
162184
</form>

0 commit comments

Comments
 (0)