addon-ui 0.3.0

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.
Files changed (129) hide show
  1. package/README.md +1197 -0
  2. package/package.json +113 -0
  3. package/src/components/Avatar/Avatar.tsx +56 -0
  4. package/src/components/Avatar/avatar.module.scss +78 -0
  5. package/src/components/Avatar/index.ts +2 -0
  6. package/src/components/Avatar/types.ts +11 -0
  7. package/src/components/BaseButton/BaseButton.tsx +36 -0
  8. package/src/components/BaseButton/base-button.module.scss +24 -0
  9. package/src/components/BaseButton/index.ts +1 -0
  10. package/src/components/Button/Button.tsx +51 -0
  11. package/src/components/Button/button.module.scss +140 -0
  12. package/src/components/Button/index.ts +2 -0
  13. package/src/components/Button/types.ts +24 -0
  14. package/src/components/Checkbox/Checkbox.tsx +58 -0
  15. package/src/components/Checkbox/checkbox.module.scss +82 -0
  16. package/src/components/Checkbox/index.ts +2 -0
  17. package/src/components/Checkbox/types.ts +15 -0
  18. package/src/components/Dialog/Dialog.tsx +126 -0
  19. package/src/components/Dialog/dialog.module.scss +55 -0
  20. package/src/components/Dialog/index.ts +1 -0
  21. package/src/components/Drawer/Drawer.tsx +53 -0
  22. package/src/components/Drawer/drawer.module.scss +170 -0
  23. package/src/components/Drawer/index.ts +2 -0
  24. package/src/components/Drawer/types.ts +6 -0
  25. package/src/components/Footer/Footer.tsx +59 -0
  26. package/src/components/Footer/footer.module.scss +45 -0
  27. package/src/components/Footer/index.ts +1 -0
  28. package/src/components/Header/Header.tsx +74 -0
  29. package/src/components/Header/header.module.scss +56 -0
  30. package/src/components/Header/index.ts +1 -0
  31. package/src/components/Highlight/Highlight.tsx +36 -0
  32. package/src/components/Highlight/highlight.module.scss +48 -0
  33. package/src/components/Highlight/index.ts +2 -0
  34. package/src/components/Highlight/types.ts +5 -0
  35. package/src/components/Icon/Icon.tsx +46 -0
  36. package/src/components/Icon/icon.module.scss +17 -0
  37. package/src/components/Icon/index.ts +1 -0
  38. package/src/components/IconButton/IconButton.tsx +50 -0
  39. package/src/components/IconButton/icon-button.module.scss +86 -0
  40. package/src/components/IconButton/index.ts +2 -0
  41. package/src/components/IconButton/types.ts +17 -0
  42. package/src/components/Layout/Provider.tsx +60 -0
  43. package/src/components/Layout/context.ts +24 -0
  44. package/src/components/Layout/index.ts +2 -0
  45. package/src/components/Layout/layout.module.scss +17 -0
  46. package/src/components/List/List.tsx +24 -0
  47. package/src/components/List/index.ts +1 -0
  48. package/src/components/List/list.module.scss +8 -0
  49. package/src/components/ListItem/ListItem.tsx +75 -0
  50. package/src/components/ListItem/index.ts +1 -0
  51. package/src/components/ListItem/list-item.module.scss +37 -0
  52. package/src/components/Modal/Modal.tsx +90 -0
  53. package/src/components/Modal/index.ts +2 -0
  54. package/src/components/Modal/modal.module.scss +97 -0
  55. package/src/components/Modal/types.ts +6 -0
  56. package/src/components/Odometer/Odometer.tsx +45 -0
  57. package/src/components/Odometer/hooks/useOdometer.tsx +24 -0
  58. package/src/components/Odometer/index.ts +2 -0
  59. package/src/components/Odometer/odometer.module.scss +81 -0
  60. package/src/components/Odometer/odometr.d.ts +9 -0
  61. package/src/components/ScrollArea/ScrollArea.tsx +75 -0
  62. package/src/components/ScrollArea/index.ts +1 -0
  63. package/src/components/ScrollArea/scroll-area.module.scss +58 -0
  64. package/src/components/SvgSprite/SvgSprite.tsx +21 -0
  65. package/src/components/SvgSprite/index.ts +1 -0
  66. package/src/components/Switch/Switch.tsx +24 -0
  67. package/src/components/Switch/index.ts +1 -0
  68. package/src/components/Switch/switch.module.scss +65 -0
  69. package/src/components/Tag/Tag.tsx +50 -0
  70. package/src/components/Tag/index.ts +2 -0
  71. package/src/components/Tag/tag.module.scss +118 -0
  72. package/src/components/Tag/types.ts +23 -0
  73. package/src/components/TextArea/TextArea.tsx +126 -0
  74. package/src/components/TextArea/index.ts +2 -0
  75. package/src/components/TextArea/text-area.module.scss +88 -0
  76. package/src/components/TextArea/types.ts +18 -0
  77. package/src/components/TextField/TextField.tsx +139 -0
  78. package/src/components/TextField/index.ts +2 -0
  79. package/src/components/TextField/text-field.module.scss +129 -0
  80. package/src/components/TextField/types.ts +24 -0
  81. package/src/components/Toast/Toast.tsx +124 -0
  82. package/src/components/Toast/index.ts +2 -0
  83. package/src/components/Toast/toast.module.scss +267 -0
  84. package/src/components/Toast/types.ts +20 -0
  85. package/src/components/Tooltip/Tooltip.tsx +82 -0
  86. package/src/components/Tooltip/index.ts +1 -0
  87. package/src/components/Tooltip/tooltip.module.scss +123 -0
  88. package/src/components/View/View.tsx +68 -0
  89. package/src/components/View/index.ts +1 -0
  90. package/src/components/View/view.module.scss +38 -0
  91. package/src/components/ViewDrawer/ViewDrawer.tsx +24 -0
  92. package/src/components/ViewDrawer/index.ts +1 -0
  93. package/src/components/ViewModal/ViewModal.tsx +24 -0
  94. package/src/components/ViewModal/index.ts +1 -0
  95. package/src/components/index.ts +27 -0
  96. package/src/components/types.ts +65 -0
  97. package/src/config/default.ts +3 -0
  98. package/src/config/index.ts +8 -0
  99. package/src/declaration.d.ts +8 -0
  100. package/src/index.ts +3 -0
  101. package/src/plugin/builder/ConfigBuilder.ts +32 -0
  102. package/src/plugin/builder/StyleBuilder.ts +35 -0
  103. package/src/plugin/builder/virtual.config.ts +5 -0
  104. package/src/plugin/finder/ConfigFinder.ts +26 -0
  105. package/src/plugin/finder/Finder.ts +76 -0
  106. package/src/plugin/finder/StyleFinder.ts +23 -0
  107. package/src/plugin/index.ts +73 -0
  108. package/src/plugin/types.ts +8 -0
  109. package/src/providers/extra/ExtraProvider.tsx +13 -0
  110. package/src/providers/extra/context.ts +14 -0
  111. package/src/providers/extra/index.ts +2 -0
  112. package/src/providers/icons/IconsProvider.tsx +35 -0
  113. package/src/providers/icons/context.ts +20 -0
  114. package/src/providers/icons/index.ts +2 -0
  115. package/src/providers/index.ts +4 -0
  116. package/src/providers/theme/ThemeProvider.tsx +60 -0
  117. package/src/providers/theme/ThemeStorage.tsx +36 -0
  118. package/src/providers/theme/context.ts +30 -0
  119. package/src/providers/theme/index.ts +3 -0
  120. package/src/providers/ui/UIProvider.tsx +41 -0
  121. package/src/providers/ui/index.ts +1 -0
  122. package/src/providers/ui/styles/default.scss +95 -0
  123. package/src/providers/ui/styles/reset.scss +127 -0
  124. package/src/styles/mixins.scss +23 -0
  125. package/src/types/config.ts +15 -0
  126. package/src/types/theme.ts +11 -0
  127. package/src/utils/index.ts +2 -0
  128. package/src/utils/react.ts +21 -0
  129. package/src/utils/utils.ts +12 -0
