@emporix/component-library 1.0.0 โ†’ 1.0.2

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 CHANGED
@@ -10,6 +10,7 @@ A modern React component library built with TypeScript, Vite, and SCSS modules.
10
10
  - ๐Ÿงช **Testing**: Comprehensive test suite with Vitest and React Testing Library
11
11
  - ๐Ÿ“ฆ **Library Build**: Optimized for npm package distribution
12
12
  - ๐Ÿ”„ **CI/CD**: Automated testing and publishing pipeline
13
+ - ๐ŸŽจ **CSS Variables**: Global theming system with CSS custom properties
13
14
 
14
15
  ## Quick Start
15
16
 
@@ -29,13 +30,13 @@ npm install @emporix/component-library
29
30
  ```
30
31
 
31
32
  ```tsx
32
- import { Button } from '@emporix/component-library'
33
+ import { PrimaryButton } from '@emporix/component-library'
33
34
 
34
35
  const MyComponent = () => {
35
36
  return (
36
- <Button variant='primary' onClick={() => console.log('Clicked!')}>
37
+ <PrimaryButton onClick={() => console.log('Clicked!')}>
37
38
  Click me
38
- </Button>
39
+ </PrimaryButton>
39
40
  )
40
41
  }
41
42
  ```
@@ -43,21 +44,107 @@ const MyComponent = () => {
43
44
  #### Method 2: Import styles in your main JavaScript/TypeScript file
44
45
 
45
46
  ```tsx
46
- import { Button } from '@emporix/component-library'
47
+ import { PrimaryButton } from '@emporix/component-library'
47
48
  import '@emporix/component-library/styles'
48
49
 
49
50
  const MyComponent = () => {
50
51
  return (
51
- <Button variant='primary' onClick={() => console.log('Clicked!')}>
52
+ <PrimaryButton onClick={() => console.log('Clicked!')}>
52
53
  Click me
53
- </Button>
54
+ </PrimaryButton>
54
55
  )
55
56
  }
56
57
  ```
57
58
 
58
- #### Method 3: Copy CSS file manually
59
+ #### Method 3: Copy CSS file manually (Fallback)
59
60
 
60
- If the above methods don't work, you can copy the CSS file from `node_modules/@emporix/component-library/dist/style.css` to your project and import it directly.
61
+ If the above methods don't work, copy the CSS file from `node_modules/@emporix/component-library/dist/style.css` to your project and import it directly.
62
+
63
+ ## Components
64
+
65
+ ### PrimaryButton
66
+
67
+ A simple, focused button component for primary actions.
68
+
69
+ ```tsx
70
+ import { PrimaryButton } from '@emporix/component-library'
71
+
72
+ // Basic usage
73
+ <PrimaryButton>Click me</PrimaryButton>
74
+
75
+ // With disabled state
76
+ <PrimaryButton disabled>Disabled Button</PrimaryButton>
77
+
78
+ // With click handler
79
+ <PrimaryButton onClick={() => alert('Confirmed!')}>
80
+ Confirm Action
81
+ </PrimaryButton>
82
+ ```
83
+
84
+ #### Props
85
+
86
+ | Prop | Type | Default | Description |
87
+ | ----------- | ---------- | ------- | -------------------------- |
88
+ | children | ReactNode | - | Button content |
89
+ | disabled | boolean | false | Whether button is disabled |
90
+ | onClick | () => void | - | Click handler |
91
+ | className | string | - | Additional CSS class |
92
+ | data-testid | string | - | Test ID for testing |
93
+
94
+ ### Tabs
95
+
96
+ A flexible tabs component for organizing content into multiple panels.
97
+
98
+ ```tsx
99
+ import { Tabs, TabItem } from '@emporix/component-library'
100
+
101
+ const tabs: TabItem[] = [
102
+ {
103
+ id: 'tab1',
104
+ label: 'First Tab',
105
+ content: <div>First tab content</div>,
106
+ },
107
+ {
108
+ id: 'tab2',
109
+ label: 'Second Tab',
110
+ content: <div>Second tab content</div>,
111
+ },
112
+ ]
113
+
114
+ // Basic usage
115
+ <Tabs
116
+ tabs={tabs}
117
+ activeTabId="tab1"
118
+ onTabChange={(tabId) => setActiveTab(tabId)}
119
+ />
120
+
121
+ // With custom styling and test ID
122
+ <Tabs
123
+ tabs={tabs}
124
+ activeTabId="tab1"
125
+ onTabChange={(tabId) => setActiveTab(tabId)}
126
+ className="custom-tabs"
127
+ data-testid="my-tabs"
128
+ />
129
+ ```
130
+
131
+ #### Props
132
+
133
+ | Prop | Type | Default | Description |
134
+ | ----------- | ----------------------- | ------- | ------------------------------ |
135
+ | tabs | TabItem[] | - | Array of tab items |
136
+ | activeTabId | string | - | ID of the currently active tab |
137
+ | onTabChange | (tabId: string) => void | - | Callback when tab is changed |
138
+ | className | string | - | Additional CSS class |
139
+ | data-testid | string | - | Test ID for testing |
140
+
141
+ #### TabItem Interface
142
+
143
+ | Prop | Type | Description |
144
+ | ------- | --------- | ------------------------------ |
145
+ | id | string | Unique identifier for the tab |
146
+ | label | string | Display label for the tab |
147
+ | content | ReactNode | Content to display when active |
61
148
 
62
149
  ## Theming with CSS Variables
63
150
 
@@ -67,24 +154,116 @@ The component library uses CSS variables for easy theming. You can customize the
67
154
  :root {
68
155
  --color-primary: #your-primary-color;
69
156
  --color-primary-hover: #your-primary-hover-color;
70
- --color-secondary: #your-secondary-color;
71
157
  --border-radius-md: 0.5rem;
72
- --font-size-base: 1.1rem;
158
+ --font-size-lg: 1.2rem;
73
159
  /* ... other variables */
74
160
  }
75
161
  ```
76
162
 
77
- Available CSS variables:
163
+ ### Available CSS Variables
78
164
 
79
- - **Colors**: `--color-primary`, `--color-secondary`, `--color-success`, `--color-danger`, `--color-warning`, `--color-info`, `--color-light`, `--color-dark`
80
- - **Border Radius**: `--border-radius-sm`, `--border-radius-md`, `--border-radius-lg`
81
- - **Font Sizes**: `--font-size-sm`, `--font-size-base`, `--font-size-lg`
82
- - **Font Weight**: `--font-weight-medium`
83
- - **Transitions**: `--transition-fast`, `--transition-normal`, `--transition-slow`
84
- - **Z-Index Layers**: `--z-dropdown`, `--z-modal`, `--z-tooltip`, etc.
85
- - **Component Variables**: `--button-padding-md`, `--input-padding-lg`, `--card-padding`, etc.
165
+ The component library provides a minimal set of CSS variables that are actually used in the codebase. These variables are primarily used for the showcase page styling and can be customized for theming.
86
166
 
87
- For a complete reference of all available CSS variables, see [CSS_VARIABLES.md](./CSS_VARIABLES.md).
167
+ #### Colors
168
+
169
+ ```css
170
+ --color-primary: #007bff;
171
+ --color-primary-hover: #0056b3;
172
+ --color-dark: #343a40;
173
+ ```
174
+
175
+ #### Text Colors
176
+
177
+ ```css
178
+ --color-text-primary: #212529;
179
+ --color-text-secondary: #6c757d;
180
+ ```
181
+
182
+ #### Background Colors
183
+
184
+ ```css
185
+ --color-bg-primary: #ffffff;
186
+ --color-bg-secondary: #f8f9fa;
187
+ ```
188
+
189
+ #### Border Colors
190
+
191
+ ```css
192
+ --color-border-light: #e9ecef;
193
+ ```
194
+
195
+ #### Spacing
196
+
197
+ ```css
198
+ --spacing-sm: 0.5rem; /* 8px */
199
+ --spacing-md: 1rem; /* 16px */
200
+ --spacing-lg: 1.5rem; /* 24px */
201
+ --spacing-xl: 3rem; /* 48px */
202
+ ```
203
+
204
+ #### Border Radius
205
+
206
+ ```css
207
+ --border-radius-sm: 0.25rem; /* 4px */
208
+ --border-radius-md: 0.375rem; /* 6px */
209
+ --border-radius-lg: 0.5rem; /* 8px */
210
+ ```
211
+
212
+ #### Typography
213
+
214
+ **Font Sizes:**
215
+
216
+ ```css
217
+ --font-size-sm: 0.875rem; /* 14px */
218
+ --font-size-base: 1rem; /* 16px */
219
+ --font-size-lg: 1.125rem; /* 18px */
220
+ ```
221
+
222
+ **Font Weights:**
223
+
224
+ ```css
225
+ --font-weight-normal: 400;
226
+ --font-weight-medium: 500;
227
+ --font-weight-semibold: 600;
228
+ --font-weight-bold: 700;
229
+ ```
230
+
231
+ ### Theming Examples
232
+
233
+ #### Basic Theming
234
+
235
+ ```css
236
+ :root {
237
+ --color-primary: #your-brand-color;
238
+ --color-primary-hover: #your-brand-hover-color;
239
+ --border-radius-md: 0.5rem;
240
+ --font-size-lg: 1.2rem;
241
+ }
242
+ ```
243
+
244
+ #### Dark Theme
245
+
246
+ ```css
247
+ :root {
248
+ --color-bg-primary: #1a1a1a;
249
+ --color-bg-secondary: #2d2d2d;
250
+ --color-text-primary: #ffffff;
251
+ --color-text-secondary: #cccccc;
252
+ --color-border-light: #404040;
253
+ }
254
+ ```
255
+
256
+ #### Custom Component Styling
257
+
258
+ ```css
259
+ .my-custom-component {
260
+ padding: var(--spacing-md);
261
+ border-radius: var(--border-radius-lg);
262
+ background-color: var(--color-bg-primary);
263
+ color: var(--color-text-primary);
264
+ border: 1px solid var(--color-border-light);
265
+ }
266
+ ```
88
267
 
