@databiosphere/findable-ui 7.0.0 → 8.0.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.
Files changed (72) hide show
  1. package/lib/common/entities.d.ts +0 -9
  2. package/lib/common/entities.js +1 -9
  3. package/lib/components/Index/components/Tabs/common/utils.d.ts +8 -0
  4. package/lib/components/Index/components/Tabs/common/utils.js +18 -0
  5. package/lib/components/Index/components/Tabs/tabs.d.ts +2 -0
  6. package/lib/components/Index/components/Tabs/tabs.js +20 -0
  7. package/lib/components/Layout/components/Header/common/constants.d.ts +4 -9
  8. package/lib/components/Layout/components/Header/common/constants.js +8 -9
  9. package/lib/components/Layout/components/Header/common/entities.d.ts +6 -0
  10. package/lib/components/Layout/components/Header/common/utils.d.ts +12 -17
  11. package/lib/components/Layout/components/Header/common/utils.js +77 -59
  12. package/lib/components/Layout/components/Header/components/Announcements/announcements.d.ts +6 -0
  13. package/lib/components/Layout/components/Header/components/Announcements/announcements.js +7 -0
  14. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.d.ts +1 -2
  15. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.js +2 -2
  16. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +8 -15
  17. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.d.ts +4 -3
  18. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +4 -3
  19. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.js +17 -19
  20. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +5 -12
  21. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.js +3 -4
  22. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.d.ts +3 -3
  23. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +5 -7
  24. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.d.ts +1 -6
  25. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.js +4 -19
  26. package/lib/components/Layout/components/Header/header.d.ts +5 -7
  27. package/lib/components/Layout/components/Header/header.js +35 -59
  28. package/lib/components/Layout/components/Header/header.stories.js +38 -41
  29. package/lib/components/Layout/components/Header/header.styles.d.ts +13 -1
  30. package/lib/components/Layout/components/Header/header.styles.js +23 -3
  31. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.d.ts +20 -0
  32. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.js +46 -0
  33. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
  34. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
  35. package/lib/config/entities.d.ts +2 -0
  36. package/lib/config/utils.js +1 -2
  37. package/lib/hooks/useBreakpoint.d.ts +17 -0
  38. package/lib/hooks/useBreakpoint.js +34 -0
  39. package/lib/hooks/useBreakpointHelper.d.ts +1 -1
  40. package/lib/hooks/useCurrentBreakpoint.d.ts +3 -0
  41. package/lib/hooks/useCurrentBreakpoint.js +11 -0
  42. package/lib/hooks/useMenu.d.ts +10 -0
  43. package/lib/hooks/useMenu.js +17 -0
  44. package/lib/views/ExploreView/exploreView.js +4 -29
  45. package/package.json +1 -1
  46. package/src/common/entities.ts +0 -11
  47. package/src/components/Index/components/Tabs/common/utils.ts +33 -0
  48. package/src/components/Index/components/Tabs/tabs.tsx +23 -0
  49. package/src/components/Layout/components/Header/common/constants.ts +14 -10
  50. package/src/components/Layout/components/Header/common/entities.ts +7 -0
  51. package/src/components/Layout/components/Header/common/utils.ts +89 -66
  52. package/src/components/Layout/components/Header/components/Announcements/announcements.tsx +14 -0
  53. package/src/components/Layout/components/Header/components/Content/components/Actions/actions.tsx +2 -6
  54. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.tsx +21 -32
  55. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +8 -6
  56. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.tsx +19 -26
  57. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx +11 -22
  58. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.tsx +3 -7
  59. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.ts +5 -30
  60. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +8 -27
  61. package/src/components/Layout/components/Header/header.stories.tsx +38 -41
  62. package/src/components/Layout/components/Header/header.styles.ts +27 -4
  63. package/src/components/Layout/components/Header/header.tsx +99 -137
  64. package/src/components/Layout/components/Header/hooks/useHeaderVisibility.ts +74 -0
  65. package/src/components/Layout/components/Header/hooks/useMeasureHeader.ts +28 -0
  66. package/src/config/entities.ts +2 -0
  67. package/src/config/utils.ts +1 -2
  68. package/src/hooks/useBreakpoint.ts +54 -0
  69. package/src/hooks/useBreakpointHelper.ts +1 -1
  70. package/src/hooks/useCurrentBreakpoint.ts +23 -0
  71. package/src/hooks/useMenu.ts +27 -0
  72. package/src/views/ExploreView/exploreView.tsx +5 -34
