@windstream/react-shared-components 0.1.71 → 0.1.73
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 +104 -28
- 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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/next/index.esm.js.map +1 -1
- package/dist/next/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utils/index.d.ts +12 -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/next-image/index.tsx +3 -1
- package/src/contentful/blocks/accordion/Accordion.stories.mocks.tsx +8 -8
- package/src/contentful/blocks/accordion/Accordion.stories.tsx +5 -13
- package/src/contentful/blocks/anchored-bottom-banner/index.tsx +114 -3
- package/src/contentful/blocks/anchored-bottom-banner/types.ts +4 -1
- package/src/contentful/blocks/callout/index.tsx +201 -37
- package/src/contentful/blocks/callout/types.ts +56 -3
- package/src/contentful/blocks/cards/floating-image-card/index.tsx +119 -0
- package/src/contentful/blocks/cards/floating-image-card/types.ts +30 -0
- package/src/contentful/blocks/cards/full-image-card/index.tsx +130 -0
- package/src/contentful/blocks/cards/full-image-card/types.ts +29 -0
- package/src/contentful/blocks/cards/simple-card/index.tsx +294 -58
- package/src/contentful/blocks/cards/simple-card/types.ts +47 -4
- package/src/contentful/blocks/comparison-table/index.tsx +3 -1
- package/src/contentful/blocks/footer/Footer.stories.tsx +145 -32
- package/src/hooks/contentful/use-contentful-rich-text.tsx +5 -3
- package/src/utils/index.ts +3 -0
- package/src/utils/speed-card-bg.ts +24 -0
|
@@ -2,87 +2,323 @@ import React from "react";
|
|
|
2
2
|
import { Button } from "../../button";
|
|
3
3
|
import { backgroundColorMap, Item, SimpleCardProps } from "./types";
|
|
4
4
|
|
|
5
|
+
import { Link } from "@shared/components/link";
|
|
6
|
+
import { MaterialIcon } from "@shared/components/material-icon";
|
|
5
7
|
import { NextImage } from "@shared/components/next-image";
|
|
6
8
|
import { Text } from "@shared/components/text";
|
|
9
|
+
import { cx } from "@shared/utils";
|
|
10
|
+
import { SpeedCardBg } from "@shared/utils/speed-card-bg";
|
|
11
|
+
|
|
12
|
+
const ICON_SIZE = 60;
|
|
13
|
+
|
|
14
|
+
const alignmentClasses: Record<string, string> = {
|
|
15
|
+
left: "flex w-full justify-start",
|
|
16
|
+
right: "flex w-full justify-end",
|
|
17
|
+
center: "flex w-full justify-center",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const justifyClass: Record<string, string> = {
|
|
21
|
+
left: "justify-start",
|
|
22
|
+
right: "justify-end",
|
|
23
|
+
center: "justify-center",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const formatPhoneHref = (phone: string): string => {
|
|
27
|
+
const digits = (phone || "").replace(/\D/g, "");
|
|
28
|
+
return digits ? `tel:${digits}` : "";
|
|
29
|
+
};
|
|
7
30
|
|
|
8
31
|
export const SimpleCard: React.FC<SimpleCardProps> = ({
|
|
9
32
|
card,
|
|
10
33
|
lgWidth,
|
|
11
34
|
mdWidth,
|
|
35
|
+
className,
|
|
36
|
+
contentClassName,
|
|
37
|
+
style,
|
|
12
38
|
}) => {
|
|
13
|
-
const
|
|
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
|
-
|
|
39
|
+
const view = card.imageView?.toLowerCase();
|
|
40
|
+
const fullSizeImage = view === "full";
|
|
41
|
+
const marginSizeImage = view === "margin";
|
|
42
|
+
const standardSizeImage = view === "standard";
|
|
43
|
+
const iconSizeImage =
|
|
44
|
+
view === "icon" || view === "inset" || (!view && !!card.image);
|
|
45
|
+
|
|
46
|
+
// Local @ui CalloutCard treats "standard" + "icon" as the new card design
|
|
47
|
+
// that supports background color / pinwheel / inverted text via CSS vars.
|
|
48
|
+
const hasNewDesign = standardSizeImage || iconSizeImage;
|
|
49
|
+
|
|
50
|
+
const iconAlignment =
|
|
51
|
+
card.iconAlignment?.toLowerCase() ||
|
|
52
|
+
card.imageAlignment?.toLowerCase() ||
|
|
53
|
+
"left";
|
|
54
|
+
|
|
55
|
+
const ctaAlignmentClass =
|
|
56
|
+
(card.ctaAlignment && alignmentClasses[card.ctaAlignment]) ||
|
|
57
|
+
alignmentClasses.left;
|
|
58
|
+
const ctaAlignmentBottomClass =
|
|
59
|
+
(card.ctaAlignmentBottom && justifyClass[card.ctaAlignmentBottom]) ||
|
|
60
|
+
justifyClass.left;
|
|
61
|
+
|
|
62
|
+
const pinwheelColorCode = card.pinwheelColor?.split("-")[1];
|
|
63
|
+
|
|
64
|
+
const useDynamicColors = hasNewDesign && card.applyCardBackgroundColor;
|
|
65
|
+
|
|
66
|
+
const dynamicStyle: React.CSSProperties = {
|
|
67
|
+
...style,
|
|
68
|
+
...(useDynamicColors && card.backgroundColor
|
|
69
|
+
? ({ ["--scc-bg" as any]: card.backgroundColor } as React.CSSProperties)
|
|
70
|
+
: {}),
|
|
71
|
+
...(useDynamicColors && card.textColor
|
|
72
|
+
? ({ ["--scc-fg" as any]: card.textColor } as React.CSSProperties)
|
|
73
|
+
: {}),
|
|
74
|
+
...(useDynamicColors && card.backgroundColor
|
|
75
|
+
? { backgroundColor: "var(--scc-bg)" }
|
|
76
|
+
: {}),
|
|
77
|
+
...(useDynamicColors && card.showBackgroundImage && pinwheelColorCode
|
|
78
|
+
? {
|
|
79
|
+
backgroundImage: `url('data:image/svg+xml;utf8,${encodeURIComponent(
|
|
80
|
+
SpeedCardBg(pinwheelColorCode)
|
|
81
|
+
)}')`,
|
|
82
|
+
backgroundPosition: "top left",
|
|
83
|
+
backgroundSize: "684px 107px",
|
|
84
|
+
backgroundRepeat: "no-repeat",
|
|
85
|
+
}
|
|
86
|
+
: {}),
|
|
42
87
|
};
|
|
43
88
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
89
|
+
const renderFullImage = (margin: boolean) => {
|
|
90
|
+
if (!card.image) return null;
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
className={cx(
|
|
94
|
+
"relative aspect-video overflow-hidden",
|
|
95
|
+
!margin ? "rounded-t-3xl" : "mx-6 lg:mx-8"
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
<NextImage
|
|
99
|
+
src={card.image}
|
|
100
|
+
alt={card.imageAlt ?? card.title ?? "card-image"}
|
|
101
|
+
width={card.imageWidth || 400}
|
|
102
|
+
height={card.imageHeight || 280}
|
|
103
|
+
className={cx("w-full", !margin && "rounded-t-3xl")}
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const renderIcon = () => {
|
|
110
|
+
if (!card.image) return null;
|
|
111
|
+
const imgWidth = standardSizeImage
|
|
112
|
+
? card.imageWidth || ICON_SIZE
|
|
113
|
+
: ICON_SIZE;
|
|
114
|
+
const imgHeight = standardSizeImage
|
|
115
|
+
? card.imageHeight || ICON_SIZE
|
|
116
|
+
: ICON_SIZE;
|
|
117
|
+
return (
|
|
118
|
+
<div
|
|
119
|
+
className={cx(
|
|
120
|
+
"relative mb-8 flex",
|
|
121
|
+
card.imageToRichTextAlignment && "h-[60px] w-[60px] flex-shrink-0"
|
|
122
|
+
)}
|
|
123
|
+
style={{ justifyContent: iconAlignment }}
|
|
124
|
+
>
|
|
125
|
+
<NextImage
|
|
126
|
+
src={card.image}
|
|
127
|
+
alt={card.imageAlt ?? card.title ?? "card-icon"}
|
|
128
|
+
width={imgWidth}
|
|
129
|
+
height={imgHeight}
|
|
130
|
+
className={cx(
|
|
131
|
+
"object-contain",
|
|
132
|
+
card.imageToRichTextAlignment && "!h-[60px] !w-[60px]"
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const textColorStyle =
|
|
140
|
+
useDynamicColors && card.textColor ? { color: card.textColor } : undefined;
|
|
141
|
+
|
|
142
|
+
const titleNode = card.title ? (
|
|
143
|
+
<Text
|
|
144
|
+
as="h3"
|
|
145
|
+
className="heading6 mb-2 text-text md:heading6"
|
|
146
|
+
style={textColorStyle}
|
|
147
|
+
>
|
|
148
|
+
{card.title}
|
|
149
|
+
</Text>
|
|
150
|
+
) : null;
|
|
151
|
+
|
|
152
|
+
const titleWithLink =
|
|
153
|
+
card.cta?.href && titleNode ? (
|
|
154
|
+
<Link
|
|
155
|
+
href={card.cta.href}
|
|
156
|
+
target={card.cta.target}
|
|
157
|
+
className="no-underline hover:underline"
|
|
158
|
+
style={textColorStyle}
|
|
159
|
+
>
|
|
160
|
+
{titleNode}
|
|
161
|
+
</Link>
|
|
162
|
+
) : (
|
|
163
|
+
titleNode
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const hasTable =
|
|
167
|
+
(card.workingHours?.length ?? 0) > 0 || (card.phoneNumber?.length ?? 0) > 0;
|
|
51
168
|
|
|
52
169
|
return (
|
|
53
|
-
<
|
|
54
|
-
className={
|
|
170
|
+
<section
|
|
171
|
+
className={cx(
|
|
172
|
+
"callout-card relative flex w-full flex-col rounded-3xl p-0",
|
|
173
|
+
card.shadow && "shadow-card",
|
|
174
|
+
card.image && !fullSizeImage && !card.showBackgroundImage && "pt-1",
|
|
175
|
+
!card.applyCardBackgroundColor &&
|
|
176
|
+
(backgroundColorMap[card.backgroundColor ?? ""] ?? ""),
|
|
177
|
+
mdWidth,
|
|
178
|
+
lgWidth,
|
|
179
|
+
className
|
|
180
|
+
)}
|
|
181
|
+
style={dynamicStyle}
|
|
182
|
+
aria-labelledby={card.title ? `callout-${card.title}` : undefined}
|
|
55
183
|
>
|
|
184
|
+
{/* Top "location" CTA */}
|
|
185
|
+
{card.ctaBottom?.title && card.ctaBottom?.href ? (
|
|
186
|
+
<div
|
|
187
|
+
className={cx(
|
|
188
|
+
"top-link m-6 flex items-center lg:m-8",
|
|
189
|
+
ctaAlignmentBottomClass
|
|
190
|
+
)}
|
|
191
|
+
>
|
|
192
|
+
<Link
|
|
193
|
+
href={card.ctaBottom.href}
|
|
194
|
+
className="label1 inline-flex items-center gap-2 text-text decoration-text underline-offset-4 hover:underline"
|
|
195
|
+
>
|
|
196
|
+
<MaterialIcon name="location_on" fill={1} size={24} />
|
|
197
|
+
<span>{card.ctaBottom.title}</span>
|
|
198
|
+
</Link>
|
|
199
|
+
</div>
|
|
200
|
+
) : null}
|
|
201
|
+
|
|
202
|
+
{card.image && fullSizeImage ? renderFullImage(false) : null}
|
|
203
|
+
{card.image && marginSizeImage ? renderFullImage(true) : null}
|
|
204
|
+
|
|
56
205
|
<div
|
|
57
|
-
className={
|
|
206
|
+
className={cx(
|
|
207
|
+
"relative flex flex-1 flex-col justify-between px-6 pb-8 pt-7 lg:px-8 lg:py-8",
|
|
208
|
+
contentClassName
|
|
209
|
+
)}
|
|
58
210
|
>
|
|
59
|
-
<div className="
|
|
211
|
+
<div className="flex flex-1 flex-col justify-between">
|
|
212
|
+
<div
|
|
213
|
+
className={cx(
|
|
214
|
+
"flex flex-col",
|
|
215
|
+
card.imageToRichTextAlignment &&
|
|
216
|
+
"lg:flex-row lg:items-start lg:gap-6"
|
|
217
|
+
)}
|
|
218
|
+
>
|
|
219
|
+
<div
|
|
220
|
+
className={cx(card.imageToRichTextAlignment && "flex-shrink-0")}
|
|
221
|
+
>
|
|
222
|
+
{card.image && !fullSizeImage && !marginSizeImage
|
|
223
|
+
? renderIcon()
|
|
224
|
+
: null}
|
|
225
|
+
</div>
|
|
226
|
+
<div className="flex flex-col gap-3 md:gap-4">
|
|
227
|
+
{titleWithLink}
|
|
60
228
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
229
|
+
{card.titleLocation ? (
|
|
230
|
+
<div className="mb-1 lg:mb-2">
|
|
231
|
+
<Text as="h4" className="label1 font-bold text-text">
|
|
232
|
+
{card.titleLocation}
|
|
233
|
+
</Text>
|
|
234
|
+
</div>
|
|
235
|
+
) : null}
|
|
236
|
+
|
|
237
|
+
{hasTable ? (
|
|
238
|
+
<div className="mb-2">
|
|
239
|
+
<table>
|
|
240
|
+
<tbody>
|
|
241
|
+
{card.workingHours?.map((hours, index) => {
|
|
242
|
+
const [label, value] = (hours ?? "").split("|");
|
|
243
|
+
return (
|
|
244
|
+
<tr key={`wh-${index}`}>
|
|
245
|
+
<td className="py-2 pr-3">
|
|
246
|
+
<Text className="label2 text-text">{label}</Text>
|
|
247
|
+
</td>
|
|
248
|
+
<td className="py-2 pl-3">
|
|
249
|
+
<Text className="body2 font-bold text-text">
|
|
250
|
+
{value}
|
|
251
|
+
</Text>
|
|
252
|
+
</td>
|
|
253
|
+
</tr>
|
|
254
|
+
);
|
|
255
|
+
})}
|
|
256
|
+
{card.phoneNumber?.map((phone, index) => (
|
|
257
|
+
<tr key={`ph-${index}`}>
|
|
258
|
+
<td className="py-1 pr-3 align-middle">
|
|
259
|
+
<MaterialIcon
|
|
260
|
+
fill={1}
|
|
261
|
+
name="call"
|
|
262
|
+
size={24}
|
|
263
|
+
weight="200"
|
|
264
|
+
className="text-text"
|
|
265
|
+
/>
|
|
266
|
+
</td>
|
|
267
|
+
<td className="py-1 pl-3">
|
|
268
|
+
<Link
|
|
269
|
+
href={formatPhoneHref(phone)}
|
|
270
|
+
className="text-inherit no-underline"
|
|
271
|
+
>
|
|
272
|
+
<Text className="body2 font-bold text-text">
|
|
273
|
+
{phone}
|
|
274
|
+
</Text>
|
|
275
|
+
</Link>
|
|
276
|
+
</td>
|
|
277
|
+
</tr>
|
|
278
|
+
))}
|
|
279
|
+
</tbody>
|
|
280
|
+
</table>
|
|
281
|
+
</div>
|
|
282
|
+
) : null}
|
|
283
|
+
|
|
284
|
+
{card.body ? (
|
|
285
|
+
<Text
|
|
286
|
+
as="div"
|
|
287
|
+
className="body1 text-text"
|
|
288
|
+
style={textColorStyle}
|
|
289
|
+
>
|
|
290
|
+
{card.body}
|
|
291
|
+
</Text>
|
|
292
|
+
) : null}
|
|
293
|
+
{card.richText ? (
|
|
294
|
+
<Text
|
|
295
|
+
as="div"
|
|
296
|
+
className="body1 text-text"
|
|
297
|
+
style={textColorStyle}
|
|
298
|
+
>
|
|
299
|
+
{card.richText}
|
|
300
|
+
</Text>
|
|
301
|
+
) : null}
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
72
304
|
</div>
|
|
73
|
-
|
|
74
|
-
|
|
305
|
+
|
|
306
|
+
{card.cta ? (
|
|
307
|
+
<div className={cx("mt-2", ctaAlignmentClass)}>
|
|
75
308
|
<Button
|
|
76
309
|
linkVariant="unstyled"
|
|
77
|
-
linkClassName=
|
|
310
|
+
linkClassName={cx(
|
|
311
|
+
"label1 flex items-center gap-2 text-text",
|
|
312
|
+
useDynamicColors && card.textColor && "decoration-current"
|
|
313
|
+
)}
|
|
78
314
|
{...card.cta}
|
|
79
|
-
iconName={"expand_circle_right"}
|
|
80
|
-
iconFill={1}
|
|
315
|
+
iconName={card.cta.iconName ?? "expand_circle_right"}
|
|
316
|
+
iconFill={card.cta.iconFill ?? 1}
|
|
81
317
|
/>
|
|
82
318
|
</div>
|
|
83
|
-
)}
|
|
319
|
+
) : null}
|
|
84
320
|
</div>
|
|
85
|
-
</
|
|
321
|
+
</section>
|
|
86
322
|
);
|
|
87
323
|
};
|
|
88
324
|
|
|
@@ -1,21 +1,64 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import { ButtonProps } from "../../button/types";
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import type { ButtonProps } from "../../button/types";
|
|
3
|
+
|
|
4
|
+
export type PinwheelColor =
|
|
5
|
+
| "Blue-#307998"
|
|
6
|
+
| "Green-#209A61"
|
|
7
|
+
| "Orange-#DE7E0A"
|
|
8
|
+
| "Purple-#7E1458"
|
|
9
|
+
| (string & {});
|
|
10
|
+
|
|
11
|
+
export type SimpleCardCtaBottom = {
|
|
12
|
+
title?: string;
|
|
13
|
+
href?: string;
|
|
14
|
+
};
|
|
3
15
|
|
|
4
16
|
export type Item = {
|
|
5
17
|
title?: string;
|
|
6
18
|
image?: string;
|
|
19
|
+
imageAlt?: string;
|
|
20
|
+
imageWidth?: number;
|
|
21
|
+
imageHeight?: number;
|
|
7
22
|
imageAlignment?: "left" | "right" | "center";
|
|
8
|
-
|
|
23
|
+
iconAlignment?: "left" | "right" | "center";
|
|
24
|
+
/**
|
|
25
|
+
* Layout variant for the image. `standard` / `icon` render an inline
|
|
26
|
+
* icon above the content. `full` renders a full-bleed top image.
|
|
27
|
+
* `margin` is `full` with horizontal padding.
|
|
28
|
+
*/
|
|
29
|
+
imageView?: "standard" | "icon" | "full" | "margin" | "inset";
|
|
30
|
+
body?: ReactNode;
|
|
31
|
+
/** Optional secondary rich-text region (port of local `richText`). */
|
|
32
|
+
richText?: ReactNode;
|
|
9
33
|
cta?: ButtonProps;
|
|
10
34
|
ctaAlignment?: "left" | "right" | "center";
|
|
11
|
-
|
|
35
|
+
/** Top "location" CTA, rendered above the title with a `location_on` icon. */
|
|
36
|
+
ctaBottom?: SimpleCardCtaBottom;
|
|
37
|
+
ctaAlignmentBottom?: "left" | "right" | "center";
|
|
38
|
+
/** Legacy token-based card background (mapped via `backgroundColorMap`). */
|
|
12
39
|
backgroundColor?: string;
|
|
40
|
+
/** Raw color value used when `applyCardBackgroundColor` is true. */
|
|
41
|
+
applyCardBackgroundColor?: boolean;
|
|
42
|
+
textColor?: string;
|
|
43
|
+
showBackgroundImage?: boolean;
|
|
44
|
+
pinwheelColor?: PinwheelColor;
|
|
45
|
+
/** On `lg:` and up, lays out icon + content side-by-side. */
|
|
46
|
+
imageToRichTextAlignment?: boolean;
|
|
47
|
+
/** Bold label between title and the phone/hours table. */
|
|
48
|
+
titleLocation?: string;
|
|
49
|
+
phoneNumber?: string[];
|
|
50
|
+
/** Each entry uses a `label|value` separator. */
|
|
51
|
+
workingHours?: string[];
|
|
52
|
+
shadow?: boolean;
|
|
13
53
|
};
|
|
14
54
|
|
|
15
55
|
export type SimpleCardProps = {
|
|
16
56
|
card: Item;
|
|
17
57
|
lgWidth?: string;
|
|
18
58
|
mdWidth?: string;
|
|
59
|
+
className?: string;
|
|
60
|
+
contentClassName?: string;
|
|
61
|
+
style?: CSSProperties;
|
|
19
62
|
};
|
|
20
63
|
|
|
21
64
|
export const backgroundColorMap: Record<string, string> = {
|
|
@@ -17,7 +17,9 @@ export const ComparisonTable: React.FC<ComparisonTableProps> = ({
|
|
|
17
17
|
<Text as="h2" className="heading2 md:heading1 md:text-center">
|
|
18
18
|
{title}
|
|
19
19
|
</Text>
|
|
20
|
-
<div className="comparison-table-container mt-5
|
|
20
|
+
<div className="comparison-table-container mt-5 p-5 pt-0 md:mt-10 md:px-10 md:py-9">
|
|
21
|
+
{table}
|
|
22
|
+
</div>
|
|
21
23
|
<Text as="div" className="micro mt-8 text-center">
|
|
22
24
|
{disclaimer}
|
|
23
25
|
</Text>
|