React + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
Dependencies:
npm i eslint vite-plugin-eslint eslint-config-react --save-dev
create eslintrc.json for rules
{
"extends": "react-app"
}
Be sure to have eslint extension in vsCode
Add eslint to vite.config.js
import eslint from "vite-plugin-eslint";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), eslint()],
});
install tailwind (see their docs)
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
install VS Code extension for tailwind (gives autocompletion)
install Tailwind Prettier extension (github link from search)
npm install -D prettier prettier-plugin-tailwindcss
// prettier.config.cjs
module.exports = {
plugins: ['prettier-plugin-tailwindcss'],
}
Questions:
- Gather requirements and features
- Divide the application into pages
-
- break desired UI into components
- Design and build static version (no state)
- Divide the application into feature categories
- Think a bout statemanagement and data flow
- Decide on which libraries to use
Requirements
- Users can order one or more pizas from menu
- Requires no user accounts and no logins: users just input their name
- The pizza menu can change, so it should be loaded from an API.
- Ordering requries the user's name, phone number, and address
- If Possible, GPS location should also be provided to make delivery easier.
- Use's can mark their order as 'priority' for 20% upcharge
- Orders are made by sending a POST request with teh order data (user data + selected pizzas) to the API.
- Payments are made on delivery, so no payment processing in the app
- Each new order gets unique ID that should be displayed, so the user can later look up the status of their order based on ID.
- Users should be able to mark their order as priority even after it's been placed.
Features
- User
- Menu
- Cart
- Order
Page
- Homepage /
- Pizza Menu /menu
- Cart /cart
- Placing a new order /order/new
- Looking up an order /order/:orderID
State
- User > Global UI state (no accounts, so stays in app)
- Menu > Global remote state (menu is fetched from API)
- Cart > Global UI state (no need for API, just stored in app)
- Order > Global Remote State (fetched and submitted to API)
Tech choices
- Routing > React Router
- Styling > TailwindCSS
- Remote State Management > React Router
- UI State Management > Redux