mirror of
https://github.com/ZTatman/myst.git
synced 2026-11-21 04:17:59 +00:00
refactor(ui): fix Forgejo token input styling and validation styling
This commit is contained in:
parent
4d83050b05
commit
0c7f22988b
2 changed files with 55 additions and 11 deletions
|
|
@ -191,4 +191,8 @@
|
|||
.input-mono {
|
||||
@apply rounded-md border border-border bg-input px-3 py-2 font-mono text-[13px] leading-5 text-foreground transition placeholder:text-muted-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring-muted;
|
||||
}
|
||||
|
||||
.input-error {
|
||||
@apply text-sm font-medium text-danger-foreground;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,18 +34,28 @@
|
|||
to enable share link viewing.
|
||||
</p>
|
||||
</div>
|
||||
<form method="post"
|
||||
class="grid gap-4 px-4 py-4 sm:grid-cols-[1fr_auto] sm:items-end">
|
||||
<div>
|
||||
<label for="pat" class="section-header-subtle">Forgejo access token</label>
|
||||
<input type="text"
|
||||
id="pat"
|
||||
name="pat"
|
||||
class="block w-full mt-2 input-mono"
|
||||
placeholder="ad8j3..."
|
||||
required />
|
||||
<form id="pat-form"
|
||||
method="post"
|
||||
action="/dashboard/pat"
|
||||
novalidate
|
||||
class="px-4 py-4">
|
||||
<div class="grid gap-4 sm:grid-cols-[1fr_auto] sm:items-end">
|
||||
<div>
|
||||
<label for="pat" class="section-header-subtle">Forgejo access token</label>
|
||||
<input type="text"
|
||||
id="pat"
|
||||
name="pat"
|
||||
class="block w-full mt-2 input-mono"
|
||||
placeholder="ad8j3..."
|
||||
aria-describedby="pat-error"
|
||||
aria-invalid="false"
|
||||
required />
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<p id="pat-error" class="input-error hidden">A Forgejo token is required.</p>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</form>
|
||||
</section>
|
||||
<section class="card">
|
||||
|
|
@ -76,4 +86,34 @@
|
|||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
(() => {
|
||||
const form = document.getElementById("pat-form");
|
||||
const input = document.getElementById("pat");
|
||||
const error = document.getElementById("pat-error");
|
||||
|
||||
if (!form || !input || !error) return;
|
||||
|
||||
const showError = () => {
|
||||
input.setAttribute("aria-invalid", "true");
|
||||
input.classList.add("border-danger", "focus:border-danger", "focus:ring-danger-muted");
|
||||
error.classList.remove("hidden");
|
||||
input.focus();
|
||||
};
|
||||
|
||||
const clearError = () => {
|
||||
input.setAttribute("aria-invalid", "false");
|
||||
input.classList.remove("border-danger", "focus:border-danger", "focus:ring-danger-muted");
|
||||
error.classList.add("hidden");
|
||||
};
|
||||
|
||||
form.addEventListener("submit", (event) => {
|
||||
if (input.value.trim()) return;
|
||||
event.preventDefault();
|
||||
showError();
|
||||
});
|
||||
|
||||
input.addEventListener("input", clearError);
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue