@noxickon/onyx 2.0.0 → 2.0.1
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 +107 -11
- package/dist/chunks/ui-DmUf2PZA.js +20 -0
- package/dist/chunks/{ui-CbFPvWIc.js → ui-ULvcrJjV.js} +2154 -2149
- package/dist/contexts/contexts.cjs.js +1 -1
- package/dist/contexts/contexts.es.js +1 -1
- package/dist/layouts/layouts.cjs.js +1 -1
- package/dist/layouts/layouts.es.js +90 -90
- package/dist/onyx.cjs.js +1 -1
- package/dist/onyx.es.js +1 -1
- package/dist/pages/pages.cjs.js +2 -2
- package/dist/pages/pages.es.js +39 -39
- package/dist/routes/routes.cjs.js +1 -1
- package/dist/routes/routes.es.js +1 -1
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.es.js +6 -6
- package/package.json +1 -1
- package/dist/chunks/ui-9efLp51u.js +0 -20
package/README.md
CHANGED
|
@@ -10,34 +10,67 @@ Onyx is a modern React component library built with Tailwind CSS, designed for b
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
12
|
- **Modern React Components** - Built with React 19 and TypeScript
|
|
13
|
+
- **Tree-Shakeable** - Only import what you need, optimized bundle size
|
|
13
14
|
- **Dark Mode Optimized** - All components designed for dark interfaces
|
|
14
|
-
- **Material Design Icons** -
|
|
15
|
-
- **Tailwind CSS** - Fully customizable with Tailwind
|
|
15
|
+
- **Material Design Icons** - 7,000+ icons via @mdi/js with tree-shaking support
|
|
16
|
+
- **Tailwind CSS 4** - Fully customizable with latest Tailwind
|
|
17
|
+
- **Type-Safe** - Full TypeScript support with strict typing
|
|
16
18
|
- **Storybook Documentation** - Interactive component documentation
|
|
19
|
+
- **Performance First** - ~94 KB gzipped (full library), tree-shakes to ~10-50 KB in practice
|
|
17
20
|
|
|
18
21
|
## Getting Started
|
|
19
22
|
|
|
20
23
|
### Installation
|
|
21
24
|
|
|
25
|
+
Install Onyx and its peer dependencies:
|
|
26
|
+
|
|
22
27
|
```bash
|
|
23
|
-
npm install @noxickon/onyx
|
|
28
|
+
npm install @noxickon/onyx @mdi/js
|
|
24
29
|
```
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
**Peer Dependencies:**
|
|
32
|
+
|
|
33
|
+
- `react` ^19.0.0
|
|
34
|
+
- `react-dom` ^19.0.0
|
|
35
|
+
- `@mdi/js` ^7.0.0
|
|
36
|
+
- `@apollo/client` ^4.0.0 (if using Apollo features)
|
|
37
|
+
- `graphql` ^16.0.0 (if using GraphQL features)
|
|
38
|
+
|
|
39
|
+
### Basic Usage
|
|
27
40
|
|
|
28
41
|
```tsx
|
|
42
|
+
import { mdiHomeOutline, mdiCheck } from '@mdi/js';
|
|
29
43
|
import { OxButton, OxIcon } from '@noxickon/onyx';
|
|
44
|
+
import '@noxickon/onyx/styles';
|
|
30
45
|
|
|
31
46
|
function App() {
|
|
32
47
|
return (
|
|
33
48
|
<div>
|
|
34
|
-
<OxButton variant="primary">
|
|
35
|
-
|
|
49
|
+
<OxButton variant="primary">
|
|
50
|
+
<OxButton.Icon path={mdiCheck} />
|
|
51
|
+
Click Me
|
|
52
|
+
</OxButton>
|
|
53
|
+
<OxIcon path={mdiHomeOutline} size={1.2} />
|
|
36
54
|
</div>
|
|
37
55
|
);
|
|
38
56
|
}
|
|
39
57
|
```
|
|
40
58
|
|
|
59
|
+
### Icons
|
|
60
|
+
|
|
61
|
+
Onyx uses Material Design Icons via `@mdi/js`. Import icons directly for optimal tree-shaking:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { mdiAccount, mdiHome, mdiEmail } from '@mdi/js';
|
|
65
|
+
import { OxIcon } from '@noxickon/onyx';
|
|
66
|
+
|
|
67
|
+
<OxIcon path={mdiAccount} />
|
|
68
|
+
<OxIcon path={mdiHome} size={1.5} />
|
|
69
|
+
<OxIcon path={mdiEmail} className="text-blue-500" />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Browse all 7,000+ available icons at [pictogrammers.com/library/mdi](https://pictogrammers.com/library/mdi/)
|
|
73
|
+
|
|
41
74
|
## Development
|
|
42
75
|
|
|
43
76
|
### Available Commands
|
|
@@ -46,9 +79,14 @@ function App() {
|
|
|
46
79
|
| ------------------------- | ------------------------------------------------ |
|
|
47
80
|
| `npm run dev` | Starts Storybook development server on port 6006 |
|
|
48
81
|
| `npm run build` | Builds the component library for production |
|
|
82
|
+
| `npm run build:analyze` | Builds and opens bundle size analyzer |
|
|
49
83
|
| `npm run preview` | Previews the built package locally |
|
|
50
|
-
| `npm run build
|
|
84
|
+
| `npm run build:storybook` | Builds static Storybook site for deployment |
|
|
85
|
+
| `npm run test` | Runs all tests with Vitest |
|
|
86
|
+
| `npm run test:coverage` | Runs tests with coverage report |
|
|
51
87
|
| `npm run lint` | Lint code with ESLint |
|
|
88
|
+
| `npm run lint:fix` | Fix lint issues automatically |
|
|
89
|
+
| `npm run format` | Format code with Prettier |
|
|
52
90
|
|
|
53
91
|
### Storybook
|
|
54
92
|
|
|
@@ -62,11 +100,69 @@ Then open http://localhost:6006 in your browser to view the component library.
|
|
|
62
100
|
|
|
63
101
|
### Adding a New Component
|
|
64
102
|
|
|
65
|
-
1. Create a new directory under `src/
|
|
66
|
-
2. Add the component implementation in `src/
|
|
67
|
-
3. Create types in `src/
|
|
103
|
+
1. Create a new directory under `src/ui/[ComponentName]` or `src/forms/[ComponentName]`
|
|
104
|
+
2. Add the component implementation in `src/[category]/[ComponentName]/src/[ComponentName].tsx`
|
|
105
|
+
3. Create types in `src/[category]/[ComponentName]/src/[ComponentName].types.ts`
|
|
68
106
|
4. Add an `index.ts` file that exports the component with the `Ox` prefix
|
|
69
|
-
5. Create stories in `src/
|
|
107
|
+
5. Create stories in `src/[category]/[ComponentName]/[ComponentName].stories.tsx`
|
|
108
|
+
6. Add tests in `src/[category]/[ComponentName]/test/[ComponentName].test.tsx`
|
|
109
|
+
|
|
110
|
+
## Migration Guide
|
|
111
|
+
|
|
112
|
+
### Upgrading from v1.x to v2.0
|
|
113
|
+
|
|
114
|
+
Version 2.0 introduces tree-shakeable icons for better performance. This is a **breaking change** requiring code updates.
|
|
115
|
+
|
|
116
|
+
#### 1. Install @mdi/js
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install @mdi/js
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### 2. Update Icon Usage
|
|
123
|
+
|
|
124
|
+
**Before (v1.x):**
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { OxIcon } from '@noxickon/onyx';
|
|
128
|
+
|
|
129
|
+
<OxIcon path="mdiHome" />
|
|
130
|
+
<OxAlert.Icon path="mdiCheck" />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**After (v2.0):**
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { mdiHome, mdiCheck } from '@mdi/js';
|
|
137
|
+
import { OxIcon, OxAlert } from '@noxickon/onyx';
|
|
138
|
+
|
|
139
|
+
<OxIcon path={mdiHome} />
|
|
140
|
+
<OxAlert.Icon path={mdiCheck} />
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### 3. Benefits
|
|
144
|
+
|
|
145
|
+
- **91% smaller bundle** - From ~3 MB to ~267 KB (Frontend example)
|
|
146
|
+
- **Tree-shaking** - Only icons you use are bundled
|
|
147
|
+
- **Type-safe** - Full TypeScript validation for icon paths
|
|
148
|
+
- **Better performance** - Faster load times and reduced network transfer
|
|
149
|
+
|
|
150
|
+
#### 4. Migration Tips
|
|
151
|
+
|
|
152
|
+
Search your codebase for icon usage:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Find all icon usages
|
|
156
|
+
grep -r 'path="mdi' src/
|
|
157
|
+
|
|
158
|
+
# Or with ripgrep
|
|
159
|
+
rg 'path="mdi' src/
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Update each file:
|
|
163
|
+
|
|
164
|
+
1. Import icons from `@mdi/js` at the top
|
|
165
|
+
2. Change `path="mdiXxx"` to `path={mdiXxx}`
|
|
70
166
|
|
|
71
167
|
## License
|
|
72
168
|
|