@@ -17,17 +17,6 @@ export interface CategoryTag {
17
17
  */
18
18
  export type CategoryValueKey = string;
19
19
 
20
- /**
21
- * Element alignment.
22
- */
23
- export enum ELEMENT_ALIGNMENT {
24
- CENTER = "CENTER",
25
- LEFT = "LEFT",
26
- RIGHT = "RIGHT",
27
- }
28
-
29
- export type ElementAlignment = ELEMENT_ALIGNMENT;
30
-
31
20
  /**
32
21
  * Set of selected category values.
33
22
  */
@@ -0,0 +1,33 @@
1
+ import { EntityConfig } from "../../../../../config/entities";
2
+ import { Tab } from "../../../../common/Tabs/tabs";
3
+
4
+ /**
5
+ * Returns entity list tabs list for the tabs component.
6
+ * @param entities - Entities config.
7
+ * @returns tabs list.
8
+ */
9
+ export function getEntityListTabs(entities: EntityConfig[]): Tab[] {
10
+ return entities.reduce(
11
+ (
12
+ acc: Tab[],
13
+ {
14
+ label,
15
+ listView: { enableTab = true } = {},
16
+ route,
17
+ tabIcon: icon,
18
+ tabIconPosition: iconPosition,
19
+ }
20
+ ) => {
21
+ if (enableTab) {
22
+ acc.push({
23
+ icon,
24
+ iconPosition,
25
+ label,
26
+ value: route,
27
+ });
28
+ }
29
+ return acc;
30
+ },
31
+ []
32
+ );
33
+ }
@@ -0,0 +1,23 @@
1
+ import Router from "next/router";
2
+ import React, { useCallback, useMemo } from "react";
3
+ import { useConfig } from "../../../../hooks/useConfig";
4
+ import { useExploreState } from "../../../../hooks/useExploreState";
5
+ import { Tabs as DXTabs, TabValue } from "../../../common/Tabs/tabs";
6
+ import { getEntityListTabs } from "./common/utils";
7
+
8
+ export const Tabs = (): JSX.Element | null => {
9
+ const { config } = useConfig();
10
+ const { exploreState } = useExploreState();
11
+ const { entities } = config;
12
+ const { tabValue } = exploreState;
13
+ const tabs = useMemo(() => getEntityListTabs(entities), [entities]);
14
+
15
+ // Callback fired when selected tab value changes.
16
+ const onTabChange = useCallback(async (tabValue: TabValue): Promise<void> => {
17
+ await Router.push(`/${tabValue}`);
18
+ }, []);
19
+
20
+ if (tabs.length <= 1) return null;
21
+
22
+ return <DXTabs onTabChange={onTabChange} tabs={tabs} value={tabValue} />;
23
+ };
@@ -1,17 +1,21 @@
1
- export const HEADER_HEIGHT = 56;
2
- export const HEADER_FADE_TIMEOUT = 0;
1
+ import {
2
+ AppBarProps as MAppBarProps,
3
+ ToolbarProps as MToolbarProps,
4
+ } from "@mui/material";
3
5
 
4
- export const FADE_TRANSITION_PROPS = {
5
- timeout: HEADER_FADE_TIMEOUT,
6
- unmountOnExit: true,
7
- };
6
+ export const HEADER_HEIGHT = 56;
8
7
 
9
- export const HEADER_NAVIGATION_LABEL = {
10
- MORE: "More",
11
- SOCIALS: "Follow Us",
8
+ export const APP_BAR_PROPS: Partial<MAppBarProps> = {
9
+ elevation: 1,
10
+ position: "fixed",
12
11
  };
13
12
 
14
- export const SWITCH_TRANSITION_PROPS = {
13
+ export const FADE_TRANSITION_PROPS = {
14
+ appear: false,
15
15
  timeout: 0,
16
16
  unmountOnExit: true,
17
17
  };
18
+
19
+ export const TOOLBAR_PROPS: Partial<MToolbarProps> = {
20
+ variant: "dense",
21
+ };
@@ -1,5 +1,12 @@
1
1
  import { ReactNode } from "react";
2
2
  import { Social } from "../../../../common/Socials/socials";
3
+ import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
4
+
5
+ export type Navigation = [
6
+ NavLinkItem[] | undefined,
7
+ NavLinkItem[] | undefined,
8
+ NavLinkItem[] | undefined
9
+ ]; // [LEFT, CENTER, RIGHT]
3
10
 
4
11
  export interface SocialMedia {
5
12
  label: ReactNode;
@@ -1,84 +1,107 @@
1
- import { Social } from "../../../../common/Socials/socials";
2
- import { RenderComponent } from "../../../../ComponentCreator/components/RenderComponent/renderComponent";
3
- import { ANCHOR_TARGET } from "../../../../Links/common/entities";
4
- import { MenuItem } from "../components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems";
1
+ import { Breakpoint } from "@mui/material";
5
2
  import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
6
- import { HEADER_NAVIGATION_LABEL } from "./constants";
7
- import { SocialMedia } from "./entities";
3
+ import { Navigation } from "./entities";
8
4
 
9
5
  /**
10
- * Returns the navigation links as configured, where the "More" menu is flattened.
11
- * @param links - Header navigation links.
12
- * @returns header navigation links, without links grouped under the "More" menu.
6
+ * Returns the configured menu navigation links, for the current breakpoint.
7
+ * @param navigation - Navigation links.
8
+ * @param breakpoint - Current breakpoint.
9
+ * @returns navigation links.
13
10
  */
14
- export function flattenMoreLink(links: NavLinkItem[]): NavLinkItem[] {
15
- return links.flatMap((link: NavLinkItem) => {
16
- if (link.label === HEADER_NAVIGATION_LABEL.MORE) {
17
- if (link.flatten === false) {
18
- return link;
11
+ export function getMenuNavigationLinks(
12
+ navigation?: Navigation,
13
+ breakpoint?: Breakpoint
14
+ ): NavLinkItem[] {
15
+ if (!navigation) return [];
16
+ const navLinkItems = navigation.reduce((acc: NavLinkItem[], navLinkItems) => {
17
+ if (!navLinkItems) return acc;
18
+ acc.push(...navLinkItems);
19
+ return acc;
20
+ }, []);
21
+ return getNavigationLinks(navLinkItems, breakpoint);
22
+ }
23
+
24
+ /**
25
+ * Returns configured navigation links, for the current breakpoint.
26
+ * @param navigationLinks - Navigation links.
27
+ * @param breakpoint - Current breakpoint.
28
+ * @returns navigation links.
29
+ */
30
+ export function getNavigationLinks(
31
+ navigationLinks?: NavLinkItem[],
32
+ breakpoint?: Breakpoint
33
+ ): NavLinkItem[] {
34
+ if (!navigationLinks) return [];
35
+ return navigationLinks.reduce(
36
+ (acc: NavLinkItem[], navLinkItem: NavLinkItem) => {
37
+ const processedNavLink = processNavLinkItem(navLinkItem, breakpoint);
38
+ if (processedNavLink) {
39
+ acc.push(...processedNavLink);
19
40
  }
20
- return link.menuItems as NavLinkItem[];
21
- }
22
- return link;
23
- });
41
+ return acc;
42
+ },
43
+ []
44
+ );
24
45
  }
25
46
 
26
47
  /**
27
- * Returns the navigation links as configured, all menu links specified as "flatten" are flattened, including the "More" menu.
28
- * @param links - Header navigation links.
29
- * @returns header navigation links.
48
+ * Returns true if the link is flattened at the current breakpoint.
49
+ * @param navLinkItem - Navigation link.
50
+ * @param breakpoint - Current breakpoint.
51
+ * @returns true if the link is flattened.
30
52
  */
31
- export function flattenNavigationLinks(links: NavLinkItem[]): NavLinkItem[] {
32
- return links.flatMap((link: NavLinkItem) => {
33
- if (link.flatten || link.label === HEADER_NAVIGATION_LABEL.MORE) {
34
- return link.menuItems as NavLinkItem[];
35
- }
36
- return link;
37
- });
53
+ function isLinkFlattened(
54
+ navLinkItem: NavLinkItem,
55
+ breakpoint?: Breakpoint
56
+ ): boolean {
57
+ if (!breakpoint) return false; // Default is not flattened.
58
+ if (!navLinkItem.flatten) return false; // Default is not flattened.
59
+ return navLinkItem.flatten[breakpoint] === true;
38
60
  }
39
61
 
40
62
  /**
41
- * Returns header navigation links with socials appended with the corresponding label "Follow Us".
42
- * @param links - Header navigation links.
43
- * @param socialMedia - Header social media.
44
- * @param onlySmDesktop - Media breakpoint query is "true" for small desktop only.
45
- * @returns header navigation links.
63
+ * Returns true if the link is visible at the current breakpoint.
64
+ * @param navLinkItem - Navigation link.
65
+ * @param breakpoint - Current breakpoint.
66
+ * @returns true if the link is visible.
46
67
  */
47
- export function getHeaderNavigationLinks(
48
- links: NavLinkItem[],
49
- socialMedia: SocialMedia | undefined,
50
- onlySmDesktop: boolean
51
- ): NavLinkItem[] {
52
- if (onlySmDesktop) {
53
- const navLinks = [...links];
54
- if (socialMedia) {
55
- navLinks.push({
56
- label: socialMedia.label,
57
- menuItems: getFollowUsMenuItems(socialMedia.socials),
58
- url: "",
59
- });
60
- }
61
- return navLinks;
62
- }
63
- // Return the links without the "More" or "Follow Us" menu.
64
- return flattenMoreLink(links);
68
+ function isLinkVisible(
69
+ navLinkItem: NavLinkItem,
70
+ breakpoint?: Breakpoint
71
+ ): boolean {
72
+ if (!breakpoint) return true; // Default is visible.
73
+ if (!navLinkItem.visible) return true; // Default is visible.
74
+ return navLinkItem.visible[breakpoint] !== false;
65
75
  }
66
76
 
67
77
  /**
68
- * Returns menu items for the "Follow Us" menu.
69
- * @param socials - Social configuration.
70
- * @returns a list of social menu items for the "Follow Us" menu.
78
+ * Returns the processed navigation link item.
79
+ * Flattens menu items, and removes items that are not visible for the current breakpoint.
80
+ * @param navLinkItem - Navigation link.
81
+ * @param breakpoint - Current breakpoint.
82
+ * @returns processed navigation link item.
71
83
  */
72
- function getFollowUsMenuItems(socials: Social[]): MenuItem[] {
73
- return socials.map(({ Icon, label, url }) => {
74
- return {
75
- icon: RenderComponent({
76
- Component: Icon,
77
- ...{ fontSize: "small" },
78
- }),
79
- label,
80
- target: ANCHOR_TARGET.BLANK,
81
- url,
82
- };
83
- });
84
+ function processNavLinkItem(
85
+ navLinkItem: NavLinkItem,
86
+ breakpoint?: Breakpoint
87
+ ): NavLinkItem[] | undefined {
88
+ if (isLinkVisible(navLinkItem, breakpoint)) {
89
+ const cloneLink = { ...navLinkItem };
90
+ // Recursively process menu items.
91
+ if (cloneLink.menuItems) {
92
+ const menuItems = getNavigationLinks(navLinkItem.menuItems, breakpoint);
93
+ // Remove menu items if empty.
94
+ if (menuItems.length === 0) {
95
+ delete cloneLink.menuItems;
96
+ } else {
97
+ // Flatten the menu items if the navigation is flattened.
98
+ if (isLinkFlattened(cloneLink, breakpoint)) {
99
+ return menuItems;
100
+ } else {
101
+ cloneLink.menuItems = menuItems;
102
+ }
103
+ }
104
+ }
105
+ return [cloneLink];
106
+ }
84
107
  }
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { ComponentsConfig } from "../../../../../../config/entities";
3
+ import { ComponentCreator } from "../../../../../ComponentCreator/ComponentCreator";
4
+
5
+ export interface AnnouncementsProps {
6
+ announcements?: ComponentsConfig;
7
+ }
8
+
9
+ export const Announcements = ({
10
+ announcements,
11
+ }: AnnouncementsProps): JSX.Element | null => {
12
+ if (!announcements) return null;
13
+ return <ComponentCreator components={announcements} response={{}} />;
14
+ };
@@ -3,12 +3,8 @@ import { HeaderActions } from "./actions.styles";
3
3
 
4
4
  export interface ActionsProps {
5
5
  children: ReactNode | ReactNode[];
6
- showActions?: boolean;
7
6
  }
8
7
 
9
- export const Actions = ({
10
- children,
11
- showActions = true,
12
- }: ActionsProps): JSX.Element => {
13
- return <>{showActions && <HeaderActions>{children}</HeaderActions>}</>;
8
+ export const Actions = ({ children }: ActionsProps): JSX.Element => {
9
+ return <HeaderActions>{children}</HeaderActions>;
14
10
  };
@@ -1,12 +1,7 @@
1
1
  import LoginRoundedIcon from "@mui/icons-material/LoginRounded";
2
- import { Fade, IconButton } from "@mui/material";
2
+ import { IconButton as MIconButton } from "@mui/material";
3
3
  import React 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";
4
+ import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
10
5
  import { Button } from "./requestAuthentication.styles";
11
6
 
12
7
  export interface RequestAuthenticationProps {
@@ -18,30 +13,24 @@ export const RequestAuthentication = ({
18
13
  closeMenu,
19
14
  requestAuthorization,
20
15
  }: RequestAuthenticationProps): JSX.Element => {
21
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
22
- const switchProps = SWITCH_TRANSITION_PROPS;
23
- return (
24
- <>
25
- <Fade in={smDesktop} {...switchProps}>
26
- <Button
27
- onClick={requestAuthorization}
28
- startIcon={<LoginRoundedIcon />}
29
- variant="nav"
30
- >
31
- Sign in
32
- </Button>
33
- </Fade>
34
- <Fade in={!smDesktop} {...switchProps}>
35
- <IconButton
36
- color="ink"
37
- onClick={(): void => {
38
- closeMenu();
39
- requestAuthorization();
40
- }}
41
- >
42
- <LoginRoundedIcon />
43
- </IconButton>
44
- </Fade>
45
- </>
16
+ const { mdUp } = useBreakpoint();
17
+ return mdUp ? (
18
+ <Button
19
+ onClick={requestAuthorization}
20
+ startIcon={<LoginRoundedIcon />}
21
+ variant="nav"
22
+ >
23
+ Sign in
24
+ </Button>
25
+ ) : (
26
+ <MIconButton
27
+ color="ink"
28
+ onClick={(): void => {
29
+ closeMenu();
30
+ requestAuthorization();
31
+ }}
32
+ >
33
+ <LoginRoundedIcon />
34
+ </MIconButton>
46
35
  );
47
36
  };
@@ -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";
@@ -28,25 +23,23 @@ export const Menu = forwardRef<HTMLButtonElement, MenuProps>(
28
23
  function HeaderMenu(
29
24
  { closeMenu, headerProps, open, openMenu, style }: MenuProps,
30
25
  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;
26
+ ): JSX.Element | null {
27
+ const { navigation, slogan, socialMedia } = headerProps;
28
+ const { breakpoint, smDown } = useBreakpoint();
35
29
 
36
- // Set drawer open state to false on change of media breakpoint from mobile to "small desktop".
30
+ // Set drawer open state to false on change of media breakpoint from small desktop "md" and up.
37
31
  useEffect(() => {
38
- if (smDesktop) {
39
- closeMenu();
40
- }
41
- }, [closeMenu, smDesktop]);
32
+ if (smDown) return;
33
+ closeMenu();
34
+ }, [closeMenu, smDown]);
35
+
36
+ if (!smDown) return null;
42
37
 
43
38
  return (
44
- <>
45
- <Fade in={!smDesktop} {...switchProps}>
46
- <IconButton color="ink" onClick={openMenu} ref={ref} style={style}>
47
- <MenuRoundedIcon />
48
- </IconButton>
49
- </Fade>
39
+ <Fragment>
40
+ <IconButton color="ink" onClick={openMenu} ref={ref} style={style}>
41
+ <MenuRoundedIcon />
42
+ </IconButton>
50
43
  <MDialog
51
44
  disableScrollLock
52
45
  fullScreen
@@ -56,7 +49,7 @@ export const Menu = forwardRef<HTMLButtonElement, MenuProps>(
56
49
  open={open}
57
50
  PaperProps={{ elevation: 0 }}
58
51
  TransitionComponent={Fade}
59
- transitionDuration={smDesktop ? 0 : 600}
52
+ transitionDuration={smDown ? 600 : 0}
60
53
  TransitionProps={{ easing: "ease-out" }}
61
54
  >
62
55
  <AppBar component="div" elevation={0}>
@@ -67,14 +60,14 @@ export const Menu = forwardRef<HTMLButtonElement, MenuProps>(
67
60
  <Navigation
68
61
  closeAncestor={closeMenu}
69
62
  headerProps={headerProps}
70
- links={flattenNavigationLinks(navLinks)}
63
+ links={getMenuNavigationLinks(navigation, breakpoint)}
71
64
  />
72
65
  {socialMedia && (
73
66
  <Socials buttonSize="xlarge" socials={socialMedia.socials} />
74
67
  )}
75
68
  </Content>
76
69
  </MDialog>
77
- </>
70
+ </Fragment>
78
71
  );
79
72
  }
80
73
  );
@@ -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
  };
@@ -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,
@@ -25,7 +21,7 @@ export const NavigationMenu = ({
25
21
  menuItems,
26
22
  menuLabel,
27
23
  }: NavLinkMenuProps): JSX.Element => {
28
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
24
+ const { mdUp } = useBreakpoint();
29
25
  const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
30
26
  const open = Boolean(anchorEl);
31
27
  const openMenu = (event: MouseEvent<HTMLButtonElement>): void => {
@@ -49,7 +45,7 @@ export const NavigationMenu = ({
49
45
  anchorEl={anchorEl}
50
46
  anchorOrigin={anchorOrigin}
51
47
  onClose={closeMenu}
52
- open={smDesktop && open}
48
+ open={mdUp && open}
53
49
  slotProps={{ paper: { variant: "menu" } }}
54
50
  transformOrigin={{
55
51
  horizontal: "left",
@@ -1,43 +1,18 @@
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
 
42
17
  .MuiButton-nav {
43
18
  ${textBody500};