MiniQuiz is a Vite + React single-page quiz about screen-life balance. It asks 15 weighted multiple-choice questions, collects an email after the final question, and shows a scored summary with category feedback.
- Flow: Questions → Email capture → Results
- Weighted scoring (0–150) with descriptive ranges (e.g., Digital Zen Master, Burnout Risk)
- Category breakdown cards with thresholds and tailored feedback
- Progress saved in
localStorageand restored on reload - View Transitions API for smoother step changes (with graceful fallback)
- React 19
- Vite
- classnames for conditional classes
- Local storage for persistence
Prerequisites:
- Node.js 18+
Install dependencies:
npm install
Run in development:
npm run dev
Build for production:
npm run build
Preview production build:
npm run preview
src/App.jsx— Orchestrates steps, quiz state, scoring, and persistencesrc/components/Question.jsx— Question UI with selectable options and navigationsrc/components/Email.jsx— Email capture form (step 2 of 3)src/components/Results.jsx— Score label, total, email echo, and category cardssrc/components/ui/QuizSection.jsx— Shared layout shell used across stepssrc/data/questions.js— Question copy, categories, and weighted optionssrc/data/results.js— Score ranges and category metadata (thresholds, feedback)src/utils— Helpers for scoring, hydration (loadSavedData), and view transitions
- State in
App.jsx:step,questionIndex,selectedOption,results,email. - Selecting an option stores
{ selectedOptionId, value, category }for the current question and enables Continue. You can change the selection before continuing. - After the last question, clicking Continue moves to the email step; submitting the form shows results.
- Results show:
- A labeled status based on
scoreRanges(seesrc/data/results.js) - Total score vs. computed max (from
calculateMaxScore) - Entered email
- Category cards with percentage-to-threshold and feedback text
- A labeled status based on
- Retake resets state and clears the
miniQuizkey inlocalStorage.
- Add or edit questions in
src/data/questions.js(each option needsid,optionText, andvalue). - Adjust score ranges or category thresholds/feedback in
src/data/results.js. - Update styling in component-level CSS files (e.g.,
src/components/question.css,src/components/ui/button.css).