@windstream/react-shared-components 0.1.21 → 0.1.22
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/dist/contentful/index.d.ts +1 -0
- package/dist/contentful/index.esm.js +2 -2
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +2 -2
- package/dist/contentful/index.js.map +1 -1
- package/dist/core.d.ts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/modal/index.tsx +171 -164
- package/src/contentful/blocks/blogs-grid/index.tsx +7 -2
- package/src/contentful/blocks/cards/blog-card/index.tsx +6 -1
- package/src/contentful/blocks/cards/blog-card/types.ts +1 -0
package/package.json
CHANGED
|
@@ -1,164 +1,171 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useMemo, useState } from "react";
|
|
4
|
-
import useBodyScrollLock from "../../hooks/use-body-scroll-lock";
|
|
5
|
-
import { cx } from "../../utils";
|
|
6
|
-
import { Button } from "../button";
|
|
7
|
-
import { MaterialIcon } from "../material-icon";
|
|
8
|
-
import { Animation, ModalProps, Shape, Size } from "./types";
|
|
9
|
-
import ReactModal from "react-modal";
|
|
10
|
-
import { Transition } from "react-transition-group";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
return
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
)}
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
4
|
+
import useBodyScrollLock from "../../hooks/use-body-scroll-lock";
|
|
5
|
+
import { cx } from "../../utils";
|
|
6
|
+
import { Button } from "../button";
|
|
7
|
+
import { MaterialIcon } from "../material-icon";
|
|
8
|
+
import { Animation, ModalProps, Shape, Size } from "./types";
|
|
9
|
+
import ReactModal from "react-modal";
|
|
10
|
+
import { Transition } from "react-transition-group";
|
|
11
|
+
|
|
12
|
+
type ExtendedModalProps = ModalProps & {
|
|
13
|
+
bodyAttributes?: React.HTMLAttributes<HTMLDivElement>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Modal: React.FC<ExtendedModalProps> = ({
|
|
17
|
+
size = "md",
|
|
18
|
+
shape = "default",
|
|
19
|
+
animation = "popper",
|
|
20
|
+
centered,
|
|
21
|
+
title,
|
|
22
|
+
isOpen,
|
|
23
|
+
children,
|
|
24
|
+
bodyStyle,
|
|
25
|
+
className,
|
|
26
|
+
bodyClassName,
|
|
27
|
+
portalClassName,
|
|
28
|
+
overlayClassName,
|
|
29
|
+
closeButtonClassName,
|
|
30
|
+
closeWrapperClassName,
|
|
31
|
+
onRequestClose,
|
|
32
|
+
parentSelector,
|
|
33
|
+
hideScrollOnIsOpenFalse = true,
|
|
34
|
+
hideCloseButton = false,
|
|
35
|
+
bodyAttributes,
|
|
36
|
+
...modalProps
|
|
37
|
+
}: ExtendedModalProps) => {
|
|
38
|
+
// Use the custom hook to lock/unlock the body scroll when the modal is open/closed.
|
|
39
|
+
useBodyScrollLock(isOpen, hideScrollOnIsOpenFalse);
|
|
40
|
+
|
|
41
|
+
// Animation cannot run at the same time as the modal opening
|
|
42
|
+
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
// Run animation one frame after rendering the modal
|
|
46
|
+
setIsTransitioning(isOpen);
|
|
47
|
+
}, [isOpen]);
|
|
48
|
+
|
|
49
|
+
const parent = useMemo(() => {
|
|
50
|
+
/* istanbul ignore next */ if (typeof document === "undefined") return null;
|
|
51
|
+
let parent = document.querySelector("main") || document.body;
|
|
52
|
+
if (parentSelector)
|
|
53
|
+
parent = document.querySelector(parentSelector) || document.body;
|
|
54
|
+
|
|
55
|
+
return parent;
|
|
56
|
+
}, [parentSelector]);
|
|
57
|
+
|
|
58
|
+
if (!parent) return null;
|
|
59
|
+
|
|
60
|
+
// Don't render anything when modal is closed
|
|
61
|
+
if (!isOpen) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const getSizeClasses = (size: Size) => {
|
|
66
|
+
const sizeMap = {
|
|
67
|
+
xl: "inset-[5%] min-h-fit",
|
|
68
|
+
lg: "inset-[10%] min-h-fit",
|
|
69
|
+
md: "inset-[15%] min-h-fit",
|
|
70
|
+
sm: "top-[18%] w-[640px]",
|
|
71
|
+
xs: "w-[calc(100%-30px)]",
|
|
72
|
+
};
|
|
73
|
+
return sizeMap[size];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const getAnimationClasses = (animation: Animation, state: string) => {
|
|
77
|
+
if (animation === "popper") {
|
|
78
|
+
const baseClasses = "transition-transform duration-300";
|
|
79
|
+
if (state === "entering" || state === "entered") {
|
|
80
|
+
return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
|
|
81
|
+
}
|
|
82
|
+
if (state === "exiting" || state === "exited") {
|
|
83
|
+
return `${baseClasses} opacity-0 translate-y-[-18px] duration-[180ms]`;
|
|
84
|
+
}
|
|
85
|
+
return `${baseClasses} opacity-0 translate-y-[-18px]`;
|
|
86
|
+
}
|
|
87
|
+
if (animation === "bottomSheet") {
|
|
88
|
+
const baseClasses = "transition-transform duration-200 ease-in-out";
|
|
89
|
+
if (state === "entering" || state === "entered") {
|
|
90
|
+
return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
|
|
91
|
+
}
|
|
92
|
+
if (state === "exiting" || state === "exited") {
|
|
93
|
+
return `${baseClasses} opacity-0 translate-y-full duration-[180ms]`;
|
|
94
|
+
}
|
|
95
|
+
return `${baseClasses} opacity-0 translate-y-full`;
|
|
96
|
+
}
|
|
97
|
+
return "";
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Transition enter={true} exit={true} in={isTransitioning} timeout={0}>
|
|
102
|
+
{(state: string) => (
|
|
103
|
+
<ReactModal
|
|
104
|
+
ariaHideApp={false}
|
|
105
|
+
isOpen={isOpen}
|
|
106
|
+
onRequestClose={onRequestClose}
|
|
107
|
+
closeTimeoutMS={0}
|
|
108
|
+
parentSelector={() => parent}
|
|
109
|
+
className={cx(
|
|
110
|
+
"absolute min-w-[150px] max-w-[calc(100vw-30px)] overflow-auto rounded-lg bg-white outline-none",
|
|
111
|
+
getSizeClasses(size),
|
|
112
|
+
shape === "rounded" && "rounded-3xl",
|
|
113
|
+
centered && "top-0 translate-y-[calc(50vh-50%)]",
|
|
114
|
+
getAnimationClasses(animation, state),
|
|
115
|
+
className
|
|
116
|
+
)}
|
|
117
|
+
portalClassName={cx("z-80", portalClassName)}
|
|
118
|
+
overlayClassName={cx(
|
|
119
|
+
"z-80 fixed inset-0 bg-black/50 flex items-center justify-center pb-[300px]",
|
|
120
|
+
overlayClassName
|
|
121
|
+
)}
|
|
122
|
+
{...modalProps}
|
|
123
|
+
>
|
|
124
|
+
<div {...bodyAttributes}>
|
|
125
|
+
{!hideCloseButton && (
|
|
126
|
+
<div className={cx(closeWrapperClassName)}>
|
|
127
|
+
<Button
|
|
128
|
+
className={cx(
|
|
129
|
+
"absolute right-0 top-0 float-right h-6 cursor-pointer p-5 text-text",
|
|
130
|
+
closeButtonClassName
|
|
131
|
+
)}
|
|
132
|
+
onClick={onRequestClose as () => void}
|
|
133
|
+
data-testid="close-button"
|
|
134
|
+
data-track-element-name="modal_close_button"
|
|
135
|
+
data-track-click-text="Close Modal"
|
|
136
|
+
data-track-element-clicked="modal"
|
|
137
|
+
>
|
|
138
|
+
<MaterialIcon name="close" size={24} />
|
|
139
|
+
</Button>
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
{title ? (
|
|
144
|
+
<div
|
|
145
|
+
className={cx(
|
|
146
|
+
"border-b border-border-secondary-on-bg-fill px-[7px] py-[7px] text-text"
|
|
147
|
+
)}
|
|
148
|
+
>
|
|
149
|
+
{title}
|
|
150
|
+
</div>
|
|
151
|
+
) : null}
|
|
152
|
+
<div
|
|
153
|
+
className={cx("p-5", bodyClassName)}
|
|
154
|
+
style={bodyStyle}
|
|
155
|
+
data-testid={modalProps["data-testid"]}
|
|
156
|
+
data-cy={modalProps["data-cy"]}
|
|
157
|
+
>
|
|
158
|
+
{children}
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</ReactModal>
|
|
162
|
+
)}
|
|
163
|
+
</Transition>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export { Modal };
|
|
168
|
+
|
|
169
|
+
Modal.displayName = "Modal";
|
|
170
|
+
|
|
171
|
+
export type { ModalProps, Size, Shape, Animation };
|
|
@@ -46,7 +46,11 @@ export function BlogGrid({
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
|
-
<section
|
|
49
|
+
<section
|
|
50
|
+
aria-label="Blog articles"
|
|
51
|
+
data-section-type={"blogs-grid"}
|
|
52
|
+
data-section-index={"0"}
|
|
53
|
+
>
|
|
50
54
|
{/* Controls bar */}
|
|
51
55
|
<div className="mx-auto flex max-w-[1200px] flex-wrap items-center justify-between gap-3 px-6 pb-6">
|
|
52
56
|
<Text className="w-full text-center text-heading5 font-black lowercase text-text-secondary md:w-auto md:text-left">
|
|
@@ -80,7 +84,7 @@ export function BlogGrid({
|
|
|
80
84
|
{/* Articles grid */}
|
|
81
85
|
{paginatedArticles.length > 0 ? (
|
|
82
86
|
<div className="mx-auto grid max-w-[1200px] grid-cols-1 gap-6 px-5 pb-16 sm:grid-cols-2 lg:grid-cols-3">
|
|
83
|
-
{paginatedArticles.map(article => {
|
|
87
|
+
{paginatedArticles.map((article, index) => {
|
|
84
88
|
const href = article.slug.startsWith("/")
|
|
85
89
|
? article.slug
|
|
86
90
|
: `/${article.slug}`;
|
|
@@ -105,6 +109,7 @@ export function BlogGrid({
|
|
|
105
109
|
date={article.blogCreationDate}
|
|
106
110
|
category={article.category}
|
|
107
111
|
image={coverImage}
|
|
112
|
+
index={index}
|
|
108
113
|
/>
|
|
109
114
|
);
|
|
110
115
|
})}
|
|
@@ -16,13 +16,18 @@ export const BlogCard: React.FC<BlogCardProps> = ({
|
|
|
16
16
|
image,
|
|
17
17
|
readMoreText = "Read more",
|
|
18
18
|
asGrid = true,
|
|
19
|
+
index,
|
|
19
20
|
}: BlogCardProps) => {
|
|
20
21
|
const parentClassName = asGrid
|
|
21
22
|
? "flex h-full flex-col overflow-hidden rounded-xl bg-white shadow-[0_1px_4px_rgba(0,0,0,0.08),0_4px_16px_rgba(0,0,0,0.06)] transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_4px_12px_rgba(0,0,0,0.12),0_8px_24px_rgba(0,0,0,0.10)]"
|
|
22
23
|
: "callout-card lg:w-[calc(33.3333%-1rem)] md:w-[calc(50%-1rem)] w-full overflow-hidden rounded-xl bg-white shadow-[0_1px_4px_rgba(0,0,0,0.08),0_4px_16px_rgba(0,0,0,0.06)] transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_4px_12px_rgba(0,0,0,0.12),0_8px_24px_rgba(0,0,0,0.10)]";
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
<article
|
|
26
|
+
<article
|
|
27
|
+
className={parentClassName}
|
|
28
|
+
data-section-type={"blog-card"}
|
|
29
|
+
data-section-index={index}
|
|
30
|
+
>
|
|
26
31
|
{/* Image */}
|
|
27
32
|
<Link href={href} tabIndex={-1} aria-hidden="true" className="block">
|
|
28
33
|
<div className="aspect-video w-full flex-shrink-0 overflow-hidden bg-gray-100">
|