@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,6 +1,6 @@
1
1
  {
2
2
  "name": "@windstream/react-shared-components",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "type": "module",
5
5
  "description": "Shared React components for Kinetic applications",
6
6
  "main": "dist/index.js",
@@ -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
- export const Modal: React.FC<ModalProps> = props => {
19
- const {
20
- isOpen,
21
- onRequestClose,
22
- size,
23
- title,
24
- content,
25
- description,
26
- children,
27
- bodyClassName,
28
- ...rest
29
- } = props;
30
-
31
- return (
32
- <Dialog.Root
33
- open={isOpen}
34
- onOpenChange={() => isOpen && onRequestClose?.()}
35
- >
36
- <Dialog.Portal>
37
- <motion.div
38
- initial="closed"
39
- animate={isOpen ? "open" : "closed"}
40
- variants={backdropAnimationVariants}
41
- transition={{ type: "tween", duration: 0.2, ease: "easeInOut" }}
42
- className="fixed inset-0 z-[1000] bg-scrim-bg-modal"
43
- >
44
- <Dialog.Overlay />
45
- </motion.div>
46
- <motion.div
47
- initial="closed"
48
- animate={isOpen ? "open" : "closed"}
49
- variants={contentAnimationVariants}
50
- transition={{ type: "tween", duration: 0.3, ease: "easeInOut" }}
51
- className="fixed left-1/2 top-1/2 z-[1001] w-auto -translate-x-1/2 -translate-y-1/2 focus:outline-none"
52
- >
53
- <Dialog.Content
54
- className={cx(
55
- "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",
56
- bodyClassName
57
- )}
58
- style={{ maxWidth: sizeToPixel[size || "lg"] }}
59
- >
60
- <div {...rest}>
61
- <Dialog.Close asChild={true}>
62
- <Button
63
- showButtonAs="unstyled"
64
- buttonClassName="absolute right-0 top-0 mr-2 mt-2 bg-bg"
65
- >
66
- <MaterialIcon name="close" />
67
- </Button>
68
- </Dialog.Close>
69
- <div className="custom-modal-body max-h-[85vh] overflow-visible">
70
- {title ? (
71
- <Text
72
- className={cx(
73
- "mx-auto mb-3 mt-5 text-center",
74
- "heading5 md:max-w-[80%] md:pt-0",
75
- "mb-5 md:mb-[60px]"
76
- )}
77
- as="h2"
78
- >
79
- {title}
80
- </Text>
81
- ) : null}
82
-
83
- {description ? <Text as="div">{description}</Text> : null}
84
-
85
- {content}
86
- {children ? children : null}
87
- </div>
88
- </div>
89
- </Dialog.Content>
90
- </motion.div>
91
- </Dialog.Portal>
92
- </Dialog.Root>
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
+ };