This repository contains a single-page React app scaffolded with Vite. Your task is to build it into a small phonebook/directory: start with a static contact list, then make it dynamic by fetching JSON, adding search, and basic interactivity.
-
Fork this repository to your account.
-
Clone your fork to your machine.
-
Install dependencies:
npm install
-
Run the dev server:
npm run dev
-
Open the app in your browser at the URL printed in the terminal.
src/App.jsx: Main page markup and interactive logic with TASK/TODO comments.src/App.css: Page layout and components. You will write responsive CSS.src/index.css: Global tokens, color scheme, resets.public/data/contacts.json: Data to fetch and render.index.html: Document metadata.
A single page that:
- Starts with a static, hardcoded list of contacts (name, phone, email, photo).
- Later fetches and displays contacts from JSON.
- Supports search by name or phone.
- Allows adding a contact with basic validation.
- Has accessible labels and headings.
Complete these tasks in order. Save most JavaScript for Sections 3 & 4.
- Choose your theme (examples below) and add HTML elements like titles and headers where appropriate.
- Add meaningful, hierarchical headings (
h1for the page title,h2for sections,h3for card titles). - Add helpful placeholder text where appropriate.
- Add descriptive
alttext to any images/icons. - Use semantic elements where possible:
main,header,section,footer,ul,li,form. - Add 10 hardcoded contacts in the JSX (name, phone, email, photo). You may loop an array of contacts or hardcode the whole list.
- Choose a theme for your directory and implement it using CSS (colors, fonts, imagery).
- Ensure comfortable spacing with margins/padding, and make text readable.
- Provide focus styles for interactive elements (
button,input,select). - Use imagery that fits your theme.
- Implement pagination for the contact directory.
- Display one contact per page.
- Add navigation buttons (e.g., Previous, Next) to move between pages.
- Update the view to display the contact based on the current page.
- Fetch contacts from
/data/contacts.jsoninuseEffect.- Implement
loadinganderrorstates; if fetch fails, fall back to a local hardcoded list.
- Implement
- Search (case-insensitive) by name OR phone; update the visible list accordingly.
- Add Contact form with validation:
- Name required (min 2 chars), phone required, and email must include
@. - On submit, add the new contact to the top of the list. Clear the form.
- Show inline validation messages.
- Name required (min 2 chars), phone required, and email must include
- Highlight the portion of name/phone that matches the search query.
- Persist contacts to
localStorage; restore on load while keeping the fetch fallback behavior. - Implement responsive layout.
- Create additional files and components.
- Alter the contact list and layout to fit the theme you choose (e.g. space, anime, games).
- Consult online documentation for assistance with syntax.
- Use genAI within reason to assist with complex code (I think Copilot is ok, but be sure to guide it properly and not blindly trust it).
- Ping me with questions and set up office hours. I can guide you as you code.
- Throw the whole thing into ChatGPT.
- Cry.
I will check for:
- Correctness of features.
- Clean, readable code and meaningful naming.
- Clean, semantic HTML.
- Cohesive theme and basic styling.
- Graceful error handling and edge case coverage.
- Proper use of React Hooks.
- Start simple; get each task passing before moving on.
- Use loops!
- Research, research, research when you're stuck.
- Keep components small and functions descriptive.
- Test, test, test.
- Commit your code often.
- Research the
useStateanduseEffecthooks.
You should create a branch for each section. That is, create a Section 1 branch from main before you begin, then branch into a Section 2 branch, etc. We'll learn how to merge these back to main as we go.
For each section, there is an assignment on Brightspace. Provide:
- Your final code repository link directly to the branch for the specific section's work.
- A short note (1–2 paragraphs) describing what you implemented and any trade-offs.