@windstream/react-shared-components 0.1.99 → 0.2.0
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.esm.js +1 -1
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +1 -1
- package/dist/contentful/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/contentful/blocks/cards/floating-image-card/index.tsx +2 -2
- package/src/contentful/blocks/navigation/desktop-link-groups.tsx/index.tsx +139 -139
- package/src/contentful/blocks/navigation/index.tsx +571 -571
- package/src/contentful/blocks/navigation/mobile-link-groups.tsx/index.tsx +82 -82
package/dist/index.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ declare const Input: React$1.ForwardRefExoticComponent<Omit<React$1.InputHTMLAtt
|
|
|
65
65
|
size?: "slim" | "medium" | "large" | undefined;
|
|
66
66
|
label?: string | undefined;
|
|
67
67
|
errorText?: string | undefined;
|
|
68
|
-
prefixIconName?: "
|
|
68
|
+
prefixIconName?: "search" | "location_on" | undefined;
|
|
69
69
|
prefixIconSize?: 20 | 24 | 40 | 48 | undefined;
|
|
70
70
|
prefixIconFill?: boolean | undefined;
|
|
71
71
|
suffixIconFill?: boolean | undefined;
|
|
@@ -351,7 +351,7 @@ type ButtonAsAnchor = ButtonCustomProps & Omit<AnchorHTMLAttributes<HTMLAnchorEl
|
|
|
351
351
|
};
|
|
352
352
|
type ButtonProps = ButtonAsButton | ButtonAsAnchor;
|
|
353
353
|
|
|
354
|
-
declare const BrandButton: React__default.ForwardRefExoticComponent<ButtonProps$2 & React__default.RefAttributes<
|
|
354
|
+
declare const BrandButton: React__default.ForwardRefExoticComponent<ButtonProps$2 & React__default.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
355
355
|
|
|
356
356
|
declare const Checklist: React__default.FC<ChecklistProps>;
|
|
357
357
|
|
package/package.json
CHANGED
|
@@ -71,7 +71,7 @@ export const FloatingImageCard: React.FC<FloatingImageCardProps> = ({
|
|
|
71
71
|
{image?.href ? (
|
|
72
72
|
<div
|
|
73
73
|
className={cx(
|
|
74
|
-
"relative aspect-video w-full overflow-hidden
|
|
74
|
+
"relative aspect-video w-full overflow-hidden sm:mb-1 md:flex-none lg:mb-0",
|
|
75
75
|
imageClassName
|
|
76
76
|
)}
|
|
77
77
|
>
|
|
@@ -82,7 +82,7 @@ export const FloatingImageCard: React.FC<FloatingImageCardProps> = ({
|
|
|
82
82
|
height={image.height || 285}
|
|
83
83
|
onClick={handleImageClick}
|
|
84
84
|
className={cx(
|
|
85
|
-
"h-full max-h-[285px] w-full object-cover",
|
|
85
|
+
"h-full max-h-[285px] w-full rounded-[40px] object-cover",
|
|
86
86
|
imageLinkAvailableClass
|
|
87
87
|
)}
|
|
88
88
|
/>
|
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
import React, { CSSProperties } from "react";
|
|
2
|
-
|
|
3
|
-
import { MaterialIcon } from "@shared/components/material-icon";
|
|
4
|
-
import { Text } from "@shared/components/text";
|
|
5
|
-
import { Button } from "@shared/contentful/blocks/button";
|
|
6
|
-
import { ButtonProps as ContentfulButtonProps } from "@shared/contentful/blocks/button/types";
|
|
7
|
-
import { useOutsideClick } from "@shared/hooks/use-outside-click";
|
|
8
|
-
import { cx } from "@shared/utils";
|
|
9
|
-
|
|
10
|
-
type ComponentButtonGroup = {
|
|
11
|
-
anchorId?: string | null;
|
|
12
|
-
title?: string | null;
|
|
13
|
-
items?: { items?: ContentfulButtonProps[] | null } | null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type Link = ContentfulButtonProps | ComponentButtonGroup;
|
|
17
|
-
|
|
18
|
-
type LinkGroupsProps = {
|
|
19
|
-
link?: Link;
|
|
20
|
-
anchorName: string;
|
|
21
|
-
/**
|
|
22
|
-
* Tailwind text-color class to apply to the top-level link/group
|
|
23
|
-
* label. Lets the parent navbar invert text color (e.g. `text-white`)
|
|
24
|
-
* when rendered on a dark background. Submenu items keep their
|
|
25
|
-
* default `text-text-link` so they remain readable on the white
|
|
26
|
-
* popover background.
|
|
27
|
-
*/
|
|
28
|
-
linkColorClassName?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const isButton = (link: Link): link is ContentfulButtonProps => {
|
|
32
|
-
// If your group never has `href`, this is a simple and effective guard
|
|
33
|
-
return typeof (link as ContentfulButtonProps).href === "string";
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const DesktopLinkGroups: React.FC<LinkGroupsProps> = ({
|
|
37
|
-
link,
|
|
38
|
-
anchorName,
|
|
39
|
-
linkColorClassName,
|
|
40
|
-
}) => {
|
|
41
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
42
|
-
|
|
43
|
-
const ref = React.useRef<HTMLDivElement>(null);
|
|
44
|
-
useOutsideClick(ref, () => setIsOpen(false));
|
|
45
|
-
|
|
46
|
-
if (!link) return null;
|
|
47
|
-
|
|
48
|
-
// Single button
|
|
49
|
-
if (isButton(link)) {
|
|
50
|
-
return (
|
|
51
|
-
<Button
|
|
52
|
-
key={`submenu-link-btn-${link.anchorId}`}
|
|
53
|
-
{...link}
|
|
54
|
-
linkClassName={cx(
|
|
55
|
-
"body3 flex items-center h-full",
|
|
56
|
-
linkColorClassName || "text-text"
|
|
57
|
-
)}
|
|
58
|
-
linkVariant="unstyled"
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Group
|
|
64
|
-
const { anchorId, title, items } = link;
|
|
65
|
-
const subMenu = Array.isArray(items?.items) ? items!.items! : [];
|
|
66
|
-
const fullAnchorName = `--link-anchor-${anchorName}`;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
className="relative h-full"
|
|
71
|
-
style={{ anchorName: fullAnchorName } as CSSProperties}
|
|
72
|
-
ref={ref}
|
|
73
|
-
>
|
|
74
|
-
<Button
|
|
75
|
-
onClick={() => setIsOpen(prev => !prev)}
|
|
76
|
-
aria-expanded={isOpen}
|
|
77
|
-
buttonClassName={cx(
|
|
78
|
-
"group body3 flex items-center h-full",
|
|
79
|
-
linkColorClassName || "text-text"
|
|
80
|
-
)}
|
|
81
|
-
key={anchorId}
|
|
82
|
-
showButtonAs="unstyled"
|
|
83
|
-
>
|
|
84
|
-
<Text as="span" className="group-hover:underline">
|
|
85
|
-
{title ?? null}
|
|
86
|
-
</Text>
|
|
87
|
-
<MaterialIcon
|
|
88
|
-
weight="200"
|
|
89
|
-
size={24}
|
|
90
|
-
className="group-hover:opacity-50 text-icon-secondary"
|
|
91
|
-
name={isOpen ? "keyboard_arrow_up" : "keyboard_arrow_down"}
|
|
92
|
-
/>
|
|
93
|
-
</Button>
|
|
94
|
-
|
|
95
|
-
<div
|
|
96
|
-
className={cx(
|
|
97
|
-
"shadow-navDrop fixed z-[1001] min-w-44 rounded-input-poppers border border-border bg-bg",
|
|
98
|
-
"transition-[opacity,transform] ease-out",
|
|
99
|
-
isOpen && subMenu.length > 0
|
|
100
|
-
? "pointer-events-auto translate-y-0 opacity-100 duration-75"
|
|
101
|
-
: "pointer-events-none -translate-y-2 opacity-0 duration-0"
|
|
102
|
-
)}
|
|
103
|
-
style={
|
|
104
|
-
{
|
|
105
|
-
positionAnchor: fullAnchorName,
|
|
106
|
-
top: "anchor(bottom)",
|
|
107
|
-
left: "calc((anchor(left) + anchor(right)) / 2)",
|
|
108
|
-
translate: "-50% 0",
|
|
109
|
-
} as CSSProperties
|
|
110
|
-
}
|
|
111
|
-
>
|
|
112
|
-
<ul
|
|
113
|
-
className="flex flex-col gap-2 py-2"
|
|
114
|
-
onClick={event => {
|
|
115
|
-
// Close the popup when a submenu link is clicked.
|
|
116
|
-
// Required for Pages Router where this component persists across
|
|
117
|
-
// client-side navigations and `isOpen` would otherwise stay true.
|
|
118
|
-
const target = event.target as HTMLElement | null;
|
|
119
|
-
if (target?.closest("a")) {
|
|
120
|
-
setIsOpen(false);
|
|
121
|
-
}
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
{subMenu.map((site, index) => {
|
|
125
|
-
return (
|
|
126
|
-
<li key={`submenu-link-${index}`} className="submenu-link type1">
|
|
127
|
-
<Button
|
|
128
|
-
{...site}
|
|
129
|
-
linkVariant="unstyled"
|
|
130
|
-
linkClassName="body3 px-4 hover:bg-bg-surface-hover flex items-center w-full h-11 text-text-link"
|
|
131
|
-
/>
|
|
132
|
-
</li>
|
|
133
|
-
);
|
|
134
|
-
})}
|
|
135
|
-
</ul>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
};
|
|
1
|
+
import React, { CSSProperties } from "react";
|
|
2
|
+
|
|
3
|
+
import { MaterialIcon } from "@shared/components/material-icon";
|
|
4
|
+
import { Text } from "@shared/components/text";
|
|
5
|
+
import { Button } from "@shared/contentful/blocks/button";
|
|
6
|
+
import { ButtonProps as ContentfulButtonProps } from "@shared/contentful/blocks/button/types";
|
|
7
|
+
import { useOutsideClick } from "@shared/hooks/use-outside-click";
|
|
8
|
+
import { cx } from "@shared/utils";
|
|
9
|
+
|
|
10
|
+
type ComponentButtonGroup = {
|
|
11
|
+
anchorId?: string | null;
|
|
12
|
+
title?: string | null;
|
|
13
|
+
items?: { items?: ContentfulButtonProps[] | null } | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type Link = ContentfulButtonProps | ComponentButtonGroup;
|
|
17
|
+
|
|
18
|
+
type LinkGroupsProps = {
|
|
19
|
+
link?: Link;
|
|
20
|
+
anchorName: string;
|
|
21
|
+
/**
|
|
22
|
+
* Tailwind text-color class to apply to the top-level link/group
|
|
23
|
+
* label. Lets the parent navbar invert text color (e.g. `text-white`)
|
|
24
|
+
* when rendered on a dark background. Submenu items keep their
|
|
25
|
+
* default `text-text-link` so they remain readable on the white
|
|
26
|
+
* popover background.
|
|
27
|
+
*/
|
|
28
|
+
linkColorClassName?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const isButton = (link: Link): link is ContentfulButtonProps => {
|
|
32
|
+
// If your group never has `href`, this is a simple and effective guard
|
|
33
|
+
return typeof (link as ContentfulButtonProps).href === "string";
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const DesktopLinkGroups: React.FC<LinkGroupsProps> = ({
|
|
37
|
+
link,
|
|
38
|
+
anchorName,
|
|
39
|
+
linkColorClassName,
|
|
40
|
+
}) => {
|
|
41
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
42
|
+
|
|
43
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
44
|
+
useOutsideClick(ref, () => setIsOpen(false));
|
|
45
|
+
|
|
46
|
+
if (!link) return null;
|
|
47
|
+
|
|
48
|
+
// Single button
|
|
49
|
+
if (isButton(link)) {
|
|
50
|
+
return (
|
|
51
|
+
<Button
|
|
52
|
+
key={`submenu-link-btn-${link.anchorId}`}
|
|
53
|
+
{...link}
|
|
54
|
+
linkClassName={cx(
|
|
55
|
+
"body3 flex items-center h-full",
|
|
56
|
+
linkColorClassName || "text-text"
|
|
57
|
+
)}
|
|
58
|
+
linkVariant="unstyled"
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Group
|
|
64
|
+
const { anchorId, title, items } = link;
|
|
65
|
+
const subMenu = Array.isArray(items?.items) ? items!.items! : [];
|
|
66
|
+
const fullAnchorName = `--link-anchor-${anchorName}`;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
className="relative h-full"
|
|
71
|
+
style={{ anchorName: fullAnchorName } as CSSProperties}
|
|
72
|
+
ref={ref}
|
|
73
|
+
>
|
|
74
|
+
<Button
|
|
75
|
+
onClick={() => setIsOpen(prev => !prev)}
|
|
76
|
+
aria-expanded={isOpen}
|
|
77
|
+
buttonClassName={cx(
|
|
78
|
+
"group body3 flex items-center h-full",
|
|
79
|
+
linkColorClassName || "text-text"
|
|
80
|
+
)}
|
|
81
|
+
key={anchorId}
|
|
82
|
+
showButtonAs="unstyled"
|
|
83
|
+
>
|
|
84
|
+
<Text as="span" className="group-hover:underline">
|
|
85
|
+
{title ?? null}
|
|
86
|
+
</Text>
|
|
87
|
+
<MaterialIcon
|
|
88
|
+
weight="200"
|
|
89
|
+
size={24}
|
|
90
|
+
className="group-hover:opacity-50 text-icon-secondary"
|
|
91
|
+
name={isOpen ? "keyboard_arrow_up" : "keyboard_arrow_down"}
|
|
92
|
+
/>
|
|
93
|
+
</Button>
|
|
94
|
+
|
|
95
|
+
<div
|
|
96
|
+
className={cx(
|
|
97
|
+
"shadow-navDrop fixed z-[1001] min-w-44 rounded-input-poppers border border-border bg-bg",
|
|
98
|
+
"transition-[opacity,transform] ease-out",
|
|
99
|
+
isOpen && subMenu.length > 0
|
|
100
|
+
? "pointer-events-auto translate-y-0 opacity-100 duration-75"
|
|
101
|
+
: "pointer-events-none -translate-y-2 opacity-0 duration-0"
|
|
102
|
+
)}
|
|
103
|
+
style={
|
|
104
|
+
{
|
|
105
|
+
positionAnchor: fullAnchorName,
|
|
106
|
+
top: "anchor(bottom)",
|
|
107
|
+
left: "calc((anchor(left) + anchor(right)) / 2)",
|
|
108
|
+
translate: "-50% 0",
|
|
109
|
+
} as CSSProperties
|
|
110
|
+
}
|
|
111
|
+
>
|
|
112
|
+
<ul
|
|
113
|
+
className="flex flex-col gap-2 py-2"
|
|
114
|
+
onClick={event => {
|
|
115
|
+
// Close the popup when a submenu link is clicked.
|
|
116
|
+
// Required for Pages Router where this component persists across
|
|
117
|
+
// client-side navigations and `isOpen` would otherwise stay true.
|
|
118
|
+
const target = event.target as HTMLElement | null;
|
|
119
|
+
if (target?.closest("a")) {
|
|
120
|
+
setIsOpen(false);
|
|
121
|
+
}
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
{subMenu.map((site, index) => {
|
|
125
|
+
return (
|
|
126
|
+
<li key={`submenu-link-${index}`} className="submenu-link type1">
|
|
127
|
+
<Button
|
|
128
|
+
{...site}
|
|
129
|
+
linkVariant="unstyled"
|
|
130
|
+
linkClassName="body3 px-4 hover:bg-bg-surface-hover flex items-center w-full h-11 text-text-link"
|
|
131
|
+
/>
|
|
132
|
+
</li>
|
|
133
|
+
);
|
|
134
|
+
})}
|
|
135
|
+
</ul>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
};
|