@edu-tosel/design 1.0.288 → 1.0.290
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.
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { CarouselContent } from "../../../../interface";
|
|
2
|
-
|
|
2
|
+
interface CarouselOption {
|
|
3
|
+
isStatic?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export default function Carousel({ contents, option, }: {
|
|
3
6
|
contents: CarouselContent[];
|
|
7
|
+
option?: CarouselOption;
|
|
4
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -7,15 +7,14 @@ import { LineBreaks } from "../../../../text";
|
|
|
7
7
|
import SVG from "../../../../asset/SVG";
|
|
8
8
|
import { tagString } from "../../../../interface/domain";
|
|
9
9
|
import useResponsive from "../../../../hook/useResponsive";
|
|
10
|
-
export default function Carousel({ contents, }) {
|
|
10
|
+
export default function Carousel({ contents, option, }) {
|
|
11
11
|
const [index, setIndex] = useState(0);
|
|
12
12
|
const [flag, inTime] = useEase(10000, 1000);
|
|
13
13
|
const [loaded, setLoaded] = useState(false);
|
|
14
14
|
const isMD = useResponsive("md");
|
|
15
15
|
const isXL = useResponsive("xl");
|
|
16
16
|
const intervalRef = useRef(null);
|
|
17
|
-
const { tag, titles, image
|
|
18
|
-
const { text, background } = option ?? {};
|
|
17
|
+
const { tag, titles, image } = contents[index];
|
|
19
18
|
// Transition animation using react-spring
|
|
20
19
|
const transitionStyles = useSpring({
|
|
21
20
|
opacity: loaded ? 1 : 0,
|
|
@@ -36,7 +35,9 @@ export default function Carousel({ contents, }) {
|
|
|
36
35
|
}, 3000);
|
|
37
36
|
}, [contents.length]);
|
|
38
37
|
useEffect(() => {
|
|
39
|
-
|
|
38
|
+
if (!option?.isStatic) {
|
|
39
|
+
resetTimer(); // timerstarts after mounting component
|
|
40
|
+
}
|
|
40
41
|
return () => {
|
|
41
42
|
// clear timer after unmounting component
|
|
42
43
|
if (intervalRef.current) {
|
|
@@ -59,7 +60,7 @@ export default function Carousel({ contents, }) {
|
|
|
59
60
|
displays: "relative flex justify-center items-center",
|
|
60
61
|
sizes: "w-full h-fit md:h-80 ml:h-100",
|
|
61
62
|
textstyle: "break-keep",
|
|
62
|
-
background,
|
|
63
|
+
background: contents[index].option?.background,
|
|
63
64
|
animations: "duration-300",
|
|
64
65
|
};
|
|
65
66
|
const titleWrapper = {
|
|
@@ -81,7 +82,7 @@ export default function Carousel({ contents, }) {
|
|
|
81
82
|
const body = {
|
|
82
83
|
displays: "flex flex-none flex-col items-center justify-center md:flex-row",
|
|
83
84
|
sizes: "w-full max-w-256 h-full",
|
|
84
|
-
text: text ?? "text-gray-dark",
|
|
85
|
+
text: contents[index].option?.text ?? "text-gray-dark",
|
|
85
86
|
animations: "duration-500",
|
|
86
87
|
};
|
|
87
88
|
const tagBox = {
|
|
@@ -39,13 +39,13 @@ function ModalV2({ titles, openState, contents, theme, btns, }) {
|
|
|
39
39
|
const themeColors = {
|
|
40
40
|
green: "green-dark",
|
|
41
41
|
blue: "blue-navy",
|
|
42
|
-
red: "
|
|
42
|
+
red: "crimson-dark",
|
|
43
43
|
};
|
|
44
44
|
const buttonStyles = (btn) => btn.active
|
|
45
45
|
? cn("flex justify-center items-center w-full h-fit rounded-lg p-3", btn.type === "main"
|
|
46
46
|
? `bg-${themeColors[theme]} text-white`
|
|
47
47
|
: `bg-${themeColors[theme]}/10 text-${themeColors[theme]}`)
|
|
48
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", children: contents }), btns && (_jsx("div", { className: "w-full flex justify-center gap-2 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) }))] }) }) }));
|
|
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
50
|
}
|
|
51
51
|
export default ModalV2;
|
package/package.json
CHANGED
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.290
|