@databiosphere/findable-ui 7.0.0 → 8.0.1

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 (90) hide show
  1. package/lib/common/entities.d.ts +0 -9
  2. package/lib/common/entities.js +1 -9
  3. package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
  4. package/lib/components/Index/components/Tabs/common/utils.d.ts +8 -0
  5. package/lib/components/Index/components/Tabs/common/utils.js +18 -0
  6. package/lib/components/Index/components/Tabs/tabs.d.ts +2 -0
  7. package/lib/components/Index/components/Tabs/tabs.js +20 -0
  8. package/lib/components/Layout/components/Header/common/constants.d.ts +4 -9
  9. package/lib/components/Layout/components/Header/common/constants.js +8 -9
  10. package/lib/components/Layout/components/Header/common/entities.d.ts +6 -0
  11. package/lib/components/Layout/components/Header/common/utils.d.ts +12 -17
  12. package/lib/components/Layout/components/Header/common/utils.js +77 -59
  13. package/lib/components/Layout/components/Header/components/Announcements/announcements.d.ts +6 -0
  14. package/lib/components/Layout/components/Header/components/Announcements/announcements.js +7 -0
  15. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.d.ts +1 -2
  16. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.js +2 -2
  17. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +8 -15
  18. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +1 -1
  19. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Content/components/Navigation/navigation.styles.js +2 -0
  20. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.d.ts +4 -3
  21. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +4 -3
  22. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.d.ts +1 -0
  23. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.js +18 -20
  24. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +5 -12
  25. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +1 -1
  26. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.d.ts +2 -1
  27. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.js +2 -2
  28. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.d.ts +2 -1
  29. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.js +5 -6
  30. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.js +10 -4
  31. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.d.ts +2 -1
  32. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.js +3 -3
  33. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.d.ts +4 -3
  34. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +6 -8
  35. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.d.ts +1 -6
  36. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.js +5 -19
  37. package/lib/components/Layout/components/Header/header.d.ts +5 -7
  38. package/lib/components/Layout/components/Header/header.js +38 -59
  39. package/lib/components/Layout/components/Header/header.stories.js +38 -41
  40. package/lib/components/Layout/components/Header/header.styles.d.ts +13 -1
  41. package/lib/components/Layout/components/Header/header.styles.js +23 -3
  42. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.d.ts +20 -0
  43. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.js +46 -0
  44. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
  45. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
  46. package/lib/config/entities.d.ts +2 -0
  47. package/lib/config/utils.js +1 -2
  48. package/lib/hooks/useBreakpoint.d.ts +17 -0
  49. package/lib/hooks/useBreakpoint.js +34 -0
  50. package/lib/hooks/useBreakpointHelper.d.ts +1 -1
  51. package/lib/hooks/useCurrentBreakpoint.d.ts +3 -0
  52. package/lib/hooks/useCurrentBreakpoint.js +11 -0
  53. package/lib/hooks/useMenu.d.ts +10 -0
  54. package/lib/hooks/useMenu.js +17 -0
  55. package/lib/theme/common/components.js +17 -0
  56. package/lib/views/ExploreView/exploreView.js +4 -29
  57. package/package.json +1 -1
  58. package/src/common/entities.ts +0 -11
  59. package/src/components/Index/components/Tabs/common/utils.ts +33 -0
  60. package/src/components/Index/components/Tabs/tabs.tsx +23 -0
  61. package/src/components/Layout/components/Header/common/constants.ts +14 -10
  62. package/src/components/Layout/components/Header/common/entities.ts +7 -0
  63. package/src/components/Layout/components/Header/common/utils.ts +89 -66
  64. package/src/components/Layout/components/Header/components/Announcements/announcements.tsx +14 -0
  65. package/src/components/Layout/components/Header/components/Content/components/Actions/actions.tsx +2 -6
  66. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.tsx +21 -32
  67. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Content/components/Navigation/navigation.styles.ts +2 -0
  68. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +8 -6
  69. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.tsx +22 -27
  70. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx +11 -22
  71. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.tsx +3 -0
  72. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.ts +15 -5
  73. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.tsx +10 -8
  74. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.tsx +4 -0
  75. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.ts +6 -30
  76. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +12 -21
  77. package/src/components/Layout/components/Header/header.stories.tsx +38 -41
  78. package/src/components/Layout/components/Header/header.styles.ts +27 -4
  79. package/src/components/Layout/components/Header/header.tsx +102 -137
  80. package/src/components/Layout/components/Header/hooks/useHeaderVisibility.ts +74 -0
  81. package/src/components/Layout/components/Header/hooks/useMeasureHeader.ts +28 -0
  82. package/src/config/entities.ts +2 -0
  83. package/src/config/utils.ts +1 -2
  84. package/src/hooks/useBreakpoint.ts +54 -0
  85. package/src/hooks/useBreakpointHelper.ts +1 -1
  86. package/src/hooks/useCurrentBreakpoint.ts +23 -0
  87. package/src/hooks/useMenu.ts +27 -0
  88. package/src/theme/common/components.ts +17 -0
  89. package/src/views/ExploreView/exploreView.tsx +5 -34
  90. package/types/data-explorer-ui.d.ts +1 -0