89
268
  ## Development
90
269
 
@@ -126,45 +305,6 @@ npm run storybook
126
305
  - `npm run format` - Format code with Prettier
127
306
  - `npm run format:check` - Check code formatting
128
307
 
129
- ## Components
130
-
131
- ### Button
132
-
133
- A versatile button component with multiple variants and sizes.
134
-
135
- ```tsx
136
- import { Button } from '@emporix/component-library'
137
-
138
- // Variants
139
- <Button variant="primary">Primary</Button>
140
- <Button variant="secondary">Secondary</Button>
141
- <Button variant="success">Success</Button>
142
- <Button variant="danger">Danger</Button>
143
-
144
- // Sizes
145
- <Button size="sm">Small</Button>
146
- <Button size="md">Medium</Button>
147
- <Button size="lg">Large</Button>
148
-
149
- // States
150
- <Button disabled>Disabled</Button>
151
- <Button fullWidth>Full Width</Button>
152
- ```
153
-
154
- #### Props
155
-
156
- | Prop | Type | Default | Description |
157
- | ----------- | --------------------------------------------------------------------------------------------- | --------- | ------------------------------- |
158
- | children | ReactNode | - | Button content |
159
- | variant | 'primary' \| 'secondary' \| 'success' \| 'danger' \| 'warning' \| 'info' \| 'light' \| 'dark' | 'primary' | Button variant |
160
- | size | 'sm' \| 'md' \| 'lg' | 'md' | Button size |
161
- | disabled | boolean | false | Whether button is disabled |
162
- | fullWidth | boolean | false | Whether button takes full width |
163
- | type | 'button' \| 'submit' \| 'reset' | 'button' | Button type |
164
- | onClick | (event: MouseEvent) => void | - | Click handler |
165
- | className | string | - | Additional CSS class |
166
- | data-testid | string | - | Test ID for testing |
167
-
168
308
  ## Testing
169
309
 
170
310
  The library includes comprehensive tests using Vitest and React Testing Library.
@@ -239,10 +379,8 @@ The project also includes pre-commit hooks that automatically format staged file
239
379
  - Update documentation as needed
240
380
  - Use arrow functions for React components (enforced by ESLint)
241
381
  - Avoid using `React.FC` type annotation (redundant with modern TypeScript)
242
-
243
- ## License
244
-
245
- MIT License - see [LICENSE](LICENSE) file for details.
382
+ - Use CSS variables for all styling values
383
+ - Follow the established naming conventions for CSS classes
246
384
 
247
385
  ## Troubleshooting
248
386
 
@@ -253,14 +391,14 @@ If you encounter import errors like "Failed to resolve entry for package", ensur
253
391
  1. The package is properly installed: `npm install @emporix/component-library`
254
392
  2. You're using the correct import syntax:
255
393
  ```tsx
256
- import { Button } from '@emporix/component-library'
394
+ import { PrimaryButton } from '@emporix/component-library'
257
395
  import '@emporix/component-library/styles'
258
396
  ```
259
397
  3. Your bundler supports ES modules and the package.json exports field
260
398
 
261
399
  ### Styling Issues
262
400
 
263
- If the Button component appears unstyled or you get "styles not found" errors:
401
+ If the PrimaryButton component appears unstyled or you get "styles not found" errors:
264
402
 
265
403
  1. **Try Method 1 (Recommended):** Import styles in your main CSS file:
266
404
 
@@ -280,7 +418,7 @@ If the Button component appears unstyled or you get "styles not found" errors:
280
418
 
