diff --git a/country-explorer/README.md b/country-explorer/README.md index d8cb914..ebcc408 100644 --- a/country-explorer/README.md +++ b/country-explorer/README.md @@ -1,17 +1,45 @@ -# React + TypeScript + Vite +# Country Explorer -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. +React + TypeScript + Vite app that fetches and displays country data from a REST API. + +## Project structure + +``` +src/ +├── api/ # Functions for calling the external REST API (one file per resource) +├── components/ # Reusable UI components, e.g. App.tsx (one file per component) +├── hooks/ # Custom React hooks +├── types/ # Shared TypeScript types and interfaces +├── utils/ # Small, framework-agnostic helper functions +├── assets/ # Images, icons, and other static assets +├── index.css # Global stylesheet +└── main.tsx # Application entry point +``` + +`api/`, `hooks/`, `types/`, and `utils/` are created once there is real code to put in them. + +Naming conventions: + +- Components: PascalCase file names matching the default export (e.g. `CountryCard.tsx`), colocated with their own CSS file when they have one (e.g. `App.tsx` + `App.css`). +- Hooks: camelCase file names prefixed with `use` (e.g. `useFetch.ts`). +- API functions & utilities: camelCase file names describing what they do (e.g. `getCountries.ts`, `formatNumber.ts`). +- Types: camelCase file names matching the domain they describe (e.g. `country.ts`). +- Tests are colocated with the file they test (e.g. `CountryCard.test.tsx` next to `CountryCard.tsx`), rather than kept in a separate top-level test folder. + +## About this template + +This project was scaffolded with the React + TypeScript + Vite template, which provides a minimal setup to get React working in Vite with HMR and some ESLint rules. Currently, two official plugins are available: - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) -## React Compiler +### React Compiler The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). -## Expanding the ESLint configuration +### Expanding the ESLint configuration If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: diff --git a/country-explorer/src/App.css b/country-explorer/src/components/App.css similarity index 100% rename from country-explorer/src/App.css rename to country-explorer/src/components/App.css diff --git a/country-explorer/src/App.tsx b/country-explorer/src/components/App.tsx similarity index 93% rename from country-explorer/src/App.tsx rename to country-explorer/src/components/App.tsx index 9ec34bc..0937f92 100644 --- a/country-explorer/src/App.tsx +++ b/country-explorer/src/components/App.tsx @@ -1,7 +1,7 @@ import { useState } from 'react'; -import heroImg from './assets/hero.png'; -import reactLogo from './assets/react.svg'; -import viteLogo from './assets/vite.svg'; +import heroImg from '../assets/hero.png'; +import reactLogo from '../assets/react.svg'; +import viteLogo from '../assets/vite.svg'; import './App.css'; function App() { @@ -18,7 +18,7 @@ function App() {
- Edit src/App.tsx and save to test HMR
+ Edit src/components/App.tsx and save to test HMR