@@ -1,15 +1,17 @@
1
1
  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
+ import { ComponentsConfig } from "../../../../../../../../../../../../config/entities";
5
+ import { Announcements } from "../../../../../../../Announcements/announcements";
4
6
  import { Actions } from "../../../../actions";
5
7
  import { Authentication } from "../../../Authentication/authentication";
6
8
  import { Search } from "../../../Search/search";
7
9
 
8
10
  export interface DialogTitleProps {
9
11
  actions?: ReactNode;
10
- Announcements?: ReactNode;
12
+ announcements?: ComponentsConfig;
11
13
  authenticationEnabled?: boolean;
12
- Logo?: ReactNode;
14
+ logo?: ReactNode;
13
15
  onClose: () => void;
14
16
  searchEnabled?: boolean;
15
17
  searchURL?: string;
@@ -17,18 +19,18 @@ export interface DialogTitleProps {
17
19
 
18
20
  export const Toolbar = ({
19
21
  actions,
20
- Announcements,
22
+ announcements,
21
23
  authenticationEnabled,
22
- Logo,
24
+ logo,
23
25
  onClose,
24
26
  searchEnabled,
25
27
  searchURL,
26
28
  }: DialogTitleProps): JSX.Element => {
27
29
  return (
28
30
  <Fragment>
29
- {Announcements}
31
+ <Announcements announcements={announcements} />
30
32
  <MToolbar>
31
- {Logo}
33
+ {logo}
32
34
  <Actions>
33
35
  {/* Search */}
34
36
  <Search
@@ -1,13 +1,8 @@
1
1
  import MenuRoundedIcon from "@mui/icons-material/MenuRounded";
2
2
  import { Dialog as MDialog, Fade, IconButton } from "@mui/material";
3
- import React, { CSSProperties, forwardRef, useEffect } from "react";
4
- import {
5
- BREAKPOINT_FN_NAME,
6
- useBreakpointHelper,
7
- } from "../../../../../../../../../../hooks/useBreakpointHelper";
8
- import { DESKTOP_SM } from "../../../../../../../../../../theme/common/breakpoints";
9
- import { SWITCH_TRANSITION_PROPS } from "../../../../../../common/constants";
10
- import { flattenNavigationLinks } from "../../../../../../common/utils";
3
+ import React, { CSSProperties, forwardRef, Fragment, useEffect } from "react";
4
+ import { useBreakpoint } from "../../../../../../../../../../hooks/useBreakpoint";
5
+ import { getMenuNavigationLinks } from "../../../../../../common/utils";
11
6
  import { HeaderProps } from "../../../../../../header";
12
7
  import { AppBar } from "../../../../../../header.styles";
13
8
  import { Content } from "../../../../content.styles";
@@ -21,32 +16,31 @@ export interface MenuProps {
21
16
  headerProps: HeaderProps;
22
17
  open: boolean;
23
18
  openMenu: () => void;
19
+ pathname?: string;
24
20
  style?: CSSProperties; // Required for Fade component. See https://mui.com/material-ui/transitions/#child-requirement.
25
21
  }
26
22
 
27
23
  export const Menu = forwardRef<HTMLButtonElement, MenuProps>(
28
24
  function HeaderMenu(
29
- { closeMenu, headerProps, open, openMenu, style }: MenuProps,
25
+ { closeMenu, headerProps, open, openMenu, pathname, style }: MenuProps,
30
26
  ref
31
- ): JSX.Element {
32
- const { navLinks, slogan, socialMedia } = headerProps;
33
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
34
- const switchProps = SWITCH_TRANSITION_PROPS;
27
+ ): JSX.Element | null {
28
+ const { navigation, slogan, socialMedia } = headerProps;
29
+ const { breakpoint, smDown } = useBreakpoint();
35
30
 
36
- // Set drawer open state to false on change of media breakpoint from mobile to "small desktop".
31
+ // Set drawer open state to false on change of media breakpoint from small desktop "md" and up.
37
32
  useEffect(() => {
38
- if (smDesktop) {
39
- closeMenu();
40
- }
41
- }, [closeMenu, smDesktop]);
33
+ if (smDown) return;
34
+ closeMenu();
35
+ }, [closeMenu, smDown]);
36
+
37
+ if (!smDown) return null;
42
38
 
43
39
  return (
44
- <>
45
- <Fade in={!smDesktop} {...switchProps}>
46
- <IconButton color="ink" onClick={openMenu} ref={ref} style={style}>
47
- <MenuRoundedIcon />
48
- </IconButton>
49
- </Fade>
40
+ <Fragment>
41
+ <IconButton color="ink" onClick={openMenu} ref={ref} style={style}>
42
+ <MenuRoundedIcon />
43
+ </IconButton>
50
44
  <MDialog
51
45
  disableScrollLock
52
46
  fullScreen
@@ -56,7 +50,7 @@ export const Menu = forwardRef<HTMLButtonElement, MenuProps>(
56
50
  open={open}
57
51
  PaperProps={{ elevation: 0 }}
58
52
  TransitionComponent={Fade}
59
- transitionDuration={smDesktop ? 0 : 600}
53
+ transitionDuration={smDown ? 600 : 0}
60
54
  TransitionProps={{ easing: "ease-out" }}
61
55
  >
62
56
  <AppBar component="div" elevation={0}>
@@ -67,14 +61,15 @@ export const Menu = forwardRef<HTMLButtonElement, MenuProps>(
67
61
  <Navigation
68
62
  closeAncestor={closeMenu}
69
63
  headerProps={headerProps}
70
- links={flattenNavigationLinks(navLinks)}
64
+ links={getMenuNavigationLinks(navigation, breakpoint)}
65
+ pathname={pathname}
71
66
  />
72
67
  {socialMedia && (
73
68
  <Socials buttonSize="xlarge" socials={socialMedia.socials} />
74
69
  )}
75
70
  </Content>
76
71
  </MDialog>
77
- </>
72
+ </Fragment>
78
73
  );
79
74
  }
80
75
  );
@@ -1,12 +1,7 @@
1
- import { Fade, IconButton } from "@mui/material";
1
+ import { IconButton } from "@mui/material";
2
2
  import React from "react";
3
- import {
4
- BREAKPOINT_FN_NAME,
5
- useBreakpointHelper,
6
- } from "../../../../../../../../../../../../hooks/useBreakpointHelper";
7
- import { DESKTOP_SM } from "../../../../../../../../../../../../theme/common/breakpoints";
3
+ import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
8
4
  import { SearchIcon } from "../../../../../../../../../../../common/CustomIcon/components/SearchIcon/searchIcon";
9
- import { SWITCH_TRANSITION_PROPS } from "../../../../../../../../common/constants";
10
5
  import { Button } from "./searchButton.styles";
11
6
 
12
7
  export interface SearchProps {
@@ -14,20 +9,14 @@ export interface SearchProps {
14
9
  }
15
10
 
16
11
  export const SearchButton = ({ openSearch }: SearchProps): JSX.Element => {
17
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
18
- const switchProps = SWITCH_TRANSITION_PROPS;
19
- return (
20
- <>
21
- <Fade in={smDesktop} {...switchProps}>
22
- <Button onClick={openSearch} startIcon={<SearchIcon />} variant="nav">
23
- Search
24
- </Button>
25
- </Fade>
26
- <Fade in={!smDesktop} {...switchProps}>
27
- <IconButton color="ink" onClick={openSearch}>
28
- <SearchIcon fontSize="medium" />
29
- </IconButton>
30
- </Fade>
31
- </>
12
+ const { mdUp } = useBreakpoint();
13
+ return mdUp ? (
14
+ <Button onClick={openSearch} startIcon={<SearchIcon />} variant="nav">
15
+ Search
16
+ </Button>
17
+ ) : (
18
+ <IconButton color="ink" onClick={openSearch}>
19
+ <SearchIcon fontSize="medium" />
20
+ </IconButton>
32
21
  );
33
22
  };
@@ -16,6 +16,7 @@ export interface NavigationDrawerProps {
16
16
  headerProps?: HeaderProps;
17
17
  menuItems: MenuItem[];
18
18
  menuLabel: ReactNode;
19
+ pathname?: string;
19
20
  }
20
21
 
21
22
  export const NavigationDrawer = ({
@@ -23,6 +24,7 @@ export const NavigationDrawer = ({
23
24
  headerProps,
24
25
  menuItems,
25
26
  menuLabel,
27
+ pathname,
26
28
  }: NavigationDrawerProps): JSX.Element => {
27
29
  const [drawerOpen, setDrawerOpen] = useState<boolean>(false);
28
30
  const openDrawer = (): void => {
@@ -71,6 +73,7 @@ export const NavigationDrawer = ({
71
73
  closeAncestor={closeDrawers}
72
74
  headerProps={headerProps}
73
75
  links={menuItems}
76
+ pathname={pathname}
74
77
  />
75
78
  </Content>
76
79
  </MDialog>
@@ -1,6 +1,11 @@
1
1
  import { css } from "@emotion/react";
2
2
  import styled from "@emotion/styled";
3
3
  import { Menu as MMenu } from "@mui/material";
4
+ import {
5
+ inkLight,
6
+ smokeLight,
7
+ smokeMain,
8
+ } from "../../../../../../../../../../styles/common/mixins/colors";
4
9
  import { Button as DXButton } from "../../../../../../../../../common/Button/button";
5
10
 
6
11
  interface Props {
@@ -9,7 +14,7 @@ interface Props {
9
14
 
10
15
  export const Menu = styled(MMenu)`
11
16
  .MuiPaper-menu {
12
- border-color: ${({ theme }) => theme.palette.smoke.main};
17
+ border-color: ${smokeMain};
13
18
  margin: 4px 0;
14
19
  max-width: 324px;
15
20
  min-width: 204px;
@@ -36,12 +41,17 @@ export const Menu = styled(MMenu)`
36
41
  }
37
42
 
38
43
  .MuiListItemText-secondary {
39
- color: ${({ theme }) => theme.palette.ink.light};
44
+ color: ${inkLight};
40
45
  white-space: normal;
41
46
  }
42
47
  }
48
+
49
+ &.Mui-selected {
50
+ background-color: ${smokeLight};
51
+ }
43
52
  }
44
53
 
54
+ .MuiButton-activeNav,
45
55
  .MuiButton-nav {
46
56
  font-weight: 400;
47
57
  justify-content: space-between;
@@ -63,9 +73,9 @@ export const Button = styled(DXButton, {
63
73
  shouldForwardProp: (prop) => prop !== "isActive",
64
74
  })<Props>`
65
75
  // Button is "active" i.e. menu is open.
66
- ${({ isActive, theme }) =>
67
- isActive &&
76
+ ${(props) =>
77
+ props.isActive &&
68
78
  css`
69
- background-color: ${theme.palette.smoke.light};
79
+ background-color: ${smokeLight(props)};
70
80
  `};
71
81
  `;
@@ -1,11 +1,7 @@
1
1
  import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded";
2
2
  import { MenuProps as MMenuProps } from "@mui/material";
3
3
  import React, { MouseEvent, ReactNode, useState } from "react";
4
- import {
5
- BREAKPOINT_FN_NAME,
6
- useBreakpointHelper,
7
- } from "../../../../../../../../../../hooks/useBreakpointHelper";
8
- import { DESKTOP_SM } from "../../../../../../../../../../theme/common/breakpoints";
4
+ import { useBreakpoint } from "../../../../../../../../../../hooks/useBreakpoint";
9
5
  import {
10
6
  MenuItem,
11
7
  NavigationMenuItems,
@@ -17,6 +13,7 @@ export interface NavLinkMenuProps {
17
13
  closeAncestor?: () => void;
18
14
  menuItems: MenuItem[];
19
15
  menuLabel: ReactNode;
16
+ pathname?: string;
20
17
  }
21
18
 
22
19
  export const NavigationMenu = ({
@@ -24,8 +21,9 @@ export const NavigationMenu = ({
24
21
  closeAncestor,
25
22
  menuItems,
26
23
  menuLabel,
24
+ pathname,
27
25
  }: NavLinkMenuProps): JSX.Element => {
28
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
26
+ const { mdUp } = useBreakpoint();
29
27
  const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
30
28
  const open = Boolean(anchorEl);
31
29
  const openMenu = (event: MouseEvent<HTMLButtonElement>): void => {
@@ -49,14 +47,18 @@ export const NavigationMenu = ({
49
47
  anchorEl={anchorEl}
50
48
  anchorOrigin={anchorOrigin}
51
49
  onClose={closeMenu}
52
- open={smDesktop && open}
50
+ open={mdUp && open}
53
51
  slotProps={{ paper: { variant: "menu" } }}
54
52
  transformOrigin={{
55
53
  horizontal: "left",
56
54
  vertical: "top",
57
55
  }}
58
56
  >
59
- <NavigationMenuItems closeMenu={closeMenu} menuItems={menuItems} />
57
+ <NavigationMenuItems
58
+ closeMenu={closeMenu}
59
+ menuItems={menuItems}
60
+ pathname={pathname}
61
+ />
60
62
  </Menu>
61
63
  </>
62
64
  );
@@ -24,11 +24,13 @@ export interface MenuItem extends NavLinkItem {
24
24
  export interface NavLinkMenuProps {
25
25
  closeMenu: () => void;
26
26
  menuItems: MenuItem[];
27
+ pathname?: string;
27
28
  }
28
29
 
29
30
  export const NavigationMenuItems = ({
30
31
  closeMenu,
31
32
  menuItems,
33
+ pathname,
32
34
  }: NavLinkMenuProps): JSX.Element => {
33
35
  const router = useRouter();
34
36
  return (
@@ -53,6 +55,7 @@ export const NavigationMenuItems = ({
53
55
  closeAncestor={closeMenu}
54
56
  menuItems={nestedMenuItems}
55
57
  menuLabel={label}
58
+ pathname={pathname}
56
59
  />
57
60
  ) : (
58
61
  <Fragment key={i}>
@@ -63,6 +66,7 @@ export const NavigationMenuItems = ({
63
66
  ? router.push(url)
64
67
  : window.open(url, target, "noopener noreferrer");
65
68
  }}
69
+ selected={url === pathname}
66
70
  >
67
71
  {icon && <ListItemIcon>{icon}</ListItemIcon>}
68
72
  <ListItemText
@@ -1,44 +1,20 @@
1
- import { css } from "@emotion/react";
2
1
  import styled from "@emotion/styled";
3
- import {
4
- ElementAlignment,
5
- ELEMENT_ALIGNMENT,
6
- } from "../../../../../../../../common/entities";
7
2
  import { mediaDesktopSmallUp } from "../../../../../../../../styles/common/mixins/breakpoints";
8
3
  import { textBody500 } from "../../../../../../../../styles/common/mixins/fonts";
9
4
 
10
- interface Props {
11
- alignment: ElementAlignment;
12
- }
13
-
14
- export const Navigation = styled("div")<Props>`
5
+ export const Navigation = styled("div")`
15
6
  display: flex;
16
7
  flex: 1;
17
8
  flex-direction: row;
18
9
  gap: 8px;
19
10
  justify-content: flex-start;
20
11
 
21
- // Left alignment.
22
- ${({ alignment }) =>
23
- alignment === ELEMENT_ALIGNMENT.LEFT &&
24
- css`
25
- margin-left: 24px;
26
- `};
27
-
28
- // Center alignment.
29
- ${({ alignment }) =>
30
- alignment === ELEMENT_ALIGNMENT.CENTER &&
31
- css`
32
- justify-content: center;
33
- `};
34
-
35
- // Right alignment.
36
- ${({ alignment }) =>
37
- alignment === ELEMENT_ALIGNMENT.RIGHT &&
38
- css`
39
- justify-content: flex-end;
40
- `};
12
+ ${mediaDesktopSmallUp} {
13
+ flex: unset;
14
+ justify-content: inherit;
15
+ }
41
16
 
17
+ .MuiButton-activeNav,
42
18
  .MuiButton-nav {
43
19
  ${textBody500};
44
20
  padding: 6px 12px;
@@ -1,15 +1,8 @@
1
1
  import { Button, Divider } from "@mui/material";
2
2
  import { useRouter } from "next/router";
3
3
  import React, { CSSProperties, forwardRef, Fragment, ReactNode } from "react";
4
- import {
5
- ElementAlignment,
6
- ELEMENT_ALIGNMENT,
7
- } from "../../../../../../../../common/entities";
8
- import {
9
- BREAKPOINT_FN_NAME,
10
- useBreakpointHelper,
11
- } from "../../../../../../../../hooks/useBreakpointHelper";
12
- import { DESKTOP_SM } from "../../../../../../../../theme/common/breakpoints";
4
+ import { useBreakpoint } from "../../../../../../../../hooks/useBreakpoint";
5
+ import { BreakpointKey } from "../../../../../../../../hooks/useBreakpointHelper";
13
6
  import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
14
7
  import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
15
8
  import { HeaderProps } from "../../../../header";
@@ -20,43 +13,39 @@ import { Navigation as Links } from "./navigation.styles";
20
13
 
21
14
  export interface NavLinkItem {
22
15
  divider?: boolean;
23
- flatten?: boolean;
16
+ flatten?: Partial<Record<BreakpointKey, boolean>>;
24
17
  label: ReactNode;
25
18
  menuItems?: MenuItem[];
26
19
  target?: ANCHOR_TARGET;
27
20
  url: string;
21
+ visible?: Partial<Record<BreakpointKey, boolean>>;
28
22
  }
29
23
 
30
24
  export interface NavigationProps {
31
- alignment?: ElementAlignment;
32
25
  className?: string;
33
26
  closeAncestor?: () => void;
34
27
  headerProps?: HeaderProps;
35
28
  links: NavLinkItem[];
29
+ pathname?: string;
36
30
  style?: CSSProperties; // Required for Fade component. See https://mui.com/material-ui/transitions/#child-requirement.
37
31
  }
38
32
 
39
33
  export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
40
34
  function Navigation(
41
35
  {
42
- alignment = ELEMENT_ALIGNMENT.LEFT,
43
36
  className,
44
37
  closeAncestor,
45
38
  headerProps,
46
39
  links,
40
+ pathname,
47
41
  style,
48
42
  }: NavigationProps,
49
43
  ref
50
44
  ): JSX.Element {
51
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
45
+ const { mdUp } = useBreakpoint();
52
46
  const router = useRouter();
53
47
  return (
54
- <Links
55
- ref={ref}
56
- alignment={alignment}
57
- className={className}
58
- style={style}
59
- >
48
+ <Links ref={ref} className={className} style={style}>
60
49
  {links.map(
61
50
  (
62
51
  { divider, label, menuItems, target = ANCHOR_TARGET.SELF, url },
@@ -64,11 +53,12 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
64
53
  ) =>
65
54
  menuItems ? (
66
55
  <Fragment key={i}>
67
- {smDesktop ? (
56
+ {mdUp ? (
68
57
  <NavigationMenu
69
58
  closeAncestor={closeAncestor}
70
59
  menuItems={menuItems}
71
60
  menuLabel={label}
61
+ pathname={pathname}
72
62
  />
73
63
  ) : (
74
64
  <NavigationDrawer
@@ -76,6 +66,7 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
76
66
  headerProps={headerProps}
77
67
  menuItems={menuItems}
78
68
  menuLabel={label}
69
+ pathname={pathname}
79
70
  />
80
71
  )}
81
72
  {divider && <Divider />}
@@ -89,7 +80,7 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
89
80
  : window.open(url, target, "noopener noreferrer");
90
81
  closeAncestor?.();
91
82
  }}
92
- variant="nav"
83
+ variant={url === pathname ? "activeNav" : "nav"}
93
84
  >
94
85
  {label}
95
86
  </Button>
@@ -1,23 +1,17 @@
1
1
  import { Meta, StoryObj } from "@storybook/react";
2
2
  import React from "react";
3
- import { ELEMENT_ALIGNMENT } from "../../../../common/entities";
4
3
  import logo from "../../../../images/logo.svg";
5
4
  import { DiscourseIcon } from "../../../common/CustomIcon/components/DiscourseIcon/discourseIcon";
6
5
  import { GitHubIcon } from "../../../common/CustomIcon/components/GitHubIcon/gitHubIcon";
7
6
  import { XIcon } from "../../../common/CustomIcon/components/XIcon/xIcon";
8
7
  import { YouTubeIcon } from "../../../common/CustomIcon/components/YouTubeIcon/youTubeIcon";
9
- import { HEADER_NAVIGATION_LABEL } from "./common/constants";
10
8
  import { Logo } from "./components/Content/components/Logo/logo";
11
9
  import { Header } from "./header";
12
10
 
13
11
  export default {
14
12
  argTypes: {
15
- Logo: { control: { disable: true } },
16
13
  authenticationEnabled: { control: "boolean" },
17
- navAlignment: {
18
- control: "select",
19
- options: [ELEMENT_ALIGNMENT.LEFT, ELEMENT_ALIGNMENT.CENTER],
20
- },
14
+ logo: { control: { disable: true } },
21
15
  navLinks: { control: "array" },
22
16
  searchEnabled: { control: "boolean" },
23
17
  slogan: { control: "text" },
@@ -36,45 +30,48 @@ const url = "/";
36
30
 
37
31
  export const HeaderStory: Story = {
38
32
  args: {
39
- Logo: <Logo alt="Logo" height={40} link="/" src={logo} />,
40
33
  authenticationEnabled: false,
41
- navAlignment: ELEMENT_ALIGNMENT.CENTER,
42
- navLinks: [
43
- {
44
- label: "Overview",
45
- url,
46
- },
47
- {
48
- label: "Learn",
49
- url,
50
- },
51
- {
52
- label: "Datasets",
53
- url,
54
- },
55
- {
56
- label: "More",
57
- menuItems: [
58
- {
59
- label: "Team",
60
- url,
61
- },
62
- {
63
- label: "FAQ",
64
- url,
65
- },
66
- {
67
- label: "Help",
68
- url,
69
- },
70
- ],
71
- url: "",
72
- },
34
+ logo: <Logo alt="Logo" height={40} link="/" src={logo} />,
35
+ navigation: [
36
+ undefined,
37
+ [
38
+ {
39
+ label: "Overview",
40
+ url,
41
+ },
42
+ {
43
+ label: "Learn",
44
+ url,
45
+ },
46
+ {
47
+ label: "Datasets",
48
+ url,
49
+ },
50
+ {
51
+ label: "More",
52
+ menuItems: [
53
+ {
54
+ label: "Team",
55
+ url,
56
+ },
57
+ {
58
+ label: "FAQ",
59
+ url,
60
+ },
61
+ {
62
+ label: "Help",
63
+ url,
64
+ },
65
+ ],
66
+ url: "",
67
+ },
68
+ ],
69
+ undefined,
73
70
  ],
74
71
  searchEnabled: true,
75
72
  slogan: "Header Slogan",
76
73
  socialMedia: {
77
- label: HEADER_NAVIGATION_LABEL.SOCIALS,
74
+ label: "Follow Us",
78
75
  socials: [
79
76
  {
80
77
  Icon: XIcon,
@@ -1,3 +1,4 @@
1
+ import { css } from "@emotion/react";
1
2
  import styled from "@emotion/styled";
2
3
  import { AppBar as MAppBar } from "@mui/material";
3
4
  import { HEADER_HEIGHT } from "./common/constants";
@@ -16,8 +17,30 @@ export const AppBar = styled(MAppBar)`
16
17
  }
17
18
  ` as typeof MAppBar;
18
19
 
19
- export const HeaderSmAppBar = styled(AppBar)`
20
- .MuiToolbar-root {
21
- gap: 8px;
20
+ const group = css`
21
+ align-items: center;
22
+ display: flex;
23
+ flex: 1;
24
+ `;
25
+
26
+ export const Left = styled.div`
27
+ ${group};
28
+ gap: 16px;
29
+ justify-content: flex-start;
30
+
31
+ .MuiButton-navPrimary {
32
+ &:first-of-type {
33
+ margin-left: 24px;
34
+ }
22
35
  }
23
- ` as typeof MAppBar;
36
+ `;
37
+
38
+ export const Center = styled.div`
39
+ ${group};
40
+ justify-content: center;
41
+ `;
42
+
43
+ export const Right = styled.div`
44
+ ${group};
45
+ justify-content: flex-end;
46
+ `;