| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- ---
- import Head from "@components/_head.astro"
- import Footer from "@components/dashboard/_footer.astro"
- import Topbar from "@components/dashboard/_topbar.astro"
- import Sidenav from "@components/dashboard/_sidenav.astro"
- import Scripts from "@components/_scripts.astro"
- const title = "AdminLTE 4 | Form Wizard"
- const path = "../../../dist"
- const mainPage = "forms"
- const page = "wizard";
- ---
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <Head title={title} path={path} />
- <style is:inline>
- .wizard-steps {
- counter-reset: step;
- list-style: none;
- padding: 0;
- display: flex;
- justify-content: space-between;
- position: relative;
- }
- .wizard-steps::before {
- content: "";
- position: absolute;
- top: 1rem;
- left: 0;
- right: 0;
- height: 2px;
- background: var(--bs-border-color);
- z-index: 0;
- }
- .wizard-steps li {
- position: relative;
- z-index: 1;
- background: var(--bs-body-bg);
- padding: 0 .75rem;
- text-align: center;
- color: var(--bs-secondary-color);
- font-size: .875rem;
- }
- .wizard-steps li::before {
- counter-increment: step;
- content: counter(step);
- display: flex;
- align-items: center;
- justify-content: center;
- width: 2rem;
- height: 2rem;
- margin: 0 auto .5rem;
- border-radius: 50%;
- background: var(--bs-body-tertiary-bg);
- border: 2px solid var(--bs-border-color);
- color: var(--bs-secondary-color);
- font-weight: 600;
- }
- .wizard-steps li.active {
- color: var(--bs-primary);
- font-weight: 600;
- }
- .wizard-steps li.active::before {
- background: var(--bs-primary);
- border-color: var(--bs-primary);
- color: #fff;
- }
- .wizard-steps li.completed::before {
- background: var(--bs-success);
- border-color: var(--bs-success);
- color: #fff;
- content: "\f633";
- font-family: "bootstrap-icons";
- }
- </style>
- </head>
- <body class="layout-fixed sidebar-expand-lg bg-body-tertiary">
- <div class="app-wrapper">
- <Topbar path={path} />
- <Sidenav path={path} mainPage={mainPage} page={page} />
- <main class="app-main">
- <div class="app-content-header">
- <div class="container-fluid">
- <div class="row">
- <div class="col-sm-6">
- <h3 class="mb-0">Form Wizard</h3>
- </div>
- <div class="col-sm-6">
- <ol class="breadcrumb float-sm-end">
- <li class="breadcrumb-item"><a href="#">Home</a></li>
- <li class="breadcrumb-item"><a href="#">Forms</a></li>
- <li class="breadcrumb-item active" aria-current="page">Wizard</li>
- </ol>
- </div>
- </div>
- </div>
- </div>
- <div class="app-content">
- <div class="container-fluid">
- <div class="row justify-content-center">
- <div class="col-lg-10 col-xl-8">
- <div class="card">
- <div class="card-body p-4">
- <!-- Step indicators -->
- <ol class="wizard-steps mb-4" id="wizard-steps">
- <li class="active" data-step="0">Account</li>
- <li data-step="1">Profile</li>
- <li data-step="2">Preferences</li>
- <li data-step="3">Review</li>
- </ol>
- <!-- Form -->
- <form id="wizard-form" novalidate>
- <!-- Step 1 -->
- <fieldset class="wizard-step" data-step="0">
- <h2 class="h5 mb-3">Create your account</h2>
- <div class="row g-3">
- <div class="col-md-6">
- <label class="form-label" for="wz-email">Email</label>
- <input
- type="email"
- class="form-control"
- id="wz-email"
- required
- />
- <div class="invalid-feedback">
- Please enter a valid email.
- </div>
- </div>
- <div class="col-md-6">
- <label class="form-label" for="wz-username">
- Username
- </label>
- <input
- type="text"
- class="form-control"
- id="wz-username"
- required
- minlength="3"
- />
- <div class="invalid-feedback">
- Username must be at least 3 characters.
- </div>
- </div>
- <div class="col-md-6">
- <label class="form-label" for="wz-password">
- Password
- </label>
- <input
- type="password"
- class="form-control"
- id="wz-password"
- required
- minlength="8"
- />
- <div class="invalid-feedback">
- Password must be at least 8 characters.
- </div>
- </div>
- <div class="col-md-6">
- <label class="form-label" for="wz-password2">
- Confirm password
- </label>
- <input
- type="password"
- class="form-control"
- id="wz-password2"
- required
- />
- <div class="invalid-feedback">
- Passwords must match.
- </div>
- </div>
- </div>
- </fieldset>
- <!-- Step 2 -->
- <fieldset class="wizard-step d-none" data-step="1">
- <h2 class="h5 mb-3">Tell us about yourself</h2>
- <div class="row g-3">
- <div class="col-md-6">
- <label class="form-label" for="wz-first">
- First name
- </label>
- <input
- type="text"
- class="form-control"
- id="wz-first"
- required
- />
- <div class="invalid-feedback">
- First name is required.
- </div>
- </div>
- <div class="col-md-6">
- <label class="form-label" for="wz-last">
- Last name
- </label>
- <input
- type="text"
- class="form-control"
- id="wz-last"
- required
- />
- <div class="invalid-feedback">
- Last name is required.
- </div>
- </div>
- <div class="col-md-6">
- <label class="form-label" for="wz-company">
- Company
- </label>
- <input
- type="text"
- class="form-control"
- id="wz-company"
- />
- </div>
- <div class="col-md-6">
- <label class="form-label" for="wz-role">
- Role
- </label>
- <select class="form-select" id="wz-role" required>
- <option value="">Choose…</option>
- <option>Founder / CEO</option>
- <option>Engineering</option>
- <option>Design</option>
- <option>Marketing</option>
- <option>Other</option>
- </select>
- <div class="invalid-feedback">
- Please select a role.
- </div>
- </div>
- </div>
- </fieldset>
- <!-- Step 3 -->
- <fieldset class="wizard-step d-none" data-step="2">
- <h2 class="h5 mb-3">Notification preferences</h2>
- <div class="form-check form-switch mb-2">
- <input
- class="form-check-input"
- type="checkbox"
- id="wz-notif-product"
- role="switch"
- checked
- />
- <label class="form-check-label" for="wz-notif-product">
- Product updates & releases
- </label>
- </div>
- <div class="form-check form-switch mb-2">
- <input
- class="form-check-input"
- type="checkbox"
- id="wz-notif-security"
- role="switch"
- checked
- />
- <label class="form-check-label" for="wz-notif-security">
- Security alerts
- </label>
- </div>
- <div class="form-check form-switch mb-3">
- <input
- class="form-check-input"
- type="checkbox"
- id="wz-notif-marketing"
- role="switch"
- />
- <label class="form-check-label" for="wz-notif-marketing">
- Marketing & tips
- </label>
- </div>
- <label class="form-label" for="wz-frequency">
- Digest frequency
- </label>
- <select class="form-select" id="wz-frequency">
- <option>Real time</option>
- <option selected>Daily</option>
- <option>Weekly</option>
- <option>Never</option>
- </select>
- </fieldset>
- <!-- Step 4 -->
- <fieldset class="wizard-step d-none" data-step="3">
- <h2 class="h5 mb-3">Review & confirm</h2>
- <dl class="row mb-3" id="wz-summary"></dl>
- <div class="form-check">
- <input
- class="form-check-input"
- type="checkbox"
- id="wz-terms"
- required
- />
- <label class="form-check-label" for="wz-terms">
- I agree to the <a href="#">terms of service</a>.
- </label>
- <div class="invalid-feedback">
- You must accept the terms to continue.
- </div>
- </div>
- </fieldset>
- <!-- Navigation -->
- <div class="d-flex justify-content-between mt-4">
- <button
- type="button"
- class="btn btn-outline-secondary"
- id="wz-prev"
- disabled
- >
- <i class="bi bi-arrow-left me-1" aria-hidden="true"></i>
- Previous
- </button>
- <button
- type="button"
- class="btn btn-primary"
- id="wz-next"
- >
- Next
- <i class="bi bi-arrow-right ms-1" aria-hidden="true"></i>
- </button>
- <button
- type="submit"
- class="btn btn-success d-none"
- id="wz-submit"
- >
- <i class="bi bi-check-lg me-1" aria-hidden="true"></i>
- Submit
- </button>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </main>
- <Footer />
- </div>
- <Scripts path={path} />
- <script is:inline>
- document.addEventListener("DOMContentLoaded", () => {
- const form = document.getElementById("wizard-form");
- const steps = form.querySelectorAll(".wizard-step");
- const indicators = document.querySelectorAll("#wizard-steps li");
- const prevBtn = document.getElementById("wz-prev");
- const nextBtn = document.getElementById("wz-next");
- const submitBtn = document.getElementById("wz-submit");
- let current = 0;
- const show = (i) => {
- steps.forEach((s, idx) => s.classList.toggle("d-none", idx !== i));
- indicators.forEach((li, idx) => {
- li.classList.toggle("active", idx === i);
- li.classList.toggle("completed", idx < i);
- });
- prevBtn.disabled = i === 0;
- const last = i === steps.length - 1;
- nextBtn.classList.toggle("d-none", last);
- submitBtn.classList.toggle("d-none", !last);
- if (last) renderSummary();
- };
- const validateStep = (i) => {
- const step = steps[i];
- const fields = step.querySelectorAll("input, select, textarea");
- let valid = true;
- fields.forEach((field) => {
- field.classList.remove("is-invalid");
- if (!field.checkValidity()) {
- field.classList.add("is-invalid");
- valid = false;
- }
- });
- // Password match check on step 0
- if (i === 0) {
- const p1 = document.getElementById("wz-password");
- const p2 = document.getElementById("wz-password2");
- if (p1.value !== p2.value) {
- p2.classList.add("is-invalid");
- valid = false;
- }
- }
- return valid;
- };
- const renderSummary = () => {
- const summary = document.getElementById("wz-summary");
- const get = (id) => document.getElementById(id);
- const rows = [
- ["Email", get("wz-email").value],
- ["Username", get("wz-username").value],
- ["Name", `${get("wz-first").value} ${get("wz-last").value}`],
- ["Company", get("wz-company").value || "—"],
- ["Role", get("wz-role").value || "—"],
- ["Digest", get("wz-frequency").value]
- ];
- summary.innerHTML = rows
- .map(
- ([k, v]) =>
- `<dt class="col-sm-4 text-secondary fw-normal">${k}</dt><dd class="col-sm-8 fw-semibold">${v}</dd>`
- )
- .join("");
- };
- nextBtn.addEventListener("click", () => {
- if (!validateStep(current)) return;
- if (current < steps.length - 1) {
- current++;
- show(current);
- }
- });
- prevBtn.addEventListener("click", () => {
- if (current > 0) {
- current--;
- show(current);
- }
- });
- form.addEventListener("submit", (e) => {
- e.preventDefault();
- if (!validateStep(current)) return;
- alert("Wizard complete! Form would submit here.");
- });
- show(0);
- });
- </script>
- </body>
- </html>
|