create-bluecopa-react-app 1.0.2 → 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 CHANGED
@@ -4,10 +4,11 @@ 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, React Router v6, Vite
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 with hooks
11
+ - 📡 **BlueCopa React Components**: Pre-configured @bluecopa/react package with hooks (includes TanStack Query integration)
11
12
  - 🎯 **Type Safety**: Full TypeScript support
12
13
  - 📱 **Responsive Design**: Tailwind CSS with mobile-first approach and BlueCopa design system
13
14
  - 🛠️ **Development Tools**: ESLint, TypeScript checking, and Vite fast build system
@@ -62,17 +63,31 @@ A foundational template that provides:
62
63
  "typescript": "^5.6.0"
63
64
 
64
65
  // UI and Styling
65
- "@radix-ui/*": "Latest versions"
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"
66
72
  "tailwindcss": "^3.4.17"
67
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"
68
78
 
69
79
  // Data Visualization
70
80
  "recharts": "^2.12.0"
71
81
 
82
+ // Microfrontend
83
+ "single-spa": "^6.0.3"
84
+ "single-spa-react": "^6.0.2"
85
+
72
86
  // Development and Build
73
- "vite": "^5.4.20"
87
+ "vite": "^7.1.5"
74
88
  "eslint": "^8.57.0"
75
- "@vitejs/plugin-react": "^4.3.0"
89
+ "@vitejs/plugin-react-swc": "^4.0.1"
90
+ "@originjs/vite-plugin-federation": "^1.4.1"
76
91
  ```
77
92
 
78
93
  ## Project Structure
@@ -93,15 +108,16 @@ my-bluecopa-app/
93
108
  │ │ ├── Home.tsx # Home page component
94
109
  │ │ └── Dashboard.tsx # Dashboard page component
95
110
  │ ├── providers/ # React context providers
96
- │ │ └── query-provider.tsx # TanStack Query provider
111
+ │ │ └── query-provider.tsx # TanStack Query provider via @bluecopa/react
97
112
  │ ├── types/ # TypeScript type definitions
98
113
  │ ├── App.tsx # Main app component with routing
99
114
  │ ├── main.tsx # Application entry point
115
+ │ ├── single-spa.tsx # Single-spa root component
100
116
  │ └── index.css # Global styles and Tailwind imports
101
117
  ├── public/ # Static assets
102
118
  ├── .env.example # Environment variables template
103
119
  ├── package.json # Dependencies and scripts
104
- ├── vite.config.ts # Vite configuration
120
+ ├── vite.config.ts # Vite configuration with module federation
105
121
  ├── tailwind.config.js # Tailwind CSS configuration
106
122
  ├── tsconfig.json # TypeScript configuration
107
123
  ├── postcss.config.js # PostCSS configuration
@@ -217,15 +233,19 @@ Required environment variables:
217
233
  VITE_BLUECOPA_API_TOKEN=your-bluecopa-api-token
218
234
  VITE_BLUECOPA_API_URL=https://develop.bluecopa.com/api/v1
219
235
  VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id
236
+ - **Vite Module Federation** - For microfrontend integration
220
237
  ```
221
238
 
222
239
  ## Available Scripts
223
240
 
224
241
  - `npm run dev` - Start Vite development server with hot reload
225
242
  - `npm run build` - Build for production (TypeScript + Vite optimization)
243
+ - `npm run start` - Start production build locally
226
244
  - `npm run preview` - Preview production build locally
227
245
  - `npm run lint` - Run ESLint for code quality
246
+ - `npm run lint:fix` - Fix linting issues
228
247
  - `npm run type-check` - Run TypeScript type checking without emitting files
248
+ - `npm run clean` - Clean build artifacts and dependencies
229
249
 
230
250
  ## Technologies Used
231
251
 
@@ -233,9 +253,9 @@ VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id
233
253
  - **React Router v6** - Declarative routing for React SPAs
234
254
  - **Vite** - Fast build tool and development server
235
255
  - **TypeScript** - Full type safety and developer experience
