@tunjiadeyemi/ui 1.0.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/LICENSE +21 -0
- package/README.md +80 -0
- package/dist/index.d.mts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +247 -0
- package/dist/index.mjs +218 -0
- package/dist/styles.css +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tunji Adeyemi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @tunjiadeyemi/ui
|
|
2
|
+
|
|
3
|
+
A collection of reusable React UI components built with TypeScript.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tunjiadeyemi/ui framer-motion lucide-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @tunjiadeyemi/ui framer-motion lucide-react
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
First, import the styles in your app's entry point (e.g., `App.tsx` or `main.tsx`):
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import '@tunjiadeyemi/ui/styles.css';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then use the components:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { Modal } from '@tunjiadeyemi/ui';
|
|
29
|
+
import { useState } from 'react';
|
|
30
|
+
|
|
31
|
+
function App() {
|
|
32
|
+
const [showModal, setShowModal] = useState(false);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<button onClick={() => setShowModal(true)}>Open Modal</button>
|
|
37
|
+
|
|
38
|
+
<Modal
|
|
39
|
+
showModal={showModal}
|
|
40
|
+
onClose={() => setShowModal(false)}
|
|
41
|
+
revealMode="fade"
|
|
42
|
+
className="bg-white p-8 rounded-lg max-w-md"
|
|
43
|
+
>
|
|
44
|
+
<h2 className="text-2xl font-bold mb-4">Modal Title</h2>
|
|
45
|
+
<p>Modal content goes here</p>
|
|
46
|
+
</Modal>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Available Components
|
|
53
|
+
|
|
54
|
+
#### Modal
|
|
55
|
+
|
|
56
|
+
A flexible modal component with multiple reveal animations.
|
|
57
|
+
|
|
58
|
+
**Props:**
|
|
59
|
+
- `showModal` (boolean): Controls modal visibility
|
|
60
|
+
- `onClose` (function): Callback when modal is closed
|
|
61
|
+
- `revealMode` ('fade' | 'slide-right' | 'slide-bottom'): Animation style
|
|
62
|
+
- `className` (string): Custom classes for the modal content
|
|
63
|
+
- `children` (ReactNode): Modal content
|
|
64
|
+
|
|
65
|
+
## Development
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Install dependencies
|
|
69
|
+
npm install
|
|
70
|
+
|
|
71
|
+
# Build the package
|
|
72
|
+
npm run build
|
|
73
|
+
|
|
74
|
+
# Watch mode for development
|
|
75
|
+
npm run dev
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT © Tunji Adeyemi
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
|
|
4
|
+
type RevealMode = 'fade' | 'slide-right' | 'slide-bottom';
|
|
5
|
+
interface ModalProps {
|
|
6
|
+
children: React$1.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
revealMode?: RevealMode;
|
|
9
|
+
showModal?: boolean;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
isDrag?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const Modal: ({ children, className, revealMode, showModal, onClose, isDrag }: ModalProps) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
|
|
15
|
+
declare const TextInput: ({ type, value, onChange, placeholder, className, backgroundColor, onOtpClick }: {
|
|
16
|
+
type?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
onOtpClick?: () => void;
|
|
19
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
backgroundColor?: string;
|
|
23
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
24
|
+
|
|
25
|
+
interface SkeletonProps {
|
|
26
|
+
className?: string;
|
|
27
|
+
variant?: 'text' | 'circular' | 'rectangular';
|
|
28
|
+
width?: string | number;
|
|
29
|
+
height?: string | number;
|
|
30
|
+
animation?: 'pulse' | 'wave' | 'none';
|
|
31
|
+
}
|
|
32
|
+
declare const Skeleton: ({ className, variant, width, height, animation }: SkeletonProps) => react_jsx_runtime.JSX.Element;
|
|
33
|
+
|
|
34
|
+
export { Modal, Skeleton, TextInput };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
|
|
4
|
+
type RevealMode = 'fade' | 'slide-right' | 'slide-bottom';
|
|
5
|
+
interface ModalProps {
|
|
6
|
+
children: React$1.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
revealMode?: RevealMode;
|
|
9
|
+
showModal?: boolean;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
isDrag?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const Modal: ({ children, className, revealMode, showModal, onClose, isDrag }: ModalProps) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
|
|
15
|
+
declare const TextInput: ({ type, value, onChange, placeholder, className, backgroundColor, onOtpClick }: {
|
|
16
|
+
type?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
onOtpClick?: () => void;
|
|
19
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
backgroundColor?: string;
|
|
23
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
24
|
+
|
|
25
|
+
interface SkeletonProps {
|
|
26
|
+
className?: string;
|
|
27
|
+
variant?: 'text' | 'circular' | 'rectangular';
|
|
28
|
+
width?: string | number;
|
|
29
|
+
height?: string | number;
|
|
30
|
+
animation?: 'pulse' | 'wave' | 'none';
|
|
31
|
+
}
|
|
32
|
+
declare const Skeleton: ({ className, variant, width, height, animation }: SkeletonProps) => react_jsx_runtime.JSX.Element;
|
|
33
|
+
|
|
34
|
+
export { Modal, Skeleton, TextInput };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Modal: () => Modal_default,
|
|
24
|
+
Skeleton: () => Skeleton_default,
|
|
25
|
+
TextInput: () => TextInput_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/components/Modal.tsx
|
|
30
|
+
var import_framer_motion = require("framer-motion");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var revealVariants = {
|
|
33
|
+
fade: {
|
|
34
|
+
initial: { opacity: 0 },
|
|
35
|
+
animate: { opacity: 1 },
|
|
36
|
+
exit: { opacity: 0 }
|
|
37
|
+
},
|
|
38
|
+
"slide-right": {
|
|
39
|
+
initial: { x: "100%", opacity: 0 },
|
|
40
|
+
animate: { x: 0, opacity: 1 },
|
|
41
|
+
exit: { x: "100%", opacity: 0 }
|
|
42
|
+
},
|
|
43
|
+
"slide-bottom": {
|
|
44
|
+
initial: { y: "100%", opacity: 0 },
|
|
45
|
+
animate: { y: 0, opacity: 1 },
|
|
46
|
+
exit: { y: "100%", opacity: 0 }
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var Modal = ({
|
|
50
|
+
children,
|
|
51
|
+
className,
|
|
52
|
+
revealMode = "fade",
|
|
53
|
+
showModal = true,
|
|
54
|
+
onClose,
|
|
55
|
+
isDrag = false
|
|
56
|
+
}) => {
|
|
57
|
+
const variants = revealVariants[revealMode];
|
|
58
|
+
const handleOverlayClick = (e) => {
|
|
59
|
+
if (e.target === e.currentTarget && onClose) {
|
|
60
|
+
onClose();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const handleDragEnd = (_event, info) => {
|
|
64
|
+
if (info.offset.y > 100 && onClose) {
|
|
65
|
+
onClose();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { mode: "wait", children: showModal && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
import_framer_motion.motion.div,
|
|
70
|
+
{
|
|
71
|
+
initial: { opacity: 0 },
|
|
72
|
+
animate: { opacity: 1 },
|
|
73
|
+
exit: { opacity: 0 },
|
|
74
|
+
transition: { duration: 0.3 },
|
|
75
|
+
className: `fixed inset-0 bg-black/80 flex items-center z-50 ${revealMode === "slide-right" ? "justify-end" : "justify-center"}`,
|
|
76
|
+
onClick: handleOverlayClick,
|
|
77
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
78
|
+
import_framer_motion.motion.div,
|
|
79
|
+
{
|
|
80
|
+
initial: variants.initial,
|
|
81
|
+
animate: variants.animate,
|
|
82
|
+
exit: variants.exit,
|
|
83
|
+
transition: { duration: 0.4, ease: "easeInOut" },
|
|
84
|
+
className: `${className}`,
|
|
85
|
+
onClick: (e) => e.stopPropagation(),
|
|
86
|
+
drag: revealMode === "slide-bottom" ? "y" : false,
|
|
87
|
+
dragConstraints: { top: 0, bottom: 0 },
|
|
88
|
+
dragElastic: { top: 0, bottom: 0.5 },
|
|
89
|
+
onDragEnd: handleDragEnd,
|
|
90
|
+
children: [
|
|
91
|
+
isDrag && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
+
"button",
|
|
93
|
+
{
|
|
94
|
+
className: "w-full flex justify-center mb-4 lg:hidden pt-2",
|
|
95
|
+
"aria-label": "Drag Indicator",
|
|
96
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
+
"img",
|
|
98
|
+
{
|
|
99
|
+
src: `/icons/mobile-modal-drag.svg`,
|
|
100
|
+
height: 50,
|
|
101
|
+
width: 50,
|
|
102
|
+
alt: "Modal Icon"
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
children
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
"modal-content"
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
) });
|
|
114
|
+
};
|
|
115
|
+
var Modal_default = Modal;
|
|
116
|
+
|
|
117
|
+
// src/components/TextInput.tsx
|
|
118
|
+
var import_react = require("react");
|
|
119
|
+
var import_lucide_react = require("lucide-react");
|
|
120
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
121
|
+
var TextInput = ({
|
|
122
|
+
type,
|
|
123
|
+
value,
|
|
124
|
+
onChange,
|
|
125
|
+
placeholder,
|
|
126
|
+
className,
|
|
127
|
+
backgroundColor = "#1F1F23",
|
|
128
|
+
onOtpClick
|
|
129
|
+
}) => {
|
|
130
|
+
const [showPassword, setShowPassword] = (0, import_react.useState)(false);
|
|
131
|
+
const togglePasswordVisibility = () => {
|
|
132
|
+
setShowPassword(!showPassword);
|
|
133
|
+
};
|
|
134
|
+
if (type === "password") {
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "relative w-full", children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
137
|
+
"input",
|
|
138
|
+
{
|
|
139
|
+
type: showPassword ? "text" : "password",
|
|
140
|
+
value,
|
|
141
|
+
onChange,
|
|
142
|
+
placeholder,
|
|
143
|
+
style: { backgroundColor },
|
|
144
|
+
className: `w-full border rounded-[10px] border-transparent placeholder:text-sm text-sm px-4 pr-12 h-[40px] text-white placeholder:opacity-30 focus:outline-none focus:border-[#6B2CE9] transition ${className}`
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
148
|
+
"button",
|
|
149
|
+
{
|
|
150
|
+
type: "button",
|
|
151
|
+
onClick: togglePasswordVisibility,
|
|
152
|
+
className: "absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 hover:text-white transition-colors",
|
|
153
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
154
|
+
children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Eye, { className: "cursor-pointer", size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.EyeClosed, { className: "cursor-pointer", size: 18 })
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] });
|
|
158
|
+
} else if (type === "otp") {
|
|
159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "relative w-full flex items-center gap-4", children: [
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
161
|
+
"input",
|
|
162
|
+
{
|
|
163
|
+
type: "number",
|
|
164
|
+
value,
|
|
165
|
+
onChange,
|
|
166
|
+
placeholder,
|
|
167
|
+
style: { backgroundColor },
|
|
168
|
+
className: `w-full border rounded-[10px] border-transparent placeholder:text-sm text-sm px-4 pr-28 h-[40px] text-white placeholder:opacity-30 focus:outline-none focus:border-[#6B2CE9] transition ${className}`
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
172
|
+
"button",
|
|
173
|
+
{
|
|
174
|
+
type: "button",
|
|
175
|
+
onClick: onOtpClick,
|
|
176
|
+
className: "text-[#A77BFF] cursor-pointer font-medium text-sm w-fit absolute right-4 top-1/2 -translate-y-1/2",
|
|
177
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
178
|
+
children: "Resend code"
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
] });
|
|
182
|
+
} else {
|
|
183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
184
|
+
"input",
|
|
185
|
+
{
|
|
186
|
+
type,
|
|
187
|
+
value,
|
|
188
|
+
onChange,
|
|
189
|
+
placeholder,
|
|
190
|
+
style: { backgroundColor },
|
|
191
|
+
className: `w-full border rounded-[10px] border-transparent placeholder:text-sm text-sm px-4 h-[40px] text-white placeholder:opacity-30 focus:outline-none focus:border-[#6B2CE9] transition ${className}`
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
var TextInput_default = TextInput;
|
|
197
|
+
|
|
198
|
+
// src/components/Skeleton.tsx
|
|
199
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
200
|
+
var Skeleton = ({
|
|
201
|
+
className = "",
|
|
202
|
+
variant = "rectangular",
|
|
203
|
+
width,
|
|
204
|
+
height,
|
|
205
|
+
animation = "pulse"
|
|
206
|
+
}) => {
|
|
207
|
+
const getVariantClasses = () => {
|
|
208
|
+
switch (variant) {
|
|
209
|
+
case "text":
|
|
210
|
+
return "rounded-[4px] h-4";
|
|
211
|
+
case "circular":
|
|
212
|
+
return "rounded-full";
|
|
213
|
+
case "rectangular":
|
|
214
|
+
default:
|
|
215
|
+
return "rounded-[12px]";
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const getAnimationClasses = () => {
|
|
219
|
+
switch (animation) {
|
|
220
|
+
case "pulse":
|
|
221
|
+
return "animate-pulse";
|
|
222
|
+
case "wave":
|
|
223
|
+
return "animate-shimmer bg-gradient-to-r from-[#27272E] via-[#2f2f35] to-[#27272E] bg-[length:200%_100%]";
|
|
224
|
+
case "none":
|
|
225
|
+
default:
|
|
226
|
+
return "";
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
const style = {
|
|
230
|
+
width: width || "100%",
|
|
231
|
+
height: height || "100%"
|
|
232
|
+
};
|
|
233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
234
|
+
"div",
|
|
235
|
+
{
|
|
236
|
+
className: `bg-[#27272E] ${getVariantClasses()} ${getAnimationClasses()} ${className}`,
|
|
237
|
+
style
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
var Skeleton_default = Skeleton;
|
|
242
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
243
|
+
0 && (module.exports = {
|
|
244
|
+
Modal,
|
|
245
|
+
Skeleton,
|
|
246
|
+
TextInput
|
|
247
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// src/components/Modal.tsx
|
|
2
|
+
import { motion, AnimatePresence } from "framer-motion";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var revealVariants = {
|
|
5
|
+
fade: {
|
|
6
|
+
initial: { opacity: 0 },
|
|
7
|
+
animate: { opacity: 1 },
|
|
8
|
+
exit: { opacity: 0 }
|
|
9
|
+
},
|
|
10
|
+
"slide-right": {
|
|
11
|
+
initial: { x: "100%", opacity: 0 },
|
|
12
|
+
animate: { x: 0, opacity: 1 },
|
|
13
|
+
exit: { x: "100%", opacity: 0 }
|
|
14
|
+
},
|
|
15
|
+
"slide-bottom": {
|
|
16
|
+
initial: { y: "100%", opacity: 0 },
|
|
17
|
+
animate: { y: 0, opacity: 1 },
|
|
18
|
+
exit: { y: "100%", opacity: 0 }
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var Modal = ({
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
revealMode = "fade",
|
|
25
|
+
showModal = true,
|
|
26
|
+
onClose,
|
|
27
|
+
isDrag = false
|
|
28
|
+
}) => {
|
|
29
|
+
const variants = revealVariants[revealMode];
|
|
30
|
+
const handleOverlayClick = (e) => {
|
|
31
|
+
if (e.target === e.currentTarget && onClose) {
|
|
32
|
+
onClose();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const handleDragEnd = (_event, info) => {
|
|
36
|
+
if (info.offset.y > 100 && onClose) {
|
|
37
|
+
onClose();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: showModal && /* @__PURE__ */ jsx(
|
|
41
|
+
motion.div,
|
|
42
|
+
{
|
|
43
|
+
initial: { opacity: 0 },
|
|
44
|
+
animate: { opacity: 1 },
|
|
45
|
+
exit: { opacity: 0 },
|
|
46
|
+
transition: { duration: 0.3 },
|
|
47
|
+
className: `fixed inset-0 bg-black/80 flex items-center z-50 ${revealMode === "slide-right" ? "justify-end" : "justify-center"}`,
|
|
48
|
+
onClick: handleOverlayClick,
|
|
49
|
+
children: /* @__PURE__ */ jsxs(
|
|
50
|
+
motion.div,
|
|
51
|
+
{
|
|
52
|
+
initial: variants.initial,
|
|
53
|
+
animate: variants.animate,
|
|
54
|
+
exit: variants.exit,
|
|
55
|
+
transition: { duration: 0.4, ease: "easeInOut" },
|
|
56
|
+
className: `${className}`,
|
|
57
|
+
onClick: (e) => e.stopPropagation(),
|
|
58
|
+
drag: revealMode === "slide-bottom" ? "y" : false,
|
|
59
|
+
dragConstraints: { top: 0, bottom: 0 },
|
|
60
|
+
dragElastic: { top: 0, bottom: 0.5 },
|
|
61
|
+
onDragEnd: handleDragEnd,
|
|
62
|
+
children: [
|
|
63
|
+
isDrag && /* @__PURE__ */ jsx(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
className: "w-full flex justify-center mb-4 lg:hidden pt-2",
|
|
67
|
+
"aria-label": "Drag Indicator",
|
|
68
|
+
children: /* @__PURE__ */ jsx(
|
|
69
|
+
"img",
|
|
70
|
+
{
|
|
71
|
+
src: `/icons/mobile-modal-drag.svg`,
|
|
72
|
+
height: 50,
|
|
73
|
+
width: 50,
|
|
74
|
+
alt: "Modal Icon"
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
children
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"modal-content"
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
) });
|
|
86
|
+
};
|
|
87
|
+
var Modal_default = Modal;
|
|
88
|
+
|
|
89
|
+
// src/components/TextInput.tsx
|
|
90
|
+
import { useState } from "react";
|
|
91
|
+
import { Eye, EyeClosed } from "lucide-react";
|
|
92
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
93
|
+
var TextInput = ({
|
|
94
|
+
type,
|
|
95
|
+
value,
|
|
96
|
+
onChange,
|
|
97
|
+
placeholder,
|
|
98
|
+
className,
|
|
99
|
+
backgroundColor = "#1F1F23",
|
|
100
|
+
onOtpClick
|
|
101
|
+
}) => {
|
|
102
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
103
|
+
const togglePasswordVisibility = () => {
|
|
104
|
+
setShowPassword(!showPassword);
|
|
105
|
+
};
|
|
106
|
+
if (type === "password") {
|
|
107
|
+
return /* @__PURE__ */ jsxs2("div", { className: "relative w-full", children: [
|
|
108
|
+
/* @__PURE__ */ jsx2(
|
|
109
|
+
"input",
|
|
110
|
+
{
|
|
111
|
+
type: showPassword ? "text" : "password",
|
|
112
|
+
value,
|
|
113
|
+
onChange,
|
|
114
|
+
placeholder,
|
|
115
|
+
style: { backgroundColor },
|
|
116
|
+
className: `w-full border rounded-[10px] border-transparent placeholder:text-sm text-sm px-4 pr-12 h-[40px] text-white placeholder:opacity-30 focus:outline-none focus:border-[#6B2CE9] transition ${className}`
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ jsx2(
|
|
120
|
+
"button",
|
|
121
|
+
{
|
|
122
|
+
type: "button",
|
|
123
|
+
onClick: togglePasswordVisibility,
|
|
124
|
+
className: "absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 hover:text-white transition-colors",
|
|
125
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
126
|
+
children: showPassword ? /* @__PURE__ */ jsx2(Eye, { className: "cursor-pointer", size: 18 }) : /* @__PURE__ */ jsx2(EyeClosed, { className: "cursor-pointer", size: 18 })
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
] });
|
|
130
|
+
} else if (type === "otp") {
|
|
131
|
+
return /* @__PURE__ */ jsxs2("div", { className: "relative w-full flex items-center gap-4", children: [
|
|
132
|
+
/* @__PURE__ */ jsx2(
|
|
133
|
+
"input",
|
|
134
|
+
{
|
|
135
|
+
type: "number",
|
|
136
|
+
value,
|
|
137
|
+
onChange,
|
|
138
|
+
placeholder,
|
|
139
|
+
style: { backgroundColor },
|
|
140
|
+
className: `w-full border rounded-[10px] border-transparent placeholder:text-sm text-sm px-4 pr-28 h-[40px] text-white placeholder:opacity-30 focus:outline-none focus:border-[#6B2CE9] transition ${className}`
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ jsx2(
|
|
144
|
+
"button",
|
|
145
|
+
{
|
|
146
|
+
type: "button",
|
|
147
|
+
onClick: onOtpClick,
|
|
148
|
+
className: "text-[#A77BFF] cursor-pointer font-medium text-sm w-fit absolute right-4 top-1/2 -translate-y-1/2",
|
|
149
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
150
|
+
children: "Resend code"
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] });
|
|
154
|
+
} else {
|
|
155
|
+
return /* @__PURE__ */ jsx2(
|
|
156
|
+
"input",
|
|
157
|
+
{
|
|
158
|
+
type,
|
|
159
|
+
value,
|
|
160
|
+
onChange,
|
|
161
|
+
placeholder,
|
|
162
|
+
style: { backgroundColor },
|
|
163
|
+
className: `w-full border rounded-[10px] border-transparent placeholder:text-sm text-sm px-4 h-[40px] text-white placeholder:opacity-30 focus:outline-none focus:border-[#6B2CE9] transition ${className}`
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var TextInput_default = TextInput;
|
|
169
|
+
|
|
170
|
+
// src/components/Skeleton.tsx
|
|
171
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
172
|
+
var Skeleton = ({
|
|
173
|
+
className = "",
|
|
174
|
+
variant = "rectangular",
|
|
175
|
+
width,
|
|
176
|
+
height,
|
|
177
|
+
animation = "pulse"
|
|
178
|
+
}) => {
|
|
179
|
+
const getVariantClasses = () => {
|
|
180
|
+
switch (variant) {
|
|
181
|
+
case "text":
|
|
182
|
+
return "rounded-[4px] h-4";
|
|
183
|
+
case "circular":
|
|
184
|
+
return "rounded-full";
|
|
185
|
+
case "rectangular":
|
|
186
|
+
default:
|
|
187
|
+
return "rounded-[12px]";
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const getAnimationClasses = () => {
|
|
191
|
+
switch (animation) {
|
|
192
|
+
case "pulse":
|
|
193
|
+
return "animate-pulse";
|
|
194
|
+
case "wave":
|
|
195
|
+
return "animate-shimmer bg-gradient-to-r from-[#27272E] via-[#2f2f35] to-[#27272E] bg-[length:200%_100%]";
|
|
196
|
+
case "none":
|
|
197
|
+
default:
|
|
198
|
+
return "";
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const style = {
|
|
202
|
+
width: width || "100%",
|
|
203
|
+
height: height || "100%"
|
|
204
|
+
};
|
|
205
|
+
return /* @__PURE__ */ jsx3(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
className: `bg-[#27272E] ${getVariantClasses()} ${getAnimationClasses()} ${className}`,
|
|
209
|
+
style
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
var Skeleton_default = Skeleton;
|
|
214
|
+
export {
|
|
215
|
+
Modal_default as Modal,
|
|
216
|
+
Skeleton_default as Skeleton,
|
|
217
|
+
TextInput_default as TextInput
|
|
218
|
+
};
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tunjiadeyemi/ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A collection of reusable UI components",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./styles.css": "./dist/styles.css"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --external react --external react-dom --external framer-motion --external lucide-react && npm run build:css",
|
|
23
|
+
"build:css": "cp ./src/styles.css ./dist/styles.css",
|
|
24
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --external react --external react-dom --external framer-motion --external lucide-react",
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
26
|
+
"lint": "eslint src --ext .ts,.tsx"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"react",
|
|
30
|
+
"ui",
|
|
31
|
+
"components",
|
|
32
|
+
"typescript"
|
|
33
|
+
],
|
|
34
|
+
"author": "Tunji Adeyemi",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/tunjiadeyemi/ui"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"framer-motion": "^11.0.0",
|
|
42
|
+
"lucide-react": "^0.400.0",
|
|
43
|
+
"react": "^18.0.0",
|
|
44
|
+
"react-dom": "^18.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/react": "^18.2.0",
|
|
48
|
+
"@types/react-dom": "^18.2.0",
|
|
49
|
+
"autoprefixer": "^10.4.16",
|
|
50
|
+
"lucide-react": "^0.562.0",
|
|
51
|
+
"postcss": "^8.4.32",
|
|
52
|
+
"tailwindcss": "4.0.0",
|
|
53
|
+
"tsup": "^8.0.0",
|
|
54
|
+
"typescript": "^5.3.0"
|
|
55
|
+
}
|
|
56
|
+
}
|