@windstream/react-shared-components 0.2.52 → 0.2.53
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 +21 -2
- package/dist/contentful/index.esm.js +2 -2
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +4 -4
- package/dist/contentful/index.js.map +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/contentful/blocks/award-marquee/AwardMarquee.stories.tsx +50 -0
- package/src/contentful/blocks/award-marquee/index.test.tsx +86 -0
- package/src/contentful/blocks/award-marquee/index.tsx +110 -0
- package/src/contentful/blocks/award-marquee/types.ts +19 -0
- package/src/contentful/index.ts +8 -0
- package/tailwind.config.cjs +7 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
AwardMarqueeBackground,
|
|
4
|
+
AwardMarqueeItem,
|
|
5
|
+
AwardMarqueeProps,
|
|
6
|
+
AwardMarqueeSpeed,
|
|
7
|
+
} from "./types";
|
|
8
|
+
|
|
9
|
+
import { cx } from "@shared/utils";
|
|
10
|
+
|
|
11
|
+
const DURATION_IN_SECONDS: Record<AwardMarqueeSpeed, number> = {
|
|
12
|
+
slow: 30,
|
|
13
|
+
medium: 20,
|
|
14
|
+
fast: 10,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const BACKGROUND_CLASS: Record<AwardMarqueeBackground, string> = {
|
|
18
|
+
cream: "bg-[#FFFEEF]",
|
|
19
|
+
gray90: "bg-[#FBFBFC]",
|
|
20
|
+
white: "bg-white",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const renderAwardItem = (
|
|
24
|
+
{ iconUrl, iconAlt, title, description }: AwardMarqueeItem,
|
|
25
|
+
key: React.Key
|
|
26
|
+
) => (
|
|
27
|
+
<div
|
|
28
|
+
key={key}
|
|
29
|
+
className="ml-4 flex w-auto flex-shrink-0 items-center whitespace-nowrap"
|
|
30
|
+
>
|
|
31
|
+
<img src={iconUrl} alt={iconAlt ?? ""} width={200} />
|
|
32
|
+
<div className="w-[250px] text-center">
|
|
33
|
+
<p className="flex justify-center text-center text-body3 font-bold">
|
|
34
|
+
{title}
|
|
35
|
+
</p>
|
|
36
|
+
<p className="flex flex-wrap whitespace-normal text-center text-footnote">
|
|
37
|
+
{description}
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export const AwardMarquee: React.FC<AwardMarqueeProps> = ({
|
|
44
|
+
anchorId = "Award-Marquee",
|
|
45
|
+
items = [],
|
|
46
|
+
speed = "medium",
|
|
47
|
+
scroll = false,
|
|
48
|
+
backgroundColor = "white",
|
|
49
|
+
className,
|
|
50
|
+
}) => {
|
|
51
|
+
const scrollAvailable = items.length > 3;
|
|
52
|
+
const shouldDuplicate = items.length < 8;
|
|
53
|
+
const duration = DURATION_IN_SECONDS[speed];
|
|
54
|
+
|
|
55
|
+
const animatedMarquee = () => {
|
|
56
|
+
const marqueeItems = shouldDuplicate ? [...items, ...items] : items;
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
className={cx(
|
|
61
|
+
"flex items-center overflow-x-hidden",
|
|
62
|
+
BACKGROUND_CLASS[backgroundColor]
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
className="flex animate-award-marquee gap-4 px-2"
|
|
67
|
+
style={
|
|
68
|
+
{
|
|
69
|
+
"--award-marquee-duration": `${duration}s`,
|
|
70
|
+
} as React.CSSProperties
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
{marqueeItems.map((item, index) => renderAwardItem(item, index))}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const staticMarquee = (
|
|
80
|
+
<div className="flex flex-nowrap items-center justify-around overflow-clip">
|
|
81
|
+
{items.map((item, index) => renderAwardItem(item, index))}
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// No scroll: always static at every breakpoint.
|
|
86
|
+
if (!scroll)
|
|
87
|
+
return (
|
|
88
|
+
<div id={anchorId} className={className}>
|
|
89
|
+
{staticMarquee}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Scroll with >3 items: animate at every breakpoint.
|
|
94
|
+
if (scrollAvailable)
|
|
95
|
+
return (
|
|
96
|
+
<div id={anchorId} className={className}>
|
|
97
|
+
{animatedMarquee()}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// Scroll with <=3 items: animate on mobile, static on >= sm (CSS-driven).
|
|
102
|
+
return (
|
|
103
|
+
<div id={anchorId} className={className}>
|
|
104
|
+
<div className="sm:hidden">{animatedMarquee()}</div>
|
|
105
|
+
<div className="hidden sm:block">{staticMarquee}</div>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default AwardMarquee;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type AwardMarqueeSpeed = "fast" | "medium" | "slow";
|
|
2
|
+
|
|
3
|
+
export type AwardMarqueeBackground = "cream" | "gray90" | "white";
|
|
4
|
+
|
|
5
|
+
export type AwardMarqueeItem = {
|
|
6
|
+
iconUrl: string;
|
|
7
|
+
iconAlt?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type AwardMarqueeProps = {
|
|
13
|
+
anchorId?: string;
|
|
14
|
+
items: AwardMarqueeItem[];
|
|
15
|
+
speed?: AwardMarqueeSpeed;
|
|
16
|
+
scroll?: boolean;
|
|
17
|
+
backgroundColor?: AwardMarqueeBackground;
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
package/src/contentful/index.ts
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
export { Accordion } from "./blocks/accordion";
|
|
3
3
|
export type { AccordionProps } from "./blocks/accordion/types";
|
|
4
4
|
|
|
5
|
+
export { AwardMarquee } from "./blocks/award-marquee";
|
|
6
|
+
export type {
|
|
7
|
+
AwardMarqueeProps,
|
|
8
|
+
AwardMarqueeItem,
|
|
9
|
+
AwardMarqueeSpeed,
|
|
10
|
+
AwardMarqueeBackground,
|
|
11
|
+
} from "./blocks/award-marquee/types";
|
|
12
|
+
|
|
5
13
|
export { Callout } from "./blocks/callout";
|
|
6
14
|
export type { CalloutProps } from "./blocks/callout/types";
|
|
7
15
|
|
package/tailwind.config.cjs
CHANGED
|
@@ -378,10 +378,17 @@ module.exports = {
|
|
|
378
378
|
"70%": { transform: "scale(1.6)", opacity: "0" },
|
|
379
379
|
"100%": { transform: "scale(1.6)", opacity: "0" },
|
|
380
380
|
},
|
|
381
|
+
awardMarqueeScroll: {
|
|
382
|
+
from: { transform: "translateX(0)" },
|
|
383
|
+
to: { transform: "translateX(-100%)" },
|
|
384
|
+
},
|
|
381
385
|
},
|
|
382
386
|
animation: {
|
|
383
387
|
blink: "blink 1.2s ease-in-out infinite",
|
|
384
388
|
"pulse-dot": "pulseDot 1.6s ease-out infinite",
|
|
389
|
+
// Duration is supplied per-instance via the --award-marquee-duration var.
|
|
390
|
+
"award-marquee":
|
|
391
|
+
"awardMarqueeScroll var(--award-marquee-duration, 20s) linear infinite",
|
|
385
392
|
},
|
|
386
393
|
},
|
|
387
394
|
screens: {
|