Skip to content

Commit

Permalink
added toaster toggle function
Browse files Browse the repository at this point in the history
  • Loading branch information
TimTJoe committed Aug 19, 2024
1 parent 1a481ec commit c0b878f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions public/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

export function openToaster(text) {
let toaster = document.getElementById("toaster");
document.getElementById("toaster-text").innerText = text;
toaster.classList.remove("hide");
toaster.classList.add("show");
setTimeout(() => {
toaster.classList.add("hide");
toaster.classList.remove("show");
}, 2000);
}
11 changes: 11 additions & 0 deletions public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ export function getState() {
return history.state.value || null;
}

export function openToaster(text) {
let toaster = document.getElementById("toaster");
let toasterText = document.getElementById("toaster-text");
toaster.classList.remove("hide");
toaster.classList.add("show");
setTimeout(() => {
toaster.classList.add("hide");
toaster.classList.remove("show");
}, 3000);
}

export default { setState, getState };
2 changes: 1 addition & 1 deletion views/partials/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
</head>

<body>
<section class="toaster row around padding" id="toaster">
<section class="toaster row around padding hide" id="toaster">
<span class="text padding" id="toaster-text">Registration is Successful</span>
</section>
3 changes: 3 additions & 0 deletions views/partials/sidebar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@
<span>
<a href="/voters/registration" class="button outlined">Voter Registration</a>
</span>
<section class="padding">
<%- include("./foot") %>
</section>
</nav>

0 comments on commit c0b878f

Please sign in to comment.