@ambuj.bhaskar/react-component-library 0.18.2-alpha โ†’ 0.18.4-alpha

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
@@ -1,155 +1,34 @@
1
- # ๐Ÿš€ React UI Library
2
-
3
- ## A scalable, customizable, and accessible **React component library** designed for building modern UIs. This package includes reusable components, a flexible theming system, and a consistent icon set.
4
-
5
- ## ๐Ÿ“ฆ What's Included?
6
-
7
- ### โœ… Components
8
-
9
- The library currently provides the following components:
10
-
11
- - **`Button`** โ€“ Customizable buttons with multiple variants and sizes
12
- - **`Input`** โ€“ Accessible input fields with optional icons and validation
13
- - **`Icon`** โ€“ A collection of SVG-based icons
14
- - **`Select`** โ€“ Single select dropdown component
15
- - **`MultiSelect`** โ€“ Multi-select dropdown with tags
16
- - **`Modal`** โ€“ Flexible modal dialog with header, body, and footer support
17
- - **`Backdrop`** โ€“ Dimmable background for modals or dialogs
18
- - **`DateRangePicker`** โ€“ Date picker for selecting start and end dates
19
- - **`ContactInput`** โ€“ A specialized input component for contact/email entry
20
- - **`Spinner`** โ€“ A loading spinner indicator
21
-
22
- ---
23
-
24
- ### ๐ŸŽจ Theming
25
-
26
- The library supports **theme customization** using:
27
-
28
- - **`ThemeProvider`** โ€“ Wrap your app with this provider to apply a custom theme
29
- - **`useTheme()` hook** โ€“ Access the active theme and color palette in your components
30
-
31
- Themes are managed using a flexible token-based system and can be extended or overridden easily.
32
-
33
- ---
34
-
35
- ## ๐Ÿ› ๏ธ How to Add & Export a New Component
36
-
37
- To add a new component to the library:
38
-
39
- ### **Step 1 โ€“ Create Base Files**
40
-
41
- Inside `src/components/<ComponentName>/`, create the following:
42
-
43
- ```
44
- <ComponentName>.tsx # Component logic
45
- <ComponentName>.stories.tsx # Storybook stories
46
- <ComponentName>.types.ts # Type definitions
47
- <ComponentName>.module.scss # Component-specific styles
48
- index.tsx # Local export
49
- ```
50
-
51
- ### **Step 2 โ€“ Export the Component Locally**
52
-
53
- In `src/components/<ComponentName>/index.tsx`:
54
-
55
- ```ts
56
- export { ComponentName } from "./ComponentName";
57
- ```
58
-
59
- ### **Step 3 โ€“ Export the Component Globally**
60
-
61
- In `src/index.tsx`:
62
-
63
- ```ts
64
- export * from "./components/ComponentName";
65
- export type { ComponentNameProps } from "./components/ComponentName/ComponentName.types";
66
- ```
67
-
68
- ---
69
-
70
- ## ๐Ÿ“ Folder Structure
71
-
72
- ```
73
- src/
74
- โ”œโ”€โ”€ components/
75
- โ”‚ โ””โ”€โ”€ <ComponentName>/
76
- โ”‚ โ”œโ”€โ”€ <ComponentName>.tsx
77
- โ”‚ โ”œโ”€โ”€ <ComponentName>.types.ts
78
- โ”‚ โ”œโ”€โ”€ <ComponentName>.stories.tsx
79
- โ”‚ โ”œโ”€โ”€ <ComponentName>.module.scss
80
- โ”‚ โ””โ”€โ”€ index.tsx
81
- โ”‚
82
- โ”œโ”€โ”€ utils/
83
- โ”‚ โ””โ”€โ”€ theme/
84
- โ”‚ โ”œโ”€โ”€ ThemeProvider.tsx
85
- โ”‚ โ”œโ”€โ”€ useTheme.ts
86
- โ”‚ โ””โ”€โ”€ tokens.ts
87
- โ”‚
88
- โ””โ”€โ”€ index.tsx
89
-
90
- ```
91
-
92
- ---
93
-
94
- ## ๐ŸŒˆ Theming Example
95
-
96
- ```tsx
97
- import { ThemeProvider, useTheme } from "your-ui-library";
98
-
99
- const App = () => {
100
- return (
101
- <ThemeProvider theme="dark">
102
- <YourApp />
103
- </ThemeProvider>
104
- );
105
- };
106
-
107
- const CustomComponent = () => {
108
- const { colors } = useTheme();
109
- return <div style={{ color: colors.primary }}>Themed Text</div>;
110
- };
111
- ```
112
-
113
- ---
114
-
115
- ## ๐Ÿงช Storybook
116
-
117
- We use **Storybook** for isolated component development and documentation. Run:
118
-
119
- ```bash
120
- npm run storybook
121
- ```
122
-
123
- ---
124
-
125
- ## ๐Ÿ“ฆ Installation
126
-
127
- Coming soon when published to npm. For now, use via a GitHub reference or local link.
128
-
129
- ---
130
-
131
- ## ๐Ÿงฉ Tech Stack
132
-
133
- - **React**
134
- - **TypeScript**
135
- - **SCSS Modules**
136
- - **Storybook**
137
- - **Jest** (optional for testing setup)
138
-
139
- ---
140
-
141
- ## ๐Ÿค Contribution Guide
142
-
143
- 1. Clone the repo
144
- 2. Create a new component under `src/components/`
145
- 3. Follow the export guide above
146
- 4. Add stories in Storybook
147
- 5. Run `npm run lint` and `npm run build` before PR
148
-
149
- ---
150
-
151
- ## ๐Ÿ“ License
152
-
153
- MIT โ€“ ยฉ \[Awiros]
154
-
155
- ---
1
+ # ๐Ÿš€ React UI Library
2
+
3
+ ## A scalable, customizable, and accessible **React component library** designed for building modern UIs. This package includes reusable components, a flexible theming system, and a consistent icon set.
4
+
5
+ ## ๐Ÿ“ฆ What's Included?
6
+
7
+ ### โœ… Components
8
+
9
+ The library currently provides the following components:
10
+
11
+ - **`Button`** โ€“ Customizable buttons with multiple variants and sizes
12
+ - **`Input`** โ€“ Accessible input fields with optional icons and validation
13
+ - **`Icon`** โ€“ A collection of SVG-based icons
14
+ - **`Select`** โ€“ Single select dropdown component
15
+ - **`MultiSelect`** โ€“ Multi-select dropdown with tags
16
+ - **`Modal`** โ€“ Flexible modal dialog with header, body, and footer support
17
+ - **`Backdrop`** โ€“ Dimmable background for modals or dialogs
18
+ - **`DateRangePicker`** โ€“ Date picker for selecting start and end dates
19
+ - **`ContactInput`** โ€“ A specialized input component for contact/email entry
20
+ - **`Spinner`** โ€“ A loading spinner indicator
21
+ - and more ...
22
+
23
+ ---
24
+
25
+ ### ๐ŸŽจ Theming
26
+
27
+ The library supports **theme customization** using:
28
+
29
+ - **`ThemeProvider`** โ€“ Wrap your app with this provider to apply a custom theme
30
+ - **`useTheme()` hook** โ€“ Access the active theme and color palette in your components
31
+
32
+ Themes are managed using a flexible token-based system and can be extended or overridden easily.
33
+
34
+ ---
package/bin/cli.js CHANGED
@@ -1,87 +1,87 @@
1
- #!/usr/bin/env node
2
-
3
- import boxen from "boxen";
4
- import chalk from "chalk";
5
- import { Command } from "commander";
6
- import fs from "fs";
7
- import path from "path";
8
- import { fileURLToPath } from "url";
9
-
10
- const program = new Command();
11
-
12
- // Get __dirname equivalent in ES Modules
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = path.dirname(__filename);
15
-
16
- // Styled banner
17
- console.log(
18
- boxen(chalk.bold.cyan("โšก AWI CLI - Component Generator"), {
19
- padding: 1,
20
- margin: 1,
21
- borderStyle: "round",
22
- borderColor: "cyan",
23
- })
24
- );
25
-
26
- program
27
- .name("awi")
28
- .description(chalk.green("A CLI tool for generating components and utilities"))
29
- .version(chalk.yellow("1.0.0"));
30
-
31
- // Component Generator Command
32
- program
33
- .command("generate <type> <name>")
34
- .alias("g")
35
- .description(chalk.blue("Generate a new component or utility"))
36
- .action((type, name) => {
37
- if (type === "component" || type === "c") {
38
- createComponent(name);
39
- } else {
40
- console.log(chalk.red.bold(`โŒ Unknown type: ${type}`));
41
- }
42
- });
43
-
44
- function createComponent(componentName) {
45
- const componentDir = path.join(process.cwd(), componentName);
46
- const formattedName = componentName.replace(/-/g, ".");
47
- const pascalCaseName = formattedName
48
- .split(".")
49
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
50
- .join("");
51
-
52
- // Ensure the directory exists
53
- fs.mkdirSync(componentDir, { recursive: true });
54
-
55
- // Define file contents
56
- const indexContent = `import { ${pascalCaseName} } from "./${formattedName}";\nexport type { ${pascalCaseName}Props } from "./${formattedName}.type";\n\nexport default ${pascalCaseName};`;
57
-
58
- const componentContent = `import "./${formattedName}.css";\nimport { ${pascalCaseName}Props } from "./${formattedName}.type";\n\nexport const ${pascalCaseName}: React.FC<${pascalCaseName}Props> = ({\n title = "${pascalCaseName}",\n}) => {\n return <div>{title}</div>;\n};`;
59
-
60
- const typeContent = `export type ${pascalCaseName}Props = {\n title?: string;\n};`;
61
-
62
- const storiesContent = `import type { Meta, StoryObj } from "@storybook/react";\nimport ${pascalCaseName} from "./";\n\nconst meta: Meta<typeof ${pascalCaseName}> = {\n component: ${pascalCaseName},\n title: "Components/Atoms/${pascalCaseName}",\n tags: ["autodocs"],\n parameters: {\n layout: "centered",\n docs: {\n panelPosition: "right",\n },\n },\n argTypes: {\n title: {\n control: "text",\n description: "Title of the component",\n table: {\n type: { summary: "string" },\n defaultValue: { summary: "${pascalCaseName}" },\n },\n },\n },\n};\nexport default meta;\n\ntype Story = StoryObj<typeof ${pascalCaseName}>;\n\nexport const Default: Story = {\n args: { title: "${pascalCaseName}" },\n};`;
63
-
64
- // Create and write files
65
- const files = {
66
- "index.tsx": indexContent,
67
- [`${formattedName}.tsx`]: componentContent,
68
- [`${formattedName}.type.ts`]: typeContent,
69
- [`${formattedName}.stories.tsx`]: storiesContent,
70
- [`${formattedName}.css`]: "",
71
- [`${formattedName}.utils.ts`]: "",
72
- };
73
-
74
- for (const [file, content] of Object.entries(files)) {
75
- fs.writeFileSync(path.join(componentDir, file), content, { flag: "w" });
76
- }
77
-
78
- console.log(
79
- boxen(
80
- chalk.greenBright(`โœ… Component '${componentName}' created successfully!`),
81
- { padding: 1, margin: 1, borderStyle: "double", borderColor: "green" }
82
- )
83
- );
84
- }
85
-
86
- // Parse CLI arguments
87
- program.parse(process.argv);
1
+ #!/usr/bin/env node
2
+
3
+ import boxen from "boxen";
4
+ import chalk from "chalk";
5
+ import { Command } from "commander";
6
+ import fs from "fs";
7
+ import path from "path";
8
+ import { fileURLToPath } from "url";
9
+
10
+ const program = new Command();
11
+
12
+ // Get __dirname equivalent in ES Modules
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+
16
+ // Styled banner
17
+ console.log(
18
+ boxen(chalk.bold.cyan("โšก AWI CLI - Component Generator"), {
19
+ padding: 1,
20
+ margin: 1,
21
+ borderStyle: "round",
22
+ borderColor: "cyan",
23
+ })
24
+ );
25
+
26
+ program
27
+ .name("awi")
28
+ .description(chalk.green("A CLI tool for generating components and utilities"))
29
+ .version(chalk.yellow("1.0.0"));
30
+
31
+ // Component Generator Command
32
+ program
33
+ .command("generate <type> <name>")
34
+ .alias("g")
35
+ .description(chalk.blue("Generate a new component or utility"))
36
+ .action((type, name) => {
37
+ if (type === "component" || type === "c") {
38
+ createComponent(name);
39
+ } else {
40
+ console.log(chalk.red.bold(`โŒ Unknown type: ${type}`));
41
+ }
42
+ });
43
+
44
+ function createComponent(componentName) {
45
+ const componentDir = path.join(process.cwd(), componentName);
46
+ const formattedName = componentName.replace(/-/g, ".");
47
+ const pascalCaseName = formattedName
48
+ .split(".")
49
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
50
+ .join("");
51
+
52
+ // Ensure the directory exists
53
+ fs.mkdirSync(componentDir, { recursive: true });
54
+
55
+ // Define file contents
56
+ const indexContent = `import { ${pascalCaseName} } from "./${formattedName}";\nexport type { ${pascalCaseName}Props } from "./${formattedName}.type";\n\nexport default ${pascalCaseName};`;
57
+
58
+ const componentContent = `import "./${formattedName}.css";\nimport { ${pascalCaseName}Props } from "./${formattedName}.type";\n\nexport const ${pascalCaseName}: React.FC<${pascalCaseName}Props> = ({\n title = "${pascalCaseName}",\n}) => {\n return <div>{title}</div>;\n};`;
59
+
60
+ const typeContent = `export type ${pascalCaseName}Props = {\n title?: string;\n};`;
61
+
62
+ const storiesContent = `import type { Meta, StoryObj } from "@storybook/react";\nimport ${pascalCaseName} from "./";\n\nconst meta: Meta<typeof ${pascalCaseName}> = {\n component: ${pascalCaseName},\n title: "Components/Atoms/${pascalCaseName}",\n tags: ["autodocs"],\n parameters: {\n layout: "centered",\n docs: {\n panelPosition: "right",\n },\n },\n argTypes: {\n title: {\n control: "text",\n description: "Title of the component",\n table: {\n type: { summary: "string" },\n defaultValue: { summary: "${pascalCaseName}" },\n },\n },\n },\n};\nexport default meta;\n\ntype Story = StoryObj<typeof ${pascalCaseName}>;\n\nexport const Default: Story = {\n args: { title: "${pascalCaseName}" },\n};`;
63
+
64
+ // Create and write files
65
+ const files = {
66
+ "index.tsx": indexContent,
67
+ [`${formattedName}.tsx`]: componentContent,
68
+ [`${formattedName}.type.ts`]: typeContent,
69
+ [`${formattedName}.stories.tsx`]: storiesContent,
70
+ [`${formattedName}.css`]: "",
71
+ [`${formattedName}.utils.ts`]: "",
72
+ };
73
+
74
+ for (const [file, content] of Object.entries(files)) {
75
+ fs.writeFileSync(path.join(componentDir, file), content, { flag: "w" });
76
+ }
77
+
78
+ console.log(
79
+ boxen(
80
+ chalk.greenBright(`โœ… Component '${componentName}' created successfully!`),
81
+ { padding: 1, margin: 1, borderStyle: "double", borderColor: "green" }
82
+ )
83
+ );
84
+ }
85
+
86
+ // Parse CLI arguments
87
+ program.parse(process.argv);