@edu-tosel/design 1.0.287 → 1.0.289
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/modalV2/index.d.ts +1 -0
- package/modalV2/index.js +1 -0
- package/modalV2/template/index.d.ts +22 -0
- package/modalV2/template/index.js +51 -0
- package/package.json +1 -1
- package/version.txt +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ModalV2 } from "./template";
|
package/modalV2/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ModalV2 } from "./template";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface Button {
|
|
3
|
+
active: boolean;
|
|
4
|
+
type: ButtonType;
|
|
5
|
+
options?: {
|
|
6
|
+
title: string;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
type Theme = "green" | "red" | "blue";
|
|
11
|
+
type ButtonType = "main" | "sub";
|
|
12
|
+
declare function ModalV2({ titles, openState, contents, theme, btns, }: {
|
|
13
|
+
titles: {
|
|
14
|
+
title: string;
|
|
15
|
+
subtitle: string;
|
|
16
|
+
};
|
|
17
|
+
openState: [boolean, React.Dispatch<React.SetStateAction<boolean>>];
|
|
18
|
+
contents: React.ReactNode;
|
|
19
|
+
theme: Theme;
|
|
20
|
+
btns?: Button[];
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default ModalV2;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../util";
|
|
3
|
+
function ModalV2({ titles, openState, contents, theme, btns, }) {
|
|
4
|
+
const [isOpen, setIsOpen] = openState;
|
|
5
|
+
const container = {
|
|
6
|
+
positions: "fixed inset-0 z-100",
|
|
7
|
+
displays: "flex flex-col justify-center items-center",
|
|
8
|
+
backgrounds: "bg-black/20 backdrop-blur-sm duration-300",
|
|
9
|
+
animation: isOpen
|
|
10
|
+
? "opacity-100 pointer-events-auto"
|
|
11
|
+
: "opacity-0 pointer-events-none",
|
|
12
|
+
};
|
|
13
|
+
const boxPositionWrapper = {
|
|
14
|
+
displays: "flex flex-col justify-end items-center",
|
|
15
|
+
sizes: "w-full h-full",
|
|
16
|
+
};
|
|
17
|
+
const tagWrapper = {
|
|
18
|
+
displays: "flex flex-col rounded-tl-lg rounded-tr-lg bg-white",
|
|
19
|
+
sizes: "w-full h-fit max-w-120",
|
|
20
|
+
spacings: "p-5 gap-5",
|
|
21
|
+
position: isOpen ? "translate-y-0" : "translate-y-full",
|
|
22
|
+
animation: "duration-300",
|
|
23
|
+
pointer: "pointer-events-auto",
|
|
24
|
+
};
|
|
25
|
+
const titleWrapper = {
|
|
26
|
+
displays: "flex flex-col gap-2",
|
|
27
|
+
sizes: "w-full",
|
|
28
|
+
};
|
|
29
|
+
const titleText = {
|
|
30
|
+
sizes: "w-full",
|
|
31
|
+
textStyles: "font-bold text-lg leading-none",
|
|
32
|
+
colors: "text-gray-dark",
|
|
33
|
+
};
|
|
34
|
+
const subtitleText = {
|
|
35
|
+
sizes: "w-full",
|
|
36
|
+
textStyles: "font-medium text-sm leading-none",
|
|
37
|
+
colors: "text-gray-medium",
|
|
38
|
+
};
|
|
39
|
+
const themeColors = {
|
|
40
|
+
green: "green-dark",
|
|
41
|
+
blue: "blue-navy",
|
|
42
|
+
red: "crimson-dark",
|
|
43
|
+
};
|
|
44
|
+
const buttonStyles = (btn) => btn.active
|
|
45
|
+
? cn("flex justify-center items-center w-full h-fit rounded-lg p-3", btn.type === "main"
|
|
46
|
+
? `bg-${themeColors[theme]} text-white`
|
|
47
|
+
: `bg-${themeColors[theme]}/10 text-${themeColors[theme]}`)
|
|
48
|
+
: "flex justify-center items-center w-full h-fit rounded-lg p-3 bg-gray-light text-gray-dark cursor-not-allowed";
|
|
49
|
+
return (_jsx("div", { className: cn(container), onClick: () => setIsOpen(false), children: _jsx("div", { className: cn(boxPositionWrapper), children: _jsxs("div", { className: cn(tagWrapper), onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "w-full flex justify-between items-start", children: [_jsxs("div", { className: cn(titleWrapper), children: [_jsx("div", { className: cn(titleText), children: titles.title }), _jsx("div", { className: cn(subtitleText), children: titles.subtitle })] }), _jsx("div", { className: "size-6 flex justify-center items-center cursor-pointer", onClick: () => setIsOpen(false), children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "size-6", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18 18 6M6 6l12 12" }) }) })] }), _jsx("div", { className: "w-full flex flex-wrap max-h-100 overflow-scroll", children: contents }), btns && (_jsx("div", { className: "w-full flex justify-center gap-2 cursor-pointer flex-col sm:flex-row", children: btns.map((btn, index) => btn ? (_jsx("div", { className: cn(buttonStyles(btn), btns.length === 1 ? "w-full" : "w-1/2 sm:w-full"), onClick: btn.active ? btn.options?.onClick : undefined, children: btn.options?.title }, index)) : null) }))] }) }) }));
|
|
50
|
+
}
|
|
51
|
+
export default ModalV2;
|
package/package.json
CHANGED
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.289
|