Let form declare status card

This commit is contained in:
Florine W. Dekker 2022-12-16 21:39:05 +01:00
parent 080c1f852c
commit c495714867
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
3 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@fwdekker/template", "name": "@fwdekker/template",
"version": "3.5.7", "version": "3.6.0",
"description": "The base template for pages on fwdekker.com.", "description": "The base template for pages on fwdekker.com.",
"author": "Florine W. Dekker", "author": "Florine W. Dekker",
"license": "MIT", "license": "MIT",

View File

@ -27,7 +27,9 @@ export function showMessageType(card: HTMLElement | HTMLFormElement,
message?: string, message?: string,
type?: "busy" | "error" | "info" | "success" | "warning"): void { type?: "busy" | "error" | "info" | "success" | "warning"): void {
if (card instanceof HTMLFormElement) { if (card instanceof HTMLFormElement) {
const formCard = $(`article[data-status-for="${card.id}"]`); if (card.dataset.statusCard == null) return;
const formCard = $(`#${card.dataset.statusCard}`);
if (formCard == null) return; if (formCard == null) return;
card = formCard; card = formCard;

View File

@ -61,8 +61,8 @@
<h3>Already have an account? Welcome back!</h3> <h3>Already have an account? Welcome back!</h3>
</hgroup> </hgroup>
</header> </header>
<form id="test-form" novalidate> <form id="test-form" data-status-card="test-status-card" novalidate>
<article class="status-card hidden" data-status-for="test-form"> <article id="test-status-card" class="status-card hidden">
<output>Congrats!</output> <output>Congrats!</output>
<a class="close" href="#" aria-label="Close"></a> <a class="close" href="#" aria-label="Close"></a>
</article> </article>