@conduction/components 2.2.54 → 2.2.55
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/README.md +217 -213
- package/lib/components/card/cardHeader/CardHeader.module.css +54 -54
- package/lib/components/displaySwitch/DisplaySwitch.js +1 -1
- package/lib/components/formFields/select/select.js +44 -0
- package/lib/components/logo/Logo.d.ts +1 -0
- package/lib/components/logo/Logo.js +2 -2
- package/lib/components/topNav/primaryTopNav/PrimaryTopNav.module.css +315 -315
- package/package.json +50 -50
- package/src/components/card/cardHeader/CardHeader.module.css +54 -54
- package/src/components/displaySwitch/DisplaySwitch.tsx +49 -49
- package/src/components/formFields/select/select.tsx +49 -0
- package/src/components/horizontalOverflowWrapper/HorizontalOverflowWrapper.tsx +80 -80
- package/src/components/logo/Logo.tsx +24 -21
- package/src/components/topNav/primaryTopNav/PrimaryTopNav.module.css +315 -315
- package/src/components/topNav/primaryTopNav/PrimaryTopNav.tsx +133 -133
- package/tsconfig.json +21 -21
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as styles from "./PrimaryTopNav.module.css";
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import { Link } from "@utrecht/component-library-react/dist/css-module";
|
|
5
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
6
|
-
import { faBars, faChevronRight } from "@fortawesome/free-solid-svg-icons";
|
|
7
|
-
import { IconPrefix, IconName } from "@fortawesome/fontawesome-svg-core";
|
|
8
|
-
|
|
9
|
-
interface ITopNavItemBase {
|
|
10
|
-
label: string;
|
|
11
|
-
icon?: JSX.Element;
|
|
12
|
-
current?: boolean | ICurrentItemJSONFormat;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface ICurrentItemJSONFormat {
|
|
16
|
-
pathname: string;
|
|
17
|
-
operator: "equals" | "includes";
|
|
18
|
-
filterCondition?: {
|
|
19
|
-
filter: string;
|
|
20
|
-
value: string;
|
|
21
|
-
isObject: boolean;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface IIconJSONFormat {
|
|
26
|
-
icon?: {
|
|
27
|
-
icon: IconName;
|
|
28
|
-
prefix: IconPrefix;
|
|
29
|
-
placement: "left" | "right";
|
|
30
|
-
};
|
|
31
|
-
customIcon?: {
|
|
32
|
-
icon: string;
|
|
33
|
-
placement: "left" | "right";
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface IHandleClickJSONFormat {
|
|
38
|
-
link: string;
|
|
39
|
-
setFilter?: {
|
|
40
|
-
filter: string;
|
|
41
|
-
value: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface ITopNavItemWithSubItems extends ITopNavItemBase {
|
|
46
|
-
handleClick?: never;
|
|
47
|
-
subItems: ITopNavItem[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface ITopNavItemWithoutSubItems extends ITopNavItemBase {
|
|
51
|
-
handleClick?: () => any | IHandleClickJSONFormat;
|
|
52
|
-
type: "readme" | "internal" | "external";
|
|
53
|
-
subItems?: never;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type ITopNavItem = ITopNavItemWithSubItems | ITopNavItemWithoutSubItems;
|
|
57
|
-
|
|
58
|
-
export interface TopNavProps {
|
|
59
|
-
items: ITopNavItem[];
|
|
60
|
-
mobileLogo?: JSX.Element;
|
|
61
|
-
layoutClassName?: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const PrimaryTopNav = ({ items, mobileLogo, layoutClassName }: TopNavProps): JSX.Element => {
|
|
65
|
-
const [isOpen, setIsOpen] = React.useState<boolean>(false);
|
|
66
|
-
const [isMobile, setIsMobile] = React.useState<boolean>(window.innerWidth < 992);
|
|
67
|
-
|
|
68
|
-
React.useEffect(() => {
|
|
69
|
-
const handleResize = () => {
|
|
70
|
-
setIsMobile(window.innerWidth < 992);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
window.addEventListener("resize", handleResize);
|
|
74
|
-
|
|
75
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
const handleSubItemClick = (handleClick: any) => {
|
|
79
|
-
setIsOpen(false);
|
|
80
|
-
|
|
81
|
-
handleClick();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<div className={clsx(styles.container, layoutClassName && layoutClassName)}>
|
|
86
|
-
<div className={styles.menuToggleContainer}>
|
|
87
|
-
{mobileLogo}
|
|
88
|
-
|
|
89
|
-
<button className={styles.menuToggle} onClick={() => setIsOpen((o) => !o)}>
|
|
90
|
-
<FontAwesomeIcon icon={faBars} />
|
|
91
|
-
</button>
|
|
92
|
-
</div>
|
|
93
|
-
|
|
94
|
-
<nav className={clsx(styles.primary, isOpen && styles.isOpen)}>
|
|
95
|
-
<ul className={styles.ul}>
|
|
96
|
-
{items.map(({ label, icon, current, handleClick, subItems }, idx) => (
|
|
97
|
-
<li onClick={handleClick} className={clsx(styles.li, current && styles.current)} key={idx}>
|
|
98
|
-
<Link
|
|
99
|
-
className={clsx(
|
|
100
|
-
styles.link,
|
|
101
|
-
styles.label,
|
|
102
|
-
subItems && styles.mobileLink,
|
|
103
|
-
current && styles.currentLink,
|
|
104
|
-
)}
|
|
105
|
-
>
|
|
106
|
-
{icon && icon}
|
|
107
|
-
{label}{" "}
|
|
108
|
-
{subItems && isMobile && <FontAwesomeIcon className={styles.toggleIcon} icon={faChevronRight} />}
|
|
109
|
-
</Link>
|
|
110
|
-
|
|
111
|
-
{subItems && (
|
|
112
|
-
<ul className={clsx(styles.dropdown, [subItems.length > 8 && styles.dropdownOverflow])}>
|
|
113
|
-
{subItems.map(({ label, icon, current, handleClick }, idx) => (
|
|
114
|
-
<li
|
|
115
|
-
key={idx}
|
|
116
|
-
className={clsx(styles.li, current && styles.dropdownCurrent)}
|
|
117
|
-
onClick={() => handleSubItemClick(handleClick)}
|
|
118
|
-
>
|
|
119
|
-
<Link className={clsx(styles.link, styles.label, current && styles.dropdownCurrentLink)}>
|
|
120
|
-
{icon}
|
|
121
|
-
{label}
|
|
122
|
-
</Link>
|
|
123
|
-
</li>
|
|
124
|
-
))}
|
|
125
|
-
</ul>
|
|
126
|
-
)}
|
|
127
|
-
</li>
|
|
128
|
-
))}
|
|
129
|
-
</ul>
|
|
130
|
-
</nav>
|
|
131
|
-
</div>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as styles from "./PrimaryTopNav.module.css";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { Link } from "@utrecht/component-library-react/dist/css-module";
|
|
5
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
6
|
+
import { faBars, faChevronRight } from "@fortawesome/free-solid-svg-icons";
|
|
7
|
+
import { IconPrefix, IconName } from "@fortawesome/fontawesome-svg-core";
|
|
8
|
+
|
|
9
|
+
interface ITopNavItemBase {
|
|
10
|
+
label: string;
|
|
11
|
+
icon?: JSX.Element;
|
|
12
|
+
current?: boolean | ICurrentItemJSONFormat;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ICurrentItemJSONFormat {
|
|
16
|
+
pathname: string;
|
|
17
|
+
operator: "equals" | "includes";
|
|
18
|
+
filterCondition?: {
|
|
19
|
+
filter: string;
|
|
20
|
+
value: string;
|
|
21
|
+
isObject: boolean;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface IIconJSONFormat {
|
|
26
|
+
icon?: {
|
|
27
|
+
icon: IconName;
|
|
28
|
+
prefix: IconPrefix;
|
|
29
|
+
placement: "left" | "right";
|
|
30
|
+
};
|
|
31
|
+
customIcon?: {
|
|
32
|
+
icon: string;
|
|
33
|
+
placement: "left" | "right";
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface IHandleClickJSONFormat {
|
|
38
|
+
link: string;
|
|
39
|
+
setFilter?: {
|
|
40
|
+
filter: string;
|
|
41
|
+
value: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ITopNavItemWithSubItems extends ITopNavItemBase {
|
|
46
|
+
handleClick?: never;
|
|
47
|
+
subItems: ITopNavItem[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface ITopNavItemWithoutSubItems extends ITopNavItemBase {
|
|
51
|
+
handleClick?: () => any | IHandleClickJSONFormat;
|
|
52
|
+
type: "readme" | "internal" | "external";
|
|
53
|
+
subItems?: never;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type ITopNavItem = ITopNavItemWithSubItems | ITopNavItemWithoutSubItems;
|
|
57
|
+
|
|
58
|
+
export interface TopNavProps {
|
|
59
|
+
items: ITopNavItem[];
|
|
60
|
+
mobileLogo?: JSX.Element;
|
|
61
|
+
layoutClassName?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const PrimaryTopNav = ({ items, mobileLogo, layoutClassName }: TopNavProps): JSX.Element => {
|
|
65
|
+
const [isOpen, setIsOpen] = React.useState<boolean>(false);
|
|
66
|
+
const [isMobile, setIsMobile] = React.useState<boolean>(window.innerWidth < 992);
|
|
67
|
+
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
const handleResize = () => {
|
|
70
|
+
setIsMobile(window.innerWidth < 992);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
window.addEventListener("resize", handleResize);
|
|
74
|
+
|
|
75
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
const handleSubItemClick = (handleClick: any) => {
|
|
79
|
+
setIsOpen(false);
|
|
80
|
+
|
|
81
|
+
handleClick();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className={clsx(styles.container, layoutClassName && layoutClassName)}>
|
|
86
|
+
<div className={styles.menuToggleContainer}>
|
|
87
|
+
{mobileLogo}
|
|
88
|
+
|
|
89
|
+
<button className={styles.menuToggle} onClick={() => setIsOpen((o) => !o)}>
|
|
90
|
+
<FontAwesomeIcon icon={faBars} />
|
|
91
|
+
</button>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<nav className={clsx(styles.primary, isOpen && styles.isOpen)}>
|
|
95
|
+
<ul className={styles.ul}>
|
|
96
|
+
{items.map(({ label, icon, current, handleClick, subItems }, idx) => (
|
|
97
|
+
<li onClick={handleClick} className={clsx(styles.li, current && styles.current)} key={idx}>
|
|
98
|
+
<Link
|
|
99
|
+
className={clsx(
|
|
100
|
+
styles.link,
|
|
101
|
+
styles.label,
|
|
102
|
+
subItems && styles.mobileLink,
|
|
103
|
+
current && styles.currentLink,
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
{icon && icon}
|
|
107
|
+
{label}{" "}
|
|
108
|
+
{subItems && isMobile && <FontAwesomeIcon className={styles.toggleIcon} icon={faChevronRight} />}
|
|
109
|
+
</Link>
|
|
110
|
+
|
|
111
|
+
{subItems && (
|
|
112
|
+
<ul className={clsx(styles.dropdown, [subItems.length > 8 && styles.dropdownOverflow])}>
|
|
113
|
+
{subItems.map(({ label, icon, current, handleClick }, idx) => (
|
|
114
|
+
<li
|
|
115
|
+
key={idx}
|
|
116
|
+
className={clsx(styles.li, current && styles.dropdownCurrent)}
|
|
117
|
+
onClick={() => handleSubItemClick(handleClick)}
|
|
118
|
+
>
|
|
119
|
+
<Link className={clsx(styles.link, styles.label, current && styles.dropdownCurrentLink)}>
|
|
120
|
+
{icon}
|
|
121
|
+
{label}
|
|
122
|
+
</Link>
|
|
123
|
+
</li>
|
|
124
|
+
))}
|
|
125
|
+
</ul>
|
|
126
|
+
)}
|
|
127
|
+
</li>
|
|
128
|
+
))}
|
|
129
|
+
</ul>
|
|
130
|
+
</nav>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"outDir": "./lib",
|
|
5
|
-
"target": "esnext",
|
|
6
|
-
"lib": ["dom", "esnext"],
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"module": "esnext",
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"skipLibCheck": true
|
|
14
|
-
},
|
|
15
|
-
"hooks": ["copy-files"],
|
|
16
|
-
"include": ["src", "src/**/*.css"],
|
|
17
|
-
"exclude": [
|
|
18
|
-
"**/__tests__/*",
|
|
19
|
-
"./lib/**/*"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"target": "esnext",
|
|
6
|
+
"lib": ["dom", "esnext"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"module": "esnext",
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"skipLibCheck": true
|
|
14
|
+
},
|
|
15
|
+
"hooks": ["copy-files"],
|
|
16
|
+
"include": ["src", "src/**/*.css"],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"**/__tests__/*",
|
|
19
|
+
"./lib/**/*"
|
|
20
|
+
]
|
|
21
|
+
}
|