236
- - **@bluecopa/react** - BlueCopa-specific React components and hooks
237
- - **TanStack Query** - Powerful data synchronization for React
256
+ - **@bluecopa/react** - BlueCopa-specific React components and hooks (includes TanStack Query)
238
257
  - **Radix UI** - Unstyled, accessible UI primitives
258
+ - **Single-spa** - Microfrontend framework support
239
259
  - **Recharts** - Composable charting library for React
240
260
  - **Tailwind CSS** - Utility-first CSS framework with BlueCopa design system
241
261
  - **Lucide React** - Beautiful, customizable icons
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bluecopa-react-app",
3
- "version": "1.0.2",
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
+ }
@@ -12,7 +12,7 @@ This template is designed to work seamlessly with AI coding assistants for rapid
12
12
  - **Frontend**: React 18 + TypeScript + React Router v6
13
13
  - **Build Tool**: Vite (fast HMR and building)
14
14
  - **Styling**: TailwindCSS with BlueCopa design system
15
- - **UI Components**: Radix UI primitives
15
+ - **UI Components**: Radix UI primitives (add via shadcn-ui for pre-styled components)
16
16
  - **Data Fetching**: TanStack Query with @bluecopa/react hooks
17
17
  - **Charts**: Recharts for data visualization
18
18
  - **Icons**: Lucide React
@@ -20,13 +20,13 @@ This template is designed to work seamlessly with AI coding assistants for rapid
20
20
  ### Key Directories
21
21
  ```
22
22
  src/
23
- ├── components/ui/ # Reusable UI components (Button, Card, etc.)
24
- ├── components/ # Business logic components (Navbar, etc.)
25
- ├── hooks/ # Custom React hooks and API integration
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
26
  ├── pages/ # Route components (Home, Dashboard)
27
- ├── providers/ # React context providers
28
- ├── lib/ # Utility functions and helpers
29
- └── types/ # TypeScript type definitions
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
30
  ```
31
31
 
32
32
  ## 🔧 Development Patterns
@@ -38,8 +38,13 @@ When asked to create a new page:
38
38
  1. **Create the page component** in `src/pages/NewPage.tsx`:
39
39
  ```tsx
40
40
  import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
41
+ import { useUser } from '@bluecopa/react';
41
42
 
42
43
  export default function NewPage() {
44
+ const { data: userData, isLoading } = useUser();
45
+
46
+ if (isLoading) return <div>Loading...</div>;
47
+
43
48
  return (
44
49
  <div className="container mx-auto py-6">
45
50
  <Card>
@@ -48,6 +53,7 @@ export default function NewPage() {
48
53
  </CardHeader>
49
54
  <CardContent>
50
55
  {/* Page content */}
56
+ <p>Welcome, {userData?.name}!</p>
51
57
  </CardContent>
52
58
  </Card>
53
59
  </div>
@@ -63,8 +69,10 @@ import NewPage from '@/pages/NewPage';
63
69
  <Route path="/new-page" element={<NewPage />} />
64
70
  ```
65
71
 
66
- 3. **Update navigation** in `src/components/navbar.tsx`:
72
+ 3. **Update navigation** in `src/components/page/navbar.tsx` (import icon from lucide-react):
67
73
  ```tsx
74
+ import { Settings } from 'lucide-react';
75
+
68
76
  const navigation = [
69
77
  // ... existing routes
70
78
  { name: 'New Page', href: '/new-page', icon: Settings },
@@ -73,30 +81,38 @@ const navigation = [
73
81
 
74
82
  ### 2. Using BlueCopa API Hooks
75
83
 
76
- Always use the pre-configured hooks from `@/hooks/use-api.ts`:
84
+ Install @bluecopa/react if not present: `npm install @bluecopa/react`
85
+
86
+ Use the pre-configured hooks from `@bluecopa/react`:
77
87
 
78
88
  ```tsx
79
- import { useUserData, useMetricDataDemo, useDatasetDataDemo } from '@/hooks/use-api';
89
+ import { useUser, useMetric, useDataset } from '@bluecopa/react';
80
90
 
