From 90e0bd974f3caf3acf789219f397c0b3337ea2d8 Mon Sep 17 00:00:00 2001 From: Diem-Trang Pham <6422507+pdtrang@users.noreply.github.com> Date: Wed, 22 Oct 2025 17:22:55 -0500 Subject: [PATCH] feat(curriculum): add interactive examples to progress indication lesson (#62943) --- .../672bb02009ffc0797ca567ab.md | 479 +++++++++++++++++- 1 file changed, 478 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/blocks/lecture-user-centered-design/672bb02009ffc0797ca567ab.md b/curriculum/challenges/english/blocks/lecture-user-centered-design/672bb02009ffc0797ca567ab.md index 43cb240a953..7f377ac9167 100644 --- a/curriculum/challenges/english/blocks/lecture-user-centered-design/672bb02009ffc0797ca567ab.md +++ b/curriculum/challenges/english/blocks/lecture-user-centered-design/672bb02009ffc0797ca567ab.md @@ -5,12 +5,245 @@ challengeType: 19 dashedName: what-are-best-practices-for-progress-indication-on-forms-registration-and-setup --- -# --description-- +# --interactive-- + +**NOTE**: Some of the interactive examples might use CSS and JavaScript that you haven't learned yet. Don't worry about trying to understand all of the code. The goal of the examples is to show you previews for these design concepts so you better understand how things work. Progress indication is a way to show users how far they are in a process. It can be used in forms, registration, and setup processes. The goal is to help users understand where they are in the process and how much more they need to do. For example, you can use a progress indication bar to show users what is left to do when filling forms. You don't want to create a situation where the user needs to fill out a lengthy form and they don't know how many more steps they need to complete. Transparency is key so the user knows whether they have enough time to sit down and complete the form or if they need to come back later. +:::interactive_editor + +```html + + +
+
+ +
+
+
Step 1 of 3
+
+
+ + +
+ Personal Information + + + + + + + +
+ + +
+ Address + + + + + + + + +
+ + +
+ Review & Submit +

Please review your information before submitting.

+ + + +
+
+ + +``` + +```css +.form-progress { + max-width: 500px; + margin: 20px auto 30px; + font-family: Arial, sans-serif; +} + +.progress-label { + display: block; + margin-bottom: 8px; + font-size: 16px; + font-weight: 600; + color: #333; +} + +.progress-container { + position: relative; + background-color: #555; + border-radius: 8px; + height: 30px; + overflow: hidden; + box-shadow: inset 0 1px 3px rgba(0,0,0,0.3); +} + +.progress-bar { + background-color: #4caf50; + height: 100%; + width: 0; + border-radius: 8px 0 0 8px; + transition: width 0.3s ease; +} + +.progress-text { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 30px; + line-height: 30px; + text-align: center; + font-weight: bold; + color: #fff; + pointer-events: none; + user-select: none; +} + +form { + max-width: 500px; + margin: 0 auto; + font-family: Arial, sans-serif; +} + +fieldset { + border: none; + padding: 0; + margin: 0 0 20px; +} + +legend { + font-size: 1.2em; + font-weight: 700; + margin-bottom: 10px; + color: #222; +} + +label { + display: block; + margin-bottom: 6px; + font-weight: 600; + color: #333; +} + +input[type="text"], +input[type="email"] { + width: 100%; + padding: 8px 10px; + font-size: 1em; + border: 1px solid #ccc; + border-radius: 4px; + margin-bottom: 15px; + box-sizing: border-box; + transition: border-color 0.2s ease; +} + +input[type="text"]:focus, +input[type="email"]:focus { + outline: none; + border-color: #4caf50; + box-shadow: 0 0 5px rgba(76, 175, 80, 0.5); +} + +.form-step { + display: none; +} + +.form-step.active { + display: block; +} + +button { + background-color: #4caf50; + border: none; + color: white; + padding: 10px 18px; + font-size: 1em; + border-radius: 5px; + cursor: pointer; + margin-right: 10px; + transition: background-color 0.2s ease; +} + +button:hover:not(:disabled) { + background-color: #45a049; +} + +button:disabled { + background-color: #9e9e9e; + cursor: not-allowed; +} + +@media (max-width: 600px) { + .form-progress, form { + max-width: 90%; + margin: 20px auto; + } +} +``` + +```js +const form = document.getElementById('multiStepForm'); +const steps = form.querySelectorAll('.form-step'); +const progressBar = form.querySelector('.progress-bar'); +const progressText = form.querySelector('.progress-text'); +const totalSteps = steps.length; + +let currentStep = 0; + +function updateProgress() { + const percent = ((currentStep + 1) / totalSteps) * 100; + progressBar.style.width = percent + '%'; + progressText.textContent = `Step ${currentStep + 1} of ${totalSteps}`; +} + +function showStep(index) { + steps.forEach((step, i) => { + step.classList.toggle('active', i === index); + }); + updateProgress(); +} + +form.querySelectorAll('.next-btn').forEach(btn => { + btn.addEventListener('click', () => { + if (currentStep < totalSteps - 1) { + currentStep++; + showStep(currentStep); + } + }); +}); + +form.querySelectorAll('.prev-btn').forEach(btn => { + btn.addEventListener('click', () => { + if (currentStep > 0) { + currentStep--; + showStep(currentStep); + } + }); +}); + +showStep(currentStep); + +form.addEventListener('submit', e => { + e.preventDefault(); + alert('Form submitted!'); +}); + +``` + +::: + When designing a progress indication section, there are a few best practices to keep in mind. The first consideration is to keep it simple. You don't want to overwhelm the user with too much information where they get frustrated and leave the site. The second consideration is to make it possible to go back to previous steps. This is important because users may want to go back and check their previous answers or make changes. @@ -19,6 +252,250 @@ Another consideration is to make the progress indication section easy to find. I The last consideration is to have clear section titles, percentages, or steps. If you just have a progress bar with no context, the user won't know what it means. +:::interactive_editor + +```html + + +
+
+ +
+
+
+
+ + +
+ Basic Information +

Please enter your basic information.

+ + + + +
+ + +
+ Contact Details +

How can we reach you?

+ + + + + +
+ + +
+ Address +

Where do you live?

+ + + + + +
+ + +
+ Review +

Review your answers before submitting.

+ + + +
+
+ +``` + +```css +.form-progress { + max-width: 500px; + margin: 20px auto 30px; + font-family: Arial, sans-serif; +} + +.progress-label { + display: block; + margin-bottom: 8px; + font-size: 16px; + font-weight: 600; + color: #333; +} + +.progress-container { + position: relative; + background-color: #555; + border-radius: 8px; + height: 30px; + overflow: hidden; + box-shadow: inset 0 1px 3px rgba(0,0,0,0.3); +} + +.progress-bar { + background-color: #4caf50; + height: 100%; + width: 0; + border-radius: 8px 0 0 8px; + transition: width 0.3s ease; +} + +.progress-text { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 30px; + line-height: 30px; + text-align: center; + font-weight: bold; + color: #fff; + pointer-events: none; + user-select: none; +} + +form { + max-width: 500px; + margin: 0 auto; + font-family: Arial, sans-serif; +} + +fieldset { + border: none; + padding: 0; + margin: 0 0 20px; +} + +legend { + font-size: 1.2em; + font-weight: 700; + margin-bottom: 10px; + color: #222; +} + +label { + display: block; + margin-bottom: 6px; + font-weight: 600; + color: #333; +} + +input[type="text"], +input[type="email"] { + width: 100%; + padding: 8px 10px; + font-size: 1em; + border: 1px solid #ccc; + border-radius: 4px; + margin-bottom: 15px; + box-sizing: border-box; + transition: border-color 0.2s ease; +} + +input[type="text"]:focus, +input[type="email"]:focus { + outline: none; + border-color: #4caf50; + box-shadow: 0 0 5px rgba(76, 175, 80, 0.5); +} + +.form-step { + display: none; +} + +.form-step.active { + display: block; +} + +button { + background-color: #4caf50; + border: none; + color: white; + padding: 10px 18px; + font-size: 1em; + border-radius: 5px; + cursor: pointer; + margin-right: 10px; + transition: background-color 0.2s ease; +} + +button:hover:not(:disabled) { + background-color: #45a049; +} + +button:disabled { + background-color: #9e9e9e; + cursor: not-allowed; +} + +@media (max-width: 600px) { + .form-progress, form { + max-width: 90%; + margin: 20px auto; + } +} +``` + +```js +const form = document.getElementById('progressForm'); +const steps = form.querySelectorAll('.form-step'); +const progressBar = form.querySelector('.progress-bar'); +const currentStepSpan = document.getElementById('currentStep'); +const totalStepsSpan = document.getElementById('totalSteps'); +const percentageSpan = document.getElementById('percentage'); + +const totalSteps = steps.length; +let currentStep = 0; + +totalStepsSpan.textContent = totalSteps; + +function updateProgress() { + const percent = Math.round(((currentStep + 1) / totalSteps) * 100); + progressBar.style.width = percent + '%'; + currentStepSpan.textContent = currentStep + 1; + percentageSpan.textContent = percent + '%'; + + // Update ARIA attribute + form.querySelector('.progress-container').setAttribute('aria-valuenow', percent); +} + +function showStep(index) { + steps.forEach((step, i) => { + step.classList.toggle('active', i === index); + }); + updateProgress(); +} + +form.querySelectorAll('.next-btn').forEach(btn => { + btn.addEventListener('click', () => { + if (currentStep < totalSteps - 1) { + currentStep++; + showStep(currentStep); + } + }); +}); + +form.querySelectorAll('.prev-btn').forEach(btn => { + btn.addEventListener('click', () => { + if (currentStep > 0) { + currentStep--; + showStep(currentStep); + } + }); +}); + +form.addEventListener('submit', e => { + e.preventDefault(); + alert('Form submitted! Thanks!'); +}); + +showStep(currentStep); + +``` + +::: + These are just a few best practices to keep in mind when designing progress indication on forms, registration, and setup processes. Study a few examples on big websites and see how they implement progress indication. Then test your design with real users to see how well it works. # --questions--