@databiosphere/findable-ui 8.0.2 → 8.0.3
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/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +9 -7
- package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.js +2 -5
- package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.styles.d.ts +3 -0
- package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.styles.js +10 -0
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.d.ts +7 -0
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.js +11 -0
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.js +2 -1
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +4 -1
- package/lib/components/Layout/components/Header/components/Content/components/Slogan/slogan.styles.js +3 -1
- package/lib/components/Layout/components/Header/header.styles.js +6 -0
- package/lib/components/Layout/components/Nav/nav.styles.js +6 -0
- package/package.json +1 -1
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +23 -20
- package/src/components/Layout/components/Header/components/Content/components/Logo/logo.styles.ts +11 -0
- package/src/components/Layout/components/Header/components/Content/components/Logo/logo.tsx +6 -18
- package/src/components/Layout/components/Header/components/Content/components/Navigation/common/utils.ts +13 -0
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.tsx +2 -1
- package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +6 -1
- package/src/components/Layout/components/Header/components/Content/components/Slogan/slogan.styles.ts +3 -1
- package/src/components/Layout/components/Header/header.styles.ts +6 -0
- package/src/components/Layout/components/Nav/nav.styles.ts +6 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
|
|
2
2
|
import { IconButton, Toolbar as MToolbar } from "@mui/material";
|
|
3
3
|
import React, { Fragment } from "react";
|
|
4
|
+
import { Left, Right } from "../../../../../../../../header.styles";
|
|
4
5
|
import { Announcements } from "../../../../../../../Announcements/announcements";
|
|
5
6
|
import { Actions } from "../../../../actions";
|
|
6
7
|
import { Authentication } from "../../../Authentication/authentication";
|
|
@@ -9,11 +10,12 @@ export const Toolbar = ({ actions, announcements, authenticationEnabled, logo, o
|
|
|
9
10
|
return (React.createElement(Fragment, null,
|
|
10
11
|
React.createElement(Announcements, { announcements: announcements }),
|
|
11
12
|
React.createElement(MToolbar, null,
|
|
12
|
-
logo,
|
|
13
|
-
React.createElement(
|
|
14
|
-
React.createElement(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
React.createElement(
|
|
13
|
+
React.createElement(Left, null, logo),
|
|
14
|
+
React.createElement(Right, null,
|
|
15
|
+
React.createElement(Actions, null,
|
|
16
|
+
React.createElement(Search, { closeMenu: onClose, searchEnabled: searchEnabled, searchURL: searchURL }),
|
|
17
|
+
React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: onClose }),
|
|
18
|
+
actions,
|
|
19
|
+
React.createElement(IconButton, { color: "ink", onClick: onClose },
|
|
20
|
+
React.createElement(CloseRoundedIcon, null)))))));
|
|
19
21
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import Link from "next/link";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { StaticImage, } from "../../../../../../../common/StaticImage/staticImage";
|
|
4
3
|
import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
|
|
5
|
-
import {
|
|
4
|
+
import { StyledLink } from "./logo.styles";
|
|
6
5
|
export const Logo = ({ alt, className, height, link, src, target = ANCHOR_TARGET.SELF, width, }) => {
|
|
7
|
-
|
|
8
|
-
return isClientSideNavigation(link) ? (React.createElement(Link, { href: link, legacyBehavior: true, passHref: true },
|
|
9
|
-
React.createElement("a", { className: className, href: "passHref", rel: "noopener", target: target }, logo))) : (React.createElement("a", { className: className, href: link, rel: "noopener noreferrer", target: target }, logo));
|
|
6
|
+
return (React.createElement(StyledLink, { className: className, label: React.createElement(StaticImage, { alt: alt, height: height, src: src, width: width }), target: target, url: link }));
|
|
10
7
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the navigation link is selected.
|
|
3
|
+
* @param url - The URL of the navigation link.
|
|
4
|
+
* @param pathname - The current pathname.
|
|
5
|
+
* @returns true if the navigation link is selected.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isNavigationLinkSelected(url: string, pathname?: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the navigation link is selected.
|
|
3
|
+
* @param url - The URL of the navigation link.
|
|
4
|
+
* @param pathname - The current pathname.
|
|
5
|
+
* @returns true if the navigation link is selected.
|
|
6
|
+
*/
|
|
7
|
+
export function isNavigationLinkSelected(url, pathname) {
|
|
8
|
+
if (!pathname)
|
|
9
|
+
return false;
|
|
10
|
+
return pathname.startsWith(url);
|
|
11
|
+
}
|
|
@@ -4,6 +4,7 @@ import React, { Fragment } from "react";
|
|
|
4
4
|
import { TEXT_BODY_400, TEXT_BODY_500, TEXT_BODY_SMALL_400_2_LINES, } from "../../../../../../../../../../theme/common/typography";
|
|
5
5
|
import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
|
|
6
6
|
import { isClientSideNavigation } from "../../../../../../../../../Links/common/utils";
|
|
7
|
+
import { isNavigationLinkSelected } from "../../common/utils";
|
|
7
8
|
import { NavigationMenu } from "../NavigationMenu/navigationMenu";
|
|
8
9
|
export const NavigationMenuItems = ({ closeMenu, menuItems, pathname, }) => {
|
|
9
10
|
const router = useRouter();
|
|
@@ -13,7 +14,7 @@ export const NavigationMenuItems = ({ closeMenu, menuItems, pathname, }) => {
|
|
|
13
14
|
isClientSideNavigation(url)
|
|
14
15
|
? router.push(url)
|
|
15
16
|
: window.open(url, target, "noopener noreferrer");
|
|
16
|
-
}, selected: url
|
|
17
|
+
}, selected: isNavigationLinkSelected(url, pathname) },
|
|
17
18
|
icon && React.createElement(ListItemIcon, null, icon),
|
|
18
19
|
React.createElement(ListItemText, { primary: label, primaryTypographyProps: {
|
|
19
20
|
variant: description ? TEXT_BODY_500 : TEXT_BODY_400,
|
|
@@ -4,6 +4,7 @@ import React, { forwardRef, Fragment } from "react";
|
|
|
4
4
|
import { useBreakpoint } from "../../../../../../../../hooks/useBreakpoint";
|
|
5
5
|
import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
|
|
6
6
|
import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
|
|
7
|
+
import { isNavigationLinkSelected } from "./common/utils";
|
|
7
8
|
import { NavigationDrawer } from "./components/NavigationDrawer/navigationDrawer";
|
|
8
9
|
import { NavigationMenu } from "./components/NavigationMenu/navigationMenu";
|
|
9
10
|
import { Navigation as Links } from "./navigation.styles";
|
|
@@ -18,6 +19,8 @@ export const Navigation = forwardRef(function Navigation({ className, closeAnces
|
|
|
18
19
|
? router.push(url)
|
|
19
20
|
: window.open(url, target, "noopener noreferrer");
|
|
20
21
|
closeAncestor?.();
|
|
21
|
-
}, variant: url
|
|
22
|
+
}, variant: isNavigationLinkSelected(url, pathname)
|
|
23
|
+
? "activeNav"
|
|
24
|
+
: "nav" }, label),
|
|
22
25
|
divider && React.createElement(Divider, null))))));
|
|
23
26
|
});
|
|
@@ -10,7 +10,10 @@ export const AppBar = styled(MAppBar) `
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.MuiToolbar-root {
|
|
13
|
+
display: grid;
|
|
13
14
|
gap: 16px;
|
|
15
|
+
grid-template-areas: "left center right";
|
|
16
|
+
grid-template-columns: 1fr auto 1fr;
|
|
14
17
|
height: ${HEADER_HEIGHT}px;
|
|
15
18
|
min-height: unset;
|
|
16
19
|
}
|
|
@@ -23,6 +26,7 @@ const group = css `
|
|
|
23
26
|
export const Left = styled.div `
|
|
24
27
|
${group};
|
|
25
28
|
gap: 16px;
|
|
29
|
+
grid-area: left;
|
|
26
30
|
justify-content: flex-start;
|
|
27
31
|
|
|
28
32
|
.MuiButton-navPrimary {
|
|
@@ -33,9 +37,11 @@ export const Left = styled.div `
|
|
|
33
37
|
`;
|
|
34
38
|
export const Center = styled.div `
|
|
35
39
|
${group};
|
|
40
|
+
grid-area: center;
|
|
36
41
|
justify-content: center;
|
|
37
42
|
`;
|
|
38
43
|
export const Right = styled.div `
|
|
39
44
|
${group};
|
|
45
|
+
grid-area: right;
|
|
40
46
|
justify-content: flex-end;
|
|
41
47
|
`;
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
|
|
|
2
2
|
import { IconButton, Toolbar as MToolbar } from "@mui/material";
|
|
3
3
|
import React, { Fragment, ReactNode } from "react";
|
|
4
4
|
import { ComponentsConfig } from "../../../../../../../../../../../../config/entities";
|
|
5
|
+
import { Left, Right } from "../../../../../../../../header.styles";
|
|
5
6
|
import { Announcements } from "../../../../../../../Announcements/announcements";
|
|
6
7
|
import { Actions } from "../../../../actions";
|
|
7
8
|
import { Authentication } from "../../../Authentication/authentication";
|
|
@@ -30,26 +31,28 @@ export const Toolbar = ({
|
|
|
30
31
|
<Fragment>
|
|
31
32
|
<Announcements announcements={announcements} />
|
|
32
33
|
<MToolbar>
|
|
33
|
-
{logo}
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
<Left>{logo}</Left>
|
|
35
|
+
<Right>
|
|
36
|
+
<Actions>
|
|
37
|
+
{/* Search */}
|
|
38
|
+
<Search
|
|
39
|
+
closeMenu={onClose}
|
|
40
|
+
searchEnabled={searchEnabled}
|
|
41
|
+
searchURL={searchURL}
|
|
42
|
+
/>
|
|
43
|
+
{/* Authentication */}
|
|
44
|
+
<Authentication
|
|
45
|
+
authenticationEnabled={authenticationEnabled}
|
|
46
|
+
closeMenu={onClose}
|
|
47
|
+
/>
|
|
48
|
+
{/* Additional actions i.e. call-to-action button */}
|
|
49
|
+
{actions}
|
|
50
|
+
{/* Close menu */}
|
|
51
|
+
<IconButton color="ink" onClick={onClose}>
|
|
52
|
+
<CloseRoundedIcon />
|
|
53
|
+
</IconButton>
|
|
54
|
+
</Actions>
|
|
55
|
+
</Right>
|
|
53
56
|
</MToolbar>
|
|
54
57
|
</Fragment>
|
|
55
58
|
);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import Link from "next/link";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import {
|
|
4
3
|
ImageSrc,
|
|
5
4
|
StaticImage,
|
|
6
5
|
} from "../../../../../../../common/StaticImage/staticImage";
|
|
7
6
|
import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
|
|
8
|
-
import {
|
|
7
|
+
import { StyledLink } from "./logo.styles";
|
|
9
8
|
|
|
10
9
|
export interface LogoProps {
|
|
11
10
|
alt: string;
|
|
@@ -26,23 +25,12 @@ export const Logo = ({
|
|
|
26
25
|
target = ANCHOR_TARGET.SELF,
|
|
27
26
|
width,
|
|
28
27
|
}: LogoProps): JSX.Element => {
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
);
|
|
32
|
-
return isClientSideNavigation(link) ? (
|
|
33
|
-
<Link href={link} legacyBehavior passHref>
|
|
34
|
-
<a className={className} href="passHref" rel="noopener" target={target}>
|
|
35
|
-
{logo}
|
|
36
|
-
</a>
|
|
37
|
-
</Link>
|
|
38
|
-
) : (
|
|
39
|
-
<a
|
|
28
|
+
return (
|
|
29
|
+
<StyledLink
|
|
40
30
|
className={className}
|
|
41
|
-
|
|
42
|
-
rel="noopener noreferrer"
|
|
31
|
+
label={<StaticImage alt={alt} height={height} src={src} width={width} />}
|
|
43
32
|
target={target}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</a>
|
|
33
|
+
url={link}
|
|
34
|
+
/>
|
|
47
35
|
);
|
|
48
36
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the navigation link is selected.
|
|
3
|
+
* @param url - The URL of the navigation link.
|
|
4
|
+
* @param pathname - The current pathname.
|
|
5
|
+
* @returns true if the navigation link is selected.
|
|
6
|
+
*/
|
|
7
|
+
export function isNavigationLinkSelected(
|
|
8
|
+
url: string,
|
|
9
|
+
pathname?: string
|
|
10
|
+
): boolean {
|
|
11
|
+
if (!pathname) return false;
|
|
12
|
+
return pathname.startsWith(url);
|
|
13
|
+
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "../../../../../../../../../../theme/common/typography";
|
|
14
14
|
import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
|
|
15
15
|
import { isClientSideNavigation } from "../../../../../../../../../Links/common/utils";
|
|
16
|
+
import { isNavigationLinkSelected } from "../../common/utils";
|
|
16
17
|
import { NavLinkItem } from "../../navigation";
|
|
17
18
|
import { NavigationMenu } from "../NavigationMenu/navigationMenu";
|
|
18
19
|
|
|
@@ -66,7 +67,7 @@ export const NavigationMenuItems = ({
|
|
|
66
67
|
? router.push(url)
|
|
67
68
|
: window.open(url, target, "noopener noreferrer");
|
|
68
69
|
}}
|
|
69
|
-
selected={url
|
|
70
|
+
selected={isNavigationLinkSelected(url, pathname)}
|
|
70
71
|
>
|
|
71
72
|
{icon && <ListItemIcon>{icon}</ListItemIcon>}
|
|
72
73
|
<ListItemText
|
|
@@ -6,6 +6,7 @@ import { BreakpointKey } from "../../../../../../../../hooks/useBreakpointHelper
|
|
|
6
6
|
import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
|
|
7
7
|
import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
|
|
8
8
|
import { HeaderProps } from "../../../../header";
|
|
9
|
+
import { isNavigationLinkSelected } from "./common/utils";
|
|
9
10
|
import { NavigationDrawer } from "./components/NavigationDrawer/navigationDrawer";
|
|
10
11
|
import { NavigationMenu } from "./components/NavigationMenu/navigationMenu";
|
|
11
12
|
import { MenuItem } from "./components/NavigationMenuItems/navigationMenuItems";
|
|
@@ -80,7 +81,11 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
|
|
|
80
81
|
: window.open(url, target, "noopener noreferrer");
|
|
81
82
|
closeAncestor?.();
|
|
82
83
|
}}
|
|
83
|
-
variant={
|
|
84
|
+
variant={
|
|
85
|
+
isNavigationLinkSelected(url, pathname)
|
|
86
|
+
? "activeNav"
|
|
87
|
+
: "nav"
|
|
88
|
+
}
|
|
84
89
|
>
|
|
85
90
|
{label}
|
|
86
91
|
</Button>
|
|
@@ -11,7 +11,10 @@ export const AppBar = styled(MAppBar)`
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.MuiToolbar-root {
|
|
14
|
+
display: grid;
|
|
14
15
|
gap: 16px;
|
|
16
|
+
grid-template-areas: "left center right";
|
|
17
|
+
grid-template-columns: 1fr auto 1fr;
|
|
15
18
|
height: ${HEADER_HEIGHT}px;
|
|
16
19
|
min-height: unset;
|
|
17
20
|
}
|
|
@@ -26,6 +29,7 @@ const group = css`
|
|
|
26
29
|
export const Left = styled.div`
|
|
27
30
|
${group};
|
|
28
31
|
gap: 16px;
|
|
32
|
+
grid-area: left;
|
|
29
33
|
justify-content: flex-start;
|
|
30
34
|
|
|
31
35
|
.MuiButton-navPrimary {
|
|
@@ -37,10 +41,12 @@ export const Left = styled.div`
|
|
|
37
41
|
|
|
38
42
|
export const Center = styled.div`
|
|
39
43
|
${group};
|
|
44
|
+
grid-area: center;
|
|
40
45
|
justify-content: center;
|
|
41
46
|
`;
|
|
42
47
|
|
|
43
48
|
export const Right = styled.div`
|
|
44
49
|
${group};
|
|
50
|
+
grid-area: right;
|
|
45
51
|
justify-content: flex-end;
|
|
46
52
|
`;
|