81
91
  function DataComponent() {
82
- const { data: userData, isLoading, error } = useUserData();
83
- const { data: metrics } = useMetricDataDemo();
92
+ const { data: userData, isLoading: userLoading, error: userError } = useUser();
93
+ const { data: metrics } = useMetric({ metricId: 'example' });
94
+ const { data: datasets } = useDataset({ datasetId: 'example' });
84
95
 
85
- if (isLoading) return <div>Loading...</div>;
86
- if (error) return <div>Error: {error.message}</div>;
96
+ if (userLoading) return <div>Loading...</div>;
97
+ if (userError) return <div>Error: {userError.message}</div>;
87
98
 
88
99
  return <div>Data: {JSON.stringify(userData)}</div>;
89
100
  }
90
101
  ```
91
102
 
103
+ For custom hooks, create in `src/hooks/` and wrap TanStack Query.
104
+
92
105
  ### 3. UI Component Patterns
93
106
 
107
+ Add shadcn-ui components if needed: `npx shadcn-ui@latest add card button tabs`
108
+
94
109
  Use the existing UI components from `src/components/ui/`:
95
110
 
96
111
  ```tsx
97
112
  import { Button } from '@/components/ui/button';
98
113
  import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
99
114
  import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
115
+ import { cn } from '@/lib/utils';
100
116
 
101
117
  // Example usage
102
118
  <Card>
@@ -104,7 +120,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
104
120
  <CardTitle>Dashboard</CardTitle>
105
121
  </CardHeader>
106
122
  <CardContent>
107
- <Tabs defaultValue="overview">
123
+ <Tabs defaultValue="overview" className={cn("w-full")}>
108
124
  <TabsList>
109
125
  <TabsTrigger value="overview">Overview</TabsTrigger>
110
126
  <TabsTrigger value="analytics">Analytics</TabsTrigger>
@@ -119,12 +135,20 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
119
135
 
120
136
  ### 4. Chart Integration
121
137
 
138
+ Install Recharts if not present: `npm install recharts`
139
+
122
140
  Use Recharts for data visualization:
123
141
 
124
142
  ```tsx
125
143
  import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
144
+ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
126
145
 
127
- function ChartComponent({ data }: { data: any[] }) {
146
+ interface ChartData {
147
+ name: string;
148
+ value: number;
149
+ }
150
+
151
+ function ChartComponent({ data }: { data: ChartData[] }) {
128
152
  return (
129
153
  <Card>
130
154
  <CardHeader>
@@ -177,27 +201,28 @@ function ChartComponent({ data }: { data: any[] }) {
177
201
  ## 🛠️ Common Tasks for Agents
178
202
 
179
203
  ### Adding a New Dashboard Card
180
- 1. Create component in appropriate location
181
- 2. Use Card component wrapper
182
- 3. Include loading and error states
183
- 4. Use BlueCopa hooks for data
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)
184
208
 
185
209
  ### Creating Forms
186
- 1. Use Radix UI form components
187
- 2. Add TypeScript types for form data
188
- 3. Include validation and error handling
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
189
213
  4. Follow BlueCopa styling patterns
190
214
 
191
215
  ### Adding Data Tables
192
- 1. Consider using AG Grid (@bluecopa/aggrid) for complex tables
216
+ 1. For complex tables, install and use AG Grid (@bluecopa/aggrid)
193
217
  2. For simple tables, use HTML table with Tailwind styling
194
218
  3. Include sorting, filtering, and pagination as needed
219
+ 4. Integrate with @bluecopa/react for data
195
220
 
196
221
  ### Implementing Search
197
- 1. Add search state management
198
- 2. Use debounced input for API calls
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)
199
224
  3. Show loading states during search
200
- 4. Handle empty states gracefully
225
+ 4. Handle empty states gracefully with conditional rendering
201
226
 
202
227
  ## 🚨 Important Notes for Agents
203
228
 
@@ -209,18 +234,20 @@ const apiUrl = import.meta.env.VITE_BLUECOPA_API_URL;
209
234
  ```
210
235
 
211
236
  ### Imports