281
419
  4. **Check your bundler configuration:** Ensure your bundler (Vite, Webpack, etc.) is configured to handle CSS imports from node_modules
282
420
 
283
- 5. **Verify the CSS classes:** The component uses SCSS modules with hashed class names (e.g., `_button_184r1_20`, `_primary_184r1_45`) and CSS variables for theming
421
+ 5. **Verify the CSS classes:** The component uses SCSS modules with hashed class names (e.g., `_primaryButton_1d0ha_1`, `_primaryButtonDisabled_1d0ha_53`) and CSS variables for theming
284
422
 
285
423
  ### TypeScript Issues
286
424
 
@@ -289,6 +427,28 @@ If TypeScript can't find types, make sure:
289
427
  1. The `@types/react` package is installed
290
428
  2. Your `tsconfig.json` includes the library in `node_modules`
291
429
 
430
+ ### Bundler-Specific Notes
431
+
432
+ #### Vite
433
+
434
+ All methods should work with Vite. Method 1 (CSS import) is recommended.
435
+
436
+ #### Webpack
437
+
438
+ Method 1 and Method 2 should work. If you encounter issues, try Method 3.
439
+
440
+ #### Create React App
441
+
442
+ Method 1 and Method 2 should work. If you encounter issues, try Method 3.
443
+
444
+ #### Next.js
445
+
446
+ Method 1 (CSS import) is recommended. Import the CSS in your `_app.tsx` or `_app.js` file.
447
+
448
+ ## License
449
+
450
+ MIT License - see [LICENSE](LICENSE) file for details.
451
+
292
452
  ## Support
293
453
 
294
454
  For support and questions, please open an issue in the repository.
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ export interface PrimaryButtonProps {
3
+ /**
4
+ * The content of the button
5
+ */
6
+ children: React.ReactNode;
7
+ /**
8
+ * Whether the button is disabled
9
+ */
10
+ disabled?: boolean;
11
+ /**
12
+ * Click handler
13
+ */
14
+ onClick?: () => void;
15
+ /**
16
+ * Additional CSS class name
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Test ID for testing
21
+ */
22
+ 'data-testid'?: string;
23
+ }
24
+ export declare const PrimaryButton: ({ children, disabled, onClick, className, "data-testid": testId, ...props }: PrimaryButtonProps) => import("react/jsx-runtime").JSX.Element;
25
+ //# sourceMappingURL=PrimaryButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimaryButton.d.ts","sourceRoot":"","sources":["../../../src/components/buttons/PrimaryButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,aAAa,GAAI,6EAO3B,kBAAkB,4CAqBpB,CAAA"}
@@ -0,0 +1,39 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TabItem {
3
+ /**
4
+ * Unique identifier for the tab
5
+ */
6
+ id: string;
7
+ /**
8
+ * Display label for the tab
9
+ */
10
+ label: string;
11
+ /**
12
+ * Content to display when tab is active
13
+ */
14
+ content: ReactNode;
15
+ }
16
+ export interface TabsProps {
17
+ /**
18
+ * Array of tab items to display
19
+ */
20
+ tabs: TabItem[];
21
+ /**
22
+ * ID of the currently active tab
23
+ */
24
+ activeTabId: string;
25
+ /**
26
+ * Callback function when tab is changed
27
+ */
28
+ onTabChange: (tabId: string) => void;
29
+ /**
30
+ * Additional CSS class name
31
+ */
32
+ className?: string;
33
+ /**
34
+ * Test ID for testing
35
+ */
36
+ 'data-testid'?: string;
37
+ }
38
+ export declare const Tabs: ({ tabs, activeTabId, onTabChange, className, "data-testid": testId, ...props }: TabsProps) => import("react/jsx-runtime").JSX.Element;
39
+ //# sourceMappingURL=Tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGjC,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,OAAO,EAAE,SAAS,CAAA;CACnB;AAED,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,IAAI,EAAE,OAAO,EAAE,CAAA;IACf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,IAAI,GAAI,gFAOlB,SAAS,4CAsCX,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export { Button } from './components/Button/Button';
2
- export type { ButtonProps } from './components/Button/Button';
1
+ export { PrimaryButton } from './components/buttons/PrimaryButton';
2
+ export type { PrimaryButtonProps } from './components/buttons/PrimaryButton';
3
+ export { Tabs } from './components/tabs/Tabs';
4
+ export type { TabsProps, TabItem } from './components/tabs/Tabs';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAG7D,OAAO,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAE5E,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGhE,OAAO,qBAAqB,CAAA"}