package/README.md ADDED
@@ -0,0 +1,1197 @@
1
+ # Addon UI (addon-ui)
2
+
3
+ [![npm version](https://img.shields.io/npm/v/addon-ui.svg)](https://www.npmjs.com/package/addon-ui)
4
+ [![npm downloads](https://img.shields.io/npm/dm/addon-ui.svg)](https://www.npmjs.com/package/addon-ui)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ A comprehensive UI component library designed for the Addon Bone framework.
8
+ This library provides a set of customizable React components with theming capabilities to build modern,
9
+ responsive user interfaces.
10
+
11
+ ## Features
12
+
13
+ - 🎨 **Customizable Theming**: Easily customize the look and feel of components through theme configuration
14
+ - 🧩 **Rich Component Set**: Includes buttons, forms, layouts, modals, and more
15
+ - 🔌 **Addon Bone Integration**: Seamless integration with the Addon Bone framework
16
+ - 📚 **Storybook Documentation**: Comprehensive component documentation with examples
17
+ - 🛠️ **TypeScript Support**: Full TypeScript support with type definitions
18
+
19
+ ## Table of Contents
20
+
21
+ - [Installation](#installation)
22
+ - [Basic Usage](#basic-usage)
23
+ - [Integration](#integration)
24
+ - [Customization](#customization)
25
+ - [Using Extra Props](#using-extra-props)
26
+ - [Component Examples](#component-examples)
27
+ - [Supported Components](#supported-components)
28
+ - [Avatar](#avatar)
29
+ - [BaseButton](#basebutton)
30
+ - [Button](#button)
31
+ - [Checkbox](#checkbox)
32
+ - [Dialog](#dialog)
33
+ - [Drawer](#drawer)
34
+ - [Footer](#footer)
35
+ - [Header](#header)
36
+ - [Highlight](#highlight)
37
+ - [Icon](#icon)
38
+ - [IconButton](#iconbutton)
39
+ - [Layout](#layout)
40
+ - [List](#list)
41
+ - [ListItem](#listitem)
42
+ - [Modal](#modal)
43
+ - [Odometer](#odometer)
44
+ - [ScrollArea](#scrollarea)
45
+ - [SvgSprite](#svgsprite)
46
+ - [Switch](#switch)
47
+ - [Tag](#tag)
48
+ - [TextArea](#textarea)
49
+ - [TextField](#textfield)
50
+ - [Toast](#toast)
51
+ - [Tooltip](#tooltip)
52
+ - [View](#view)
53
+ - [ViewDrawer](#viewdrawer)
54
+ - [ViewModal](#viewmodal)
55
+ - [License](#license)
56
+
57
+ ## Installation
58
+
59
+ Using npm:
60
+
61
+ ```bash
62
+ npm install addon-ui
63
+ ```
64
+
65
+ Using Yarn:
66
+
67
+ ```bash
68
+ yarn add addon-ui
69
+ ```
70
+
71
+ ## Basic Usage
72
+
73
+ ```jsx
74
+ import React from "react";
75
+ import {Button, ButtonColor, ButtonVariant, TextField, UIProvider} from "addon-ui";
76
+
77
+ function App() {
78
+ return (
79
+ <UIProvider>
80
+ <div>
81
+ <TextField label="Username" placeholder="Enter your username" />
82
+ <Button color={ButtonColor.Primary} variant={ButtonVariant.Contained}>
83
+ Submit
84
+ </Button>
85
+ </div>
86
+ </UIProvider>
87
+ );
88
+ }
89
+
90
+ export default App;
91
+ ```
92
+
93
+ ## Integration
94
+
95
+ **Addon UI** is designed exclusively for the Addon Bone framework and does not have a standalone build as it's connected as a plugin. This library is an integral part of the Addon Bone ecosystem for developing browser extensions with a shared codebase.
96
+
97
+ Addon Bone is a framework for developing browser extensions with a common codebase. This means you can create multiple extensions with the same functionality but with different designs, localizations, and feature sets depending on the needs of each extension while maintaining access to a shared codebase.
98
+
99
+ ### Plugin Setup
100
+
101
+ ```ts
102
+ // adnbn.config.ts
103
+ import {defineConfig} from "adnbn";
104
+ import ui from "addon-ui/plugin";
105
+
106
+ export default defineConfig({
107
+ plugins: [
108
+ ui({
109
+ themeDir: "./theme", // Directory for theme files
110
+ configFileName: "ui.config", // Name of config files
111
+ styleFileName: "ui.style", // Name of style files
112
+ mergeConfig: true, // Merge configs from different directories
113
+ mergeStyles: true, // Merge styles from different directories
114
+ }),
115
+ ],
116
+ });
117
+ ```
118
+
119
+ ### Configuration Files
120
+
121
+ The `addon-ui` configuration is designed to retrieve configuration from each extension separately, allowing for different designs for different extensions without changing any code. You only need to modify the configuration, style variables, and icons.
122
+
123
+ The plugin looks for configuration files in specific directories within your project. By default, it searches in the following locations (in order of priority):
124
+
125
+ 1. **App-specific directory**: `src/apps/[app-name]/[app-src-dir]/[theme-dir]`
126
+ 2. **Shared directory**: `src/shared/[theme-dir]`
127
+
128
+ Where `[theme-dir]` is the directory specified in the `themeDir` option (defaults to the current directory).
129
+
130
+ The `mergeConfig` option (default: `true`) determines whether configurations from multiple directories should be merged. When enabled, configurations from both app-specific and shared directories will be combined, with app-specific values taking precedence in case of conflicts. If disabled, only the first configuration found will be used (with app-specific having priority).
131
+
132
+ You can create these files to customize the UI components:
133
+
134
+ #### ui.config.ts
135
+
136
+ You can use the `defineConfig` helper which provides type checking:
137
+
138
+ ```ts
139
+ // src/shared/theme/ui.config.ts
140
+ import {defineConfig} from "addon-ui/config";
141
+ import {ButtonColor, ButtonRadius, ButtonVariant, TextFieldRadius, TextFieldSize} from "addon-ui";
142
+
143
+ import CloseIcon from "./icons/close.svg?react";
144
+
145
+ export default defineConfig({
146
+ components: {
147
+ button: {
148
+ variant: ButtonVariant.Contained,
149
+ color: ButtonColor.Primary,
150
+ radius: ButtonRadius.Medium,
151
+ },
152
+ textField: {
153
+ size: TextFieldSize.Medium,
154
+ radius: TextFieldRadius.Small,
155
+ },
156
+ // ... other component configurations
157
+ },
158
+ icons: {
159
+ close: CloseIcon,
160
+ // Other custom icons
161
+ },
162
+ });
163
+ ```
164
+
165
+ The example above shows how to use the TypeScript configuration with the Addon Bone framework.
166
+ The `defineConfig` helper provides type checking and autocompletion for your configuration.
167
+ You can import enum values from "addon-ui/config" to ensure type safety when configuring components.
168
+ The configuration can also include SVG icons imported directly from your project files.
169
+
170
+ #### ui.style.scss
171
+
172
+ Similar to configuration files, style files are also searched for in the same directories with the same priority order. The `mergeStyles` option (default: `true`) works the same way as `mergeConfig`, allowing styles from multiple directories to be combined when enabled.
173
+
174
+ ```scss
175
+ // src/shared/theme/ui.style.scss
176
+ // Custom CSS variables and mixins for theming
177
+ @import "addon-ui/theme";
178
+
179
+ @include light {
180
+ // Base colors
181
+ --primary-color: #3f51b5;
182
+ --secondary-color: #f50057;
183
+ --accent-color: #4caf50;
184
+
185
+ // Text colors
186
+ --text-primary-color: #212121;
187
+ --text-secondary-color: #757575;
188
+
189
+ // Background colors
190
+ --bg-primary-color: #ffffff;
191
+ --bg-secondary-color: #f5f5f5;
192
+
193
+ // Font settings
194
+ --font-family: "Roboto", sans-serif;
195
+ --font-size: 14px;
196
+ --line-height: 1.5;
197
+
198
+ // Button specific variables
199
+ --button-font-family: var(--font-family);
200
+ --button-font-size: var(--font-size);
201
+ --button-height: 34px;
202
+ --button-border-radius: 10px;
203
+
204
+ // Button size variants
205
+ --button-height-sm: 24px;
206
+ --button-height-md: 44px;
207
+ --button-height-lg: 54px;
208
+
209
+ // Button radius variants
210
+ --button-border-radius-sm: 5px;
211
+ --button-border-radius-md: 12px;
212
+ --button-border-radius-lg: 15px;
213
+ }
214
+
215
+ @include dark {
216
+ // Base colors for dark theme
217
+ --primary-color: #7986cb;
218
+ --secondary-color: #ff4081;
219
+ --accent-color: #66bb6a;
220
+
221
+ // Text colors for dark theme
222
+ --text-primary-color: #ffffff;
223
+ --text-secondary-color: #b0bec5;
224
+
225
+ // Background colors for dark theme
226
+ --bg-primary-color: #121212;
227
+ --bg-secondary-color: #1e1e1e;
228
+ }
229
+ ```
230
+
231
+ ## Customization
232
+
233
+ The `addon-ui` library allows for extensive customization to create different designs for different extensions without changing code. This is particularly useful in the Addon Bone framework where you might need to maintain multiple browser extensions with the same functionality but different visual appearances.
234
+
235
+ ### Global Theme Customization
236
+
237
+ You can customize the theme globally by passing props to the UIProvider:
238
+
239
+ ```jsx
240
+ import {UIProvider} from "addon-ui";
241
+
242
+ const customTheme = {
243
+ components: {
244
+ button: {
245
+ variant: "outlined",
246
+ color: "primary",
247
+ },
248
+ textField: {
249
+ radius: "medium",
250
+ },
251
+ },
252
+ icons: {
253
+ // Custom icons
254
+ },
255
+ };
256
+
257
+ function App() {
258
+ return <UIProvider {...customTheme}>{/* Your application */}</UIProvider>;
259
+ }
260
+ ```
261
+
262
+ ### Using Extra Props
263
+
264
+ Extra Props is a powerful feature that allows you to extend component props with custom properties. This is particularly useful when you need to add custom functionality or data to components across your application without modifying the original component code.
265
+
266
+ #### What are Extra Props?
267
+
268
+ Extra Props provide a way to pass additional properties to components throughout your application using React Context. This allows you to:
269
+
270
+ - Add application-specific properties to UI components
271
+ - Share common data across multiple components
272
+ - Extend the library's components with your own custom properties
273
+
274
+ #### How to Use Extra Props
275
+
276
+ 1. **Configure Extra Props in your theme configuration:**
277
+
278
+ ```ts
279
+ // src/shared/theme/ui.config.ts
280
+ import {defineConfig} from "addon-ui/config";
281
+
282
+ export default defineConfig({
283
+ components: {
284
+ // Component configurations
285
+ },
286
+ extra: {
287
+ // Your custom properties
288
+ appName: "My Awesome App",
289
+ version: "1.0.0",
290
+ features: {
291
+ darkMode: true,
292
+ analytics: false,
293
+ },
294
+ },
295
+ icons: {
296
+ // Icon configurations
297
+ },
298
+ });
299
+ ```
300
+
301
+ 2. **Access Extra Props in your components using the `useExtra` hook:**
302
+
303
+ ```jsx
304
+ import {useExtra} from "addon-ui";
305
+
306
+ function AppHeader() {
307
+ const extra = useExtra();
308
+
309
+ return (
310
+ <header>
311
+ <h1>{extra.appName}</h1>
312
+ <span>Version: {extra.version}</span>
313
+ </header>
314
+ );
315
+ }
316
+ ```
317
+
318
+ #### Example Use Case
319
+
320
+ A common use case for Extra Props is to add application-specific configuration to UI components. For example, you might want to add custom analytics tracking to buttons:
321
+
322
+ ```jsx
323
+ import {Button, useExtra} from "addon-ui";
324
+
325
+ function TrackableButton(props) {
326
+ const extra = useExtra();
327
+
328
+ const handleClick = e => {
329
+ // Use extra props for analytics
330
+ if (extra.features.analytics) {
331
+ trackButtonClick(props.trackingId);
332
+ }
333
+
334
+ // Call the original onClick handler
335
+ props.onClick?.(e);
336
+ };
337
+
338
+ return <Button {...props} onClick={handleClick} />;
339
+ }
340
+ ```
341
+
342
+ #### Extending ExtraProps in TypeScript
343
+
344
+ To get proper type checking for your custom Extra Props, you can extend the `ExtraProps` interface:
345
+
346
+ ```ts
347
+ // ui.d.ts or similar file
348
+ import "addon-ui";
349
+
350
+ declare module "addon-ui" {
351
+ interface ExtraProps {
352
+ appName: string;
353
+ version: string;
354
+ features: {
355
+ darkMode: boolean;
356
+ analytics: boolean;
357
+ };
358
+ // Add any other custom properties
359
+ }
360
+ }
361
+ ```
362
+
363
+ With this type definition, TypeScript will provide proper type checking and autocompletion when using the `useExtra` hook:
364
+
365
+ ```tsx
366
+ import React from "react";
367
+ import {useExtra, Button} from "addon-ui";
368
+
369
+ const FeatureFlag: React.FC<{feature: keyof ExtraProps["features"]; children: React.ReactNode}> = ({
370
+ feature,
371
+ children,
372
+ }) => {
373
+ const extra = useExtra();
374
+
375
+ // TypeScript knows that extra.features exists and has the properties we defined
376
+ if (extra.features[feature]) {
377
+ return <>{children}</>;
378
+ }
379
+
380
+ return null;
381
+ };
382
+
383
+ // Usage
384
+ function App() {
385
+ return (
386
+ <div>
387
+ <FeatureFlag feature="darkMode">
388
+ <Button>Dark Mode Enabled</Button>
389
+ </FeatureFlag>
390
+ </div>
391
+ );
392
+ }
393
+ ```
394
+
395
+ ## Component Examples
396
+
397
+ ### Buttons
398
+
399
+ ```jsx
400
+ import {Button, ButtonColor, ButtonSize, ButtonVariant} from 'addon-ui';
401
+
402
+ // Basic button
403
+ <Button>Click me</Button>
404
+
405
+ // Variants
406
+ <Button variant={ButtonVariant.Contained}>Contained</Button>
407
+ <Button variant={ButtonVariant.Outlined}>Outlined</Button>
408
+ <Button variant={ButtonVariant.Text}>Text</Button>
409
+
410
+ // Colors
411
+ <Button color={ButtonColor.Primary}>Primary</Button>
412
+ <Button color={ButtonColor.Secondary}>Secondary</Button>
413
+ <Button color={ButtonColor.Accent}>Accent</Button>
414
+
415
+ // Sizes
416
+ <Button size={ButtonSize.Small}>Small</Button>
417
+ <Button size={ButtonSize.Medium}>Medium</Button>
418
+ <Button size={ButtonSize.Large}>Large</Button>
419
+
420
+ // Disabled state
421
+ <Button disabled>Disabled</Button>
422
+ ```
423
+
424
+ ### Form Components
425
+
426
+ ```jsx
427
+ import {TextField, TextArea, Checkbox, Switch} from 'addon-ui';
428
+
429
+ // Text input
430
+ <TextField label="Username" placeholder="Enter username" />
431
+
432
+ // Text area
433
+ <TextArea label="Description" placeholder="Enter description" />
434
+
435
+ // Checkbox
436
+ <Checkbox label="Remember me" />
437
+
438
+ // Switch
439
+ <Switch label="Enable notifications" />
440
+ ```
441
+
442
+ ### Layout Components
443
+
444
+ ```jsx
445
+ import {Layout, Header, Footer} from "addon-ui";
446
+
447
+ <Layout>
448
+ <Header>My Application</Header>
449
+ <div>Content goes here</div>
450
+ <Footer>© 2023 My Company</Footer>
451
+ </Layout>;
452
+ ```
453
+
454
+ ### Feedback Components
455
+
456
+ ```jsx
457
+ import {Toast, Modal, Dialog, Drawer} from 'addon-ui';
458
+
459
+ // Toast notification
460
+ <Toast message="Operation successful!" />
461
+
462
+ // Modal dialog
463
+ <Modal open={isOpen} onClose={handleClose}>
464
+ <h2>Modal Title</h2>
465
+ <p>Modal content goes here</p>
466
+ </Modal>
467
+
468
+ // Confirmation dialog
469
+ <Dialog
470
+ title="Confirm Action"
471
+ content="Are you sure you want to proceed?"
472
+ confirmText="Yes"
473
+ cancelText="No"
474
+ onConfirm={handleConfirm}
475
+ onCancel={handleCancel}
476
+ />
477
+
478
+ // Side drawer
479
+ <Drawer open={isOpen} onClose={handleClose} position="right">
480
+ <h2>Drawer Content</h2>
481
+ <p>Drawer content goes here</p>
482
+ </Drawer>
483
+ ```
484
+
485
+ ## Supported Components
486
+
487
+ ### Button
488
+
489
+ The Button component provides a customizable button with various styles, colors, and sizes.
490
+
491
+ #### Props
492
+
493
+ | Prop | Type | Description |
494
+ | ----------------- | ------------- | ----------------------------------------- |
495
+ | variant | ButtonVariant | Button style variant |
496
+ | color | ButtonColor | Button color |
497
+ | size | ButtonSize | Button size |
498
+ | radius | ButtonRadius | Button border radius |
499
+ | after | ReactNode | Content to display after the button text |
500
+ | before | ReactNode | Content to display before the button text |
501
+ | afterClassName | string | Class name for the after content |
502
+ | beforeClassName | string | Class name for the before content |
503
+ | childrenClassName | string | Class name for the children content |
504
+
505
+ #### Enums
506
+
507
+ ```jsx
508
+ // Available variants
509
+ ButtonVariant.Contained;
510
+ ButtonVariant.Outlined;
511
+ ButtonVariant.Text;
512
+
513
+ // Available colors
514
+ ButtonColor.Primary;
515
+ ButtonColor.Secondary;
516
+ ButtonColor.Accent;
517
+
518
+ // Available sizes
519
+ ButtonSize.Small;
520
+ ButtonSize.Medium;
521
+ ButtonSize.Large;
522
+
523
+ // Available radius options
524
+ ButtonRadius.Small;
525
+ ButtonRadius.Medium;
526
+ ButtonRadius.Large;
527
+ ButtonRadius.Full;
528
+ ```
529
+
530
+ #### Example
531
+
532
+ ```jsx
533
+ import {Button, ButtonVariant, ButtonColor, ButtonSize, ButtonRadius} from "addon-ui";
534
+
535
+ <Button
536
+ variant={ButtonVariant.Contained}
537
+ color={ButtonColor.Primary}
538
+ size={ButtonSize.Medium}
539
+ radius={ButtonRadius.Medium}
540
+ >
541
+ Click me
542
+ </Button>;
543
+ ```
544
+
545
+ ### TextField
546
+
547
+ The TextField component provides a customizable text input field with various styles, sizes, and validation states.
548
+
549
+ #### Props
550
+
551
+ | Prop | Type | Description |
552
+ | --------------- | ---------------- | ---------------------------------------- |
553
+ | variant | TextFieldVariant | Input style variant |
554
+ | accent | TextFieldAccent | Input accent color for validation states |
555
+ | radius | TextFieldRadius | Input border radius |
556
+ | customSize | TextFieldSize | Input size |
557
+ | label | string | Input label |
558
+ | fullWidth | boolean | Whether the input should take full width |
559
+ | before | ReactNode | Content to display before the input |
560
+ | after | ReactNode | Content to display after the input |
561
+ | inputClassName | string | Class name for the input element |
562
+ | afterClassName | string | Class name for the after content |
563
+ | beforeClassName | string | Class name for the before content |
564
+
565
+ #### Enums
566
+
567
+ ```jsx
568
+ // Available variants
569
+ TextFieldVariant.Regular;
570
+ TextFieldVariant.Outlined;
571
+ TextFieldVariant.Filled;
572
+
573
+ // Available sizes
574
+ TextFieldSize.Small;
575
+ TextFieldSize.Medium;
576
+ TextFieldSize.Large;
577
+
578
+ // Available radius options
579
+ TextFieldRadius.None;
580
+ TextFieldRadius.Small;
581
+ TextFieldRadius.Medium;
582
+ TextFieldRadius.Large;
583
+ TextFieldRadius.Full;
584
+
585
+ // Available accent options
586
+ TextFieldAccent.Success;
587
+ TextFieldAccent.Error;
588
+ ```
589
+
590
+ #### Example
591
+
592
+ ```jsx
593
+ import {TextField, TextFieldVariant, TextFieldSize, TextFieldRadius, TextFieldAccent} from "addon-ui";
594
+
595
+ <TextField
596
+ variant={TextFieldVariant.Outlined}
597
+ customSize={TextFieldSize.Medium}
598
+ radius={TextFieldRadius.Medium}
599
+ accent={TextFieldAccent.Success}
600
+ label="Username"
601
+ placeholder="Enter your username"
602
+ fullWidth
603
+ />;
604
+ ```
605
+
606
+ ### TextArea
607
+
608
+ The TextArea component provides a customizable multi-line text input with auto-resizing capability.
609
+
610
+ #### Props
611
+
612
+ | Prop | Type | Description |
613
+ | --------- | --------------- | ------------------------------------------- |
614
+ | variant | TextAreaVariant | TextArea style variant |
615
+ | radius | TextAreaRadius | TextArea border radius |
616
+ | size | TextAreaSize | TextArea size |
617
+ | fullWidth | boolean | Whether the textarea should take full width |
618
+ | label | string | TextArea label |
619
+
620
+ #### Enums
621
+
622
+ ```jsx
623
+ // Available variants
624
+ TextAreaVariant.Regular;
625
+ TextAreaVariant.Outlined;
626
+ TextAreaVariant.Filled;
627
+
628
+ // Available sizes
629
+ TextAreaSize.Small;
630
+ TextAreaSize.Medium;
631
+ TextAreaSize.Large;
632
+
633
+ // Available radius options
634
+ TextAreaRadius.None;
635
+ TextAreaRadius.Small;
636
+ TextAreaRadius.Medium;
637
+ TextAreaRadius.Large;
638
+ ```
639
+
640
+ #### Example
641
+
642
+ ```jsx
643
+ import {TextArea, TextAreaVariant, TextAreaSize, TextAreaRadius} from "addon-ui";
644
+
645
+ <TextArea
646
+ variant={TextAreaVariant.Outlined}
647
+ size={TextAreaSize.Medium}
648
+ radius={TextAreaRadius.Medium}
649
+ label="Description"
650
+ placeholder="Enter description"
651
+ rows={4}
652
+ fullWidth
653
+ />;
654
+ ```
655
+
656
+ ### Checkbox
657
+
658
+ The Checkbox component provides a customizable checkbox with various styles and sizes.
659
+
660
+ #### Props
661
+
662
+ | Prop | Type | Description |
663
+ | ------------------ | --------------- | ------------------------------------ |
664
+ | indicatorClassName | string | Class name for the indicator element |
665
+ | size | CheckboxSize | Checkbox size |
666
+ | radius | CheckboxRadius | Checkbox border radius |
667
+ | variant | CheckboxVariant | Checkbox style variant |
668
+ | checkedIcon | ReactElement | Custom icon for checked state |
669
+ | indeterminateIcon | ReactElement | Custom icon for indeterminate state |
670
+
671
+ #### Enums
672
+
673
+ ```jsx
674
+ // Available variants
675
+ CheckboxVariant.Classic;
676
+ CheckboxVariant.Soft;
677
+
678
+ // Available sizes
679
+ CheckboxSize.Small;
680
+ CheckboxSize.Medium;
681
+ CheckboxSize.Large;
682
+
683
+ // Available radius options
684
+ CheckboxRadius.Small;
685
+ CheckboxRadius.Large;
686
+ ```
687
+
688
+ #### Example
689
+
690
+ ```jsx
691
+ import {Checkbox, CheckboxVariant, CheckboxSize, CheckboxRadius} from "addon-ui";
692
+
693
+ <Checkbox variant={CheckboxVariant.Classic} size={CheckboxSize.Medium} radius={CheckboxRadius.Small} checked={true} />;
694
+ ```
695
+
696
+ ### Switch
697
+
698
+ The Switch component provides a toggle switch control.
699
+
700
+ #### Props
701
+
702
+ | Prop | Type | Description |
703
+ | -------------- | ------ | -------------------------------- |
704
+ | thumbClassName | string | Class name for the thumb element |
705
+
706
+ #### Example
707
+
708
+ ```jsx
709
+ import {Switch} from "addon-ui";
710
+
711
+ <Switch checked={isEnabled} onCheckedChange={setIsEnabled} />;
712
+ ```
713
+
714
+ ### Avatar
715
+
716
+ The Avatar component displays a user's profile picture or a fallback when the image is not available.
717
+
718
+ #### Props
719
+
720
+ | Prop | Type | Description |
721
+ | ----------------- | ------------ | -------------------------------------------------- |
722
+ | size | AvatarSize | Avatar size |
723
+ | radius | AvatarRadius | Avatar border radius |
724
+ | fallback | ReactNode | Content to display when the image is not available |
725
+ | fallbackClassName | string | Class name for the fallback content |
726
+ | imageClassName | string | Class name for the image element |
727
+ | cursorPointer | boolean | Whether the avatar should have a pointer cursor |
728
+ | delayMs | number | Delay before showing the fallback content |
729
+
730
+ #### Enums
731
+
732
+ ```jsx
733
+ // Available sizes
734
+ AvatarSize.Small;
735
+ AvatarSize.Medium;
736
+ AvatarSize.Large;
737
+
738
+ // Available radius options
739
+ AvatarRadius.Small;
740
+ AvatarRadius.Medium;
741
+ AvatarRadius.Large;
742
+ ```
743
+
744
+ #### Example
745
+
746
+ ```jsx
747
+ import {Avatar, AvatarSize, AvatarRadius} from "addon-ui";
748
+
749
+ <Avatar
750
+ src="https://example.com/avatar.jpg"
751
+ alt="User Avatar"
752
+ size={AvatarSize.Medium}
753
+ radius={AvatarRadius.Medium}
754
+ fallback="JD"
755
+ />;
756
+ ```
757
+
758
+ ### BaseButton
759
+
760
+ The BaseButton component is a foundational button component that provides basic button functionality.
761
+
762
+ #### Props
763
+
764
+ | Prop | Type | Description |
765
+ | ----------------- | --------- | ----------------------------------------- |
766
+ | after | ReactNode | Content to display after the button text |
767
+ | before | ReactNode | Content to display before the button text |
768
+ | afterClassName | string | Class name for the after content |
769
+ | beforeClassName | string | Class name for the before content |
770
+ | childrenClassName | string | Class name for the children content |
771
+
772
+ #### Example
773
+
774
+ ```jsx
775
+ import {BaseButton} from "addon-ui";
776
+
777
+ <BaseButton before={<Icon name="star" />} after={<Icon name="arrow-right" />}>
778
+ Click me
779
+ </BaseButton>;
780
+ ```
781
+
782
+ ### Dialog
783
+
784
+ The Dialog component displays a modal dialog that overlays the page content.
785
+
786
+ #### Props
787
+
788
+ | Prop | Type | Description |
789
+ | ----------------- | ----------- | -------------------------------------------------------------- |
790
+ | speed | number | Animation speed in milliseconds |
791
+ | description | string | Dialog description (for accessibility) |
792
+ | fullscreen | boolean | Whether the dialog should be fullscreen |
793
+ | overlayClassName | string | Class name for the overlay element |
794
+ | childrenClassName | string | Class name for the children content |
795
+ | open | boolean | Whether the dialog is open |
796
+ | onOpenChange | function | Callback when the open state changes |
797
+ | modal | boolean | Whether the dialog is modal (blocks interaction with the page) |
798
+ | container | HTMLElement | Container element for the dialog |
799
+ | title | string | Dialog title (for accessibility) |
800
+
801
+ #### Example
802
+
803
+ ```jsx
804
+ import {Dialog} from "addon-ui";
805
+
806
+ <Dialog open={isOpen} onOpenChange={setIsOpen} title="Confirmation" description="Please confirm your action">
807
+ <div>
808
+ <h2>Are you sure?</h2>
809
+ <p>This action cannot be undone.</p>
810
+ <div>
811
+ <Button onClick={() => setIsOpen(false)}>Cancel</Button>
812
+ <Button onClick={handleConfirm}>Confirm</Button>
813
+ </div>
814
+ </div>
815
+ </Dialog>;
816
+ ```
817
+
818
+ ### Drawer
819
+
820
+ The Drawer component displays a sliding panel that comes from the edge of the screen.
821
+
822
+ #### Props
823
+
824
+ | Prop | Type | Description |
825
+ | -------- | -------------------------------------- | ---------------------------------- |
826
+ | position | 'left' \| 'right' \| 'top' \| 'bottom' | Position of the drawer |
827
+ | open | boolean | Whether the drawer is open |
828
+ | onClose | function | Callback when the drawer is closed |
829
+
830
+ #### Example
831
+
832
+ ```jsx
833
+ import {Drawer} from "addon-ui";
834
+
835
+ <Drawer open={isOpen} onClose={() => setIsOpen(false)} position="right">
836
+ <div>Drawer content</div>
837
+ </Drawer>;
838
+ ```
839
+
840
+ ### Footer
841
+
842
+ The Footer component provides a consistent footer layout.
843
+
844
+ #### Example
845
+
846
+ ```jsx
847
+ import {Footer} from "addon-ui";
848
+
849
+ <Footer>
850
+ <div>© 2023 My Company</div>
851
+ </Footer>;
852
+ ```
853
+
854
+ ### Header
855
+
856
+ The Header component provides a consistent header layout.
857
+
858
+ #### Example
859
+
860
+ ```jsx
861
+ import {Header} from "addon-ui";
862
+
863
+ <Header>
864
+ <div>My Application</div>
865
+ </Header>;
866
+ ```
867
+
868
+ ### Highlight
869
+
870
+ The Highlight component highlights text matches within content.
871
+
872
+ #### Props
873
+
874
+ | Prop | Type | Description |
875
+ | ------------------ | -------- | ------------------------------- |
876
+ | searchWords | string[] | Words to highlight |
877
+ | textToHighlight | string | Text content to search within |
878
+ | highlightClassName | string | Class name for highlighted text |
879
+
880
+ #### Example
881
+
882
+ ```jsx
883
+ import {Highlight} from "addon-ui";
884
+
885
+ <Highlight searchWords={["react", "component"]} textToHighlight="This is a React component library" />;
886
+ ```
887
+
888
+ ### Icon
889
+
890
+ The Icon component displays vector icons.
891
+
892
+ #### Props
893
+
894
+ | Prop | Type | Description |
895
+ | ----- | ------ | ----------- |
896
+ | name | string | Icon name |
897
+ | size | number | Icon size |
898
+ | color | string | Icon color |
899
+
900
+ #### Example
901
+
902
+ ```jsx
903
+ import {Icon} from "addon-ui";
904
+
905
+ <Icon name="star" size={24} color="#f5a623" />;
906
+ ```
907
+
908
+ ### IconButton
909
+
910
+ The IconButton component combines an icon with button functionality.
911
+
912
+ #### Props
913
+
914
+ | Prop | Type | Description |
915
+ | ----- | ------------------------------------ | --------------- |
916
+ | icon | ReactNode | Icon to display |
917
+ | size | 'small' \| 'medium' \| 'large' | Button size |
918
+ | color | 'primary' \| 'secondary' \| 'accent' | Button color |
919
+
920
+ #### Example
921
+
922
+ ```jsx
923
+ import {IconButton, Icon} from "addon-ui";
924
+
925
+ <IconButton icon={<Icon name="star" />} size="medium" color="primary" onClick={handleClick} />;
926
+ ```
927
+
928
+ ### Layout
929
+
930
+ The Layout component provides a consistent page layout structure.
931
+
932
+ #### Example
933
+
934
+ ```jsx
935
+ import {Layout, Header, Footer} from "addon-ui";
936
+
937
+ <Layout>
938
+ <Header>My Application</Header>
939
+ <div>Content goes here</div>
940
+ <Footer>© 2023 My Company</Footer>
941
+ </Layout>;
942
+ ```
943
+
944
+ ### List
945
+
946
+ The List component displays a list of items.
947
+
948
+ #### Props
949
+
950
+ | Prop | Type | Description |
951
+ | ------- | ---------------------------------- | --------------------- |
952
+ | variant | 'ordered' \| 'unordered' | List type |
953
+ | spacing | 'compact' \| 'normal' \| 'relaxed' | Spacing between items |
954
+
955
+ #### Example
956
+
957
+ ```jsx
958
+ import {List, ListItem} from "addon-ui";
959
+
960
+ <List variant="unordered" spacing="normal">
961
+ <ListItem>Item 1</ListItem>
962
+ <ListItem>Item 2</ListItem>
963
+ <ListItem>Item 3</ListItem>
964
+ </List>;
965
+ ```
966
+
967
+ ### ListItem
968
+
969
+ The ListItem component represents an item in a List.
970
+
971
+ #### Example
972
+
973
+ ```jsx
974
+ import {ListItem} from "addon-ui";
975
+
976
+ <ListItem>Item content</ListItem>;
977
+ ```
978
+
979
+ ### Modal
980
+
981
+ The Modal component displays content in a layer above the page.
982
+
983
+ #### Props
984
+
985
+ | Prop | Type | Description |
986
+ | ------- | --------- | --------------------------------- |
987
+ | open | boolean | Whether the modal is open |
988
+ | onClose | function | Callback when the modal is closed |
989
+ | title | string | Modal title |
990
+ | footer | ReactNode | Modal footer content |
991
+
992
+ #### Example
993
+
994
+ ```jsx
995
+ import {Modal, Button} from "addon-ui";
996
+
997
+ <Modal
998
+ open={isOpen}
999
+ onClose={() => setIsOpen(false)}
1000
+ title="Modal Title"
1001
+ footer={<Button onClick={() => setIsOpen(false)}>Close</Button>}
1002
+ >
1003
+ <p>Modal content goes here</p>
1004
+ </Modal>;
1005
+ ```
1006
+
1007
+ ### Odometer
1008
+
1009
+ The Odometer component displays animated number transitions.
1010
+
1011
+ #### Props
1012
+
1013
+ | Prop | Type | Description |
1014
+ | -------- | ------ | ---------------------------------- |
1015
+ | value | number | Current value to display |
1016
+ | format | string | Number format |
1017
+ | duration | number | Animation duration in milliseconds |
1018
+
1019
+ #### Example
1020
+
1021
+ ```jsx
1022
+ import {Odometer} from "addon-ui";
1023
+
1024
+ <Odometer value={1234} format="(,ddd)" duration={1000} />;
1025
+ ```
1026
+
1027
+ ### ScrollArea
1028
+
1029
+ The ScrollArea component provides a customizable scrollable area.
1030
+
1031
+ #### Props
1032
+
1033
+ | Prop | Type | Description |
1034
+ | --------------- | ----------------------------------------- | ------------------------------ |
1035
+ | type | 'auto' \| 'always' \| 'scroll' \| 'hover' | When to show scrollbars |
1036
+ | scrollHideDelay | number | Delay before hiding scrollbars |
1037
+
1038
+ #### Example
1039
+
1040
+ ```jsx
1041
+ import {ScrollArea} from "addon-ui";
1042
+
1043
+ <ScrollArea type="hover" scrollHideDelay={800} style={{height: 200}}>
1044
+ <div>Content that might overflow</div>
1045
+ </ScrollArea>;
1046
+ ```
1047
+
1048
+ ### SvgSprite
1049
+
1050
+ The SvgSprite component manages SVG sprite definitions.
1051
+
1052
+ #### Example
1053
+
1054
+ ```jsx
1055
+ import {SvgSprite} from "addon-ui";
1056
+
1057
+ <SvgSprite />;
1058
+ ```
1059
+
1060
+ ### Tag
1061
+
1062
+ The Tag component displays a label or category tag.
1063
+
1064
+ #### Props
1065
+
1066
+ | Prop | Type | Description |
1067
+ | ------- | ------------------------------------------------------------- | ----------------------------------------- |
1068
+ | color | 'primary' \| 'secondary' \| 'success' \| 'warning' \| 'error' | Tag color |
1069
+ | size | 'small' \| 'medium' \| 'large' | Tag size |
1070
+ | onClose | function | Callback when the close button is clicked |
1071
+
1072
+ #### Example
1073
+
1074
+ ```jsx
1075
+ import {Tag} from "addon-ui";
1076
+
1077
+ <Tag color="primary" size="medium" onClose={handleClose}>
1078
+ Featured
1079
+ </Tag>;
1080
+ ```
1081
+
1082
+ ### Toast
1083
+
1084
+ The Toast component displays brief notifications.
1085
+
1086
+ #### Props
1087
+
1088
+ | Prop | Type | Description |
1089
+ | -------- | --------------------------------------------------------------------------------- | ------------------------ |
1090
+ | message | string | Toast message |
1091
+ | type | 'info' \| 'success' \| 'warning' \| 'error' | Toast type |
1092
+ | duration | number | Duration in milliseconds |
1093
+ | position | 'top' \| 'bottom' \| 'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right' | Toast position |
1094
+
1095
+ #### Example
1096
+
1097
+ ```jsx
1098
+ import {Toast} from "addon-ui";
1099
+
1100
+ <Toast message="Operation successful!" type="success" duration={3000} position="top-right" />;
1101
+ ```
1102
+
1103
+ ### Tooltip
1104
+
1105
+ The Tooltip component displays informative text when hovering over an element.
1106
+
1107
+ #### Props
1108
+
1109
+ | Prop | Type | Description |
1110
+ | -------- | -------------------------------------- | -------------------------------- |
1111
+ | content | ReactNode | Tooltip content |
1112
+ | position | 'top' \| 'bottom' \| 'left' \| 'right' | Tooltip position |
1113
+ | delay | number | Delay before showing the tooltip |
1114
+
1115
+ #### Example
1116
+
1117
+ ```jsx
1118
+ import {Tooltip, Button} from "addon-ui";
1119
+
1120
+ <Tooltip content="More information" position="top" delay={300}>
1121
+ <Button>Hover me</Button>
1122
+ </Tooltip>;
1123
+ ```
1124
+
1125
+ ### View
1126
+
1127
+ The View component provides a container for content with consistent styling.
1128
+
1129
+ #### Example
1130
+
1131
+ ```jsx
1132
+ import {View} from "addon-ui";
1133
+
1134
+ <View>
1135
+ <h1>Page Title</h1>
1136
+ <p>Page content</p>
1137
+ </View>;
1138
+ ```
1139
+
1140
+ ### ViewDrawer
1141
+
1142
+ The ViewDrawer component combines View and Drawer components.
1143
+
1144
+ #### Example
1145
+
1146
+ ```jsx
1147
+ import {ViewDrawer} from "addon-ui";
1148
+
1149
+ <ViewDrawer open={isOpen} onClose={() => setIsOpen(false)} position="right">
1150
+ <h1>Drawer Title</h1>
1151
+ <p>Drawer content</p>
1152
+ </ViewDrawer>;
1153
+ ```
1154
+
1155
+ ### ViewModal
1156
+
1157
+ The ViewModal component combines View and Modal components.
1158
+
1159
+ #### Example
1160
+
1161
+ ```jsx
1162
+ import {ViewModal} from "addon-ui";
1163
+
1164
+ <ViewModal open={isOpen} onClose={() => setIsOpen(false)} title="Modal Title">
1165
+ <p>Modal content</p>
1166
+ </ViewModal>;
1167
+ ```
1168
+
1169
+ ## Component Props
1170
+
1171
+ All components accept standard HTML attributes in addition to their specific props. Here are some common props for key components:
1172
+
1173
+ ### Button
1174
+
1175
+ | Prop | Type | Default | Description |
1176
+ | -------- | ---------------------------------------- | ----------- | ------------------------------ |
1177
+ | variant | 'contained' \| 'outlined' \| 'text' | 'contained' | Button style variant |
1178
+ | color | 'primary' \| 'secondary' \| 'accent' | undefined | Button color |
1179
+ | size | 'small' \| 'medium' \| 'large' | undefined | Button size |
1180
+ | radius | 'small' \| 'medium' \| 'large' \| 'full' | undefined | Button border radius |
1181
+ | disabled | boolean | false | Whether the button is disabled |
1182
+
1183
+ ### TextField
1184
+
1185
+ | Prop | Type | Default | Description |
1186
+ | ----------- | -------- | --------- | ------------------------------ |
1187
+ | label | string | undefined | Input label |
1188
+ | placeholder | string | undefined | Input placeholder |
1189
+ | value | string | undefined | Input value |
1190
+ | onChange | function | undefined | Change event handler |
1191
+ | error | boolean | false | Whether the input has an error |
1192
+ | helperText | string | undefined | Helper text to display |
1193
+ | disabled | boolean | false | Whether the input is disabled |
1194
+
1195
+ ## License
1196
+
1197
+ This project is licensed under the MIT License - see the LICENSE file for details.