@rajdeep0510/scaffold-cli 1.0.2 → 1.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.
- package/.vscode/settings.json +10 -0
- package/README.md +2 -0
- package/bin/index.js +4 -4
- package/commands/addComponent.js +76 -50
- package/package.json +2 -2
- package/templates/Avatar/component.jsx +62 -0
- package/templates/Avatar/index.js +5 -0
- package/templates/Avatar/meta.json +92 -0
- package/templates/Card/Card.jsx +187 -0
- package/templates/Card/index.js +2 -0
- package/templates/Card/meta.json +100 -0
- package/templates/Input/components.jsx +33 -0
- package/templates/Input/index.js +5 -0
- package/templates/Input/meta.json +82 -0
- package/templates/Navbar/Navbar.jsx +207 -0
- package/templates/Navbar/index.js +2 -0
- package/templates/Navbar/meta.json +43 -0
- package/templates/RadioGroup/RadioGroup.jsx +148 -0
- package/templates/RadioGroup/index.js +4 -0
- package/templates/RadioGroup/meta.json +10 -0
- package/templates/button/component.jsx +73 -80
- package/templates/button/index.js +6 -2
- package/templates/button/meta.json +142 -18
|
@@ -1,92 +1,85 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import PropTypes from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import clsx from "clsx";
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* A customizable button component with multiple variants and sizes + click animation
|
|
6
|
-
*/
|
|
7
5
|
const Button = ({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
children,
|
|
7
|
+
size = "sm",
|
|
8
|
+
disabled = false,
|
|
9
|
+
loading = false,
|
|
10
|
+
className = "",
|
|
11
|
+
onClick,
|
|
12
|
+
type = "button",
|
|
13
|
+
borderColor = "white", // "white" or "black"
|
|
14
|
+
borderWidth = 1,
|
|
15
|
+
borderStyle = "solid",
|
|
16
|
+
borderRadius = "md", // sm, md, lg, xl, full
|
|
17
|
+
...rest
|
|
18
|
+
}) => {
|
|
19
|
+
const sizeClasses = {
|
|
20
|
+
sm: "h-8 px-3 text-sm",
|
|
21
|
+
md: "h-10 px-4 text-sm",
|
|
22
|
+
lg: "h-12 px-5 text-base",
|
|
23
|
+
xl: "h-14 px-6 text-lg",
|
|
24
|
+
};
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
fontWeight: '500',
|
|
28
|
-
cursor: disabled || loading ? 'not-allowed' : 'pointer',
|
|
29
|
-
transition: 'all 0.15s ease-in-out',
|
|
30
|
-
opacity: disabled || loading ? 0.6 : 1,
|
|
31
|
-
transform: isActive ? 'scale(0.95)' : 'scale(1)', // 👈 shrink effect
|
|
32
|
-
};
|
|
26
|
+
const radiusClasses = {
|
|
27
|
+
sm: "rounded-sm",
|
|
28
|
+
md: "rounded-md",
|
|
29
|
+
lg: "rounded-lg",
|
|
30
|
+
xl: "rounded-xl",
|
|
31
|
+
full: "rounded-full",
|
|
32
|
+
};
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
ghost: { backgroundColor: 'transparent', color: '#374151' },
|
|
40
|
-
};
|
|
34
|
+
const borderClasses = clsx(
|
|
35
|
+
`border-${borderWidth}`,
|
|
36
|
+
borderStyle !== "solid" && `border-${borderStyle}`,
|
|
37
|
+
borderColor === "white" ? "border-white" : "border-black"
|
|
38
|
+
);
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
const buttonClasses = clsx(
|
|
41
|
+
"inline-flex items-center justify-center font-medium",
|
|
42
|
+
"transition-transform duration-150 ease-in-out", // smooth animation
|
|
43
|
+
"active:scale-95", // 👈 shrink when clicked
|
|
44
|
+
borderClasses,
|
|
45
|
+
radiusClasses[borderRadius],
|
|
46
|
+
sizeClasses[size],
|
|
47
|
+
disabled || loading ? "opacity-60 cursor-not-allowed" : "cursor-pointer",
|
|
48
|
+
className
|
|
49
|
+
);
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
type={type}
|
|
68
|
-
disabled={disabled || loading}
|
|
69
|
-
onClick={handleClick}
|
|
70
|
-
className={className}
|
|
71
|
-
style={buttonStyles}
|
|
72
|
-
aria-disabled={disabled || loading}
|
|
73
|
-
aria-busy={loading}
|
|
74
|
-
{...rest}
|
|
75
|
-
>
|
|
76
|
-
{loading ? 'Loading...' : children}
|
|
77
|
-
</button>
|
|
78
|
-
);
|
|
51
|
+
return (
|
|
52
|
+
<button
|
|
53
|
+
type={type}
|
|
54
|
+
disabled={disabled || loading}
|
|
55
|
+
onClick={onClick}
|
|
56
|
+
className={buttonClasses}
|
|
57
|
+
{...rest}
|
|
58
|
+
>
|
|
59
|
+
{loading ? (
|
|
60
|
+
<span className="flex items-center gap-2">
|
|
61
|
+
<span className="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin" />
|
|
62
|
+
Loading...
|
|
63
|
+
</span>
|
|
64
|
+
) : (
|
|
65
|
+
children
|
|
66
|
+
)}
|
|
67
|
+
</button>
|
|
68
|
+
);
|
|
79
69
|
};
|
|
80
70
|
|
|
81
71
|
Button.propTypes = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
72
|
+
children: PropTypes.node,
|
|
73
|
+
size: PropTypes.oneOf(["sm", "md", "lg", "xl"]),
|
|
74
|
+
disabled: PropTypes.bool,
|
|
75
|
+
loading: PropTypes.bool,
|
|
76
|
+
className: PropTypes.string,
|
|
77
|
+
onClick: PropTypes.func,
|
|
78
|
+
type: PropTypes.oneOf(["button", "submit", "reset"]),
|
|
79
|
+
borderColor: PropTypes.oneOf(["black", "white"]),
|
|
80
|
+
borderWidth: PropTypes.number,
|
|
81
|
+
borderStyle: PropTypes.oneOf(["solid", "dashed", "dotted", "double"]),
|
|
82
|
+
borderRadius: PropTypes.oneOf(["sm", "md", "lg", "xl", "full"]),
|
|
90
83
|
};
|
|
91
84
|
|
|
92
85
|
export default Button;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Button component barrel export
|
|
3
|
+
* This file allows importing the Button component cleanly
|
|
4
|
+
*/
|
|
5
|
+
export { default } from "./component";
|
|
6
|
+
export { default as Button } from "./component";
|
|
@@ -1,28 +1,152 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "Button",
|
|
3
|
-
"description": "A customizable button component with
|
|
3
|
+
"description": "A customizable button component with size, border, radius, and click animation. Fully compatible with Tailwind CSS for background and text colors.",
|
|
4
4
|
"category": "form",
|
|
5
|
-
"tags": [
|
|
5
|
+
"tags": [
|
|
6
|
+
"button",
|
|
7
|
+
"interactive",
|
|
8
|
+
"form",
|
|
9
|
+
"cta",
|
|
10
|
+
"action",
|
|
11
|
+
"tailwind"
|
|
12
|
+
],
|
|
6
13
|
"version": "1.0.0",
|
|
14
|
+
"author": "@rajdeep",
|
|
15
|
+
"created": "2025-08-28",
|
|
7
16
|
"dependencies": {
|
|
8
|
-
"npm": [
|
|
9
|
-
|
|
17
|
+
"npm": [
|
|
18
|
+
"clsx"
|
|
19
|
+
],
|
|
20
|
+
"peer": [
|
|
21
|
+
"react",
|
|
22
|
+
"prop-types"
|
|
23
|
+
]
|
|
10
24
|
},
|
|
11
25
|
"props": [
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{
|
|
26
|
+
{
|
|
27
|
+
"name": "children",
|
|
28
|
+
"type": "React.ReactNode",
|
|
29
|
+
"required": false,
|
|
30
|
+
"default": "undefined",
|
|
31
|
+
"description": "The content to display inside the button"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "size",
|
|
35
|
+
"type": "string",
|
|
36
|
+
"required": false,
|
|
37
|
+
"default": "sm",
|
|
38
|
+
"description": "The size of the button",
|
|
39
|
+
"options": [
|
|
40
|
+
"sm",
|
|
41
|
+
"md",
|
|
42
|
+
"lg",
|
|
43
|
+
"xl"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "disabled",
|
|
48
|
+
"type": "boolean",
|
|
49
|
+
"required": false,
|
|
50
|
+
"default": "false",
|
|
51
|
+
"description": "Whether the button is disabled and non-interactive"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "loading",
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"required": false,
|
|
57
|
+
"default": "false",
|
|
58
|
+
"description": "Whether the button is in a loading state with spinner"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "className",
|
|
62
|
+
"type": "string",
|
|
63
|
+
"required": false,
|
|
64
|
+
"default": "''",
|
|
65
|
+
"description": "Tailwind or custom classes to style background, text, hover, etc."
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "onClick",
|
|
69
|
+
"type": "function",
|
|
70
|
+
"required": false,
|
|
71
|
+
"default": "undefined",
|
|
72
|
+
"description": "Function to call when the button is clicked"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "type",
|
|
76
|
+
"type": "string",
|
|
77
|
+
"required": false,
|
|
78
|
+
"default": "button",
|
|
79
|
+
"description": "The HTML button type attribute",
|
|
80
|
+
"options": [
|
|
81
|
+
"button",
|
|
82
|
+
"submit",
|
|
83
|
+
"reset"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "borderColor",
|
|
88
|
+
"type": "string",
|
|
89
|
+
"required": false,
|
|
90
|
+
"default": "white",
|
|
91
|
+
"description": "Border color of the button",
|
|
92
|
+
"options": [
|
|
93
|
+
"black",
|
|
94
|
+
"white"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "borderWidth",
|
|
99
|
+
"type": "number",
|
|
100
|
+
"required": false,
|
|
101
|
+
"default": "1",
|
|
102
|
+
"description": "Border thickness of the button"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "borderStyle",
|
|
106
|
+
"type": "string",
|
|
107
|
+
"required": false,
|
|
108
|
+
"default": "solid",
|
|
109
|
+
"description": "Border style of the button",
|
|
110
|
+
"options": [
|
|
111
|
+
"solid",
|
|
112
|
+
"dashed",
|
|
113
|
+
"dotted",
|
|
114
|
+
"double"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "borderRadius",
|
|
119
|
+
"type": "string",
|
|
120
|
+
"required": false,
|
|
121
|
+
"default": "md",
|
|
122
|
+
"description": "Border radius for rounded corners",
|
|
123
|
+
"options": [
|
|
124
|
+
"sm",
|
|
125
|
+
"md",
|
|
126
|
+
"lg",
|
|
127
|
+
"xl",
|
|
128
|
+
"full"
|
|
129
|
+
]
|
|
130
|
+
}
|
|
20
131
|
],
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{ "name": "Loading", "code": "<Button loading>Loading...</Button>" }
|
|
132
|
+
"files": [
|
|
133
|
+
"component.jsx",
|
|
134
|
+
"index.js",
|
|
135
|
+
"meta.json"
|
|
26
136
|
],
|
|
27
|
-
"
|
|
137
|
+
"customization": {
|
|
138
|
+
"css_variables": [
|
|
139
|
+
"--button-border-radius",
|
|
140
|
+
"--button-transition"
|
|
141
|
+
],
|
|
142
|
+
"styling_notes": "Background and text colors are meant to be customized using Tailwind classes via className. Borders and radius are controlled via props."
|
|
143
|
+
},
|
|
144
|
+
"accessibility": {
|
|
145
|
+
"features": [
|
|
146
|
+
"Keyboard navigation support",
|
|
147
|
+
"Screen reader friendly with aria-disabled and aria-busy",
|
|
148
|
+
"Focus visible outline",
|
|
149
|
+
"Semantic <button> element"
|
|
150
|
+
]
|
|
151
|
+
}
|
|
28
152
|
}
|