beacon-ui 3.1.5 → 3.1.8
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/CHANGELOG.md +31 -0
- package/README.md +407 -16
- package/dist/components/Avatar.d.ts +13 -16
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +6 -4
- package/dist/components/Button.d.ts +21 -19
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +100 -80
- package/dist/components/Card.d.ts +8 -11
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +5 -3
- package/dist/components/Checkbox.d.ts +5 -6
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +191 -38
- package/dist/components/Chip.d.ts +6 -9
- package/dist/components/Chip.d.ts.map +1 -1
- package/dist/components/Chip.js +6 -5
- package/dist/components/Input.d.ts +10 -15
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +22 -21
- package/dist/components/Menu.d.ts +9 -6
- package/dist/components/Menu.d.ts.map +1 -1
- package/dist/components/Menu.js +63 -31
- package/dist/components/MenuItem.d.ts +13 -0
- package/dist/components/MenuItem.d.ts.map +1 -0
- package/dist/components/MenuItem.js +90 -0
- package/dist/components/RadioButton.d.ts +6 -8
- package/dist/components/RadioButton.d.ts.map +1 -1
- package/dist/components/RadioButton.js +68 -16
- package/dist/components/Switch.d.ts +5 -6
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +296 -38
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.1.8] - 2025-12-29
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Button component now preserves variant colors (success, critical, warning) when in loading state
|
|
12
|
+
- Previously, buttons would revert to default/primary color when loading was enabled
|
|
13
|
+
- Loading state no longer overrides variant-specific colors
|
|
14
|
+
|
|
15
|
+
## [3.1.7] - 2025-12-29
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- Menu component desktop variant now uses `height: "100%"` by default to fill container height instead of fixed `600px`
|
|
19
|
+
- Custom height can still be set via the `style` prop to override the default behavior
|
|
20
|
+
|
|
21
|
+
## [3.1.6] - 2025-12-29
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- Optional `state` prop to Button component for controlled state management (default, hovered, focused, pressed)
|
|
25
|
+
- Optional `status` prop to Switch, Checkbox, and RadioButton components for controlled state management
|
|
26
|
+
- Components now support both controlled (via props) and uncontrolled (internal state) modes
|
|
27
|
+
- Exported status/state types: `ButtonState`, `SwitchStatus`, `CheckboxStatus`, `RadioButtonStatus`
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- Menu component now uses public `Switch` component API instead of internal `SwitchPreview`
|
|
31
|
+
- Menu component accepts optional `avatarImageUrl` prop instead of hardcoded image path
|
|
32
|
+
- Menu component properly uses theme context for theme and hue values
|
|
33
|
+
- Fixed nested button hydration error in Switch component wrapper
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Menu component falls back to `UserPersonIcon` when `avatarImageUrl` is not provided
|
|
37
|
+
- Button, Switch, Checkbox, and RadioButton components now only update internal state when status/state prop is not provided (controlled pattern)
|
|
38
|
+
|
|
8
39
|
## [3.1.5] - 2025-12-29
|
|
9
40
|
|
|
10
41
|
### Fixed
|
package/README.md
CHANGED
|
@@ -47,30 +47,302 @@ function App() {
|
|
|
47
47
|
### 3. Use Components
|
|
48
48
|
|
|
49
49
|
```tsx
|
|
50
|
-
import { Button,
|
|
50
|
+
import { Button, Checkbox, Switch, Input, Avatar, Chip } from 'beacon-ui';
|
|
51
51
|
|
|
52
52
|
function MyComponent() {
|
|
53
53
|
return (
|
|
54
54
|
<>
|
|
55
|
-
<Button
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
<Button onClick={() => console.log('Clicked!')}>
|
|
56
|
+
Click Me
|
|
57
|
+
</Button>
|
|
58
|
+
|
|
59
|
+
<Checkbox
|
|
60
|
+
checked={true}
|
|
61
|
+
onChange={(checked) => console.log(checked)}
|
|
62
|
+
label="Accept terms"
|
|
63
|
+
showLabel
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<Switch
|
|
67
|
+
checked={false}
|
|
68
|
+
onChange={(checked) => console.log(checked)}
|
|
69
|
+
/>
|
|
70
|
+
</>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Getting Started
|
|
76
|
+
|
|
77
|
+
### Basic Button Usage
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Button } from 'beacon-ui';
|
|
81
|
+
|
|
82
|
+
function MyComponent() {
|
|
83
|
+
return (
|
|
84
|
+
<Button onClick={() => alert('Hello!')}>
|
|
85
|
+
Click Me
|
|
86
|
+
</Button>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Button with Icons
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { Button } from 'beacon-ui';
|
|
95
|
+
import { SearchIcon } from 'beacon-icons';
|
|
96
|
+
|
|
97
|
+
function SearchButton() {
|
|
98
|
+
return (
|
|
99
|
+
<Button
|
|
100
|
+
startIcon={<SearchIcon size="xs" />}
|
|
101
|
+
onClick={() => console.log('Search')}
|
|
102
|
+
>
|
|
103
|
+
Search
|
|
104
|
+
</Button>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Button Variants
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { Button } from 'beacon-ui';
|
|
113
|
+
|
|
114
|
+
function ButtonVariants() {
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
<Button variant="filled">Filled</Button>
|
|
118
|
+
<Button variant="tonal">Tonal</Button>
|
|
119
|
+
<Button variant="outline">Outline</Button>
|
|
120
|
+
<Button variant="link">Link</Button>
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Button Sizes
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { Button } from 'beacon-ui';
|
|
130
|
+
|
|
131
|
+
function ButtonSizes() {
|
|
132
|
+
return (
|
|
133
|
+
<>
|
|
134
|
+
<Button size="xs">Extra Small</Button>
|
|
135
|
+
<Button size="sm">Small</Button>
|
|
136
|
+
<Button size="md">Medium</Button>
|
|
137
|
+
<Button size="lg">Large</Button>
|
|
138
|
+
<Button size="xl">Extra Large</Button>
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Button States
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { Button } from 'beacon-ui';
|
|
148
|
+
|
|
149
|
+
function ButtonStates() {
|
|
150
|
+
return (
|
|
151
|
+
<>
|
|
152
|
+
<Button>Default</Button>
|
|
153
|
+
<Button disabled>Disabled</Button>
|
|
154
|
+
<Button loading>Loading</Button>
|
|
155
|
+
</>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Form Input
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { Input } from 'beacon-ui';
|
|
164
|
+
import { SearchIcon } from 'beacon-icons';
|
|
165
|
+
|
|
166
|
+
function SearchInput() {
|
|
167
|
+
const [value, setValue] = useState('');
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<Input
|
|
171
|
+
label="Search"
|
|
172
|
+
placeholder="Enter search term"
|
|
173
|
+
value={value}
|
|
174
|
+
onChange={(e) => setValue(e.target.value)}
|
|
175
|
+
startIcon={<SearchIcon size={16} />}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Checkbox
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { Checkbox } from 'beacon-ui';
|
|
185
|
+
|
|
186
|
+
function TermsCheckbox() {
|
|
187
|
+
const [accepted, setAccepted] = useState(false);
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<Checkbox
|
|
191
|
+
checked={accepted}
|
|
192
|
+
onChange={setAccepted}
|
|
193
|
+
label="I accept the terms and conditions"
|
|
194
|
+
showLabel
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Switch
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import { Switch } from 'beacon-ui';
|
|
204
|
+
|
|
205
|
+
function NotificationSwitch() {
|
|
206
|
+
const [enabled, setEnabled] = useState(false);
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<Switch
|
|
210
|
+
checked={enabled}
|
|
211
|
+
onChange={setEnabled}
|
|
212
|
+
aria-label="Enable notifications"
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Avatar
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
import { Avatar } from 'beacon-ui';
|
|
222
|
+
|
|
223
|
+
function UserAvatar() {
|
|
224
|
+
return (
|
|
225
|
+
<>
|
|
226
|
+
<Avatar type="icon" size="md" color="primary" />
|
|
227
|
+
<Avatar type="text" initials="JD" size="md" color="primary" />
|
|
228
|
+
<Avatar type="image" imageUrl="/avatar.jpg" size="md" />
|
|
229
|
+
</>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Chip
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { Chip } from 'beacon-ui';
|
|
238
|
+
import { ListDetailsIcon } from 'beacon-icons';
|
|
239
|
+
|
|
240
|
+
function Tags() {
|
|
241
|
+
return (
|
|
242
|
+
<>
|
|
243
|
+
<Chip label="React" color="primary" />
|
|
244
|
+
<Chip label="TypeScript" color="success" />
|
|
245
|
+
<Chip
|
|
246
|
+
label="Design System"
|
|
247
|
+
color="neutral"
|
|
248
|
+
icon={<ListDetailsIcon size={20} />}
|
|
66
249
|
/>
|
|
67
|
-
<Checkbox checked={true} onChange={(checked) => console.log(checked)} />
|
|
68
|
-
<Switch checked={false} onChange={(checked) => console.log(checked)} />
|
|
69
250
|
</>
|
|
70
251
|
);
|
|
71
252
|
}
|
|
72
253
|
```
|
|
73
254
|
|
|
255
|
+
## Common Patterns
|
|
256
|
+
|
|
257
|
+
### Form with Validation
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
import { Input, Button } from 'beacon-ui';
|
|
261
|
+
|
|
262
|
+
function LoginForm() {
|
|
263
|
+
const [email, setEmail] = useState('');
|
|
264
|
+
const [error, setError] = useState('');
|
|
265
|
+
|
|
266
|
+
const handleSubmit = () => {
|
|
267
|
+
if (!email.includes('@')) {
|
|
268
|
+
setError('Invalid email address');
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
// Submit form
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<form onSubmit={(e) => { e.preventDefault(); handleSubmit(); }}>
|
|
276
|
+
<Input
|
|
277
|
+
label="Email"
|
|
278
|
+
type="email"
|
|
279
|
+
value={email}
|
|
280
|
+
onChange={(e) => {
|
|
281
|
+
setEmail(e.target.value);
|
|
282
|
+
setError('');
|
|
283
|
+
}}
|
|
284
|
+
showError={!!error}
|
|
285
|
+
errorMessage={error}
|
|
286
|
+
/>
|
|
287
|
+
<Button type="submit">Submit</Button>
|
|
288
|
+
</form>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Theme Toggle
|
|
294
|
+
|
|
295
|
+
```tsx
|
|
296
|
+
import { useTheme, Button } from 'beacon-ui';
|
|
297
|
+
|
|
298
|
+
function ThemeToggle() {
|
|
299
|
+
const { theme, toggleTheme } = useTheme();
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
<Button onClick={toggleTheme}>
|
|
303
|
+
Switch to {theme === 'dark' ? 'Light' : 'Dark'} Mode
|
|
304
|
+
</Button>
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Accessible Form Controls
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
import { Checkbox, RadioButton, Switch } from 'beacon-ui';
|
|
313
|
+
|
|
314
|
+
function SettingsForm() {
|
|
315
|
+
const [notifications, setNotifications] = useState(false);
|
|
316
|
+
const [selectedOption, setSelectedOption] = useState('option1');
|
|
317
|
+
|
|
318
|
+
return (
|
|
319
|
+
<form>
|
|
320
|
+
<Switch
|
|
321
|
+
checked={notifications}
|
|
322
|
+
onChange={setNotifications}
|
|
323
|
+
aria-label="Enable email notifications"
|
|
324
|
+
/>
|
|
325
|
+
|
|
326
|
+
<RadioButton
|
|
327
|
+
selected={selectedOption === 'option1'}
|
|
328
|
+
onChange={() => setSelectedOption('option1')}
|
|
329
|
+
label="Option 1"
|
|
330
|
+
showLabel
|
|
331
|
+
name="options"
|
|
332
|
+
/>
|
|
333
|
+
|
|
334
|
+
<RadioButton
|
|
335
|
+
selected={selectedOption === 'option2'}
|
|
336
|
+
onChange={() => setSelectedOption('option2')}
|
|
337
|
+
label="Option 2"
|
|
338
|
+
showLabel
|
|
339
|
+
name="options"
|
|
340
|
+
/>
|
|
341
|
+
</form>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
74
346
|
## Components
|
|
75
347
|
|
|
76
348
|
- **Avatar** - User avatars with icon, text, or image support
|
|
@@ -83,6 +355,63 @@ function MyComponent() {
|
|
|
83
355
|
- **Radio Button** - Radio button groups with label support
|
|
84
356
|
- **Switch** - Toggle switches with optional icons
|
|
85
357
|
|
|
358
|
+
## Component APIs
|
|
359
|
+
|
|
360
|
+
### Button
|
|
361
|
+
|
|
362
|
+
```tsx
|
|
363
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
364
|
+
variant?: "filled" | "tonal" | "outline" | "link";
|
|
365
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
366
|
+
cornerRadius?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
367
|
+
startIcon?: React.ReactNode;
|
|
368
|
+
endIcon?: React.ReactNode;
|
|
369
|
+
fillContainer?: boolean;
|
|
370
|
+
loading?: boolean;
|
|
371
|
+
children: React.ReactNode;
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Checkbox
|
|
376
|
+
|
|
377
|
+
```tsx
|
|
378
|
+
interface CheckboxProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange"> {
|
|
379
|
+
checked?: boolean;
|
|
380
|
+
onChange?: (checked: boolean) => void;
|
|
381
|
+
label?: string;
|
|
382
|
+
showLabel?: boolean;
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Switch
|
|
387
|
+
|
|
388
|
+
```tsx
|
|
389
|
+
interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange"> {
|
|
390
|
+
checked?: boolean;
|
|
391
|
+
onChange?: (checked: boolean) => void;
|
|
392
|
+
showIcons?: boolean;
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Input
|
|
397
|
+
|
|
398
|
+
```tsx
|
|
399
|
+
interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
400
|
+
label?: string;
|
|
401
|
+
size?: "sm" | "md" | "lg";
|
|
402
|
+
status?: "default" | "active";
|
|
403
|
+
showLabel?: boolean;
|
|
404
|
+
startIcon?: React.ReactNode;
|
|
405
|
+
endIcon?: React.ReactNode;
|
|
406
|
+
placeholderIcon?: React.ReactNode;
|
|
407
|
+
showError?: boolean;
|
|
408
|
+
errorMessage?: string;
|
|
409
|
+
numberPrefix?: string;
|
|
410
|
+
rounded?: boolean;
|
|
411
|
+
iconOnly?: boolean;
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
86
415
|
## Design Tokens
|
|
87
416
|
|
|
88
417
|
Beacon Design System uses a comprehensive token system:
|
|
@@ -129,6 +458,12 @@ Full TypeScript support with exported types:
|
|
|
129
458
|
|
|
130
459
|
```tsx
|
|
131
460
|
import type {
|
|
461
|
+
ButtonProps,
|
|
462
|
+
CheckboxProps,
|
|
463
|
+
SwitchProps,
|
|
464
|
+
InputProps,
|
|
465
|
+
AvatarProps,
|
|
466
|
+
ChipProps,
|
|
132
467
|
Theme,
|
|
133
468
|
HueVariant,
|
|
134
469
|
ColorPrimitive,
|
|
@@ -156,6 +491,63 @@ Components adapt seamlessly across breakpoints:
|
|
|
156
491
|
- Tablet (max-width: 1024px)
|
|
157
492
|
- Mobile (max-width: 768px)
|
|
158
493
|
|
|
494
|
+
## Troubleshooting
|
|
495
|
+
|
|
496
|
+
### Components not styling correctly
|
|
497
|
+
|
|
498
|
+
Make sure you've imported the tokens CSS:
|
|
499
|
+
|
|
500
|
+
```tsx
|
|
501
|
+
import 'beacon-ui/tokens';
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Theme not applying
|
|
505
|
+
|
|
506
|
+
Ensure your app is wrapped with `ThemeProvider`:
|
|
507
|
+
|
|
508
|
+
```tsx
|
|
509
|
+
import { ThemeProvider } from 'beacon-ui';
|
|
510
|
+
|
|
511
|
+
function App() {
|
|
512
|
+
return (
|
|
513
|
+
<ThemeProvider defaultTheme="dark">
|
|
514
|
+
{/* Your components */}
|
|
515
|
+
</ThemeProvider>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### TypeScript errors
|
|
521
|
+
|
|
522
|
+
All component props extend standard HTML element types, so you can use any standard HTML attributes:
|
|
523
|
+
|
|
524
|
+
```tsx
|
|
525
|
+
<Button
|
|
526
|
+
onClick={handleClick}
|
|
527
|
+
className="my-button"
|
|
528
|
+
id="submit-btn"
|
|
529
|
+
aria-label="Submit form"
|
|
530
|
+
>
|
|
531
|
+
Submit
|
|
532
|
+
</Button>
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### Icons not showing
|
|
536
|
+
|
|
537
|
+
Icons are in a separate package. Install and import them:
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
npm install beacon-icons
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
```tsx
|
|
544
|
+
import { SearchIcon } from 'beacon-icons';
|
|
545
|
+
|
|
546
|
+
<Button startIcon={<SearchIcon size="xs" />}>
|
|
547
|
+
Search
|
|
548
|
+
</Button>
|
|
549
|
+
```
|
|
550
|
+
|
|
159
551
|
## Documentation
|
|
160
552
|
|
|
161
553
|
For detailed documentation, component APIs, and examples, visit:
|
|
@@ -163,7 +555,7 @@ https://beacon.uxraza.com/
|
|
|
163
555
|
|
|
164
556
|
## Version
|
|
165
557
|
|
|
166
|
-
Current version: **3.1.
|
|
558
|
+
Current version: **3.1.5**
|
|
167
559
|
|
|
168
560
|
## License
|
|
169
561
|
|
|
@@ -172,4 +564,3 @@ MIT
|
|
|
172
564
|
## Repository
|
|
173
565
|
|
|
174
566
|
https://github.com/raza-ahmed/beacon
|
|
175
|
-
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
type AvatarSize = "sm" | "md" | "lg" | "xl";
|
|
3
|
-
type AvatarType = "icon" | "text" | "image";
|
|
4
|
-
type AvatarColor = "primary" | "neutral" | "success" | "critical" | "warning";
|
|
5
|
-
type AvatarVariant = "solid" | "faded";
|
|
6
|
-
interface AvatarProps {
|
|
7
|
-
size
|
|
8
|
-
type
|
|
9
|
-
color
|
|
10
|
-
variant
|
|
11
|
-
isRound
|
|
12
|
-
hasStroke
|
|
13
|
-
theme: Theme;
|
|
14
|
-
hue: HueVariant;
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type AvatarSize = "sm" | "md" | "lg" | "xl";
|
|
3
|
+
export type AvatarType = "icon" | "text" | "image";
|
|
4
|
+
export type AvatarColor = "primary" | "neutral" | "success" | "critical" | "warning";
|
|
5
|
+
export type AvatarVariant = "solid" | "faded";
|
|
6
|
+
export interface AvatarProps extends ComponentPropsWithRef<"div"> {
|
|
7
|
+
size?: AvatarSize;
|
|
8
|
+
type?: AvatarType;
|
|
9
|
+
color?: AvatarColor;
|
|
10
|
+
variant?: AvatarVariant;
|
|
11
|
+
isRound?: boolean;
|
|
12
|
+
hasStroke?: boolean;
|
|
15
13
|
initials?: string;
|
|
16
14
|
imageUrl?: string;
|
|
17
15
|
}
|
|
18
|
-
export declare function Avatar({ size, type, color, variant, isRound, hasStroke,
|
|
19
|
-
export {};
|
|
16
|
+
export declare function Avatar({ size, type, color, variant, isRound, hasStroke, initials, imageUrl, className, style, ref, ...rest }: AvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
20
17
|
//# sourceMappingURL=Avatar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../src/components/Avatar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../src/components/Avatar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAqB,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAIjE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACnD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AACrF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AAE9C,MAAM,WAAW,WAAY,SAAQ,qBAAqB,CAAC,KAAK,CAAC;IAC/D,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAwBD,wBAAgB,MAAM,CAAC,EACrB,IAAW,EACX,IAAa,EACb,KAAiB,EACjB,OAAiB,EACjB,OAAe,EACf,SAAiB,EACjB,QAAe,EACf,QAAQ,EACR,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,WAAW,2CAyLb"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
|
+
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
4
5
|
import { UserPersonIcon } from "../icons";
|
|
5
6
|
// Avatar container sizes
|
|
6
7
|
const CONTAINER_SIZE_CONFIG = {
|
|
@@ -21,7 +22,8 @@ const TEXT_SIZE_CONFIG = {
|
|
|
21
22
|
md: { fontSize: "var(--body-regular-text-size)" },
|
|
22
23
|
lg: { fontSize: "var(--heading-h5-text-size)" },
|
|
23
24
|
};
|
|
24
|
-
export function Avatar({ size, type, color, variant, isRound, hasStroke
|
|
25
|
+
export function Avatar({ size = "md", type = "icon", color = "primary", variant = "solid", isRound = false, hasStroke = false, initials = "JD", imageUrl, className, style, ref, ...rest }) {
|
|
26
|
+
useThemeSafe(); // Ensure theme context is available
|
|
25
27
|
const [imageError, setImageError] = useState(false);
|
|
26
28
|
const containerSize = CONTAINER_SIZE_CONFIG[size];
|
|
27
29
|
const avatarStyles = useMemo(() => {
|
|
@@ -137,8 +139,8 @@ export function Avatar({ size, type, color, variant, isRound, hasStroke, theme,
|
|
|
137
139
|
}
|
|
138
140
|
baseStyles.backgroundColor = backgroundColor;
|
|
139
141
|
baseStyles.color = textColor;
|
|
140
|
-
return baseStyles;
|
|
141
|
-
}, [containerSize, isRound, hasStroke, color, variant]);
|
|
142
|
+
return { ...baseStyles, ...style };
|
|
143
|
+
}, [containerSize, isRound, hasStroke, color, variant, style]);
|
|
142
144
|
const handleImageError = () => {
|
|
143
145
|
setImageError(true);
|
|
144
146
|
};
|
|
@@ -170,5 +172,5 @@ export function Avatar({ size, type, color, variant, isRound, hasStroke, theme,
|
|
|
170
172
|
justifyContent: "center",
|
|
171
173
|
}, children: _jsx(UserPersonIcon, { size: iconConfig.size }) }));
|
|
172
174
|
};
|
|
173
|
-
return (_jsx("div", {
|
|
175
|
+
return (_jsx("div", { ref: ref, className: className, style: avatarStyles, ...rest, children: renderContent() }));
|
|
174
176
|
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
type ButtonVariant = "filled" | "tonal" | "outline" | "link";
|
|
3
|
-
type ButtonSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
4
|
-
type CornerRadiusStep = 0 | 1 | 2 | 3 | 4 | 5;
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type ButtonVariant = "filled" | "tonal" | "outline" | "link";
|
|
3
|
+
export type ButtonSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
4
|
+
export type CornerRadiusStep = 0 | 1 | 2 | 3 | 4 | 5;
|
|
5
|
+
export type JustifyContent = "center" | "space-between";
|
|
6
|
+
export type ButtonState = "default" | "hovered" | "focused" | "pressed";
|
|
7
|
+
export type ButtonColor = "primary" | "success" | "critical" | "warning";
|
|
8
|
+
export interface ButtonProps extends Omit<ComponentPropsWithRef<"button">, "type"> {
|
|
9
|
+
variant?: ButtonVariant;
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
cornerRadius?: CornerRadiusStep;
|
|
12
|
+
startIcon?: React.ReactNode;
|
|
13
|
+
endIcon?: React.ReactNode;
|
|
14
|
+
fillContainer?: boolean;
|
|
15
|
+
justifyContent?: JustifyContent;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
state?: ButtonState;
|
|
18
|
+
color?: ButtonColor;
|
|
19
|
+
type?: "button" | "submit" | "reset";
|
|
20
|
+
children: React.ReactNode;
|
|
18
21
|
}
|
|
19
|
-
export declare function Button({ variant, size, cornerRadius,
|
|
20
|
-
export {};
|
|
22
|
+
export declare function Button({ variant, size, cornerRadius, startIcon, endIcon, fillContainer, justifyContent, loading, disabled, state: stateProp, color, type, children, className, style, onClick, onMouseEnter, onMouseLeave, onFocus, onBlur, onMouseDown, onMouseUp, ref, ...rest }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
21
23
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkC,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAI9E,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,eAAe,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AACxE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAChF,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAkED,wBAAgB,MAAM,CAAC,EACrB,OAAkB,EAClB,IAAW,EACX,YAAgB,EAChB,SAAS,EACT,OAAO,EACP,aAAqB,EACrB,cAAyB,EACzB,OAAe,EACf,QAAgB,EAChB,KAAK,EAAE,SAAS,EAChB,KAAiB,EACjB,IAAe,EACf,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,GAAG,EACH,GAAG,IAAI,EACR,EAAE,WAAW,2CAiPb"}
|