mirror of
https://github.com/ZTatman/myst.git
synced 2026-11-22 12:57:58 +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 {
|
.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;
|
@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.
|
to enable share link viewing.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<form method="post"
|
<form id="pat-form"
|
||||||
class="grid gap-4 px-4 py-4 sm:grid-cols-[1fr_auto] sm:items-end">
|
method="post"
|
||||||
<div>
|
action="/dashboard/pat"
|
||||||
<label for="pat" class="section-header-subtle">Forgejo access token</label>
|
novalidate
|
||||||
<input type="text"
|
class="px-4 py-4">
|
||||||
id="pat"
|
<div class="grid gap-4 sm:grid-cols-[1fr_auto] sm:items-end">
|
||||||
name="pat"
|
<div>
|
||||||
class="block w-full mt-2 input-mono"
|
<label for="pat" class="section-header-subtle">Forgejo access token</label>
|
||||||
placeholder="ad8j3..."
|
<input type="text"
|
||||||
required />
|
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>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Register</button>
|
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<section class="card">
|
<section class="card">
|
||||||
|
|
@ -76,4 +86,34 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</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 %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue