this repo has no description
React PWA Migration Plan for Values Exercise App#
Goal: Convert the existing Vanilla JS/TS application into a React-based Progressive Web App (PWA) using Vite, TypeScript, and Tailwind CSS, managed by Bun and tested with Vitest/jsdom. It should retain localStorage persistence, implement responsive UI (desktop columns with drag-and-drop, mobile "flashcard" style), and follow modern React best practices, using Zustand for state management.
Phase 1: Project Setup & Foundational Structure#
- Initialize New Project with Vite (using Bun):
- Use
bun create vite values-react-app --template react-swc-ts. cd values-react-appbun install(To install dependencies initially)
- Use
- Install Core Dependencies (using Bun):
bun add react-router-dom(for handling "parts" as routes)bun add -d tailwindcss postcss autoprefixer(for styling,-dfor dev dependency)bun add @dnd-kit/core @dnd-kit/sortable(for desktop drag-and-drop)
- Configure Tailwind CSS:
bunx tailwindcss init -p- Configure
tailwind.config.js: Updatecontentarray ('./index.html', './src/**/*.{js,ts,jsx,tsx}'). - Create
src/index.css: Add Tailwind directives (@tailwind base; @tailwind components; @tailwind utilities;). - Import
src/index.cssinsrc/main.tsx.
- Basic App Structure & Routing:
- Clean up default Vite template files in
src. - Set up basic routing in
src/App.tsxusingreact-router-dom(e.g.,/part1,/part2,/review). - Create placeholder component files for views (e.g.,
src/views/Part1View.tsx).
- Clean up default Vite template files in
- ESLint/Prettier Setup:
- Configure ESLint/Prettier for React/TSX (e.g.,
eslint-plugin-react,eslint-plugin-react-hooks,@typescript-eslint/recommended). - Add
prettier-plugin-tailwindcss(bun add -d prettier-plugin-tailwindcss). - Update
.eslintignoreand.prettierignoreto includedist/.
- Configure ESLint/Prettier for React/TSX (e.g.,
Phase 2: State Management & Core Logic#
- Define
AppStateInterface:- Reuse or adapt the existing interface from
index.ts.
- Reuse or adapt the existing interface from
- Implement State Management (Zustand):
- Install Zustand:
bun add zustand. - Create store file:
src/store/appStore.ts. - Define store using
createfrom Zustand and theAppStateinterface. - Define state properties and update functions (e.g.,
setPart,moveCard) within the store setup usingset.
- Install Zustand:
- Port Value Definitions:
- Move
values.tsdata intosrc. Make definitions available to the state store (e.g., for initializing default state).
- Move
Phase 3: Componentization & UI Implementation#
- Create Reusable Components:
ValueCard.tsxColumn.tsx(Desktop)Button.tsxModal.tsx(Add New Value)ValueDefinitionDisplay.tsx(Review)StatementInput.tsx(Part 4)
- Implement Mobile Views (Parts 1-4 - Flashcard Style):
- Create
FlashcardSorter.tsxcomponent. - Integrate
FlashcardSorterinto view components (e.g.,Part1View). - Display one unassigned card at a time (fetched from store).
- Add category assignment buttons connected to store actions.
- Implement the "Overview" component (category counts, tappable).
- Use Tailwind responsive prefixes (
flex md:hidden) to show only on mobile/small screens. - Implement necessary store actions for mobile interactions.
- Create
- Implement Desktop Views (Parts 1-4):
- Target relevant view components (e.g.,
Part1View). - Build/reveal multi-column layouts using Tailwind CSS (
hidden md:flex). - Integrate
@dnd-kit/core/@dnd-kit/sortablefor drag-and-drop. Connect drag events to call store actions.
- Target relevant view components (e.g.,
- Implement Review View (
ReviewView.tsx):- Display Core/Additional values and statements using Tailwind (data from store). Ensure responsiveness.
- Implement Navigation & Transitions:
- Use
useNavigatefor route changes. - Implement validation logic within navigation handlers (checking store state) before calling store actions/navigating.
- Implement skip logic (Part 2 -> Part 4) in handlers based on store state.
- Use
Phase 4: Persistence, PWA, and Testing#
- Implement
localStoragePersistence (Zustand Persist Middleware):- Integrate
persistmiddleware fromzustand/middlewareinto the store setup. - Configure it to save the desired state parts to
localStorage.
- Integrate
- Configure PWA Features (
vite-plugin-pwa):bun add -d vite-plugin-pwa.- Configure the plugin in
vite.config.ts. - Define
manifestoptions (name, icons, colors, etc.). - Choose a service worker strategy (e.g.,
generateSW). - Add icons to
public/. - Test installation and basic offline behavior.
- Setup & Configure Testing (Vitest,
jsdom,React Testing Library):- Install testing dependencies:
bun add -d vitest @testing-library/react @testing-library/jest-dom jsdom @testing-library/user-event. - Configure Vitest in
vite.config.ts(orvitest.config.ts): specifyglobals: true,environment: 'jsdom', and potentially a setup file for@testing-library/jest-dom. - Add test script to
package.json:"test": "vitest run". - Ensure test files (
*.test.tsx) import fromvitestinstead ofbun:test.
- Install testing dependencies:
- Update/Write Tests:
- Write unit tests for store actions/logic where feasible.
- Write integration tests for components/views using React Testing Library. Mock the Zustand store or use testing utilities if needed to verify interactions with the store.
- Use
bun run test(orvitestdirectly) to run tests.
Phase 5: Refinement & Deployment#
- Accessibility (A11y) Review:
- Semantic HTML, keyboard navigation, color contrast, ARIA attributes.
- Performance Check:
- React DevTools profiler, Zustand selectors optimization if needed, bundle size.
- Cross-Browser/Device Testing:
- Test on Chrome, Firefox, Safari, and mobile devices/simulators (iOS/Android).
- Deployment:
- Build (
bun run build). - Deploy
dist/folder to a static host (Netlify, Vercel, Cloudflare Pages).
- Build (