@machinemetrics/mm-react-components 0.2.3-0 → 0.2.3-10
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 +119 -33
- package/agent-docs/agent-documentation-reference.md +247 -0
- package/agent-docs/ai-agent-guide.md +554 -0
- package/agent-docs/ai-agent-init-guide.md +461 -0
- package/agent-docs/chakra-migration-readme.md +265 -0
- package/agent-docs/chakra-migration-troubleshooting.md +649 -0
- package/agent-docs/component-mapping-reference.md +466 -0
- package/agent-docs/init-readme.md +283 -0
- package/agent-docs/init-troubleshooting.md +550 -0
- package/agent-docs/setup-reference.md +365 -0
- package/dist/App.d.ts.map +1 -1
- package/dist/README.md +332 -0
- package/dist/components/ui/alert-dialog.d.ts +15 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/avatar.d.ts +7 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +12 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/card.d.ts +10 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/chart.d.ts +41 -0
- package/dist/components/ui/chart.d.ts.map +1 -0
- package/dist/components/ui/form.d.ts +25 -0
- package/dist/components/ui/form.d.ts.map +1 -0
- package/dist/components/ui/progress.d.ts +1 -0
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/textarea.d.ts +4 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/docs/GETTING_STARTED.md +293 -0
- package/dist/docs/TAILWIND_SETUP.md +8 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/mm-react-components.css +1 -0
- package/dist/main.d.ts +0 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/mm-react-components.es.js +11015 -926
- package/dist/mm-react-components.es.js.map +1 -1
- package/dist/mm-react-components.umd.js +27 -9
- package/dist/mm-react-components.umd.js.map +1 -1
- package/dist/preview/AlertDialogPreview.d.ts +2 -0
- package/dist/preview/AlertDialogPreview.d.ts.map +1 -0
- package/dist/preview/AlertPreview.d.ts +2 -0
- package/dist/preview/AlertPreview.d.ts.map +1 -0
- package/dist/preview/AvatarPreview.d.ts +2 -0
- package/dist/preview/AvatarPreview.d.ts.map +1 -0
- package/dist/preview/BreadcrumbPreview.d.ts +2 -0
- package/dist/preview/BreadcrumbPreview.d.ts.map +1 -0
- package/dist/preview/CardPreview.d.ts +2 -0
- package/dist/preview/CardPreview.d.ts.map +1 -0
- package/dist/preview/ChartPreview.d.ts +2 -0
- package/dist/preview/ChartPreview.d.ts.map +1 -0
- package/dist/preview/CheckboxPreview.d.ts.map +1 -1
- package/dist/preview/DataTablePreview.d.ts.map +1 -1
- package/dist/preview/FormPreview.d.ts +2 -0
- package/dist/preview/FormPreview.d.ts.map +1 -0
- package/dist/preview/InputPreview.d.ts.map +1 -1
- package/dist/preview/LabelPreview.d.ts.map +1 -1
- package/dist/preview/RadioGroupPreview.d.ts.map +1 -1
- package/dist/preview/SeparatorPreview.d.ts +2 -0
- package/dist/preview/SeparatorPreview.d.ts.map +1 -0
- package/dist/preview/SonnerPreview.d.ts +2 -0
- package/dist/preview/SonnerPreview.d.ts.map +1 -0
- package/dist/preview/TabsPreview.d.ts.map +1 -1
- package/dist/preview/TextareaPreview.d.ts +2 -0
- package/dist/preview/TextareaPreview.d.ts.map +1 -0
- package/dist/preview/data-table/data-table-preview_column-content.d.ts +1 -1
- package/dist/preview/data-table/data-table-preview_column-content.d.ts.map +1 -1
- package/dist/preview/page-header/PageHeaderPreview.d.ts.map +1 -1
- package/dist/scripts/chakra-to-shadcn-migrator/chakra-to-shadcn.config.json +512 -0
- package/dist/scripts/chakra-to-shadcn-migrator/lib/args.js +63 -0
- package/dist/scripts/chakra-to-shadcn-migrator/lib/colors.js +14 -0
- package/dist/scripts/chakra-to-shadcn-migrator/lib/config.js +15 -0
- package/dist/scripts/chakra-to-shadcn-migrator/lib/deps.js +125 -0
- package/dist/scripts/chakra-to-shadcn-migrator/lib/file-io.js +44 -0
- package/dist/scripts/chakra-to-shadcn-migrator/lib/render.js +89 -0
- package/dist/scripts/chakra-to-shadcn-migrator/lib/transform.js +550 -0
- package/dist/scripts/chakra-to-shadcn-migrator/package.json +11 -0
- package/dist/scripts/init.cjs +207 -0
- package/dist/tailwind.base.config.js +88 -0
- package/dist/themes/carbide.css +187 -32
- package/docs/TAILWIND_SETUP.md +8 -1
- package/package.json +59 -9
- package/src/index.css +99 -498
- package/dist/index.css +0 -536
- package/dist/tailwind.config.export.js +0 -153
- package/scripts/README.md +0 -171
- package/scripts/chakra-to-shadcn-migrator/README.md +0 -107
- package/src/themes/carbide.css +0 -1257
- package/tailwind.config.export.js +0 -153
- /package/{scripts → dist/scripts}/chakra-to-shadcn-migrator/bin/chakra-to-shadcn.js +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
# AI Agent Guide: MachineMetrics React Components Initialization
|
|
2
|
+
|
|
3
|
+
## 🚨 CRITICAL FOR AI AGENTS
|
|
4
|
+
|
|
5
|
+
**The library uses ZERO-CONFIG setup** - no build tools required.
|
|
6
|
+
|
|
7
|
+
- ✅ Use `/styles` import (pre-compiled CSS)
|
|
8
|
+
- ✅ No Tailwind/PostCSS needed
|
|
9
|
+
- ✅ 2 simple steps: install + CSS import
|
|
10
|
+
- ✅ Works immediately
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
This guide provides AI agents with comprehensive instructions for setting up the MachineMetrics React Components library. The library uses a **ZERO-CONFIG** approach - no build tools, no configuration files, just install and use.
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### 1. Automated Initialization (Recommended)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Run the init script via npx
|
|
22
|
+
npx @machinemetrics/mm-react-components init
|
|
23
|
+
|
|
24
|
+
# This installs the library and sets up the CSS import
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. Manual Setup (If Script Fails)
|
|
28
|
+
|
|
29
|
+
If the automated script fails, follow the manual setup guide below.
|
|
30
|
+
|
|
31
|
+
## What the Init Script Does
|
|
32
|
+
|
|
33
|
+
The init script performs minimal automated setup:
|
|
34
|
+
|
|
35
|
+
1. **Installs the component library** - `@machinemetrics/mm-react-components`
|
|
36
|
+
2. **Creates/updates CSS import** - Adds `/styles` import with pre-compiled CSS
|
|
37
|
+
3. **Done!** - No build tools, no configuration files needed
|
|
38
|
+
|
|
39
|
+
### What's Included
|
|
40
|
+
|
|
41
|
+
The `/styles` import provides everything you need:
|
|
42
|
+
|
|
43
|
+
- ✅ All Tailwind utilities (pre-compiled)
|
|
44
|
+
- ✅ Carbide industrial theme
|
|
45
|
+
- ✅ Dark mode support
|
|
46
|
+
- ✅ All component styles (focus, hover, etc.)
|
|
47
|
+
- ✅ Google Fonts
|
|
48
|
+
- ✅ 118 KB CSS (18 KB gzipped)
|
|
49
|
+
|
|
50
|
+
## Dependencies
|
|
51
|
+
|
|
52
|
+
### Required
|
|
53
|
+
|
|
54
|
+
- `@machinemetrics/mm-react-components` - Component library
|
|
55
|
+
- `react` (^19.1.1) - React library
|
|
56
|
+
- `react-dom` (^19.1.1) - React DOM renderer
|
|
57
|
+
|
|
58
|
+
**That's it!** No build tools required.
|
|
59
|
+
|
|
60
|
+
## Manual Setup
|
|
61
|
+
|
|
62
|
+
### Step 1: Install the Library
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Install the component library
|
|
66
|
+
npm install @machinemetrics/mm-react-components
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Step 2: Add CSS Import
|
|
70
|
+
|
|
71
|
+
Create or update your main CSS file (usually `src/index.css` or `src/main.css`):
|
|
72
|
+
|
|
73
|
+
```css
|
|
74
|
+
/* MM React Components - Pre-compiled CSS */
|
|
75
|
+
@import '@machinemetrics/mm-react-components/styles';
|
|
76
|
+
|
|
77
|
+
/* Your existing CSS here */
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**That's it for setup!**
|
|
81
|
+
|
|
82
|
+
### Step 3: Activate Carbide Theme
|
|
83
|
+
|
|
84
|
+
Add the Carbide theme class to your app root element:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
// Option 1: Add to root component
|
|
88
|
+
function App() {
|
|
89
|
+
return (
|
|
90
|
+
<div className="carbide">
|
|
91
|
+
<YourApp />
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Option 2: Add via JavaScript (in your main entry file)
|
|
97
|
+
document.documentElement.classList.add('carbide');
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Step 4: Import and Use Components
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import {
|
|
104
|
+
Button,
|
|
105
|
+
Input,
|
|
106
|
+
Card,
|
|
107
|
+
CardHeader,
|
|
108
|
+
CardTitle,
|
|
109
|
+
CardContent,
|
|
110
|
+
} from '@machinemetrics/mm-react-components';
|
|
111
|
+
|
|
112
|
+
function MyComponent() {
|
|
113
|
+
return (
|
|
114
|
+
<Card>
|
|
115
|
+
<CardHeader>
|
|
116
|
+
<CardTitle>Welcome to MachineMetrics Components</CardTitle>
|
|
117
|
+
</CardHeader>
|
|
118
|
+
<CardContent>
|
|
119
|
+
<Input placeholder="Enter your data" />
|
|
120
|
+
<Button>Submit</Button>
|
|
121
|
+
</CardContent>
|
|
122
|
+
</Card>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Done!** Components are ready to use.
|
|
128
|
+
|
|
129
|
+
## Project Structure After Setup
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
your-project/
|
|
133
|
+
├── src/
|
|
134
|
+
│ ├── index.css (or main.css)
|
|
135
|
+
│ └── App.tsx (or App.jsx)
|
|
136
|
+
├── tailwind.config.js
|
|
137
|
+
├── postcss.config.js
|
|
138
|
+
├── package.json
|
|
139
|
+
└── node_modules/
|
|
140
|
+
└── @machinemetrics/mm-react-components/
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Framework-Specific Setup
|
|
144
|
+
|
|
145
|
+
### React with Vite
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Create new Vite React project
|
|
149
|
+
npm create vite@latest my-app -- --template react-ts
|
|
150
|
+
cd my-app
|
|
151
|
+
|
|
152
|
+
# Run init script
|
|
153
|
+
npx @machinemetrics/mm-react-components init
|
|
154
|
+
|
|
155
|
+
# Start development server
|
|
156
|
+
npm run dev
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Next.js
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Create new Next.js project
|
|
163
|
+
npx create-next-app@latest my-app --typescript --tailwind --eslint
|
|
164
|
+
cd my-app
|
|
165
|
+
|
|
166
|
+
# Run init script
|
|
167
|
+
npx @machinemetrics/mm-react-components init
|
|
168
|
+
|
|
169
|
+
# Start development server
|
|
170
|
+
npm run dev
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Create React App
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Create new CRA project
|
|
177
|
+
npx create-react-app my-app --template typescript
|
|
178
|
+
cd my-app
|
|
179
|
+
|
|
180
|
+
# Run init script
|
|
181
|
+
npx @machinemetrics/mm-react-components init
|
|
182
|
+
|
|
183
|
+
# Start development server
|
|
184
|
+
npm start
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Advanced Configuration
|
|
188
|
+
|
|
189
|
+
### Custom Tailwind Configuration
|
|
190
|
+
|
|
191
|
+
If you need to extend the Tailwind configuration:
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
/** @type {import('tailwindcss').Config} */
|
|
195
|
+
module.exports = {
|
|
196
|
+
content: [
|
|
197
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
198
|
+
'./node_modules/@machinemetrics/mm-react-components/dist/**/*.{js,ts,jsx,tsx}',
|
|
199
|
+
],
|
|
200
|
+
theme: {
|
|
201
|
+
extend: {
|
|
202
|
+
// Your custom theme extensions
|
|
203
|
+
colors: {
|
|
204
|
+
// Custom colors
|
|
205
|
+
},
|
|
206
|
+
fontFamily: {
|
|
207
|
+
// Custom fonts
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
plugins: [
|
|
212
|
+
// Additional Tailwind plugins
|
|
213
|
+
],
|
|
214
|
+
};
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Custom CSS Setup
|
|
218
|
+
|
|
219
|
+
For more control over CSS imports:
|
|
220
|
+
|
|
221
|
+
```css
|
|
222
|
+
/* src/index.css */
|
|
223
|
+
@import '@machinemetrics/mm-react-components/themes/carbide';
|
|
224
|
+
|
|
225
|
+
/* Custom CSS variables */
|
|
226
|
+
:root {
|
|
227
|
+
--custom-primary: #your-color;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* Custom component styles */
|
|
231
|
+
.my-custom-component {
|
|
232
|
+
/* Your styles */
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### TypeScript Configuration
|
|
237
|
+
|
|
238
|
+
If using TypeScript, ensure your `tsconfig.json` includes the component library types:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"compilerOptions": {
|
|
243
|
+
"types": ["@machinemetrics/mm-react-components"]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Troubleshooting Common Issues
|
|
249
|
+
|
|
250
|
+
### Issue: Script Fails with "Command not found"
|
|
251
|
+
|
|
252
|
+
**Cause**: NPX not installed or network issues.
|
|
253
|
+
|
|
254
|
+
**Solution**:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Install npx globally
|
|
258
|
+
npm install -g npx
|
|
259
|
+
|
|
260
|
+
# Or use npm directly
|
|
261
|
+
npm init @machinemetrics/mm-react-components
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Issue: "Cannot find module" errors
|
|
265
|
+
|
|
266
|
+
**Cause**: Dependencies not installed correctly.
|
|
267
|
+
|
|
268
|
+
**Solution**:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# Clear npm cache
|
|
272
|
+
npm cache clean --force
|
|
273
|
+
|
|
274
|
+
# Delete node_modules and package-lock.json
|
|
275
|
+
rm -rf node_modules package-lock.json
|
|
276
|
+
|
|
277
|
+
# Reinstall dependencies
|
|
278
|
+
npm install
|
|
279
|
+
|
|
280
|
+
# Run init script again
|
|
281
|
+
npx @machinemetrics/mm-react-components init
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Issue: Tailwind CSS not working
|
|
285
|
+
|
|
286
|
+
**Cause**: Tailwind configuration not set up correctly.
|
|
287
|
+
|
|
288
|
+
**Solution**:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# Initialize Tailwind manually
|
|
292
|
+
npx tailwindcss init -p
|
|
293
|
+
|
|
294
|
+
# Update tailwind.config.js with correct content paths
|
|
295
|
+
# Ensure PostCSS is configured
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Issue: Components not styling correctly
|
|
299
|
+
|
|
300
|
+
**Cause**: Carbide theme not applied or CSS not imported.
|
|
301
|
+
|
|
302
|
+
**Solution**:
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
// Ensure CSS is imported in your main file
|
|
306
|
+
import '@machinemetrics/mm-react-components/themes/carbide';
|
|
307
|
+
|
|
308
|
+
// Ensure carbide class is applied to root element
|
|
309
|
+
<div className="carbide">
|
|
310
|
+
<YourApp />
|
|
311
|
+
</div>;
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Issue: Build errors with TypeScript
|
|
315
|
+
|
|
316
|
+
**Cause**: Type definitions not found.
|
|
317
|
+
|
|
318
|
+
**Solution**:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
# Install TypeScript definitions
|
|
322
|
+
npm install -D @types/react @types/react-dom
|
|
323
|
+
|
|
324
|
+
# Update tsconfig.json
|
|
325
|
+
{
|
|
326
|
+
"compilerOptions": {
|
|
327
|
+
"types": ["@machinemetrics/mm-react-components"]
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Issue: Icons not displaying
|
|
333
|
+
|
|
334
|
+
**Cause**: Lucide React not installed or imported incorrectly.
|
|
335
|
+
|
|
336
|
+
**Solution**:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Install Lucide React
|
|
340
|
+
npm install lucide-react
|
|
341
|
+
|
|
342
|
+
# Import icons correctly
|
|
343
|
+
import { Plus, Trash2 } from 'lucide-react';
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Validation Checklist
|
|
347
|
+
|
|
348
|
+
After setup, verify the following:
|
|
349
|
+
|
|
350
|
+
- [ ] `@machinemetrics/mm-react-components` is installed
|
|
351
|
+
- [ ] All peer dependencies are installed
|
|
352
|
+
- [ ] CSS file imports the Carbide theme
|
|
353
|
+
- [ ] Tailwind CSS is configured
|
|
354
|
+
- [ ] PostCSS is configured
|
|
355
|
+
- [ ] Root element has `carbide` class
|
|
356
|
+
- [ ] Components can be imported and used
|
|
357
|
+
- [ ] Icons are displaying correctly
|
|
358
|
+
- [ ] Build process works without errors
|
|
359
|
+
- [ ] Development server starts successfully
|
|
360
|
+
|
|
361
|
+
## Testing the Setup
|
|
362
|
+
|
|
363
|
+
### Basic Component Test
|
|
364
|
+
|
|
365
|
+
```tsx
|
|
366
|
+
import {
|
|
367
|
+
Button,
|
|
368
|
+
Card,
|
|
369
|
+
CardContent,
|
|
370
|
+
CardHeader,
|
|
371
|
+
CardTitle,
|
|
372
|
+
} from '@machinemetrics/mm-react-components';
|
|
373
|
+
|
|
374
|
+
function TestComponent() {
|
|
375
|
+
return (
|
|
376
|
+
<Card>
|
|
377
|
+
<CardHeader>
|
|
378
|
+
<CardTitle>Setup Test</CardTitle>
|
|
379
|
+
</CardHeader>
|
|
380
|
+
<CardContent>
|
|
381
|
+
<Button>Test Button</Button>
|
|
382
|
+
</CardContent>
|
|
383
|
+
</Card>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export default TestComponent;
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Theme Test
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
// Test that the Carbide theme is working
|
|
394
|
+
function ThemeTest() {
|
|
395
|
+
return (
|
|
396
|
+
<div className="carbide">
|
|
397
|
+
<div className="bg-primary text-primary-foreground p-4 rounded">
|
|
398
|
+
This should have industrial styling
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## Advanced Usage
|
|
406
|
+
|
|
407
|
+
### Custom Component Integration
|
|
408
|
+
|
|
409
|
+
```tsx
|
|
410
|
+
import { Button } from '@machinemetrics/mm-react-components';
|
|
411
|
+
import { cn } from '@machinemetrics/mm-react-components';
|
|
412
|
+
|
|
413
|
+
function CustomButton({ className, ...props }) {
|
|
414
|
+
return <Button className={cn('custom-styles', className)} {...props} />;
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Theme Customization
|
|
419
|
+
|
|
420
|
+
```css
|
|
421
|
+
/* Override Carbide theme variables */
|
|
422
|
+
.carbide {
|
|
423
|
+
--primary: #your-custom-color;
|
|
424
|
+
--secondary: #your-custom-color;
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### Build Optimization
|
|
429
|
+
|
|
430
|
+
```javascript
|
|
431
|
+
// vite.config.js for Vite projects
|
|
432
|
+
export default {
|
|
433
|
+
optimizeDeps: {
|
|
434
|
+
include: ['@machinemetrics/mm-react-components'],
|
|
435
|
+
},
|
|
436
|
+
};
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
## Support and Resources
|
|
440
|
+
|
|
441
|
+
### Documentation
|
|
442
|
+
|
|
443
|
+
- [Component Library Docs](https://components.machinemetrics.com)
|
|
444
|
+
- [API Reference](https://components.machinemetrics.com/api)
|
|
445
|
+
- [Getting Started Guide](https://components.machinemetrics.com/getting-started)
|
|
446
|
+
|
|
447
|
+
### Community Support
|
|
448
|
+
|
|
449
|
+
- [GitHub Issues](https://github.com/machinemetrics/mm-react-components/issues)
|
|
450
|
+
- [Discord Community](https://discord.gg/machinemetrics)
|
|
451
|
+
- [Stack Overflow](https://stackoverflow.com/questions/tagged/machinemetrics)
|
|
452
|
+
|
|
453
|
+
### Professional Support
|
|
454
|
+
|
|
455
|
+
- [MachineMetrics Support](https://support.machinemetrics.com)
|
|
456
|
+
- [Enterprise Support](https://enterprise.machinemetrics.com)
|
|
457
|
+
- [Consulting Services](https://consulting.machinemetrics.com)
|
|
458
|
+
|
|
459
|
+
## Conclusion
|
|
460
|
+
|
|
461
|
+
This guide provides comprehensive instructions for setting up the MachineMetrics React Components library. The automated init script handles most cases, but manual setup may be necessary for complex scenarios or when the script fails. Always test your setup thoroughly to ensure everything is working correctly.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# Chakra UI to MachineMetrics React Components Migration
|
|
2
|
+
|
|
3
|
+
This directory contains comprehensive tools and documentation for migrating from Chakra UI to the MachineMetrics React Components library.
|
|
4
|
+
|
|
5
|
+
## Files Overview
|
|
6
|
+
|
|
7
|
+
### Core Files
|
|
8
|
+
|
|
9
|
+
- **`chakra-to-shadcn.config.json`** - Main migration configuration with component mappings
|
|
10
|
+
- **`ai-agent-guide.md`** - Comprehensive guide for AI agents performing migrations
|
|
11
|
+
- **`component-mapping-reference.md`** - Detailed component mapping reference
|
|
12
|
+
- **`chakra-migration-troubleshooting.md`** - Common issues and solutions
|
|
13
|
+
- **`README.md`** - This file
|
|
14
|
+
|
|
15
|
+
## Quick Start for AI Agents
|
|
16
|
+
|
|
17
|
+
### 1. Automated Migration (Preferred)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Use the migration tool
|
|
21
|
+
node scripts/chakra-to-shadcn-migrator/chakra-to-shadcn.js --apply
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Manual Migration (When Scripts Fail)
|
|
25
|
+
|
|
26
|
+
Follow the comprehensive guide in `ai-agent-guide.md` for step-by-step manual conversion.
|
|
27
|
+
|
|
28
|
+
## Configuration File
|
|
29
|
+
|
|
30
|
+
The `chakra-to-shadcn.config.json` file contains:
|
|
31
|
+
|
|
32
|
+
- **Dependencies to Remove**: Chakra UI packages to uninstall
|
|
33
|
+
- **Dependencies to Add**: New packages required for MachineMetrics components
|
|
34
|
+
- **Component Mappings**: Direct component replacements
|
|
35
|
+
- **Compound Components**: Complex component structure mappings
|
|
36
|
+
- **Manual Migration Instructions**: Fallback conversion steps
|
|
37
|
+
|
|
38
|
+
## Component Mappings
|
|
39
|
+
|
|
40
|
+
### Direct Replacements (Automated)
|
|
41
|
+
|
|
42
|
+
These components can be automatically migrated:
|
|
43
|
+
|
|
44
|
+
- `Badge` → `Badge`
|
|
45
|
+
- `Button` → `Button`
|
|
46
|
+
- `Input` → `Input`
|
|
47
|
+
- `Modal` → `Dialog`
|
|
48
|
+
- `Menu` → `DropdownMenu`
|
|
49
|
+
- `Select` → `Select`
|
|
50
|
+
- `Table` → `Table`
|
|
51
|
+
- `Tabs` → `Tabs`
|
|
52
|
+
- `Tooltip` → `Tooltip`
|
|
53
|
+
- `Drawer` → `Drawer`
|
|
54
|
+
- `Switch` → `Switch`
|
|
55
|
+
- `Checkbox` → `Checkbox`
|
|
56
|
+
- `Radio` → `RadioGroupItem`
|
|
57
|
+
- `RadioGroup` → `RadioGroup`
|
|
58
|
+
- `Label` → `Label`
|
|
59
|
+
- `Sheet` → `Sheet`
|
|
60
|
+
- `Skeleton` → `Skeleton`
|
|
61
|
+
- `Collapse` → `Collapsible`
|
|
62
|
+
- `Accordion` → `Accordion`
|
|
63
|
+
- `Progress` → `Progress`
|
|
64
|
+
- `Slider` → `Slider`
|
|
65
|
+
- `Popover` → `Popover`
|
|
66
|
+
|
|
67
|
+
### New Components (Recently Added)
|
|
68
|
+
|
|
69
|
+
- `Alert` → `Alert`
|
|
70
|
+
- `AlertDialog` → `AlertDialog`
|
|
71
|
+
- `Avatar` → `Avatar`
|
|
72
|
+
- `Breadcrumb` → `Breadcrumb`
|
|
73
|
+
- `Calendar` → `Calendar`
|
|
74
|
+
- `DateRangePicker` → `DateRangePicker`
|
|
75
|
+
- `Form` → `Form`
|
|
76
|
+
- `Separator` → `Separator`
|
|
77
|
+
- `Textarea` → `Textarea`
|
|
78
|
+
- `Toaster` → `Toaster`
|
|
79
|
+
- `Chart` → `ChartContainer`, `ChartTooltip`, etc.
|
|
80
|
+
- `Dropzone` → `Dropzone`
|
|
81
|
+
- `SearchInput` → `SearchInput`
|
|
82
|
+
|
|
83
|
+
### Manual Replacements Required
|
|
84
|
+
|
|
85
|
+
These components need manual conversion to HTML + Tailwind:
|
|
86
|
+
|
|
87
|
+
- `Box` → `<div>` with Tailwind classes
|
|
88
|
+
- `Flex` → `<div className="flex">` with flex classes
|
|
89
|
+
- `VStack` → `<div className="flex flex-col gap-4">`
|
|
90
|
+
- `HStack` → `<div className="flex flex-row gap-4">`
|
|
91
|
+
- `Stack` → `<div className="flex flex-col gap-4">`
|
|
92
|
+
- `Container` → `<div className="container mx-auto px-4">`
|
|
93
|
+
- `Center` → `<div className="flex items-center justify-center">`
|
|
94
|
+
- `SimpleGrid` → `<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">`
|
|
95
|
+
- `Heading` → `<h1>`, `<h2>`, etc. with Tailwind typography
|
|
96
|
+
- `Text` → `<p>`, `<span>`, etc. with Tailwind typography
|
|
97
|
+
|
|
98
|
+
## Migration Process
|
|
99
|
+
|
|
100
|
+
### Step 1: Update Dependencies
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Remove Chakra UI packages
|
|
104
|
+
npm uninstall @chakra-ui/react @chakra-ui/icons @chakra-ui/system @emotion/react @emotion/styled
|
|
105
|
+
|
|
106
|
+
# Install MachineMetrics components
|
|
107
|
+
npm install @machinemetrics/mm-react-components
|
|
108
|
+
|
|
109
|
+
# Install additional dependencies
|
|
110
|
+
npm install class-variance-authority tailwind-merge lucide-react
|
|
111
|
+
npm install react-day-picker date-fns recharts react-dropzone sonner vaul
|
|
112
|
+
npm install @radix-ui/react-avatar @radix-ui/react-breadcrumb @radix-ui/react-calendar
|
|
113
|
+
npm install @radix-ui/react-alert-dialog @radix-ui/react-separator @radix-ui/react-form
|
|
114
|
+
npm install @radix-ui/react-textarea @radix-ui/react-toast
|
|
115
|
+
|
|
116
|
+
# Install dev dependencies
|
|
117
|
+
npm install -D tailwindcss postcss autoprefixer
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Step 2: Update Theme Configuration
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
// Remove ChakraProvider from your app root
|
|
124
|
+
// Before
|
|
125
|
+
import { ChakraProvider } from '@chakra-ui/react';
|
|
126
|
+
|
|
127
|
+
function App() {
|
|
128
|
+
return (
|
|
129
|
+
<ChakraProvider>
|
|
130
|
+
<YourApp />
|
|
131
|
+
</ChakraProvider>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// After
|
|
136
|
+
import '@machinemetrics/mm-react-components/themes/carbide';
|
|
137
|
+
|
|
138
|
+
function App() {
|
|
139
|
+
return (
|
|
140
|
+
<div className="carbide">
|
|
141
|
+
<YourApp />
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Step 3: Update Component Imports
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
// Before
|
|
151
|
+
import { Button, Input, Modal, Box, Flex } from '@chakra-ui/react';
|
|
152
|
+
import { AddIcon } from '@chakra-ui/icons';
|
|
153
|
+
|
|
154
|
+
// After
|
|
155
|
+
import { Button, Input, Dialog } from '@machinemetrics/mm-react-components';
|
|
156
|
+
import { Plus } from 'lucide-react';
|
|
157
|
+
// Layout components become generic HTML elements with Tailwind classes
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Step 4: Convert Components
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
// Before
|
|
164
|
+
<Modal isOpen={isOpen} onClose={onClose}>
|
|
165
|
+
<ModalOverlay />
|
|
166
|
+
<ModalContent>
|
|
167
|
+
<ModalHeader>Title</ModalHeader>
|
|
168
|
+
<ModalBody>Content</ModalBody>
|
|
169
|
+
</ModalContent>
|
|
170
|
+
</Modal>
|
|
171
|
+
|
|
172
|
+
// After
|
|
173
|
+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
|
174
|
+
<DialogTrigger>Open</DialogTrigger>
|
|
175
|
+
<DialogContent>
|
|
176
|
+
<DialogHeader>
|
|
177
|
+
<DialogTitle>Title</DialogTitle>
|
|
178
|
+
</DialogHeader>
|
|
179
|
+
Content
|
|
180
|
+
</DialogContent>
|
|
181
|
+
</Dialog>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Usage Examples
|
|
185
|
+
|
|
186
|
+
### Basic Migration
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Preview changes (dry run)
|
|
190
|
+
node scripts/chakra-to-shadcn-migrator/chakra-to-shadcn.js
|
|
191
|
+
|
|
192
|
+
# Apply changes
|
|
193
|
+
node scripts/chakra-to-shadcn-migrator/chakra-to-shadcn.js --apply
|
|
194
|
+
|
|
195
|
+
# With verbose output
|
|
196
|
+
node scripts/chakra-to-shadcn-migrator/chakra-to-shadcn.js --apply --verbose
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Troubleshooting
|
|
200
|
+
|
|
201
|
+
### Common Issues
|
|
202
|
+
|
|
203
|
+
1. **Missing Dependencies**: Install all required packages
|
|
204
|
+
2. **Theme Not Applied**: Ensure Carbide theme is imported and applied
|
|
205
|
+
3. **Layout Components**: Replace with HTML + Tailwind classes
|
|
206
|
+
4. **Icons Not Working**: Update to Lucide React icons
|
|
207
|
+
5. **Form Components**: Use new Form component structure
|
|
208
|
+
|
|
209
|
+
### Debugging
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Check for errors
|
|
213
|
+
npm run lint
|
|
214
|
+
|
|
215
|
+
# Test components
|
|
216
|
+
npm run test
|
|
217
|
+
|
|
218
|
+
# Build project
|
|
219
|
+
npm run build
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Validation Checklist
|
|
223
|
+
|
|
224
|
+
After migration, verify:
|
|
225
|
+
|
|
226
|
+
- [ ] All Chakra UI imports removed
|
|
227
|
+
- [ ] MachineMetrics components imported correctly
|
|
228
|
+
- [ ] Theme applied with `carbide` class
|
|
229
|
+
- [ ] Layout components converted to HTML + Tailwind
|
|
230
|
+
- [ ] Icons updated to Lucide React
|
|
231
|
+
- [ ] Form components working correctly
|
|
232
|
+
- [ ] Modal/Dialog components functioning
|
|
233
|
+
- [ ] Styling matches original design
|
|
234
|
+
- [ ] No console errors
|
|
235
|
+
- [ ] All functionality preserved
|
|
236
|
+
|
|
237
|
+
## Support and Resources
|
|
238
|
+
|
|
239
|
+
- **Documentation**: [MachineMetrics Components Docs](https://components.machinemetrics.com)
|
|
240
|
+
- **GitHub**: [Component Library Repository](https://github.com/machinemetrics/mm-react-components)
|
|
241
|
+
- **Issues**: Report migration issues on GitHub
|
|
242
|
+
- **Community**: Join the MachineMetrics developer community
|
|
243
|
+
|
|
244
|
+
## File Descriptions
|
|
245
|
+
|
|
246
|
+
### `chakra-to-shadcn.config.json`
|
|
247
|
+
|
|
248
|
+
Main configuration file containing all component mappings, dependencies, and migration instructions.
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
### `ai-agent-guide.md`
|
|
252
|
+
|
|
253
|
+
Comprehensive guide for AI agents performing migrations. Includes step-by-step instructions, examples, and best practices.
|
|
254
|
+
|
|
255
|
+
### `component-mapping-reference.md`
|
|
256
|
+
|
|
257
|
+
Detailed reference for all component mappings, including props, styling, and usage examples.
|
|
258
|
+
|
|
259
|
+
### `chakra-migration-troubleshooting.md`
|
|
260
|
+
|
|
261
|
+
Common issues and solutions encountered during migration, with debugging tips and prevention strategies.
|
|
262
|
+
|
|
263
|
+
## Conclusion
|
|
264
|
+
|
|
265
|
+
This migration toolkit provides everything needed to migrate from Chakra UI to MachineMetrics React Components. The automated tools handle most cases, but manual conversion may be necessary for complex scenarios. Always test thoroughly after migration to ensure functionality is preserved.
|