create-bluecopa-react-app 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -53
- package/bin/create-bluecopa-react-app.js +4 -4
- package/package.json +2 -2
- package/templates/latest/Agent.md +288 -0
- package/templates/latest/README.md +31 -9
- package/templates/latest/package-lock.json +282 -134
- package/templates/latest/package.json +3 -7
- package/templates/latest/preview/index.html +330 -0
- package/templates/latest/vite.config.ts +18 -31
package/README.md
CHANGED
|
@@ -4,13 +4,16 @@ A CLI tool to bootstrap modern React applications for BlueCopa with built-in UI
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- 🚀 **Modern React Stack**: React 18, TypeScript,
|
|
7
|
+
- 🚀 **Modern React Stack**: React 18, TypeScript, React Router v6, Vite 7
|
|
8
|
+
- 🌐 **Microfrontend Support**: Single-spa compatible with module federation
|
|
8
9
|
- 📊 **Data Visualization**: Recharts integration for charts and analytics
|
|
9
10
|
- 🎨 **UI Components**: Radix UI primitives with custom styling
|
|
10
|
-
- 📡 **BlueCopa React Components**: Pre-configured @bluecopa/react package
|
|
11
|
+
- 📡 **BlueCopa React Components**: Pre-configured @bluecopa/react package with hooks (includes TanStack Query integration)
|
|
11
12
|
- 🎯 **Type Safety**: Full TypeScript support
|
|
12
|
-
- 📱 **Responsive Design**: Tailwind CSS with mobile-first approach
|
|
13
|
-
- 🛠️ **Development Tools**: ESLint, TypeScript checking, and
|
|
13
|
+
- 📱 **Responsive Design**: Tailwind CSS with mobile-first approach and BlueCopa design system
|
|
14
|
+
- 🛠️ **Development Tools**: ESLint, TypeScript checking, and Vite fast build system
|
|
15
|
+
- ⚡ **Fast Development**: Hot module replacement with Vite
|
|
16
|
+
- 🔄 **Client-side Routing**: React Router v6 for SPA navigation
|
|
14
17
|
|
|
15
18
|
## Quick Start
|
|
16
19
|
|
|
@@ -36,17 +39,18 @@ npm run dev
|
|
|
36
39
|
|
|
37
40
|
## Template Included
|
|
38
41
|
|
|
39
|
-
### BlueCopa
|
|
42
|
+
### BlueCopa React Router Template
|
|
40
43
|
|
|
41
44
|
A foundational template that provides:
|
|
42
45
|
|
|
43
|
-
- **Modern
|
|
44
|
-
- **BlueCopa Components**: Pre-configured @bluecopa/react component library
|
|
46
|
+
- **Modern React Setup**: React 18 with TypeScript, React Router v6, and Vite
|
|
47
|
+
- **BlueCopa Components**: Pre-configured @bluecopa/react component library with hooks
|
|
45
48
|
- **UI Foundation**: Radix UI primitives with custom styling system
|
|
46
49
|
- **Data Visualization**: Recharts for charts and analytics
|
|
47
|
-
- **Styling System**: Tailwind CSS with BlueCopa design tokens
|
|
48
|
-
- **Development Setup**: ESLint, TypeScript configuration, and
|
|
50
|
+
- **Styling System**: Tailwind CSS with BlueCopa design tokens and navy theme
|
|
51
|
+
- **Development Setup**: ESLint, TypeScript configuration, and Vite optimization
|
|
49
52
|
- **Environment Configuration**: Ready-to-use environment variable setup
|
|
53
|
+
- **Client-side Routing**: React Router v6 for smooth SPA navigation
|
|
50
54
|
|
|
51
55
|
#### Key Dependencies Included
|
|
52
56
|
|
|
@@ -54,20 +58,36 @@ A foundational template that provides:
|
|
|
54
58
|
// Core BlueCopa and React ecosystem
|
|
55
59
|
"@bluecopa/react": "^0.1.3"
|
|
56
60
|
"react": "^18.3.0"
|
|
57
|
-
"
|
|
61
|
+
"react-dom": "^18.3.0"
|
|
62
|
+
"react-router-dom": "^6.26.0"
|
|
58
63
|
"typescript": "^5.6.0"
|
|
59
64
|
|
|
60
65
|
// UI and Styling
|
|
61
|
-
"@radix-ui
|
|
62
|
-
"
|
|
66
|
+
"@radix-ui/react-avatar": "^1.1.0"
|
|
67
|
+
"@radix-ui/react-dropdown-menu": "^2.1.0"
|
|
68
|
+
"@radix-ui/react-select": "^2.1.0"
|
|
69
|
+
"@radix-ui/react-separator": "^1.1.0"
|
|
70
|
+
"@radix-ui/react-slot": "^1.1.0"
|
|
71
|
+
"@radix-ui/react-tabs": "^1.1.0"
|
|
72
|
+
"tailwindcss": "^3.4.17"
|
|
63
73
|
"lucide-react": "^0.445.0"
|
|
74
|
+
"class-variance-authority": "^0.7.0"
|
|
75
|
+
"clsx": "^2.1.0"
|
|
76
|
+
"tailwind-merge": "^2.5.0"
|
|
77
|
+
"tailwindcss-animate": "^1.0.7"
|
|
64
78
|
|
|
65
79
|
// Data Visualization
|
|
66
80
|
"recharts": "^2.12.0"
|
|
67
81
|
|
|
82
|
+
// Microfrontend
|
|
83
|
+
"single-spa": "^6.0.3"
|
|
84
|
+
"single-spa-react": "^6.0.2"
|
|
85
|
+
|
|
68
86
|
// Development and Build
|
|
87
|
+
"vite": "^7.1.5"
|
|
69
88
|
"eslint": "^8.57.0"
|
|
70
|
-
"
|
|
89
|
+
"@vitejs/plugin-react-swc": "^4.0.1"
|
|
90
|
+
"@originjs/vite-plugin-federation": "^1.4.1"
|
|
71
91
|
```
|
|
72
92
|
|
|
73
93
|
## Project Structure
|
|
@@ -77,47 +97,78 @@ The generated project follows a clean, scalable structure:
|
|
|
77
97
|
```text
|
|
78
98
|
my-bluecopa-app/
|
|
79
99
|
├── src/
|
|
80
|
-
│ ├──
|
|
81
|
-
│ │ ├──
|
|
82
|
-
│ │
|
|
83
|
-
│
|
|
84
|
-
│
|
|
85
|
-
│
|
|
86
|
-
│ │
|
|
87
|
-
│
|
|
88
|
-
│ ├──
|
|
89
|
-
│ │
|
|
90
|
-
│
|
|
91
|
-
│ └──
|
|
92
|
-
├──
|
|
93
|
-
├── .
|
|
94
|
-
├── .
|
|
95
|
-
├──
|
|
96
|
-
|
|
97
|
-
├──
|
|
98
|
-
├──
|
|
99
|
-
├──
|
|
100
|
-
|
|
100
|
+
│ ├── components/ # Reusable UI components
|
|
101
|
+
│ │ ├── ui/ # Base UI components (buttons, cards, etc.)
|
|
102
|
+
│ │ └── navbar.tsx # Navigation component
|
|
103
|
+
│ ├── hooks/ # Custom React hooks
|
|
104
|
+
│ │ └── use-api.ts # Bluecopa API hooks
|
|
105
|
+
│ ├── lib/ # Utilities and helpers
|
|
106
|
+
│ │ └── utils.ts # Helper functions and utilities
|
|
107
|
+
│ ├── pages/ # Route components
|
|
108
|
+
│ │ ├── Home.tsx # Home page component
|
|
109
|
+
│ │ └── Dashboard.tsx # Dashboard page component
|
|
110
|
+
│ ├── providers/ # React context providers
|
|
111
|
+
│ │ └── query-provider.tsx # TanStack Query provider via @bluecopa/react
|
|
112
|
+
│ ├── types/ # TypeScript type definitions
|
|
113
|
+
│ ├── App.tsx # Main app component with routing
|
|
114
|
+
│ ├── main.tsx # Application entry point
|
|
115
|
+
│ ├── single-spa.tsx # Single-spa root component
|
|
116
|
+
│ └── index.css # Global styles and Tailwind imports
|
|
117
|
+
├── public/ # Static assets
|
|
118
|
+
├── .env.example # Environment variables template
|
|
119
|
+
├── package.json # Dependencies and scripts
|
|
120
|
+
├── vite.config.ts # Vite configuration with module federation
|
|
121
|
+
├── tailwind.config.js # Tailwind CSS configuration
|
|
122
|
+
├── tsconfig.json # TypeScript configuration
|
|
123
|
+
├── postcss.config.js # PostCSS configuration
|
|
124
|
+
└── README.md # Project documentation
|
|
101
125
|
```
|
|
102
126
|
|
|
103
127
|
## Getting Started with Development
|
|
104
128
|
|
|
105
|
-
### Adding BlueCopa Components
|
|
129
|
+
### Adding BlueCopa Components and Hooks
|
|
106
130
|
|
|
107
|
-
The template includes @bluecopa/react components. Start building by importing and using them:
|
|
131
|
+
The template includes @bluecopa/react components and hooks. Start building by importing and using them:
|
|
108
132
|
|
|
109
133
|
```typescript
|
|
110
|
-
import {
|
|
134
|
+
import { useUserData, useMetricDataDemo, useDatasetDataDemo } from '@/hooks/use-api';
|
|
111
135
|
|
|
112
136
|
function MyComponent() {
|
|
137
|
+
const { data: userData, isLoading, error } = useUserData();
|
|
138
|
+
const { data: metrics } = useMetricDataDemo();
|
|
139
|
+
|
|
140
|
+
if (isLoading) return <div>Loading...</div>;
|
|
141
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
142
|
+
|
|
113
143
|
return (
|
|
114
144
|
<div>
|
|
115
|
-
<
|
|
145
|
+
<h1>Welcome, {userData?.user?.firstName}!</h1>
|
|
116
146
|
</div>
|
|
117
147
|
);
|
|
118
148
|
}
|
|
119
149
|
```
|
|
120
150
|
|
|
151
|
+
### Adding Routes
|
|
152
|
+
|
|
153
|
+
Add new routes in `src/App.tsx`:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { Routes, Route } from 'react-router-dom';
|
|
157
|
+
import NewPage from '@/pages/NewPage';
|
|
158
|
+
|
|
159
|
+
export default function App() {
|
|
160
|
+
return (
|
|
161
|
+
<QueryProvider>
|
|
162
|
+
<Routes>
|
|
163
|
+
<Route path="/" element={<Home />} />
|
|
164
|
+
<Route path="/dashboard" element={<Dashboard />} />
|
|
165
|
+
<Route path="/new-page" element={<NewPage />} />
|
|
166
|
+
</Routes>
|
|
167
|
+
</QueryProvider>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
121
172
|
### Adding UI Components
|
|
122
173
|
|
|
123
174
|
Use the included Radix UI components with Tailwind styling:
|
|
@@ -168,36 +219,76 @@ function ChartComponent() {
|
|
|
168
219
|
}
|
|
169
220
|
```
|
|
170
221
|
|
|
171
|
-
###
|
|
222
|
+
### Environment Configuration
|
|
172
223
|
|
|
173
|
-
|
|
174
|
-
- Update CSS variables in `src/app/globals.css` for theme customization
|
|
175
|
-
- All components support consistent styling through Tailwind utilities
|
|
176
|
-
- Use the `cn()` utility function for conditional class names
|
|
224
|
+
Create a `.env.local` file from the example:
|
|
177
225
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
226
|
+
```bash
|
|
227
|
+
cp .env.example .env.local
|
|
228
|
+
# Edit .env.local with your Bluecopa credentials from dashboard → Settings → API Tokens
|
|
229
|
+
```
|
|
181
230
|
|
|
231
|
+
Required environment variables:
|
|
182
232
|
```bash
|
|
183
|
-
|
|
233
|
+
VITE_BLUECOPA_API_TOKEN=your-bluecopa-api-token
|
|
234
|
+
VITE_BLUECOPA_API_URL=https://develop.bluecopa.com/api/v1
|
|
235
|
+
VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id
|
|
236
|
+
- **Vite Module Federation** - For microfrontend integration
|
|
184
237
|
```
|
|
185
238
|
|
|
186
239
|
## Available Scripts
|
|
187
240
|
|
|
188
|
-
- `npm run dev` - Start
|
|
189
|
-
- `npm run build` - Build for production (
|
|
190
|
-
- `npm run start` - Start production
|
|
241
|
+
- `npm run dev` - Start Vite development server with hot reload
|
|
242
|
+
- `npm run build` - Build for production (TypeScript + Vite optimization)
|
|
243
|
+
- `npm run start` - Start production build locally
|
|
244
|
+
- `npm run preview` - Preview production build locally
|
|
191
245
|
- `npm run lint` - Run ESLint for code quality
|
|
246
|
+
- `npm run lint:fix` - Fix linting issues
|
|
192
247
|
- `npm run type-check` - Run TypeScript type checking without emitting files
|
|
248
|
+
- `npm run clean` - Clean build artifacts and dependencies
|
|
193
249
|
|
|
194
250
|
## Technologies Used
|
|
195
251
|
|
|
196
252
|
- **React 18** - Modern React with concurrent features
|
|
197
|
-
- **
|
|
253
|
+
- **React Router v6** - Declarative routing for React SPAs
|
|
254
|
+
- **Vite** - Fast build tool and development server
|
|
198
255
|
- **TypeScript** - Full type safety and developer experience
|
|
199
|
-
- **@bluecopa/react** - BlueCopa-specific React components
|
|
256
|
+
- **@bluecopa/react** - BlueCopa-specific React components and hooks (includes TanStack Query)
|
|
200
257
|
- **Radix UI** - Unstyled, accessible UI primitives
|
|
258
|
+
- **Single-spa** - Microfrontend framework support
|
|
201
259
|
- **Recharts** - Composable charting library for React
|
|
202
|
-
- **Tailwind CSS** - Utility-first CSS framework
|
|
260
|
+
- **Tailwind CSS** - Utility-first CSS framework with BlueCopa design system
|
|
203
261
|
- **Lucide React** - Beautiful, customizable icons
|
|
262
|
+
|
|
263
|
+
## CLI Usage
|
|
264
|
+
|
|
265
|
+
The CLI will prompt you for project details and automatically:
|
|
266
|
+
|
|
267
|
+
- Create the project structure
|
|
268
|
+
- Copy template files
|
|
269
|
+
- Update package.json with your project name
|
|
270
|
+
- Install dependencies (unless `--skip-install` is used)
|
|
271
|
+
- Provide next steps for development
|
|
272
|
+
|
|
273
|
+
Example output:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
✔ Creating project structure...
|
|
277
|
+
✔ Dependencies installed
|
|
278
|
+
✔ Success! Created my-dashboard at /path/to/my-dashboard
|
|
279
|
+
|
|
280
|
+
Inside that directory, you can run several commands:
|
|
281
|
+
|
|
282
|
+
npm run dev
|
|
283
|
+
Starts the development server.
|
|
284
|
+
|
|
285
|
+
npm run build
|
|
286
|
+
Bundles the app into static files for production.
|
|
287
|
+
|
|
288
|
+
We suggest that you begin by typing:
|
|
289
|
+
|
|
290
|
+
cd my-dashboard
|
|
291
|
+
npm run dev
|
|
292
|
+
|
|
293
|
+
Happy coding with Bluecopa! 🚀
|
|
294
|
+
```
|
|
@@ -100,19 +100,19 @@ async function createApp(projectName, options) {
|
|
|
100
100
|
console.log();
|
|
101
101
|
console.log('Inside that directory, you can run several commands:');
|
|
102
102
|
console.log();
|
|
103
|
-
console.log(chalk.cyan(' npm
|
|
103
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
104
104
|
console.log(' Starts the development server.');
|
|
105
105
|
console.log();
|
|
106
106
|
console.log(chalk.cyan(' npm run build'));
|
|
107
107
|
console.log(' Bundles the app into static files for production.');
|
|
108
108
|
console.log();
|
|
109
|
-
console.log(chalk.cyan(' npm
|
|
110
|
-
console.log('
|
|
109
|
+
console.log(chalk.cyan(' npm run preview'));
|
|
110
|
+
console.log(' Preview the production build locally.');
|
|
111
111
|
console.log();
|
|
112
112
|
console.log('We suggest that you begin by typing:');
|
|
113
113
|
console.log();
|
|
114
114
|
console.log(chalk.cyan(' cd'), appName);
|
|
115
|
-
console.log(chalk.cyan(' npm
|
|
115
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
116
116
|
console.log();
|
|
117
117
|
console.log('Happy coding with Bluecopa! 🚀');
|
|
118
118
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-bluecopa-react-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI tool to create bluecopa React applications",
|
|
5
5
|
"main": "./bin/create-bluecopa-react-app.js",
|
|
6
6
|
"bin": {
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=18.0.0"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# Agent Development Guide - BlueCopa React Template
|
|
2
|
+
|
|
3
|
+
This document provides guidance for AI agents working with BlueCopa React applications built from this template.
|
|
4
|
+
|
|
5
|
+
## 🤖 Agent Overview
|
|
6
|
+
|
|
7
|
+
This template is designed to work seamlessly with AI coding assistants for rapid development of BlueCopa dashboard applications. The project structure and patterns are optimized for AI-assisted development.
|
|
8
|
+
|
|
9
|
+
## 📋 Project Context
|
|
10
|
+
|
|
11
|
+
### Technology Stack
|
|
12
|
+
- **Frontend**: React 18 + TypeScript + React Router v6
|
|
13
|
+
- **Build Tool**: Vite (fast HMR and building)
|
|
14
|
+
- **Styling**: TailwindCSS with BlueCopa design system
|
|
15
|
+
- **UI Components**: Radix UI primitives (add via shadcn-ui for pre-styled components)
|
|
16
|
+
- **Data Fetching**: TanStack Query with @bluecopa/react hooks
|
|
17
|
+
- **Charts**: Recharts for data visualization
|
|
18
|
+
- **Icons**: Lucide React
|
|
19
|
+
|
|
20
|
+
### Key Directories
|
|
21
|
+
```
|
|
22
|
+
src/
|
|
23
|
+
├── components/ui/ # Reusable UI components (e.g., Button, Card via shadcn-ui; bluecopa-logo)
|
|
24
|
+
├── components/ # Business logic components (Navbar, DashboardLayout, etc.)
|
|
25
|
+
├── hooks/ # Custom React hooks (if needed; primarily use @bluecopa/react)
|
|
26
|
+
├── pages/ # Route components (Home, Dashboard)
|
|
27
|
+
├── providers/ # React context providers (e.g., QueryProvider)
|
|
28
|
+
├── lib/ # Utility functions and helpers (e.g., utils.ts with cn)
|
|
29
|
+
└── types/ # TypeScript type definitions (e.g., api.ts)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🔧 Development Patterns
|
|
33
|
+
|
|
34
|
+
### 1. Adding New Pages/Routes
|
|
35
|
+
|
|
36
|
+
When asked to create a new page:
|
|
37
|
+
|
|
38
|
+
1. **Create the page component** in `src/pages/NewPage.tsx`:
|
|
39
|
+
```tsx
|
|
40
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
41
|
+
import { useUser } from '@bluecopa/react';
|
|
42
|
+
|
|
43
|
+
export default function NewPage() {
|
|
44
|
+
const { data: userData, isLoading } = useUser();
|
|
45
|
+
|
|
46
|
+
if (isLoading) return <div>Loading...</div>;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className="container mx-auto py-6">
|
|
50
|
+
<Card>
|
|
51
|
+
<CardHeader>
|
|
52
|
+
<CardTitle>New Page</CardTitle>
|
|
53
|
+
</CardHeader>
|
|
54
|
+
<CardContent>
|
|
55
|
+
{/* Page content */}
|
|
56
|
+
<p>Welcome, {userData?.name}!</p>
|
|
57
|
+
</CardContent>
|
|
58
|
+
</Card>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. **Add the route** in `src/App.tsx`:
|
|
65
|
+
```tsx
|
|
66
|
+
import NewPage from '@/pages/NewPage';
|
|
67
|
+
|
|
68
|
+
// Add to Routes
|
|
69
|
+
<Route path="/new-page" element={<NewPage />} />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
3. **Update navigation** in `src/components/page/navbar.tsx` (import icon from lucide-react):
|
|
73
|
+
```tsx
|
|
74
|
+
import { Settings } from 'lucide-react';
|
|
75
|
+
|
|
76
|
+
const navigation = [
|
|
77
|
+
// ... existing routes
|
|
78
|
+
{ name: 'New Page', href: '/new-page', icon: Settings },
|
|
79
|
+
];
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2. Using BlueCopa API Hooks
|
|
83
|
+
|
|
84
|
+
Install @bluecopa/react if not present: `npm install @bluecopa/react`
|
|
85
|
+
|
|
86
|
+
Use the pre-configured hooks from `@bluecopa/react`:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { useUser, useMetric, useDataset } from '@bluecopa/react';
|
|
90
|
+
|
|
91
|
+
function DataComponent() {
|
|
92
|
+
const { data: userData, isLoading: userLoading, error: userError } = useUser();
|
|
93
|
+
const { data: metrics } = useMetric({ metricId: 'example' });
|
|
94
|
+
const { data: datasets } = useDataset({ datasetId: 'example' });
|
|
95
|
+
|
|
96
|
+
if (userLoading) return <div>Loading...</div>;
|
|
97
|
+
if (userError) return <div>Error: {userError.message}</div>;
|
|
98
|
+
|
|
99
|
+
return <div>Data: {JSON.stringify(userData)}</div>;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
For custom hooks, create in `src/hooks/` and wrap TanStack Query.
|
|
104
|
+
|
|
105
|
+
### 3. UI Component Patterns
|
|
106
|
+
|
|
107
|
+
Add shadcn-ui components if needed: `npx shadcn-ui@latest add card button tabs`
|
|
108
|
+
|
|
109
|
+
Use the existing UI components from `src/components/ui/`:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { Button } from '@/components/ui/button';
|
|
113
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
114
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
115
|
+
import { cn } from '@/lib/utils';
|
|
116
|
+
|
|
117
|
+
// Example usage
|
|
118
|
+
<Card>
|
|
119
|
+
<CardHeader>
|
|
120
|
+
<CardTitle>Dashboard</CardTitle>
|
|
121
|
+
</CardHeader>
|
|
122
|
+
<CardContent>
|
|
123
|
+
<Tabs defaultValue="overview" className={cn("w-full")}>
|
|
124
|
+
<TabsList>
|
|
125
|
+
<TabsTrigger value="overview">Overview</TabsTrigger>
|
|
126
|
+
<TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
127
|
+
</TabsList>
|
|
128
|
+
<TabsContent value="overview">
|
|
129
|
+
<Button>Action</Button>
|
|
130
|
+
</TabsContent>
|
|
131
|
+
</Tabs>
|
|
132
|
+
</CardContent>
|
|
133
|
+
</Card>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 4. Chart Integration
|
|
137
|
+
|
|
138
|
+
Install Recharts if not present: `npm install recharts`
|
|
139
|
+
|
|
140
|
+
Use Recharts for data visualization:
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
144
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
145
|
+
|
|
146
|
+
interface ChartData {
|
|
147
|
+
name: string;
|
|
148
|
+
value: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function ChartComponent({ data }: { data: ChartData[] }) {
|
|
152
|
+
return (
|
|
153
|
+
<Card>
|
|
154
|
+
<CardHeader>
|
|
155
|
+
<CardTitle>Analytics</CardTitle>
|
|
156
|
+
</CardHeader>
|
|
157
|
+
<CardContent>
|
|
158
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
159
|
+
<LineChart data={data}>
|
|
160
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
161
|
+
<XAxis dataKey="name" />
|
|
162
|
+
<YAxis />
|
|
163
|
+
<Tooltip />
|
|
164
|
+
<Line type="monotone" dataKey="value" stroke="#041e42" />
|
|
165
|
+
</LineChart>
|
|
166
|
+
</ResponsiveContainer>
|
|
167
|
+
</CardContent>
|
|
168
|
+
</Card>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 🎨 Design System Guidelines
|
|
174
|
+
|
|
175
|
+
### Colors
|
|
176
|
+
- **Primary**: Navy blue (`#041e42`) - BlueCopa brand color
|
|
177
|
+
- **Background**: Light gray (`bg-gray-50`)
|
|
178
|
+
- **Cards**: White with subtle shadow (`bg-white shadow-sm`)
|
|
179
|
+
- **Text**: Gray scale (`text-gray-900`, `text-gray-600`)
|
|
180
|
+
|
|
181
|
+
### Layout Patterns
|
|
182
|
+
- **Container**: `container mx-auto py-6` for page layouts
|
|
183
|
+
- **Grid**: `grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6` for responsive grids
|
|
184
|
+
- **Spacing**: Use Tailwind spacing scale (`p-4`, `mb-6`, etc.)
|
|
185
|
+
|
|
186
|
+
### Component Structure
|
|
187
|
+
```tsx
|
|
188
|
+
// Standard page layout
|
|
189
|
+
<div className="container mx-auto py-6">
|
|
190
|
+
<div className="mb-6">
|
|
191
|
+
<h1 className="text-2xl font-bold text-gray-900">Page Title</h1>
|
|
192
|
+
<p className="text-gray-600">Page description</p>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
196
|
+
{/* Cards or components */}
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## 🛠️ Common Tasks for Agents
|
|
202
|
+
|
|
203
|
+
### Adding a New Dashboard Card
|
|
204
|
+
1. Create component in `src/components/` (e.g., NewCard.tsx)
|
|
205
|
+
2. Use Card component wrapper from ui/
|
|
206
|
+
3. Include loading and error states with TanStack Query
|
|
207
|
+
4. Use @bluecopa/react hooks for data (e.g., useMetric)
|
|
208
|
+
|
|
209
|
+
### Creating Forms
|
|
210
|
+
1. Use Radix UI form components (add via shadcn-ui: `npx shadcn-ui@latest add form`)
|
|
211
|
+
2. Add TypeScript types for form data in `src/types/`
|
|
212
|
+
3. Include validation with Zod and error handling
|
|
213
|
+
4. Follow BlueCopa styling patterns
|
|
214
|
+
|
|
215
|
+
### Adding Data Tables
|
|
216
|
+
1. For complex tables, install and use AG Grid (@bluecopa/aggrid)
|
|
217
|
+
2. For simple tables, use HTML table with Tailwind styling
|
|
218
|
+
3. Include sorting, filtering, and pagination as needed
|
|
219
|
+
4. Integrate with @bluecopa/react for data
|
|
220
|
+
|
|
221
|
+
### Implementing Search
|
|
222
|
+
1. Add search state management with React state or form libraries
|
|
223
|
+
2. Use debounced input for API calls (e.g., via useMetric with query params)
|
|
224
|
+
3. Show loading states during search
|
|
225
|
+
4. Handle empty states gracefully with conditional rendering
|
|
226
|
+
|
|
227
|
+
## 🚨 Important Notes for Agents
|
|
228
|
+
|
|
229
|
+
### Environment Variables
|
|
230
|
+
Always reference environment variables correctly for Vite:
|
|
231
|
+
```tsx
|
|
232
|
+
const apiToken = import.meta.env.VITE_BLUECOPA_API_TOKEN;
|
|
233
|
+
const apiUrl = import.meta.env.VITE_BLUECOPA_API_URL;
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Imports
|
|
237
|
+
Use path aliases consistently (configured in tsconfig.json):
|
|
238
|
+
```tsx
|
|
239
|
+
import { Button } from '@/components/ui/button';
|
|
240
|
+
import { useUser } from '@bluecopa/react';
|
|
241
|
+
import { cn } from '@/lib/utils';
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### TypeScript
|
|
245
|
+
Always include proper TypeScript types:
|
|
246
|
+
```tsx
|
|
247
|
+
import { User } from '@/types/api';
|
|
248
|
+
|
|
249
|
+
interface ComponentProps {
|
|
250
|
+
data: User[];
|
|
251
|
+
onSelect: (id: string) => void;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function Component({ data, onSelect }: ComponentProps) {
|
|
255
|
+
// Component implementation
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Error Handling
|
|
260
|
+
Include proper error boundaries and loading states:
|
|
261
|
+
```tsx
|
|
262
|
+
if (isLoading) return <div className="p-4">Loading...</div>;
|
|
263
|
+
if (error) return <div className="p-4 text-red-600">Error: {error.message}</div>;
|
|
264
|
+
if (!data) return <div className="p-4 text-gray-500">No data available</div>;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## 📚 Reference Links
|
|
268
|
+
|
|
269
|
+
- [React Router Documentation](https://reactrouter.com)
|
|
270
|
+
- [TailwindCSS Documentation](https://tailwindcss.com)
|
|
271
|
+
- [Radix UI Documentation](https://www.radix-ui.com)
|
|
272
|
+
- [shadcn/ui Documentation](https://ui.shadcn.com)
|
|
273
|
+
- [Recharts Documentation](https://recharts.org)
|
|
274
|
+
- [TanStack Query Documentation](https://tanstack.com/query/latest)
|
|
275
|
+
- [Lucide React Icons](https://lucide.dev)
|
|
276
|
+
- [BlueCopa React Package](https://www.npmjs.com/package/@bluecopa/react)
|
|
277
|
+
|
|
278
|
+
## 🔄 Development Workflow
|
|
279
|
+
|
|
280
|
+
When working on this project:
|
|
281
|
+
|
|
282
|
+
1. **Start development server**: `npm run dev`
|
|
283
|
+
2. **Type checking**: `npm run type-check`
|
|
284
|
+
3. **Linting**: `npm run lint`
|
|
285
|
+
4. **Building**: `npm run build`
|
|
286
|
+
5. **Preview build**: `npm run preview`
|
|
287
|
+
|
|
288
|
+
The development server supports hot module replacement, so changes will be reflected immediately in the browser.
|