@foi/design-system 0.0.10 → 0.0.12
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 +104 -51
- package/dist/DatePicker.utils-ytCEcs6T.js.map +1 -1
- package/dist/{RadioGroup-BGdJ2fTN.js → RadioGroup-CdW6yS38.js} +16 -16
- package/dist/RadioGroup-CdW6yS38.js.map +1 -0
- package/dist/{RadioGroup.context-DJLdImVO.js → RadioGroup.context-BdRgENJJ.js} +7 -7
- package/dist/{RadioGroup.context-DJLdImVO.js.map → RadioGroup.context-BdRgENJJ.js.map} +1 -1
- package/dist/{Switch-BBGFtWQt.js → Switch-C7wjcrjU.js} +36 -36
- package/dist/Switch-C7wjcrjU.js.map +1 -0
- package/dist/{ThemeProvider-DtW2BY15.js → ThemeProvider-JlN3U_r2.js} +2 -2
- package/dist/{ThemeProvider-DtW2BY15.js.map → ThemeProvider-JlN3U_r2.js.map} +1 -1
- package/dist/atoms.mjs +2 -2
- package/dist/components/atoms/Button/Button.interface.d.ts +5 -1
- package/dist/components/atoms/Button/index.d.ts +1 -1
- package/dist/components/atoms/Checkbox/Checkbox.interface.d.ts +5 -1
- package/dist/components/atoms/Checkbox/index.d.ts +1 -1
- package/dist/components/atoms/DatePicker/DatePicker.interface.d.ts +4 -0
- package/dist/components/atoms/DatePicker/index.d.ts +1 -1
- package/dist/components/atoms/IconButton/IconButton.interface.d.ts +5 -1
- package/dist/components/atoms/IconButton/index.d.ts +1 -1
- package/dist/components/atoms/Input/Input.interface.d.ts +5 -1
- package/dist/components/atoms/Input/index.d.ts +1 -1
- package/dist/components/atoms/Radio/Radio.interface.d.ts +4 -0
- package/dist/components/atoms/Radio/index.d.ts +1 -1
- package/dist/components/atoms/Select/Select.interface.d.ts +4 -0
- package/dist/components/atoms/Select/index.d.ts +1 -1
- package/dist/components/atoms/Slider/Slider.interface.d.ts +4 -0
- package/dist/components/atoms/Slider/index.d.ts +1 -1
- package/dist/components/atoms/Switch/Switch.interface.d.ts +5 -1
- package/dist/components/atoms/Switch/index.d.ts +1 -1
- package/dist/components/molecules/CheckboxGroup/CheckboxGroup.interface.d.ts +4 -0
- package/dist/components/molecules/CheckboxGroup/index.d.ts +1 -1
- package/dist/components/molecules/CheckboxTree/CheckboxTree.interface.d.ts +4 -0
- package/dist/components/molecules/CheckboxTree/index.d.ts +1 -1
- package/dist/components/molecules/RadioGroup/RadioGroup.interface.d.ts +4 -0
- package/dist/components/molecules/RadioGroup/index.d.ts +1 -1
- package/dist/{emotion-react-jsx-runtime.browser.esm-BFNmScj4.js → emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js} +169 -167
- package/dist/emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js.map +1 -0
- package/dist/hocs/ThemeProvider/ThemeProvider.interface.d.ts +2 -2
- package/dist/hocs/ThemeProvider/components/Button.d.ts +17 -27
- package/dist/hocs/ThemeProvider/components/Checkbox.d.ts +23 -45
- package/dist/hocs/ThemeProvider/components/CheckboxGroup.d.ts +11 -14
- package/dist/hocs/ThemeProvider/components/CheckboxTree.d.ts +11 -14
- package/dist/hocs/ThemeProvider/components/DatePicker.d.ts +23 -45
- package/dist/hocs/ThemeProvider/components/DatePickerMenu.d.ts +17 -27
- package/dist/hocs/ThemeProvider/components/IconButton.d.ts +20 -28
- package/dist/hocs/ThemeProvider/components/Input.d.ts +23 -45
- package/dist/hocs/ThemeProvider/components/Radio.d.ts +23 -45
- package/dist/hocs/ThemeProvider/components/RadioGroup.d.ts +11 -14
- package/dist/hocs/ThemeProvider/components/Select.d.ts +23 -45
- package/dist/hocs/ThemeProvider/components/SelectMenu.d.ts +16 -24
- package/dist/hocs/ThemeProvider/components/Slider.d.ts +15 -26
- package/dist/hocs/ThemeProvider/components/Switch.d.ts +18 -30
- package/dist/hocs/ThemeProvider/createComponentStyles.d.ts +2 -1
- package/dist/hocs/ThemeProvider/useThemeProvider.hook.d.ts +1 -1
- package/dist/hocs.mjs +1 -1
- package/dist/index.mjs +5 -5
- package/dist/molecules.mjs +1 -1
- package/dist/theme/dark/colors.d.ts +0 -8
- package/dist/theme/dark/components/Button.d.ts +29 -27
- package/dist/theme/dark/components/Checkbox.d.ts +117 -54
- package/dist/theme/dark/components/CheckboxGroup.d.ts +13 -11
- package/dist/theme/dark/components/CheckboxTree.d.ts +12 -10
- package/dist/theme/dark/components/DatePicker.d.ts +53 -51
- package/dist/theme/dark/components/DatePickerMenu.d.ts +24 -22
- package/dist/theme/dark/components/IconButton.d.ts +24 -22
- package/dist/theme/dark/components/Input.d.ts +53 -51
- package/dist/theme/dark/components/Radio.d.ts +56 -54
- package/dist/theme/dark/components/RadioGroup.d.ts +13 -11
- package/dist/theme/dark/components/Select.d.ts +53 -51
- package/dist/theme/dark/components/SelectMenu.d.ts +23 -21
- package/dist/theme/dark/components/Slider.d.ts +41 -39
- package/dist/theme/dark/components/Switch.d.ts +49 -47
- package/dist/theme/dark/components/index.d.ts +567 -478
- package/dist/theme/dark/index.d.ts +567 -478
- package/dist/theme/index.d.ts +567 -478
- package/dist/{theme-DEqiATmv.js → theme-D18AZjTt.js} +112 -61
- package/dist/theme-D18AZjTt.js.map +1 -0
- package/dist/theme.mjs +1 -1
- package/package.json +1 -1
- package/dist/RadioGroup-BGdJ2fTN.js.map +0 -1
- package/dist/Switch-BBGFtWQt.js.map +0 -1
- package/dist/emotion-react-jsx-runtime.browser.esm-BFNmScj4.js.map +0 -1
- package/dist/theme-DEqiATmv.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,17 +4,16 @@ A component library built with React 19 and TypeScript. Components are designed
|
|
|
4
4
|
|
|
5
5
|
## Tech stack
|
|
6
6
|
|
|
7
|
-
| Tool
|
|
8
|
-
|
|
9
|
-
| React
|
|
10
|
-
| TypeScript
|
|
11
|
-
| Vite
|
|
12
|
-
| Emotion
|
|
13
|
-
| React Hook Form | 7
|
|
14
|
-
| Zod
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
| Vitest | 4 | Unit tests |
|
|
7
|
+
| Tool | Version | Purpose |
|
|
8
|
+
| --------------- | ------- | ----------------------- |
|
|
9
|
+
| React | 19 | UI runtime |
|
|
10
|
+
| TypeScript | 6 | Type safety |
|
|
11
|
+
| Vite | 8 | Dev server & bundler |
|
|
12
|
+
| Emotion | 11 | CSS-in-JS styling |
|
|
13
|
+
| React Hook Form | 7 | Form state & validation |
|
|
14
|
+
| Zod | 4 | Schema validation |
|
|
15
|
+
| Storybook | 10 | Component explorer |
|
|
16
|
+
| Vitest | 4 | Unit tests |
|
|
18
17
|
|
|
19
18
|
## Commands
|
|
20
19
|
|
|
@@ -43,25 +42,26 @@ npm publish --access public
|
|
|
43
42
|
|
|
44
43
|
### Atoms
|
|
45
44
|
|
|
46
|
-
| Component
|
|
47
|
-
|
|
48
|
-
| `Button`
|
|
49
|
-
| `Checkbox`
|
|
50
|
-
| `DatePicker` | Date input with calendar menu, integrates with RHF
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
45
|
+
| Component | Description |
|
|
46
|
+
| ------------ | ------------------------------------------------------------------- |
|
|
47
|
+
| `Button` | Primary action button with variant/size/color support |
|
|
48
|
+
| `Checkbox` | Single checkbox — standalone, RHF, or inside a group |
|
|
49
|
+
| `DatePicker` | Date input with calendar menu, integrates with RHF |
|
|
50
|
+
| `Icon` | Font-based icon using Material Symbols Rounded — pass a `name` prop |
|
|
51
|
+
| `IconButton` | Clickable icon with button semantics |
|
|
52
|
+
| `Input` | Text input field with label, helper text, and error state |
|
|
53
|
+
| `Radio` | Single radio button — used inside `RadioGroup` |
|
|
54
|
+
| `Select` | Dropdown select with RHF integration |
|
|
55
|
+
| `Slider` | Range slider with RHF integration |
|
|
56
|
+
| `Switch` | Toggle switch — boolean RHF field |
|
|
57
57
|
|
|
58
58
|
### Molecules
|
|
59
59
|
|
|
60
|
-
| Component
|
|
61
|
-
|
|
60
|
+
| Component | Description |
|
|
61
|
+
| --------------- | -------------------------------------------------------------- |
|
|
62
62
|
| `CheckboxGroup` | Manages a set of `Checkbox` children as a `string[]` RHF field |
|
|
63
|
-
| `CheckboxTree`
|
|
64
|
-
| `RadioGroup`
|
|
63
|
+
| `CheckboxTree` | Hierarchical checkbox group with parent/child selection logic |
|
|
64
|
+
| `RadioGroup` | Manages a set of `Radio` children as a single RHF field |
|
|
65
65
|
|
|
66
66
|
## Usage with React Hook Form
|
|
67
67
|
|
|
@@ -76,7 +76,7 @@ import Button from '@components/atoms/Button';
|
|
|
76
76
|
|
|
77
77
|
const schema = z.object({
|
|
78
78
|
email: z.string().email('Invalid email'),
|
|
79
|
-
age:
|
|
79
|
+
age: z.number().min(18, 'Must be 18 or older'),
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
type FormValues = z.infer<typeof schema>;
|
|
@@ -88,9 +88,9 @@ const MyForm = () => {
|
|
|
88
88
|
|
|
89
89
|
return (
|
|
90
90
|
<form onSubmit={handleSubmit(console.log)}>
|
|
91
|
-
<Input name=
|
|
92
|
-
<Input name=
|
|
93
|
-
<Button type=
|
|
91
|
+
<Input name='email' control={control} label='Email' />
|
|
92
|
+
<Input name='age' control={control} label='Age' type='number' />
|
|
93
|
+
<Button type='submit' label='Submit' />
|
|
94
94
|
</form>
|
|
95
95
|
);
|
|
96
96
|
};
|
|
@@ -105,11 +105,11 @@ const schema = z.object({
|
|
|
105
105
|
skills: z.array(z.string()).min(1, 'Select at least one'),
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
<CheckboxGroup name=
|
|
109
|
-
<Checkbox value=
|
|
110
|
-
<Checkbox value=
|
|
111
|
-
<Checkbox value=
|
|
112
|
-
</CheckboxGroup
|
|
108
|
+
<CheckboxGroup name='skills' control={control} label='Skills'>
|
|
109
|
+
<Checkbox value='react' label='React' />
|
|
110
|
+
<Checkbox value='vue' label='Vue' />
|
|
111
|
+
<Checkbox value='svelte' label='Svelte' />
|
|
112
|
+
</CheckboxGroup>;
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
### Controlled mode (no RHF)
|
|
@@ -119,39 +119,92 @@ Pass `checked` + `onChecked` instead of `name`/`control`.
|
|
|
119
119
|
```tsx
|
|
120
120
|
const [agreed, setAgreed] = useState(false);
|
|
121
121
|
|
|
122
|
-
<Checkbox checked={agreed} onChecked={setAgreed} label=
|
|
122
|
+
<Checkbox checked={agreed} onChecked={setAgreed} label='I agree to the terms' />;
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
## Theming
|
|
126
126
|
|
|
127
|
-
Wrap your app in `ThemeProvider` and
|
|
127
|
+
Wrap your app in `ThemeProvider` and pass one or more named themes. The active theme is selected by the `theme` prop and its tokens are injected as CSS custom properties that every component consumes.
|
|
128
128
|
|
|
129
129
|
```tsx
|
|
130
130
|
import ThemeProvider from '@hocs/ThemeProvider';
|
|
131
|
-
import
|
|
131
|
+
import darkTheme from './themes/dark';
|
|
132
132
|
|
|
133
|
-
<ThemeProvider themes={[
|
|
133
|
+
<ThemeProvider themes={[darkTheme]} theme='dark'>
|
|
134
134
|
<App />
|
|
135
|
-
</ThemeProvider
|
|
135
|
+
</ThemeProvider>;
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
### Theme structure
|
|
139
|
+
|
|
140
|
+
A theme is a plain object with a `name`, an optional `fonts` map, and a `components` map. Each component key holds one or more **variants**. Every component must define at least a `DEFAULT` variant; additional variants are optional.
|
|
141
|
+
|
|
142
|
+
Each variant contains:
|
|
143
|
+
|
|
144
|
+
- `ROOT` — static styles applied unconditionally (e.g. `border-radius`)
|
|
145
|
+
- `EVENTS` — styles scoped to interaction states (`ENABLED`, `HOVER`, `FOCUS`, `ERROR`, `DISABLED`, etc.)
|
|
139
146
|
|
|
140
147
|
```ts
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
ROOT: {
|
|
147
|
-
|
|
148
|
+
import type { BUTTON } from '@hocs/ThemeProvider/components/Button';
|
|
149
|
+
|
|
150
|
+
const component = {
|
|
151
|
+
BUTTON: {
|
|
152
|
+
DEFAULT: {
|
|
153
|
+
ROOT: {
|
|
154
|
+
'border-radius': '8px',
|
|
155
|
+
},
|
|
156
|
+
EVENTS: {
|
|
157
|
+
ENABLED: {
|
|
158
|
+
'background-color': '#0070f3',
|
|
159
|
+
'color-primary': '#ffffff',
|
|
160
|
+
},
|
|
161
|
+
HOVER: {
|
|
162
|
+
'background-color': '#005bb5',
|
|
163
|
+
},
|
|
164
|
+
FOCUS: {
|
|
165
|
+
'outline-color': '#93c5fd',
|
|
166
|
+
'outline-width': '2px',
|
|
167
|
+
'outline-style': 'solid',
|
|
168
|
+
'outline-offset': '2px',
|
|
169
|
+
},
|
|
170
|
+
DISABLED: {
|
|
171
|
+
'background-color': '#e5e7eb',
|
|
172
|
+
'color-primary': '#9ca3af',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
DANGER: {
|
|
177
|
+
EVENTS: {
|
|
178
|
+
ENABLED: {
|
|
179
|
+
'background-color': '#dc2626',
|
|
180
|
+
'color-primary': '#ffffff',
|
|
181
|
+
},
|
|
182
|
+
HOVER: {
|
|
183
|
+
'background-color': '#b91c1c',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
148
186
|
},
|
|
149
|
-
// ...other components
|
|
150
187
|
},
|
|
151
|
-
} satisfies
|
|
188
|
+
} as const satisfies BUTTON;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The `satisfies BUTTON` check enforces that `DEFAULT` is present and that every token key is valid for that component. TypeScript reports an error at the theme file if a token is misspelled or if `DEFAULT` is missing.
|
|
192
|
+
|
|
193
|
+
### Selecting a variant
|
|
194
|
+
|
|
195
|
+
Pass the `variant` prop to a component to switch between the variants you defined in the theme. The default is always `'default'`.
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
<Button label='Delete' variant='danger' />
|
|
152
199
|
```
|
|
153
200
|
|
|
154
|
-
|
|
201
|
+
### One-off theme override
|
|
202
|
+
|
|
203
|
+
Any component also accepts a `theme` prop — a partial `EVENTS` object — to override tokens for that single instance without touching the global theme.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
<Button label='Special' theme={{ ENABLED: { 'background-color': '#7c3aed' } }} />
|
|
207
|
+
```
|
|
155
208
|
|
|
156
209
|
## Project structure
|
|
157
210
|
|