212
- Use path aliases consistently:
237
+ Use path aliases consistently (configured in tsconfig.json):
213
238
  ```tsx
214
239
  import { Button } from '@/components/ui/button';
215
- import { useUserData } from '@/hooks/use-api';
240
+ import { useUser } from '@bluecopa/react';
216
241
  import { cn } from '@/lib/utils';
217
242
  ```
218
243
 
219
244
  ### TypeScript
220
245
  Always include proper TypeScript types:
221
246
  ```tsx
247
+ import { User } from '@/types/api';
248
+
222
249
  interface ComponentProps {
223
- data: UserData[];
250
+ data: User[];
224
251
  onSelect: (id: string) => void;
225
252
  }
226
253
 
@@ -241,10 +268,12 @@ if (!data) return <div className="p-4 text-gray-500">No data available</div>;
241
268
 
242
269
  - [React Router Documentation](https://reactrouter.com)
243
270
  - [TailwindCSS Documentation](https://tailwindcss.com)
244
- - [Radix UI Documentation](https://radix-ui.com)
271
+ - [Radix UI Documentation](https://www.radix-ui.com)
272
+ - [shadcn/ui Documentation](https://ui.shadcn.com)
245
273
  - [Recharts Documentation](https://recharts.org)
246
- - [TanStack Query Documentation](https://tanstack.com/query)
247
- - [BlueCopa React Package](https://github.com/bluecopa/blui/packages/react)
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)
248
277
 
249
278
  ## 🔄 Development Workflow
250
279
 
@@ -41,10 +41,10 @@ npx create-bluecopa-react-app my-dashboard
41
41
  1. **Clone or copy the template**:
42
42
  ```bash
43
43
  # If using as part of the blui monorepo
44
- cd packages/boilerplate/react/templates/react-router
44
+ cd packages/boilerplate/react/templates/latest
45
45
 
46
46
  # Or copy the template to your project location
47
- cp -r packages/boilerplate/react/templates/react-router my-bluecopa-app
47
+ cp -r packages/boilerplate/react/templates/latest my-bluecopa-app
48
48
  cd my-bluecopa-app
49
49
  ```
50
50
 
@@ -112,9 +112,11 @@ npx create-bluecopa-react-app my-dashboard
112
112
 
113
113
  ```
114
114
  src/
115
- ├── components/ # Reusable UI components
116
- │ ├── ui/ # Base UI components (buttons, cards, etc.)
117
- └── navbar.tsx # Navigation component
115
+ ├── components/ # Reusable components
116
+ │ ├── layout/ # Layout components (dashboard-header.tsx, dashboard-layout.tsx, sidebar.tsx)
117
+ ├── page/ # Page-specific components (dashboard.tsx, navbar.tsx)
118
+ │ ├── tables/ # Table components (data-grid.tsx)
119
+ │ └── ui/ # Base UI components (alert.tsx, avatar.tsx, badge.tsx, bluecopa-logo.tsx, button.tsx, card.tsx, dropdown-menu.tsx, input.tsx, label.tsx, select.tsx)
118
120
  ├── hooks/ # Custom React hooks
119
121
  │ └── use-api.ts # Bluecopa API hooks
120
122
  ├── lib/ # Utility functions
@@ -125,9 +127,12 @@ src/
125
127
  ├── providers/ # React context providers
126
128
  │ └── query-provider.tsx # TanStack Query provider
127
129
  ├── types/ # TypeScript type definitions
130
+ │ └── api.ts # API type definitions
128
131
  ├── App.tsx # Main app component with routing
132
+ ├── index.css # Global styles
129
133
  ├── main.tsx # Application entry point
130
- └── index.css # Global styles
134
+ ├── single-spa.tsx # Single-spa configuration
135
+ └── vite-env.d.ts # Vite environment types
131
136
  ```
132
137
 
133
138
  ## 🔧 Configuration
@@ -178,7 +183,7 @@ export default function App() {
178
183
  ```
179
184
 
180
185
  ### Adding Navigation Links
181
- Update the navigation in `src/components/navbar.tsx`:
186
+ Update the navigation in `src/components/page/navbar.tsx`:
182
187
 
183
188
  ```tsx
184
189
  const navigation = [