|
| 1 | +# Tasks Example |
| 2 | + |
| 3 | +A task management application demonstrating the capabilities of [@webstd-ui/router](../../packages/router) with async operations, redirects, and optimistic UI patterns. This example shows how to build a task manager with create, view, and delete functionality. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Task Management**: Create, view, and delete tasks |
| 8 | +- **Resource Routes**: Uses `resources()` helper for RESTful routing with custom destroy route |
| 9 | +- **Async Operations**: Demonstrates loading states with simulated delays |
| 10 | +- **Redirects**: Server-style redirects after mutations |
| 11 | +- **Form Handling**: Create and delete tasks via form submissions |
| 12 | +- **Navigation States**: Loading indicators during async operations |
| 13 | +- **Type-Safe Routing**: Full TypeScript support with route type inference |
| 14 | +- **Component-Based UI**: Reusable task components |
| 15 | + |
| 16 | +## Technology Stack |
| 17 | + |
| 18 | +- **Router**: [@webstd-ui/router](../../packages/router) |
| 19 | +- **UI Framework**: [@remix-run/dom](https://www.npmjs.com/package/@remix-run/dom) |
| 20 | +- **Build Tool**: Vite |
| 21 | +- **Language**: TypeScript |
| 22 | +- **Async Utilities**: [@std/async](https://jsr.io/@std/async) for delays |
| 23 | + |
| 24 | +## Getting Started |
| 25 | + |
| 26 | +### Prerequisites |
| 27 | + |
| 28 | +- [Mise](https://mise.jdx.dev/) for task automation |
| 29 | + |
| 30 | +### Installation & Running |
| 31 | + |
| 32 | +1. Install dependencies: |
| 33 | + ```sh |
| 34 | + mise install |
| 35 | + ``` |
| 36 | + |
| 37 | +2. Start the development server: |
| 38 | + ```sh |
| 39 | + mise run :dev |
| 40 | + ``` |
| 41 | + |
| 42 | +3. Open your browser to the URL shown in the terminal (typically `http://localhost:5173`) |
| 43 | + |
| 44 | +## Project Structure |
| 45 | + |
| 46 | +``` |
| 47 | +src/ |
| 48 | +├── components/ # Reusable UI components |
| 49 | +│ ├── NewTask.tsx # New task creation form |
| 50 | +│ └── TaskItem.tsx # Individual task component |
| 51 | +├── lib/ # Utilities and data management |
| 52 | +│ └── task-data.ts # Task data storage |
| 53 | +├── handlers.tsx # Route handlers for all pages |
| 54 | +├── routes.ts # Route definitions |
| 55 | +├── app.tsx # Main application component |
| 56 | +└── main.tsx # Application entry point |
| 57 | +``` |
| 58 | + |
| 59 | +## Routes |
| 60 | + |
| 61 | +| Path | Method | Handler | Description | |
| 62 | +|------|--------|---------|-------------| |
| 63 | +| `/` | GET | `index` | Redirects to first task | |
| 64 | +| `/task/new` | GET | `tasks.new` | New task form | |
| 65 | +| `/task` | POST | `tasks.create` | Create new task | |
| 66 | +| `/task/:id` | GET | `tasks.show` | View task details | |
| 67 | +| `/task/destroy/:id` | POST | `tasks.destroy` | Delete task | |
| 68 | + |
| 69 | +## Testing Loading States |
| 70 | + |
| 71 | +This example includes artificial delays (800ms) in async handlers to make loading states visible during development. This helps test: |
| 72 | + |
| 73 | +- Loading indicators during navigation |
| 74 | +- Pending states in the UI |
| 75 | +- Navigation state transitions |
| 76 | +- User experience during async operations |
| 77 | + |
| 78 | +## Learn More |
| 79 | + |
| 80 | +- [Router Documentation](../../packages/router) |
| 81 | +- [@remix-run/fetch-router Resources](https://www.npmjs.com/package/@remix-run/fetch-router) - Learn about resource routes |
| 82 | +- [@remix-run/dom](https://www.npmjs.com/package/@remix-run/dom) |
| 83 | + |
| 84 | +## License |
| 85 | + |
| 86 | +See the root repository for license information. |
0 commit comments