@windstream/react-shared-components 0.1.32 → 0.1.34
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 +14 -2
- package/dist/contentful/index.esm.js +3 -3
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +3 -3
- package/dist/contentful/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- 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/dist/styles.css +1 -1
- package/dist/utils/index.d.ts +5 -1
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/brand-button/index.tsx +3 -4
- package/src/contentful/blocks/cookiebanner/index.tsx +146 -0
- package/src/contentful/blocks/cookiebanner/type.ts +7 -0
- package/src/contentful/blocks/image-promo-bar/index.tsx +18 -16
- package/src/contentful/blocks/modal/index.tsx +12 -8
- package/src/contentful/index.ts +3 -0
- package/src/utils/cookie.ts +22 -0
- package/src/utils/index.ts +1 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { getCookie, setCookie } from "../../../utils/cookie";
|
|
6
|
+
import { Button } from "@shared/contentful/blocks/button";
|
|
7
|
+
import { MaterialIcon } from "@shared/components/material-icon";
|
|
8
|
+
import { TypeComponentRichTextFields } from "./type";
|
|
9
|
+
|
|
10
|
+
export default function CookieBanner({
|
|
11
|
+
content,
|
|
12
|
+
}: {
|
|
13
|
+
content: TypeComponentRichTextFields;
|
|
14
|
+
}) {
|
|
15
|
+
let marginBottom = 3;
|
|
16
|
+
const [isBannerVisible, setIsBannerVisible] = useState(false);
|
|
17
|
+
const [isStickyFooterPresent, setStickyFooterPresent] = useState(false);
|
|
18
|
+
const bannerRef = useRef<HTMLDivElement>(null);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const cookieBannerClosed =
|
|
22
|
+
getCookie("cookieBannerClosed");
|
|
23
|
+
if (cookieBannerClosed === "true") {
|
|
24
|
+
setIsBannerVisible(false);
|
|
25
|
+
} else {
|
|
26
|
+
setIsBannerVisible(true);
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const checkElementPresence = () => {
|
|
32
|
+
const element = document.getElementById("anchored-banner");
|
|
33
|
+
setStickyFooterPresent(!!element);
|
|
34
|
+
};
|
|
35
|
+
checkElementPresence();
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
// Add body class and calculate height for chat positioning
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (isBannerVisible) {
|
|
41
|
+
window?.document?.body?.classList.add("cookie-banner-visible");
|
|
42
|
+
} else {
|
|
43
|
+
window?.document?.body?.classList.remove("cookie-banner-visible");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
window?.document?.body?.classList.remove("cookie-banner-visible");
|
|
48
|
+
};
|
|
49
|
+
}, [isBannerVisible]);
|
|
50
|
+
|
|
51
|
+
// Calculate cookie banner height and set CSS custom property
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!isBannerVisible) return;
|
|
54
|
+
|
|
55
|
+
const calculateCookieBannerHeight = () => {
|
|
56
|
+
if (bannerRef.current) {
|
|
57
|
+
const rect = bannerRef.current.getBoundingClientRect();
|
|
58
|
+
const viewportHeight = window.innerHeight;
|
|
59
|
+
|
|
60
|
+
// Calculate how much space the banner occupies from the bottom of the viewport
|
|
61
|
+
// This is: viewport height - distance from top
|
|
62
|
+
const spaceFromBottom = viewportHeight - rect.top;
|
|
63
|
+
|
|
64
|
+
document.documentElement.style.setProperty(
|
|
65
|
+
"--cookie-banner-height",
|
|
66
|
+
`${spaceFromBottom}px`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Calculate initially after render and after a short delay to ensure layout is complete
|
|
72
|
+
const timer1 = setTimeout(calculateCookieBannerHeight, 100);
|
|
73
|
+
const timer2 = setTimeout(calculateCookieBannerHeight, 300);
|
|
74
|
+
|
|
75
|
+
// Recalculate on window resize with debounce
|
|
76
|
+
let resizeTimeout: ReturnType<typeof setTimeout>;
|
|
77
|
+
const handleResize = () => {
|
|
78
|
+
clearTimeout(resizeTimeout);
|
|
79
|
+
resizeTimeout = setTimeout(calculateCookieBannerHeight, 150);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
window.addEventListener("resize", handleResize);
|
|
83
|
+
|
|
84
|
+
return () => {
|
|
85
|
+
clearTimeout(timer1);
|
|
86
|
+
clearTimeout(timer2);
|
|
87
|
+
clearTimeout(resizeTimeout);
|
|
88
|
+
window.removeEventListener("resize", handleResize);
|
|
89
|
+
document.documentElement.style.removeProperty("--cookie-banner-height");
|
|
90
|
+
};
|
|
91
|
+
}, [isBannerVisible, isStickyFooterPresent]);
|
|
92
|
+
|
|
93
|
+
const handleClose = () => {
|
|
94
|
+
const expirationDate = new Date(Date.now() + 43200 * 60 * 1000);
|
|
95
|
+
setIsBannerVisible(false);
|
|
96
|
+
setCookie("cookieBannerClosed", "true", {
|
|
97
|
+
expires: expirationDate,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
if (isStickyFooterPresent) marginBottom = 14;
|
|
101
|
+
|
|
102
|
+
// Calculate margin values in pixels for inline styles
|
|
103
|
+
const marginBottomPx = marginBottom * 4; // Tailwind: 3 = 12px, 14 = 56px (each unit is 4px)
|
|
104
|
+
const marginLeftPx = 12; // mx-3 = 12px
|
|
105
|
+
|
|
106
|
+
if (!isBannerVisible) return null;
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<div
|
|
110
|
+
id="cookie-banner"
|
|
111
|
+
ref={bannerRef}
|
|
112
|
+
className="fixed z-[1000] max-w-[350px] md:max-w-[656px] rounded-xl bg-white py-5 pl-6 pr-12 text-black shadow-lg ring-1 ring-gray-900/10"
|
|
113
|
+
style={{
|
|
114
|
+
// maxWidth: maxWidth,
|
|
115
|
+
bottom: "0px",
|
|
116
|
+
right: "20px",
|
|
117
|
+
marginBottom: `${marginBottomPx}px`,
|
|
118
|
+
marginLeft: `${marginLeftPx}px`,
|
|
119
|
+
}}
|
|
120
|
+
aria-label="Cookie usage notification"
|
|
121
|
+
>
|
|
122
|
+
{" "}
|
|
123
|
+
{
|
|
124
|
+
<Button
|
|
125
|
+
showButtonAs="unstyled"
|
|
126
|
+
buttonClassName="absolute right-2 top-3 mr-2 mt-0 h-6 w-6 bg-white"
|
|
127
|
+
onClick={handleClose}
|
|
128
|
+
>
|
|
129
|
+
<MaterialIcon name="close" />
|
|
130
|
+
</Button>
|
|
131
|
+
}
|
|
132
|
+
{/* {content ? (
|
|
133
|
+
<div className="my-4 mx-auto [&>a]:footnote">
|
|
134
|
+
{renderContentfulRichText(
|
|
135
|
+
toDocument(content.richText),
|
|
136
|
+
false,
|
|
137
|
+
"footnote",
|
|
138
|
+
"footnote",
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
) : null} */}
|
|
142
|
+
{content.richText ? <div className="my-4 mx-auto [&>a]:footnote">
|
|
143
|
+
{content.richText}</div> : null}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -63,13 +63,13 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
63
63
|
return (
|
|
64
64
|
<div className="component-container">
|
|
65
65
|
<div
|
|
66
|
-
className={`image-promo-bar-content ${maxWidth ? "max-w-120
|
|
66
|
+
className={`image-promo-bar-content ${maxWidth ? "max-w-120 lg:mx-auto" : ""} mx-5 my-16 lg:px-8 xl:px-12`}
|
|
67
67
|
>
|
|
68
68
|
<div
|
|
69
|
-
className={`flex shrink-0 flex-col items-center gap-8 xl:gap-[126px] ${mediaPosition ? "
|
|
69
|
+
className={`flex shrink-0 flex-col items-center gap-8 lg:gap-10 xl:gap-[126px] lg:items-stretch ${mediaPosition ? "lg:flex-row-reverse" : "lg:flex-row"}`}
|
|
70
70
|
>
|
|
71
71
|
<div
|
|
72
|
-
className={`flex flex-[1_0_0] flex-col items-start justify-center gap-8
|
|
72
|
+
className={`flex flex-[1_0_0] flex-col items-start justify-center gap-8 lg:gap-10 ${color == "dark" ? "text-text" : "text-white"}`}
|
|
73
73
|
>
|
|
74
74
|
<div className="heading holder">
|
|
75
75
|
{brow && (
|
|
@@ -91,7 +91,7 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
91
91
|
{subTitle && (
|
|
92
92
|
<Text
|
|
93
93
|
as={enableHeading ? "h2" : "h3"}
|
|
94
|
-
className="subheading1 mt-3"
|
|
94
|
+
className="subheading3 md:subheading1 mt-3"
|
|
95
95
|
>
|
|
96
96
|
{subTitle}
|
|
97
97
|
</Text>
|
|
@@ -105,7 +105,7 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
105
105
|
)}
|
|
106
106
|
{/* Checklist Rendering */}
|
|
107
107
|
{checklist.length > 0 && (
|
|
108
|
-
<Checklist items={checklist} iconPosition="top" iconSize={24} />
|
|
108
|
+
<Checklist items={checklist} iconPosition="top" iconSize={24} listItemClassName="body1 text-text" listContainerClassName="mt-0 space-y-0 flex flex-col gap-3" />
|
|
109
109
|
)}
|
|
110
110
|
{imageLinks.length > 0 && (
|
|
111
111
|
<div className="flex gap-4">
|
|
@@ -128,22 +128,24 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
128
128
|
)}
|
|
129
129
|
{/* CTAs and Disclaimers */}
|
|
130
130
|
{(cta || secondaryCta) && (
|
|
131
|
-
<div className="flex w-full flex-col gap-
|
|
131
|
+
<div className="flex w-full flex-col gap-3 xl:flex-row">
|
|
132
132
|
{cta && (
|
|
133
|
-
<div className="primary-cta w-full xl:w-auto">
|
|
133
|
+
<div className="primary-cta w-full xl:w-auto xl:shrink-0">
|
|
134
134
|
<Button
|
|
135
135
|
{...cta}
|
|
136
136
|
fullWidth={true}
|
|
137
|
+
size={{ base: "large" }}
|
|
137
138
|
renderCheckPlans={renderCheckPlans}
|
|
138
139
|
onModalButtonClick={onModalButtonClick}
|
|
139
140
|
/>
|
|
140
141
|
</div>
|
|
141
142
|
)}
|
|
142
143
|
{secondaryCta && (
|
|
143
|
-
<div className="secondary-cta">
|
|
144
|
+
<div className="secondary-cta w-full xl:w-auto xl:shrink-0">
|
|
144
145
|
<Button
|
|
145
146
|
{...secondaryCta}
|
|
146
147
|
fullWidth={true}
|
|
148
|
+
size={{ base: "large" }}
|
|
147
149
|
renderCheckPlans={renderCheckPlans}
|
|
148
150
|
onModalButtonClick={onModalButtonClick}
|
|
149
151
|
/>
|
|
@@ -154,16 +156,16 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
154
156
|
{ctaDisclaimer && <div>{ctaDisclaimer}</div>}
|
|
155
157
|
{disclaimer && <div>{disclaimer}</div>}
|
|
156
158
|
</div>
|
|
157
|
-
<aside className="flex w-full shrink-0 items-center justify-center
|
|
159
|
+
<aside className="flex w-full shrink-0 items-center justify-center lg:w-auto">
|
|
158
160
|
{/* Media Section */}
|
|
159
161
|
{image && (
|
|
160
|
-
<div className="relative
|
|
162
|
+
<div className="relative w-[334px] h-[334px] md:w-[486px] md:h-[480px] rounded-image overflow-hidden">
|
|
161
163
|
<NextImage
|
|
162
164
|
src={image}
|
|
163
165
|
alt="section-image"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
className="
|
|
166
|
+
fill
|
|
167
|
+
sizes="(min-width: 768px) 486px, 334px"
|
|
168
|
+
className="object-cover"
|
|
167
169
|
/>
|
|
168
170
|
</div>
|
|
169
171
|
)}
|
|
@@ -171,7 +173,7 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
171
173
|
{videoLink?.link && (
|
|
172
174
|
<div
|
|
173
175
|
className={cx(
|
|
174
|
-
"video-section relative w-full cursor-pointer overflow-hidden rounded-
|
|
176
|
+
"video-section relative w-full cursor-pointer overflow-hidden rounded-image transition-all duration-300 lg:w-[486px]",
|
|
175
177
|
!isPlaying && "hover:shadow-2xl"
|
|
176
178
|
)}
|
|
177
179
|
onClick={handlePlayClick}
|
|
@@ -192,7 +194,7 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
192
194
|
alt="Video preview"
|
|
193
195
|
width={486}
|
|
194
196
|
height={486}
|
|
195
|
-
className="absolute inset-0 h-full w-full rounded-
|
|
197
|
+
className="absolute inset-0 h-full w-full rounded-image object-cover"
|
|
196
198
|
/>
|
|
197
199
|
)}
|
|
198
200
|
<div className="absolute inset-0 flex items-center justify-center">
|
|
@@ -204,7 +206,7 @@ export const ImagePromoBar: React.FC<ImagePromoBarProps> = ({
|
|
|
204
206
|
{!videoPopup && isPlaying && (
|
|
205
207
|
<div
|
|
206
208
|
className={cx(
|
|
207
|
-
"aspect-[16/9] w-full overflow-hidden rounded-
|
|
209
|
+
"aspect-[16/9] w-full overflow-hidden rounded-image transition-opacity duration-300",
|
|
208
210
|
isPlaying ? "opacity-100" : "opacity-0"
|
|
209
211
|
)}
|
|
210
212
|
>
|
|
@@ -48,16 +48,17 @@ export const Modal: React.FC<ExtendedModalProps> = props => {
|
|
|
48
48
|
>
|
|
49
49
|
<Dialog.Overlay />
|
|
50
50
|
</motion.div>
|
|
51
|
+
<div className="fixed inset-0 z-[1001] flex items-center justify-center pointer-events-none">
|
|
51
52
|
<motion.div
|
|
52
53
|
initial="closed"
|
|
53
54
|
animate={isOpen ? "open" : "closed"}
|
|
54
55
|
variants={contentAnimationVariants}
|
|
55
56
|
transition={{ type: "tween", duration: 0.3, ease: "easeInOut" }}
|
|
56
|
-
className="
|
|
57
|
+
className="w-[calc(100vw-10px)] sm:w-[calc(100vw-90px)] pointer-events-auto focus:outline-none"
|
|
57
58
|
>
|
|
58
59
|
<Dialog.Content
|
|
59
60
|
className={cx(
|
|
60
|
-
"
|
|
61
|
+
"relative w-full mx-auto rounded-modal bg-bg p-[25px] shadow-drop focus:outline-none",
|
|
61
62
|
bodyClassName
|
|
62
63
|
)}
|
|
63
64
|
style={{ maxWidth: sizeToPixel[size || "lg"] }}
|
|
@@ -75,9 +76,9 @@ export const Modal: React.FC<ExtendedModalProps> = props => {
|
|
|
75
76
|
{title ? (
|
|
76
77
|
<Text
|
|
77
78
|
className={cx(
|
|
78
|
-
"
|
|
79
|
-
"heading5 md:
|
|
80
|
-
"mb-
|
|
79
|
+
"w-full pr-8 sm:pr-0 mb-3 mt-5 text-center",
|
|
80
|
+
"heading5 md:pt-0",
|
|
81
|
+
"mb-4 md:mb-[60px]"
|
|
81
82
|
)}
|
|
82
83
|
as="h2"
|
|
83
84
|
>
|
|
@@ -85,14 +86,17 @@ export const Modal: React.FC<ExtendedModalProps> = props => {
|
|
|
85
86
|
</Text>
|
|
86
87
|
) : null}
|
|
87
88
|
|
|
88
|
-
{description ? <Text as="div">{description}</Text> : null}
|
|
89
|
+
{description ? <Text as="div" className="mb-8 sm:mb-5">{description}</Text> : null}
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
<div className="flex flex-col gap-4 sm:gap-5">
|
|
92
|
+
{content}
|
|
93
|
+
{children ? children : null}
|
|
94
|
+
</div>
|
|
92
95
|
</div>
|
|
93
96
|
</div>
|
|
94
97
|
</Dialog.Content>
|
|
95
98
|
</motion.div>
|
|
99
|
+
</div>
|
|
96
100
|
</Dialog.Portal>
|
|
97
101
|
</Dialog.Root>
|
|
98
102
|
);
|
package/src/contentful/index.ts
CHANGED
|
@@ -76,3 +76,6 @@ export type { DynamicTabsT } from "./blocks/dynamic-tabs/types";
|
|
|
76
76
|
|
|
77
77
|
export { AnchoredBottomBanner } from "./blocks/anchored-bottom-banner";
|
|
78
78
|
export type { AnchoredBottomBannerProps } from "./blocks/anchored-bottom-banner/types";
|
|
79
|
+
|
|
80
|
+
export { default as CookieBanner } from "./blocks/cookiebanner";
|
|
81
|
+
export type { TypeComponentRichTextFields as CookieBannerProps } from "./blocks/cookiebanner/type";
|
package/src/utils/cookie.ts
CHANGED
|
@@ -56,3 +56,25 @@ export function setUTMs(
|
|
|
56
56
|
export function removeUTMs(domain: string = DEFAULT_DOMAIN): void {
|
|
57
57
|
Cookies.remove(UTM_COOKIE_KEY, { domain, path: "/" });
|
|
58
58
|
}
|
|
59
|
+
export function getCookie(key: string): string | null {
|
|
60
|
+
if (typeof window === "undefined") return "";
|
|
61
|
+
const encryptedValue = Cookies.get(key);
|
|
62
|
+
|
|
63
|
+
if (encryptedValue) return Base64.decode(encryptedValue);
|
|
64
|
+
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
export const getParsedCookie = (key: string) => {
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(getCookie(key) || "");
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export const setCookie = (key: string, value: any, options: Cookies.CookieAttributes) => {
|
|
75
|
+
if (typeof window === "undefined") return;
|
|
76
|
+
const stringValue = JSON.stringify(value);
|
|
77
|
+
const encryptedValue = Base64.encode(stringValue);
|
|
78
|
+
|
|
79
|
+
Cookies.set(key, encryptedValue, options);
|
|
80
|
+
};
|
package/src/utils/index.ts
CHANGED
|
@@ -49,7 +49,7 @@ export { clsx };
|
|
|
49
49
|
export type { ClassValue };
|
|
50
50
|
|
|
51
51
|
// UTM & Cookie utilities
|
|
52
|
-
export { getUTMs, setUTMs, removeUTMs } from "./cookie";
|
|
52
|
+
export { getUTMs, setUTMs, removeUTMs, getCookie, getParsedCookie, setCookie } from "./cookie";
|
|
53
53
|
export {
|
|
54
54
|
getUtmParametersFromURL,
|
|
55
55
|
combineExistingAndNewUTMs,
|