@engrate/components 0.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 +167 -0
- package/dist/eg-components.cjs.js +51 -0
- package/dist/eg-components.es.js +11045 -0
- package/dist/index.d.ts +878 -0
- package/dist/styles.css +1 -0
- package/package.json +118 -0
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Engrate Components
|
|
2
|
+
|
|
3
|
+
A React component library built with Tailwind CSS, following Engrate's brand guidelines. Features accessible, customizable components with TypeScript support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install eg-components
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer Dependencies
|
|
12
|
+
|
|
13
|
+
This library requires React 18 or 19:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install react react-dom
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Option 1: Pre-compiled CSS (Non-Tailwind Projects)
|
|
22
|
+
|
|
23
|
+
Import the compiled CSS bundle for projects not using Tailwind:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { Button } from 'eg-components'
|
|
27
|
+
import 'eg-components/styles.css'
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return <Button variant="primary">Click me</Button>
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Option 2: Tailwind Preset (Tailwind Projects)
|
|
35
|
+
|
|
36
|
+
Extend your Tailwind config with Engrate's design tokens:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// tailwind.config.js
|
|
40
|
+
import { egComponentsPreset } from 'eg-components/tailwind.preset'
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
presets: [egComponentsPreset],
|
|
44
|
+
content: [
|
|
45
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
46
|
+
'./node_modules/eg-components/dist/**/*.js',
|
|
47
|
+
],
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Then use components without importing CSS:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Button } from 'eg-components'
|
|
55
|
+
|
|
56
|
+
function App() {
|
|
57
|
+
return <Button variant="primary">Click me</Button>
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
### Setup
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/engrate/eg-components.git
|
|
67
|
+
cd eg-components
|
|
68
|
+
npm install
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Scripts
|
|
72
|
+
|
|
73
|
+
| Command | Description |
|
|
74
|
+
| ------------------------- | ---------------------------------------- |
|
|
75
|
+
| `npm run dev` | Start Vite dev server |
|
|
76
|
+
| `npm run build` | Build library to `dist/` |
|
|
77
|
+
| `npm run storybook` | Start Storybook at http://localhost:6006 |
|
|
78
|
+
| `npm run build-storybook` | Build static Storybook |
|
|
79
|
+
| `npm run test` | Run tests in watch mode |
|
|
80
|
+
| `npm run test:run` | Single test run |
|
|
81
|
+
| `npm run test:coverage` | Run tests with coverage |
|
|
82
|
+
| `npm run lint` | Check for linting errors |
|
|
83
|
+
| `npm run lint:fix` | Fix linting errors |
|
|
84
|
+
| `npm run format` | Format code with Prettier |
|
|
85
|
+
| `npm run typecheck` | Type-check without emitting |
|
|
86
|
+
|
|
87
|
+
### Project Structure
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
src/
|
|
91
|
+
├── components/
|
|
92
|
+
│ ├── ui/ # Base UI components (Button, etc.)
|
|
93
|
+
│ └── layout/ # Layout components
|
|
94
|
+
├── lib/
|
|
95
|
+
│ └── utils.ts # Utility functions (cn, etc.)
|
|
96
|
+
├── styles/
|
|
97
|
+
│ ├── fonts.css # @font-face declarations
|
|
98
|
+
│ └── index.css # Tailwind entry point
|
|
99
|
+
├── test/
|
|
100
|
+
│ └── setup.ts # Test configuration
|
|
101
|
+
├── tailwind.preset.ts # Exportable design tokens
|
|
102
|
+
└── index.ts # Main entry point
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Adding a Component
|
|
106
|
+
|
|
107
|
+
1. Create component folder in `src/components/ui/ComponentName/`
|
|
108
|
+
2. Add files:
|
|
109
|
+
- `ComponentName.tsx` - Component implementation
|
|
110
|
+
- `ComponentName.test.tsx` - Tests with accessibility checks
|
|
111
|
+
- `ComponentName.stories.tsx` - Storybook stories
|
|
112
|
+
- `index.ts` - Barrel export
|
|
113
|
+
3. Export from `src/components/ui/index.ts`
|
|
114
|
+
4. Run tests and Storybook to verify
|
|
115
|
+
|
|
116
|
+
### Testing
|
|
117
|
+
|
|
118
|
+
Tests use Vitest with Testing Library and vitest-axe for accessibility:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { render, screen } from '@testing-library/react'
|
|
122
|
+
import { axe } from 'vitest-axe'
|
|
123
|
+
import { describe, expect, it } from 'vitest'
|
|
124
|
+
import { Button } from './Button'
|
|
125
|
+
|
|
126
|
+
describe('Button', () => {
|
|
127
|
+
it('has no accessibility violations', async () => {
|
|
128
|
+
const { container } = render(<Button>Click me</Button>)
|
|
129
|
+
const results = await axe(container)
|
|
130
|
+
expect(results).toHaveNoViolations()
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Brand Guidelines
|
|
136
|
+
|
|
137
|
+
This library follows Engrate's brand guidelines:
|
|
138
|
+
|
|
139
|
+
- **10/90 Rule**: 10% color, 90% grayscale
|
|
140
|
+
- **Never pure white**: Use `bg-main` (#FAFAFA) or warmer alternatives
|
|
141
|
+
- **Pill-shaped buttons**: Full border-radius (`rounded-pill`)
|
|
142
|
+
- **No bold fonts**: Use Regular weight only (Medium for emphasis)
|
|
143
|
+
- **Left-aligned text**: Default alignment
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT License
|
|
148
|
+
|
|
149
|
+
Copyright (c) 2026 Engrate AB
|
|
150
|
+
|
|
151
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
152
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
153
|
+
in the Software without restriction, including without limitation the rights
|
|
154
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
155
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
156
|
+
furnished to do so, subject to the following conditions:
|
|
157
|
+
|
|
158
|
+
The above copyright notice and this permission notice shall be included in all
|
|
159
|
+
copies or substantial portions of the Software.
|
|
160
|
+
|
|
161
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
162
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
163
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
164
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
165
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
166
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
167
|
+
SOFTWARE.
|