oneslash-design-system 1.1.1 → 1.1.3
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/components/button.tsx
CHANGED
|
@@ -111,7 +111,9 @@ export default function Button({
|
|
|
111
111
|
{IconLeft && (
|
|
112
112
|
<IconLeft className={sizeIcon} />
|
|
113
113
|
)}
|
|
114
|
-
<div className="whitespace-nowrap px-2">
|
|
114
|
+
<div className="flex-1 whitespace-nowrap overflow-hidden truncate px-2">
|
|
115
|
+
{label}
|
|
116
|
+
</div>
|
|
115
117
|
{IconRight && (
|
|
116
118
|
<div onClick={onClickActionIcon} className="cursor-pointer">
|
|
117
119
|
<IconRight className={sizeIcon} />
|
package/components/modal.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
2
|
|
|
4
3
|
interface ModalProps {
|
|
5
4
|
isOpen: boolean;
|
|
6
|
-
title
|
|
5
|
+
title?: string;
|
|
7
6
|
children: React.ReactNode;
|
|
8
7
|
onClose: () => void;
|
|
9
|
-
actions
|
|
8
|
+
actions?: React.ReactNode;
|
|
9
|
+
size?: 'medium' | 'large';
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export default function Modal({
|
|
@@ -15,28 +15,37 @@ export default function Modal({
|
|
|
15
15
|
children,
|
|
16
16
|
onClose,
|
|
17
17
|
actions,
|
|
18
|
+
size = 'medium', // Default size is medium
|
|
18
19
|
}: ModalProps) {
|
|
20
|
+
|
|
19
21
|
if (!isOpen) return null;
|
|
20
22
|
|
|
23
|
+
// close modal by clicking elsewhere
|
|
21
24
|
const handleOverlayClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
22
25
|
if (e.target === e.currentTarget) {
|
|
23
26
|
onClose();
|
|
24
27
|
}
|
|
25
28
|
};
|
|
26
29
|
|
|
30
|
+
// close modal by esc keypress
|
|
27
31
|
useEffect(() => {
|
|
28
32
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
29
33
|
if (e.key === 'Escape') {
|
|
30
34
|
onClose();
|
|
31
35
|
}
|
|
32
36
|
};
|
|
33
|
-
|
|
34
37
|
window.addEventListener('keydown', handleKeyDown);
|
|
35
38
|
return () => {
|
|
36
39
|
window.removeEventListener('keydown', handleKeyDown);
|
|
37
40
|
};
|
|
38
41
|
}, [onClose]);
|
|
39
42
|
|
|
43
|
+
// Determine width based on size prop
|
|
44
|
+
const modalWidth = size === 'large' ? 'w-[1200px]' : 'w-[600px]';
|
|
45
|
+
const maxWidth = size === 'large' ? '1200px' : '600px';
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
40
49
|
return (
|
|
41
50
|
<div
|
|
42
51
|
className="fixed inset-[-32px] bg-black bg-opacity-50 flex items-center justify-center z-50"
|
|
@@ -44,23 +53,31 @@ export default function Modal({
|
|
|
44
53
|
role="dialog"
|
|
45
54
|
aria-labelledby="modal-title"
|
|
46
55
|
aria-modal="true"
|
|
56
|
+
tabIndex={-1}
|
|
47
57
|
>
|
|
48
58
|
<div
|
|
49
|
-
className=
|
|
59
|
+
className={`bg-light-background-default dark:bg-dark-background-default p-6 rounded-[8px] space-y-4 ${modalWidth}`}
|
|
50
60
|
style={{
|
|
51
|
-
|
|
61
|
+
maxWidth,
|
|
62
|
+
width: 'calc(100vw - 64px)',
|
|
63
|
+
maxHeight: '800px',
|
|
64
|
+
height: 'auto',
|
|
52
65
|
overflowY: 'auto',
|
|
53
66
|
}}
|
|
54
67
|
>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
{title && (
|
|
69
|
+
<h2 id="modal-title" className="text-h6">
|
|
70
|
+
{title}
|
|
71
|
+
</h2>
|
|
72
|
+
)}
|
|
58
73
|
<div className="text-body1 space-y-4">
|
|
59
74
|
{children}
|
|
60
75
|
</div>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
{actions && (
|
|
77
|
+
<div className="flex justify-between">
|
|
78
|
+
{actions}
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
64
81
|
</div>
|
|
65
82
|
</div>
|
|
66
83
|
);
|
package/components/popover.tsx
CHANGED
|
Binary file
|