@databiosphere/findable-ui 8.0.1 → 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.
Files changed (23) hide show
  1. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +9 -7
  2. package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.js +2 -5
  3. package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.styles.d.ts +3 -0
  4. package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.styles.js +10 -0
  5. package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.d.ts +7 -0
  6. package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.js +11 -0
  7. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.js +2 -1
  8. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +4 -1
  9. package/lib/components/Layout/components/Header/components/Content/components/Slogan/slogan.styles.js +3 -1
  10. package/lib/components/Layout/components/Header/header.js +1 -1
  11. package/lib/components/Layout/components/Header/header.styles.js +6 -0
  12. package/lib/components/Layout/components/Nav/nav.styles.js +6 -0
  13. package/package.json +1 -1
  14. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +23 -20
  15. package/src/components/Layout/components/Header/components/Content/components/Logo/logo.styles.ts +11 -0
  16. package/src/components/Layout/components/Header/components/Content/components/Logo/logo.tsx +6 -18
  17. package/src/components/Layout/components/Header/components/Content/components/Navigation/common/utils.ts +13 -0
  18. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.tsx +2 -1
  19. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +6 -1
  20. package/src/components/Layout/components/Header/components/Content/components/Slogan/slogan.styles.ts +3 -1
  21. package/src/components/Layout/components/Header/header.styles.ts +6 -0
  22. package/src/components/Layout/components/Header/header.tsx +1 -1
  23. 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(Actions, null,
14
- React.createElement(Search, { closeMenu: onClose, searchEnabled: searchEnabled, searchURL: searchURL }),
15
- React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: onClose }),
16
- actions,
17
- React.createElement(IconButton, { color: "ink", onClick: onClose },
18
- React.createElement(CloseRoundedIcon, null))))));
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 { isClientSideNavigation } from "../../../../../../../Links/common/utils";
4
+ import { StyledLink } from "./logo.styles";
6
5
  export const Logo = ({ alt, className, height, link, src, target = ANCHOR_TARGET.SELF, width, }) => {
7
- const logo = (React.createElement(StaticImage, { alt: alt, height: height, src: src, width: width }));
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,3 @@
1
+ export declare const StyledLink: import("@emotion/styled").StyledComponent<import("../../../../../../../Links/components/Link/link").LinkProps & {
2
+ theme?: import("@emotion/react").Theme | undefined;
3
+ }, {}, {}>;
@@ -0,0 +1,10 @@
1
+ import styled from "@emotion/styled";
2
+ import { Link } from "../../../../../../../Links/components/Link/link";
3
+ export const StyledLink = styled(Link) `
4
+ &.MuiLink-root {
5
+ text-decoration: none !important;
6
+ img {
7
+ margin: 0;
8
+ }
9
+ }
10
+ `;
@@ -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 === pathname },
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 === pathname ? "activeNav" : "nav" }, label),
22
+ }, variant: isNavigationLinkSelected(url, pathname)
23
+ ? "activeNav"
24
+ : "nav" }, label),
22
25
  divider && React.createElement(Divider, null))))));
23
26
  });
@@ -20,5 +20,7 @@ export const Slogan = styled.div `
20
20
  }
21
21
  `;
22
22
  export const Divider = styled(MDivider) `
23
- max-height: 32px;
23
+ align-self: center;
24
+ display: flex;
25
+ height: 32px;
24
26
  `;
@@ -22,7 +22,7 @@ export const Header = ({ ...headerProps }) => {
22
22
  const { isIn } = useHeaderVisibility(headerProps);
23
23
  const { headerRef } = useMeasureHeader();
24
24
  const { onClose, onOpen, open } = useMenu();
25
- const pathname = usePathname();
25
+ const pathname = usePathname() ?? "";
26
26
  const { actions, announcements, authenticationEnabled, className, logo, navigation: [navItemsL, navItemsC, navItemsR] = [], searchEnabled, searchURL, slogan, socialMedia, } = headerProps;
27
27
  const navigationProps = { headerProps, pathname };
28
28
  return (React.createElement(AppBar, { ...APP_BAR_PROPS, ref: headerRef, className: className },
@@ -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
  `;
@@ -45,5 +45,11 @@ export const List = styled(MList) `
45
45
  }
46
46
  }
47
47
  }
48
+
49
+ &:first-of-type {
50
+ .MuiListItemButton-root.Mui-disabled {
51
+ margin-top: 0;
52
+ }
53
+ }
48
54
  }
49
55
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databiosphere/findable-ui",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -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
- <Actions>
35
- {/* Search */}
36
- <Search
37
- closeMenu={onClose}
38
- searchEnabled={searchEnabled}
39
- searchURL={searchURL}
40
- />
41
- {/* Authentication */}
42
- <Authentication
43
- authenticationEnabled={authenticationEnabled}
44
- closeMenu={onClose}
45
- />
46
- {/* Additional actions i.e. call-to-action button */}
47
- {actions}
48
- {/* Close menu */}
49
- <IconButton color="ink" onClick={onClose}>
50
- <CloseRoundedIcon />
51
- </IconButton>
52
- </Actions>
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
  );
@@ -0,0 +1,11 @@
1
+ import styled from "@emotion/styled";
2
+ import { Link } from "../../../../../../../Links/components/Link/link";
3
+
4
+ export const StyledLink = styled(Link)`
5
+ &.MuiLink-root {
6
+ text-decoration: none !important;
7
+ img {
8
+ margin: 0;
9
+ }
10
+ }
11
+ `;
@@ -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 { isClientSideNavigation } from "../../../../../../../Links/common/utils";
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
- const logo = (
30
- <StaticImage alt={alt} height={height} src={src} width={width} />
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
- href={link}
42
- rel="noopener noreferrer"
31
+ label={<StaticImage alt={alt} height={height} src={src} width={width} />}
43
32
  target={target}
44
- >
45
- {logo}
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 === pathname}
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={url === pathname ? "activeNav" : "nav"}
84
+ variant={
85
+ isNavigationLinkSelected(url, pathname)
86
+ ? "activeNav"
87
+ : "nav"
88
+ }
84
89
  >
85
90
  {label}
86
91
  </Button>
@@ -22,5 +22,7 @@ export const Slogan = styled.div`
22
22
  `;
23
23
 
24
24
  export const Divider = styled(MDivider)`
25
- max-height: 32px;
25
+ align-self: center;
26
+ display: flex;
27
+ height: 32px;
26
28
  `;
@@ -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
  `;
@@ -42,7 +42,7 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
42
42
  const { isIn } = useHeaderVisibility(headerProps);
43
43
  const { headerRef } = useMeasureHeader();
44
44
  const { onClose, onOpen, open } = useMenu();
45
- const pathname = usePathname();
45
+ const pathname = usePathname() ?? "";
46
46
  const {
47
47
  actions,
48
48
  announcements,
@@ -51,5 +51,11 @@ export const List = styled(MList)`
51
51
  }
52
52
  }
53
53
  }
54
+
55
+ &:first-of-type {
56
+ .MuiListItemButton-root.Mui-disabled {
57
+ margin-top: 0;
58
+ }
59
+ }
54
60
  }
55
61
  `;