@windstream/react-shared-components 0.1.25 → 0.1.26
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/package.json
CHANGED
|
@@ -1,94 +1,99 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import {
|
|
5
|
-
backdropAnimationVariants,
|
|
6
|
-
contentAnimationVariants,
|
|
7
|
-
sizeToPixel,
|
|
8
|
-
} from "./constants";
|
|
9
|
-
import { ModalProps } from "./types";
|
|
10
|
-
import { motion } from "framer-motion";
|
|
11
|
-
|
|
12
|
-
import * as Dialog from "@radix-ui/react-dialog";
|
|
13
|
-
import { MaterialIcon } from "@shared/components/material-icon";
|
|
14
|
-
import { Text } from "@shared/components/text";
|
|
15
|
-
import { Button } from "@shared/contentful/blocks/button";
|
|
16
|
-
import { cx } from "@shared/utils";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {
|
|
5
|
+
backdropAnimationVariants,
|
|
6
|
+
contentAnimationVariants,
|
|
7
|
+
sizeToPixel,
|
|
8
|
+
} from "./constants";
|
|
9
|
+
import { ModalProps } from "./types";
|
|
10
|
+
import { motion } from "framer-motion";
|
|
11
|
+
|
|
12
|
+
import * as Dialog from "@radix-ui/react-dialog";
|
|
13
|
+
import { MaterialIcon } from "@shared/components/material-icon";
|
|
14
|
+
import { Text } from "@shared/components/text";
|
|
15
|
+
import { Button } from "@shared/contentful/blocks/button";
|
|
16
|
+
import { cx } from "@shared/utils";
|
|
17
|
+
|
|
18
|
+
type ExtendedModalProps = ModalProps & {
|
|
19
|
+
type?: "modal";
|
|
20
|
+
index?: 0;
|
|
21
|
+
};
|
|
22
|
+
export const Modal: React.FC<ExtendedModalProps> = props => {
|
|
23
|
+
const {
|
|
24
|
+
isOpen,
|
|
25
|
+
onRequestClose,
|
|
26
|
+
size,
|
|
27
|
+
title,
|
|
28
|
+
content,
|
|
29
|
+
description,
|
|
30
|
+
children,
|
|
31
|
+
bodyClassName,
|
|
32
|
+
type,
|
|
33
|
+
index,
|
|
34
|
+
} = props;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Dialog.Root
|
|
38
|
+
open={isOpen}
|
|
39
|
+
onOpenChange={() => isOpen && onRequestClose?.()}
|
|
40
|
+
>
|
|
41
|
+
<Dialog.Portal>
|
|
42
|
+
<motion.div
|
|
43
|
+
initial="closed"
|
|
44
|
+
animate={isOpen ? "open" : "closed"}
|
|
45
|
+
variants={backdropAnimationVariants}
|
|
46
|
+
transition={{ type: "tween", duration: 0.2, ease: "easeInOut" }}
|
|
47
|
+
className="fixed inset-0 z-[1000] bg-scrim-bg-modal"
|
|
48
|
+
>
|
|
49
|
+
<Dialog.Overlay />
|
|
50
|
+
</motion.div>
|
|
51
|
+
<motion.div
|
|
52
|
+
initial="closed"
|
|
53
|
+
animate={isOpen ? "open" : "closed"}
|
|
54
|
+
variants={contentAnimationVariants}
|
|
55
|
+
transition={{ type: "tween", duration: 0.3, ease: "easeInOut" }}
|
|
56
|
+
className="fixed left-1/2 top-1/2 z-[1001] w-auto -translate-x-1/2 -translate-y-1/2 focus:outline-none"
|
|
57
|
+
>
|
|
58
|
+
<Dialog.Content
|
|
59
|
+
className={cx(
|
|
60
|
+
"fixed left-[50%] top-[50%] w-[90vw] translate-x-[-50%] translate-y-[-50%] rounded-[6px] bg-bg p-[25px] shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none",
|
|
61
|
+
bodyClassName
|
|
62
|
+
)}
|
|
63
|
+
style={{ maxWidth: sizeToPixel[size || "lg"] }}
|
|
64
|
+
>
|
|
65
|
+
<div data-section-type={type} data-section-index={index}>
|
|
66
|
+
<Dialog.Close asChild={true}>
|
|
67
|
+
<Button
|
|
68
|
+
showButtonAs="unstyled"
|
|
69
|
+
buttonClassName="absolute right-0 top-0 mr-2 mt-2 bg-bg"
|
|
70
|
+
>
|
|
71
|
+
<MaterialIcon name="close" />
|
|
72
|
+
</Button>
|
|
73
|
+
</Dialog.Close>
|
|
74
|
+
<div className="custom-modal-body max-h-[85vh] overflow-visible">
|
|
75
|
+
{title ? (
|
|
76
|
+
<Text
|
|
77
|
+
className={cx(
|
|
78
|
+
"mx-auto mb-3 mt-5 text-center",
|
|
79
|
+
"heading5 md:max-w-[80%] md:pt-0",
|
|
80
|
+
"mb-5 md:mb-[60px]"
|
|
81
|
+
)}
|
|
82
|
+
as="h2"
|
|
83
|
+
>
|
|
84
|
+
{title}
|
|
85
|
+
</Text>
|
|
86
|
+
) : null}
|
|
87
|
+
|
|
88
|
+
{description ? <Text as="div">{description}</Text> : null}
|
|
89
|
+
|
|
90
|
+
{content}
|
|
91
|
+
{children ? children : null}
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</Dialog.Content>
|
|
95
|
+
</motion.div>
|
|
96
|
+
</Dialog.Portal>
|
|
97
|
+
</Dialog.Root>
|
|
98
|
+
);
|
|
99
|
+
};
|