diff --git a/src/main.py b/src/main.py index 1b4df1c..045d59f 100644 --- a/src/main.py +++ b/src/main.py @@ -3,7 +3,7 @@ import json from aiohttp.client import ClientSession from flask import Flask, g, session, redirect, render_template, request, url_for -from flask_htmx import HTMX +from flask_htmx import HTMX, make_response as htmx_reponse from typing import Any from .atproto import ( @@ -167,7 +167,10 @@ async def post_editor_profile(): kv.set(user.did, json.dumps(record)) if htmx: - return render_template("_editor_profile.html", profile=record) + return htmx_reponse( + render_template("_editor_profile.html", profile=record), + reswap="outerHTML", + ) return redirect(url_for("page_editor"), 303) @@ -213,6 +216,12 @@ async def post_editor_links(): kv = KV(app, app.logger, "links_from_did") kv.set(user.did, json.dumps(record)) + if htmx: + return htmx_reponse( + render_template("_editor_links.html", links=record["links"]), + reswap="outerHTML", + ) + return redirect(url_for("page_editor"), 303) diff --git a/src/static/style.css b/src/static/style.css index 3521f39..6625681 100644 --- a/src/static/style.css +++ b/src/static/style.css @@ -5,6 +5,7 @@ --color-background-secondary: #eee; --color-border: #bbb; --color-border-secondary: #ddd; + --color-success: #080; } @media (prefers-color-scheme: dark) { @@ -12,6 +13,7 @@ --color-background-secondary: #333; --color-border: #555; --color-border-secondary: #333; + --color-success: #af2; } } @@ -69,20 +71,20 @@ input[type="submit"] { padding: 0.25em; } -input[type="submit"]:last-child { +button.submit:last-of-type, +input[type="submit"]:last-of-type { margin-top: 1em; } -label:has(input) { +editor-label { display: block; - margin-top: 0.25em; } -label:has(input):has(span) input { - display: block; +editor-label + editor-label { + margin-top: 0.25em; } -label:has(input):has(span) span { +editor-label .label { font-size: 14px; font-weight: 700; text-transform: uppercase; @@ -166,12 +168,29 @@ still-building p { } .htmx-indicator { - background: yellowgreen; - height: 2px; + --height: 2px; + height: var(--height); + margin: 2px 0; + opacity: 0; + visibility: none; +} + +.htmx-request .progress { + animation: progress-bar 0.5s linear; + animation-fill-mode: both; + background: var(--color-success); + border-radius: calc(var(--height) / 2); + display: block; + height: var(--height); } -.htmx-request .htmx-indicator { - display: block; +@keyframes progress-bar { + 0% { + width: 25%; + } + 100% { + width: 100%; + } } form[hx-post] { diff --git a/src/templates/_editor_links.html b/src/templates/_editor_links.html new file mode 100644 index 0000000..884e3bd --- /dev/null +++ b/src/templates/_editor_links.html @@ -0,0 +1,81 @@ +