@efiche/design 0.1.8 → 0.1.9
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 +42 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @efiche/design
|
|
2
2
|
|
|
3
|
-
A pre-styled, accessible React component library.
|
|
3
|
+
A pre-styled, accessible React component library. Components carry their own styles — no CSS import required.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -17,11 +17,10 @@ npm install @efiche/design
|
|
|
17
17
|
|
|
18
18
|
## Setup
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Wrap your app root with `ThemeProvider` **once**. That's it — no stylesheet import needed.
|
|
21
21
|
|
|
22
22
|
**Next.js App Router** (`app/layout.tsx`):
|
|
23
23
|
```tsx
|
|
24
|
-
import '@efiche/design/styles'
|
|
25
24
|
import { ThemeProvider } from '@efiche/design'
|
|
26
25
|
|
|
27
26
|
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
@@ -39,7 +38,6 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|
|
39
38
|
|
|
40
39
|
**Vite / CRA** (`src/main.tsx`):
|
|
41
40
|
```tsx
|
|
42
|
-
import '@efiche/design/styles'
|
|
43
41
|
import { ThemeProvider } from '@efiche/design'
|
|
44
42
|
import { createRoot } from 'react-dom/client'
|
|
45
43
|
|
|
@@ -50,6 +48,8 @@ createRoot(document.getElementById('root')!).render(
|
|
|
50
48
|
)
|
|
51
49
|
```
|
|
52
50
|
|
|
51
|
+
> **`ThemeProvider` is optional.** If you skip it, all components render with their built-in light-mode defaults. Add it when you need dark mode support or the `useTheme` hook.
|
|
52
|
+
|
|
53
53
|
---
|
|
54
54
|
|
|
55
55
|
## Usage
|
|
@@ -65,7 +65,7 @@ export function MyPage() {
|
|
|
65
65
|
</CardHeader>
|
|
66
66
|
<CardContent>
|
|
67
67
|
<Input placeholder="Type something..." />
|
|
68
|
-
<Button
|
|
68
|
+
<Button>Submit</Button>
|
|
69
69
|
</CardContent>
|
|
70
70
|
</Card>
|
|
71
71
|
)
|
|
@@ -74,6 +74,8 @@ export function MyPage() {
|
|
|
74
74
|
|
|
75
75
|
### Dark mode
|
|
76
76
|
|
|
77
|
+
Wrap your app in `ThemeProvider` then use the `useTheme` hook anywhere inside it:
|
|
78
|
+
|
|
77
79
|
```tsx
|
|
78
80
|
import { useTheme } from '@efiche/design'
|
|
79
81
|
|
|
@@ -89,6 +91,32 @@ function DarkModeToggle() {
|
|
|
89
91
|
|
|
90
92
|
---
|
|
91
93
|
|
|
94
|
+
## How styling works
|
|
95
|
+
|
|
96
|
+
Every component uses **inline styles** with CSS custom property fallbacks. For example:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
backgroundColor: 'var(--ds-primary, #3b82f6)'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This means:
|
|
103
|
+
- **Without `ThemeProvider`** — the hardcoded fallback (`#3b82f6`) is used. Components look correct out of the box.
|
|
104
|
+
- **With `ThemeProvider`** — the `--ds-*` CSS variables are active, so dark mode and any custom theme overrides take effect.
|
|
105
|
+
- **No CSS file to import.** No Tailwind, no PostCSS, no bundler config needed.
|
|
106
|
+
|
|
107
|
+
### Customising the theme
|
|
108
|
+
|
|
109
|
+
Override any `--ds-*` variable on `:root` (or `.ds-theme-dark` for dark mode) in your own CSS:
|
|
110
|
+
|
|
111
|
+
```css
|
|
112
|
+
:root {
|
|
113
|
+
--ds-primary: #6366f1; /* change the primary colour to indigo */
|
|
114
|
+
--ds-card: #fafafa;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
92
120
|
## Components
|
|
93
121
|
|
|
94
122
|
| Component | Import |
|
|
@@ -123,7 +151,7 @@ function DarkModeToggle() {
|
|
|
123
151
|
|
|
124
152
|
## Versioning
|
|
125
153
|
|
|
126
|
-
This package follows [semantic versioning](https://semver.org).
|
|
154
|
+
This package follows [semantic versioning](https://semver.org).
|
|
127
155
|
|
|
128
156
|
### Version bump rules
|
|
129
157
|
|
|
@@ -152,30 +180,26 @@ npm publish
|
|
|
152
180
|
git push && git push --tags
|
|
153
181
|
```
|
|
154
182
|
|
|
155
|
-
### What
|
|
156
|
-
|
|
157
|
-
A **major bump** is required when consumers would need to update their code after upgrading. Examples:
|
|
183
|
+
### What counts as a breaking change
|
|
158
184
|
|
|
185
|
+
A **major bump** is required when consumers would need to update their code after upgrading:
|
|
159
186
|
- Renaming a component (`CopyButton` → `ClipboardButton`)
|
|
160
|
-
- Renaming or removing a prop
|
|
187
|
+
- Renaming or removing a prop
|
|
161
188
|
- Changing a prop type in a non-backwards-compatible way
|
|
162
|
-
- Removing a component entirely
|
|
163
|
-
|
|
164
|
-
A **minor bump** is safe — consumers can upgrade without touching their code. Examples:
|
|
165
189
|
|
|
190
|
+
A **minor bump** is safe — consumers can upgrade without touching their code:
|
|
166
191
|
- Adding a new component
|
|
167
|
-
- Adding a new optional prop
|
|
192
|
+
- Adding a new optional prop
|
|
168
193
|
- Adding a new variant to `Badge`, `Button`, etc.
|
|
169
194
|
|
|
170
|
-
A **patch bump** is a fix — no API changes
|
|
171
|
-
|
|
195
|
+
A **patch bump** is a fix — no API changes:
|
|
172
196
|
- Fixing a broken style
|
|
173
197
|
- Fixing a component behaviour bug
|
|
174
198
|
- Updating documentation
|
|
175
199
|
|
|
176
200
|
### When to go from `0.x.x` to `1.0.0`
|
|
177
201
|
|
|
178
|
-
Stay on `0.x.x` while the API is still being shaped. Once
|
|
202
|
+
Stay on `0.x.x` while the API is still being shaped. Once components have been used in a real project and props feel settled, ship `1.0.0`:
|
|
179
203
|
|
|
180
204
|
```bash
|
|
181
205
|
npm version 1.0.0
|
|
@@ -183,8 +207,6 @@ npm publish
|
|
|
183
207
|
git push && git push --tags
|
|
184
208
|
```
|
|
185
209
|
|
|
186
|
-
From `1.0.0` onwards the rules above are strictly enforced.
|
|
187
|
-
|
|
188
210
|
---
|
|
189
211
|
|
|
190
212
|
## Contributing (for library maintainers)
|
|
@@ -193,7 +215,7 @@ From `1.0.0` onwards the rules above are strictly enforced.
|
|
|
193
215
|
# Run the documentation site locally
|
|
194
216
|
npm run dev
|
|
195
217
|
|
|
196
|
-
# Build the library
|
|
218
|
+
# Build the library only
|
|
197
219
|
npm run build:lib
|
|
198
220
|
|
|
199
221
|
# The docs site lives in src/app/
|