@efiche/design 0.2.12 → 0.2.14
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 +0 -115
- package/dist/index.cjs +171 -434
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -77
- package/dist/index.d.ts +1 -77
- package/dist/index.js +171 -459
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -8,11 +8,6 @@ A pre-styled, accessible React component library. Components carry their own sty
|
|
|
8
8
|
npm install @efiche/design
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
> Add `recharts` too if you plan to use the chart components:
|
|
12
|
-
> ```bash
|
|
13
|
-
> npm install recharts
|
|
14
|
-
> ```
|
|
15
|
-
|
|
16
11
|
---
|
|
17
12
|
|
|
18
13
|
## Setup
|
|
@@ -117,112 +112,6 @@ Override any `--ds-*` variable on `:root` (or `.ds-theme-dark` for dark mode) in
|
|
|
117
112
|
|
|
118
113
|
---
|
|
119
114
|
|
|
120
|
-
## Charts
|
|
121
|
-
|
|
122
|
-
Charts are built on top of [Recharts](https://recharts.org). Make sure it is installed:
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
npm install recharts
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
```tsx
|
|
129
|
-
import { LineChart, BarChart, AreaChart, PieChart } from '@efiche/design'
|
|
130
|
-
import { useTheme } from '@efiche/design'
|
|
131
|
-
|
|
132
|
-
const { theme } = useTheme() // pass to charts for dark mode awareness
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### LineChart
|
|
136
|
-
|
|
137
|
-
```tsx
|
|
138
|
-
// Single line
|
|
139
|
-
<LineChart data={data} xKey="month" lines={[{ dataKey: 'value' }]} />
|
|
140
|
-
|
|
141
|
-
// Multi-line with legend
|
|
142
|
-
<LineChart
|
|
143
|
-
data={data}
|
|
144
|
-
xKey="month"
|
|
145
|
-
lines={[
|
|
146
|
-
{ dataKey: 'revenue', color: '#22c55e', label: 'Revenue' },
|
|
147
|
-
{ dataKey: 'expenses', color: '#ef4444', label: 'Expenses' },
|
|
148
|
-
]}
|
|
149
|
-
legend
|
|
150
|
-
theme={theme}
|
|
151
|
-
/>
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### BarChart
|
|
155
|
-
|
|
156
|
-
```tsx
|
|
157
|
-
// Single bar
|
|
158
|
-
<BarChart data={data} xKey="month" bars={[{ dataKey: 'sales' }]} />
|
|
159
|
-
|
|
160
|
-
// Stacked bars
|
|
161
|
-
<BarChart
|
|
162
|
-
data={data}
|
|
163
|
-
xKey="month"
|
|
164
|
-
bars={[
|
|
165
|
-
{ dataKey: 'online', color: '#3b82f6', stackId: 'a', label: 'Online' },
|
|
166
|
-
{ dataKey: 'offline', color: '#94a3b8', stackId: 'a', label: 'Offline' },
|
|
167
|
-
]}
|
|
168
|
-
legend
|
|
169
|
-
theme={theme}
|
|
170
|
-
/>
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### AreaChart
|
|
174
|
-
|
|
175
|
-
```tsx
|
|
176
|
-
// Single area
|
|
177
|
-
<AreaChart data={data} xKey="month" areas={[{ dataKey: 'visitors' }]} />
|
|
178
|
-
|
|
179
|
-
// Stacked areas
|
|
180
|
-
<AreaChart
|
|
181
|
-
data={data}
|
|
182
|
-
xKey="month"
|
|
183
|
-
areas={[
|
|
184
|
-
{ dataKey: 'mobile', color: '#3b82f6', stackId: '1', label: 'Mobile' },
|
|
185
|
-
{ dataKey: 'desktop', color: '#22c55e', stackId: '1', label: 'Desktop' },
|
|
186
|
-
]}
|
|
187
|
-
legend
|
|
188
|
-
theme={theme}
|
|
189
|
-
/>
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### PieChart
|
|
193
|
-
|
|
194
|
-
```tsx
|
|
195
|
-
// Pie
|
|
196
|
-
<PieChart
|
|
197
|
-
data={[
|
|
198
|
-
{ name: 'Direct', value: 400, fill: '#3b82f6' },
|
|
199
|
-
{ name: 'Social', value: 300, fill: '#22c55e' },
|
|
200
|
-
{ name: 'Email', value: 200, fill: '#f59e0b' },
|
|
201
|
-
]}
|
|
202
|
-
label
|
|
203
|
-
/>
|
|
204
|
-
|
|
205
|
-
// Donut with legend
|
|
206
|
-
<PieChart data={pieData} donut legend theme={theme} />
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### Chart props reference
|
|
210
|
-
|
|
211
|
-
| Prop | Type | Default | Description |
|
|
212
|
-
|------|------|---------|-------------|
|
|
213
|
-
| `data` | `object[]` | required | Array of data objects |
|
|
214
|
-
| `xKey` | `string` | required | Key used for the X axis *(LineChart, BarChart, AreaChart)* |
|
|
215
|
-
| `lines` / `bars` / `areas` | `config[]` | required | Series definitions — see per-component docs above |
|
|
216
|
-
| `data` | `{ name, value, fill? }[]` | required | Slice definitions *(PieChart)* |
|
|
217
|
-
| `height` | `number` | `250` | Chart height in px |
|
|
218
|
-
| `legend` | `boolean` | `false` | Show the legend |
|
|
219
|
-
| `grid` | `boolean` | `true` | Show the background grid *(LineChart, BarChart, AreaChart)* |
|
|
220
|
-
| `label` | `boolean` | `false` | Show percentage labels on slices *(PieChart)* |
|
|
221
|
-
| `donut` | `boolean` | `false` | Hollow centre *(PieChart)* |
|
|
222
|
-
| `theme` | `"light" \| "dark"` | `"light"` | Controls axis, grid, and tooltip colours |
|
|
223
|
-
|
|
224
|
-
---
|
|
225
|
-
|
|
226
115
|
## Components
|
|
227
116
|
|
|
228
117
|
| Component | Import |
|
|
@@ -252,10 +141,6 @@ const { theme } = useTheme() // pass to charts for dark mode awareness
|
|
|
252
141
|
| `Textarea` | `import { Textarea } from '@efiche/design'` |
|
|
253
142
|
| `Tooltip` | `import { Tooltip } from '@efiche/design'` |
|
|
254
143
|
| `ThemeProvider` | `import { ThemeProvider, useTheme } from '@efiche/design'` |
|
|
255
|
-
| `LineChart` | `import { LineChart } from '@efiche/design'` |
|
|
256
|
-
| `BarChart` | `import { BarChart } from '@efiche/design'` |
|
|
257
|
-
| `AreaChart` | `import { AreaChart } from '@efiche/design'` |
|
|
258
|
-
| `PieChart` | `import { PieChart } from '@efiche/design'` |
|
|
259
144
|
|
|
260
145
|
---
|
|
261
146
|
|