@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.
- package/lib/common/entities.d.ts +0 -9
- package/lib/common/entities.js +1 -9
- package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
- package/lib/components/Index/components/Tabs/common/utils.d.ts +8 -0
- package/lib/components/Index/components/Tabs/common/utils.js +18 -0
- package/lib/components/Index/components/Tabs/tabs.d.ts +2 -0
- package/lib/components/Index/components/Tabs/tabs.js +20 -0
- package/lib/components/Layout/components/Header/common/constants.d.ts +4 -9
- package/lib/components/Layout/components/Header/common/constants.js +8 -9
- package/lib/components/Layout/components/Header/common/entities.d.ts +6 -0
- package/lib/components/Layout/components/Header/common/utils.d.ts +12 -17
- package/lib/components/Layout/components/Header/common/utils.js +77 -59
- package/lib/components/Layout/components/Header/components/Announcements/announcements.d.ts +6 -0
- package/lib/components/Layout/components/Header/components/Announcements/announcements.js +7 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.d.ts +1 -2
- package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.js +2 -2
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +8 -15
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Content/components/Navigation/navigation.styles.js +2 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.d.ts +4 -3
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +4 -3
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.d.ts +1 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.js +18 -20
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +5 -12
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.d.ts +2 -1
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.js +2 -2
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.d.ts +2 -1
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.js +5 -6
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.js +10 -4
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.d.ts +2 -1
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.js +3 -3
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.d.ts +4 -3
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +6 -8
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.d.ts +1 -6
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.js +5 -19
- package/lib/components/Layout/components/Header/header.d.ts +5 -7
- package/lib/components/Layout/components/Header/header.js +38 -59
- package/lib/components/Layout/components/Header/header.stories.js +38 -41
- package/lib/components/Layout/components/Header/header.styles.d.ts +13 -1
- package/lib/components/Layout/components/Header/header.styles.js +23 -3
- package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.d.ts +20 -0
- package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.js +46 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
- package/lib/config/entities.d.ts +2 -0
- package/lib/config/utils.js +1 -2
- package/lib/hooks/useBreakpoint.d.ts +17 -0
- package/lib/hooks/useBreakpoint.js +34 -0
- package/lib/hooks/useBreakpointHelper.d.ts +1 -1
- package/lib/hooks/useCurrentBreakpoint.d.ts +3 -0
- package/lib/hooks/useCurrentBreakpoint.js +11 -0
- package/lib/hooks/useMenu.d.ts +10 -0
- package/lib/hooks/useMenu.js +17 -0
- package/lib/theme/common/components.js +17 -0
- package/lib/views/ExploreView/exploreView.js +4 -29
- package/package.json +1 -1
- package/src/common/entities.ts +0 -11
- package/src/components/Index/components/Tabs/common/utils.ts +33 -0
- package/src/components/Index/components/Tabs/tabs.tsx +23 -0
- package/src/components/Layout/components/Header/common/constants.ts +14 -10
- package/src/components/Layout/components/Header/common/entities.ts +7 -0
- package/src/components/Layout/components/Header/common/utils.ts +89 -66
- package/src/components/Layout/components/Header/components/Announcements/announcements.tsx +14 -0
- package/src/components/Layout/components/Header/components/Content/components/Actions/actions.tsx +2 -6
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.tsx +21 -32
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Content/components/Navigation/navigation.styles.ts +2 -0
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +8 -6
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.tsx +22 -27
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx +11 -22
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.tsx +3 -0
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.ts +15 -5
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.tsx +10 -8
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.tsx +4 -0
- package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.ts +6 -30
- package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +12 -21
- package/src/components/Layout/components/Header/header.stories.tsx +38 -41
- package/src/components/Layout/components/Header/header.styles.ts +27 -4
- package/src/components/Layout/components/Header/header.tsx +102 -137
- package/src/components/Layout/components/Header/hooks/useHeaderVisibility.ts +74 -0
- package/src/components/Layout/components/Header/hooks/useMeasureHeader.ts +28 -0
- package/src/config/entities.ts +2 -0
- package/src/config/utils.ts +1 -2
- package/src/hooks/useBreakpoint.ts +54 -0
- package/src/hooks/useBreakpointHelper.ts +1 -1
- package/src/hooks/useCurrentBreakpoint.ts +23 -0
- package/src/hooks/useMenu.ts +27 -0
- package/src/theme/common/components.ts +17 -0
- package/src/views/ExploreView/exploreView.tsx +5 -34
- package/types/data-explorer-ui.d.ts +1 -0
package/lib/common/entities.d.ts
CHANGED
|
@@ -14,15 +14,6 @@ export interface CategoryTag {
|
|
|
14
14
|
* Category values to be used as keys. For example, "Homo sapiens" or "10X 3' v2 sequencing".
|
|
15
15
|
*/
|
|
16
16
|
export declare type CategoryValueKey = string;
|
|
17
|
-
/**
|
|
18
|
-
* Element alignment.
|
|
19
|
-
*/
|
|
20
|
-
export declare enum ELEMENT_ALIGNMENT {
|
|
21
|
-
CENTER = "CENTER",
|
|
22
|
-
LEFT = "LEFT",
|
|
23
|
-
RIGHT = "RIGHT"
|
|
24
|
-
}
|
|
25
|
-
export declare type ElementAlignment = ELEMENT_ALIGNMENT;
|
|
26
17
|
/**
|
|
27
18
|
* Set of selected category values.
|
|
28
19
|
*/
|
package/lib/common/entities.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Element alignment.
|
|
3
|
-
*/
|
|
4
|
-
export var ELEMENT_ALIGNMENT;
|
|
5
|
-
(function (ELEMENT_ALIGNMENT) {
|
|
6
|
-
ELEMENT_ALIGNMENT["CENTER"] = "CENTER";
|
|
7
|
-
ELEMENT_ALIGNMENT["LEFT"] = "LEFT";
|
|
8
|
-
ELEMENT_ALIGNMENT["RIGHT"] = "RIGHT";
|
|
9
|
-
})(ELEMENT_ALIGNMENT || (ELEMENT_ALIGNMENT = {}));
|
|
1
|
+
export {};
|
|
@@ -12,7 +12,7 @@ export declare const FilterLabel: import("@emotion/styled").StyledComponent<{
|
|
|
12
12
|
size?: "large" | "medium" | "small" | undefined;
|
|
13
13
|
startIcon?: import("react").ReactNode;
|
|
14
14
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
-
variant?: "nav" | "text" | "outlined" | "contained" | undefined;
|
|
15
|
+
variant?: "nav" | "text" | "outlined" | "contained" | "activeNav" | undefined;
|
|
16
16
|
} & Omit<{
|
|
17
17
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
18
18
|
centerRipple?: boolean | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EntityConfig } from "../../../../../config/entities";
|
|
2
|
+
import { Tab } from "../../../../common/Tabs/tabs";
|
|
3
|
+
/**
|
|
4
|
+
* Returns entity list tabs list for the tabs component.
|
|
5
|
+
* @param entities - Entities config.
|
|
6
|
+
* @returns tabs list.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getEntityListTabs(entities: EntityConfig[]): Tab[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns entity list tabs list for the tabs component.
|
|
3
|
+
* @param entities - Entities config.
|
|
4
|
+
* @returns tabs list.
|
|
5
|
+
*/
|
|
6
|
+
export function getEntityListTabs(entities) {
|
|
7
|
+
return entities.reduce((acc, { label, listView: { enableTab = true } = {}, route, tabIcon: icon, tabIconPosition: iconPosition, }) => {
|
|
8
|
+
if (enableTab) {
|
|
9
|
+
acc.push({
|
|
10
|
+
icon,
|
|
11
|
+
iconPosition,
|
|
12
|
+
label,
|
|
13
|
+
value: route,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return acc;
|
|
17
|
+
}, []);
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 } from "../../../common/Tabs/tabs";
|
|
6
|
+
import { getEntityListTabs } from "./common/utils";
|
|
7
|
+
export const Tabs = () => {
|
|
8
|
+
const { config } = useConfig();
|
|
9
|
+
const { exploreState } = useExploreState();
|
|
10
|
+
const { entities } = config;
|
|
11
|
+
const { tabValue } = exploreState;
|
|
12
|
+
const tabs = useMemo(() => getEntityListTabs(entities), [entities]);
|
|
13
|
+
// Callback fired when selected tab value changes.
|
|
14
|
+
const onTabChange = useCallback(async (tabValue) => {
|
|
15
|
+
await Router.push(`/${tabValue}`);
|
|
16
|
+
}, []);
|
|
17
|
+
if (tabs.length <= 1)
|
|
18
|
+
return null;
|
|
19
|
+
return React.createElement(DXTabs, { onTabChange: onTabChange, tabs: tabs, value: tabValue });
|
|
20
|
+
};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
+
import { AppBarProps as MAppBarProps, ToolbarProps as MToolbarProps } from "@mui/material";
|
|
1
2
|
export declare const HEADER_HEIGHT = 56;
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const APP_BAR_PROPS: Partial<MAppBarProps>;
|
|
3
4
|
export declare const FADE_TRANSITION_PROPS: {
|
|
5
|
+
appear: boolean;
|
|
4
6
|
timeout: number;
|
|
5
7
|
unmountOnExit: boolean;
|
|
6
8
|
};
|
|
7
|
-
export declare const
|
|
8
|
-
MORE: string;
|
|
9
|
-
SOCIALS: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const SWITCH_TRANSITION_PROPS: {
|
|
12
|
-
timeout: number;
|
|
13
|
-
unmountOnExit: boolean;
|
|
14
|
-
};
|
|
9
|
+
export declare const TOOLBAR_PROPS: Partial<MToolbarProps>;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
export const HEADER_HEIGHT = 56;
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
unmountOnExit: true,
|
|
6
|
-
};
|
|
7
|
-
export const HEADER_NAVIGATION_LABEL = {
|
|
8
|
-
MORE: "More",
|
|
9
|
-
SOCIALS: "Follow Us",
|
|
2
|
+
export const APP_BAR_PROPS = {
|
|
3
|
+
elevation: 1,
|
|
4
|
+
position: "fixed",
|
|
10
5
|
};
|
|
11
|
-
export const
|
|
6
|
+
export const FADE_TRANSITION_PROPS = {
|
|
7
|
+
appear: false,
|
|
12
8
|
timeout: 0,
|
|
13
9
|
unmountOnExit: true,
|
|
14
10
|
};
|
|
11
|
+
export const TOOLBAR_PROPS = {
|
|
12
|
+
variant: "dense",
|
|
13
|
+
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { Social } from "../../../../common/Socials/socials";
|
|
3
|
+
import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
|
|
4
|
+
export declare type Navigation = [
|
|
5
|
+
NavLinkItem[] | undefined,
|
|
6
|
+
NavLinkItem[] | undefined,
|
|
7
|
+
NavLinkItem[] | undefined
|
|
8
|
+
];
|
|
3
9
|
export interface SocialMedia {
|
|
4
10
|
label: ReactNode;
|
|
5
11
|
socials: Social[];
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
+
import { Breakpoint } from "@mui/material";
|
|
1
2
|
import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
|
|
2
|
-
import {
|
|
3
|
+
import { Navigation } from "./entities";
|
|
3
4
|
/**
|
|
4
|
-
* Returns the navigation links
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
5
|
+
* Returns the configured menu navigation links, for the current breakpoint.
|
|
6
|
+
* @param navigation - Navigation links.
|
|
7
|
+
* @param breakpoint - Current breakpoint.
|
|
8
|
+
* @returns navigation links.
|
|
7
9
|
*/
|
|
8
|
-
export declare function
|
|
10
|
+
export declare function getMenuNavigationLinks(navigation?: Navigation, breakpoint?: Breakpoint): NavLinkItem[];
|
|
9
11
|
/**
|
|
10
|
-
* Returns
|
|
11
|
-
* @param
|
|
12
|
-
* @
|
|
12
|
+
* Returns configured navigation links, for the current breakpoint.
|
|
13
|
+
* @param navigationLinks - Navigation links.
|
|
14
|
+
* @param breakpoint - Current breakpoint.
|
|
15
|
+
* @returns navigation links.
|
|
13
16
|
*/
|
|
14
|
-
export declare function
|
|
15
|
-
/**
|
|
16
|
-
* Returns header navigation links with socials appended with the corresponding label "Follow Us".
|
|
17
|
-
* @param links - Header navigation links.
|
|
18
|
-
* @param socialMedia - Header social media.
|
|
19
|
-
* @param onlySmDesktop - Media breakpoint query is "true" for small desktop only.
|
|
20
|
-
* @returns header navigation links.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getHeaderNavigationLinks(links: NavLinkItem[], socialMedia: SocialMedia | undefined, onlySmDesktop: boolean): NavLinkItem[];
|
|
17
|
+
export declare function getNavigationLinks(navigationLinks?: NavLinkItem[], breakpoint?: Breakpoint): NavLinkItem[];
|
|
@@ -1,72 +1,90 @@
|
|
|
1
|
-
import { RenderComponent } from "../../../../ComponentCreator/components/RenderComponent/renderComponent";
|
|
2
|
-
import { ANCHOR_TARGET } from "../../../../Links/common/entities";
|
|
3
|
-
import { HEADER_NAVIGATION_LABEL } from "./constants";
|
|
4
1
|
/**
|
|
5
|
-
* Returns the navigation links
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
2
|
+
* Returns the configured menu navigation links, for the current breakpoint.
|
|
3
|
+
* @param navigation - Navigation links.
|
|
4
|
+
* @param breakpoint - Current breakpoint.
|
|
5
|
+
* @returns navigation links.
|
|
8
6
|
*/
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
export function getMenuNavigationLinks(navigation, breakpoint) {
|
|
8
|
+
if (!navigation)
|
|
9
|
+
return [];
|
|
10
|
+
const navLinkItems = navigation.reduce((acc, navLinkItems) => {
|
|
11
|
+
if (!navLinkItems)
|
|
12
|
+
return acc;
|
|
13
|
+
acc.push(...navLinkItems);
|
|
14
|
+
return acc;
|
|
15
|
+
}, []);
|
|
16
|
+
return getNavigationLinks(navLinkItems, breakpoint);
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
|
-
* Returns
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
19
|
+
* Returns configured navigation links, for the current breakpoint.
|
|
20
|
+
* @param navigationLinks - Navigation links.
|
|
21
|
+
* @param breakpoint - Current breakpoint.
|
|
22
|
+
* @returns navigation links.
|
|
24
23
|
*/
|
|
25
|
-
export function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export function getNavigationLinks(navigationLinks, breakpoint) {
|
|
25
|
+
if (!navigationLinks)
|
|
26
|
+
return [];
|
|
27
|
+
return navigationLinks.reduce((acc, navLinkItem) => {
|
|
28
|
+
const processedNavLink = processNavLinkItem(navLinkItem, breakpoint);
|
|
29
|
+
if (processedNavLink) {
|
|
30
|
+
acc.push(...processedNavLink);
|
|
29
31
|
}
|
|
30
|
-
return
|
|
31
|
-
});
|
|
32
|
+
return acc;
|
|
33
|
+
}, []);
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
|
-
* Returns
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @
|
|
38
|
-
* @returns header navigation links.
|
|
36
|
+
* Returns true if the link is flattened at the current breakpoint.
|
|
37
|
+
* @param navLinkItem - Navigation link.
|
|
38
|
+
* @param breakpoint - Current breakpoint.
|
|
39
|
+
* @returns true if the link is flattened.
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
menuItems: getFollowUsMenuItems(socialMedia.socials),
|
|
47
|
-
url: "",
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return navLinks;
|
|
51
|
-
}
|
|
52
|
-
// Return the links without the "More" or "Follow Us" menu.
|
|
53
|
-
return flattenMoreLink(links);
|
|
41
|
+
function isLinkFlattened(navLinkItem, breakpoint) {
|
|
42
|
+
if (!breakpoint)
|
|
43
|
+
return false; // Default is not flattened.
|
|
44
|
+
if (!navLinkItem.flatten)
|
|
45
|
+
return false; // Default is not flattened.
|
|
46
|
+
return navLinkItem.flatten[breakpoint] === true;
|
|
54
47
|
}
|
|
55
48
|
/**
|
|
56
|
-
* Returns
|
|
57
|
-
* @param
|
|
58
|
-
* @
|
|
49
|
+
* Returns true if the link is visible at the current breakpoint.
|
|
50
|
+
* @param navLinkItem - Navigation link.
|
|
51
|
+
* @param breakpoint - Current breakpoint.
|
|
52
|
+
* @returns true if the link is visible.
|
|
59
53
|
*/
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
function isLinkVisible(navLinkItem, breakpoint) {
|
|
55
|
+
if (!breakpoint)
|
|
56
|
+
return true; // Default is visible.
|
|
57
|
+
if (!navLinkItem.visible)
|
|
58
|
+
return true; // Default is visible.
|
|
59
|
+
return navLinkItem.visible[breakpoint] !== false;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the processed navigation link item.
|
|
63
|
+
* Flattens menu items, and removes items that are not visible for the current breakpoint.
|
|
64
|
+
* @param navLinkItem - Navigation link.
|
|
65
|
+
* @param breakpoint - Current breakpoint.
|
|
66
|
+
* @returns processed navigation link item.
|
|
67
|
+
*/
|
|
68
|
+
function processNavLinkItem(navLinkItem, breakpoint) {
|
|
69
|
+
if (isLinkVisible(navLinkItem, breakpoint)) {
|
|
70
|
+
const cloneLink = { ...navLinkItem };
|
|
71
|
+
// Recursively process menu items.
|
|
72
|
+
if (cloneLink.menuItems) {
|
|
73
|
+
const menuItems = getNavigationLinks(navLinkItem.menuItems, breakpoint);
|
|
74
|
+
// Remove menu items if empty.
|
|
75
|
+
if (menuItems.length === 0) {
|
|
76
|
+
delete cloneLink.menuItems;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Flatten the menu items if the navigation is flattened.
|
|
80
|
+
if (isLinkFlattened(cloneLink, breakpoint)) {
|
|
81
|
+
return menuItems;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
cloneLink.menuItems = menuItems;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [cloneLink];
|
|
89
|
+
}
|
|
72
90
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentsConfig } from "../../../../../../config/entities";
|
|
3
|
+
export interface AnnouncementsProps {
|
|
4
|
+
announcements?: ComponentsConfig;
|
|
5
|
+
}
|
|
6
|
+
export declare const Announcements: ({ announcements, }: AnnouncementsProps) => JSX.Element | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ComponentCreator } from "../../../../../ComponentCreator/ComponentCreator";
|
|
3
|
+
export const Announcements = ({ announcements, }) => {
|
|
4
|
+
if (!announcements)
|
|
5
|
+
return null;
|
|
6
|
+
return React.createElement(ComponentCreator, { components: announcements, response: {} });
|
|
7
|
+
};
|
package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
export interface ActionsProps {
|
|
3
3
|
children: ReactNode | ReactNode[];
|
|
4
|
-
showActions?: boolean;
|
|
5
4
|
}
|
|
6
|
-
export declare const Actions: ({ children
|
|
5
|
+
export declare const Actions: ({ children }: ActionsProps) => JSX.Element;
|
package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { HeaderActions } from "./actions.styles";
|
|
3
|
-
export const Actions = ({ children
|
|
4
|
-
return React.createElement(
|
|
3
|
+
export const Actions = ({ children }) => {
|
|
4
|
+
return React.createElement(HeaderActions, null, children);
|
|
5
5
|
};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import LoginRoundedIcon from "@mui/icons-material/LoginRounded";
|
|
2
|
-
import {
|
|
2
|
+
import { IconButton as MIconButton } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { DESKTOP_SM } from "../../../../../../../../../../../../theme/common/breakpoints";
|
|
6
|
-
import { SWITCH_TRANSITION_PROPS } from "../../../../../../../../common/constants";
|
|
4
|
+
import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
|
|
7
5
|
import { Button } from "./requestAuthentication.styles";
|
|
8
6
|
export const RequestAuthentication = ({ closeMenu, requestAuthorization, }) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
React.createElement(
|
|
15
|
-
React.createElement(IconButton, { color: "ink", onClick: () => {
|
|
16
|
-
closeMenu();
|
|
17
|
-
requestAuthorization();
|
|
18
|
-
} },
|
|
19
|
-
React.createElement(LoginRoundedIcon, null)))));
|
|
7
|
+
const { mdUp } = useBreakpoint();
|
|
8
|
+
return mdUp ? (React.createElement(Button, { onClick: requestAuthorization, startIcon: React.createElement(LoginRoundedIcon, null), variant: "nav" }, "Sign in")) : (React.createElement(MIconButton, { color: "ink", onClick: () => {
|
|
9
|
+
closeMenu();
|
|
10
|
+
requestAuthorization();
|
|
11
|
+
} },
|
|
12
|
+
React.createElement(LoginRoundedIcon, null)));
|
|
20
13
|
};
|
|
@@ -12,7 +12,7 @@ export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
|
12
12
|
size?: "large" | "medium" | "small" | undefined;
|
|
13
13
|
startIcon?: import("react").ReactNode;
|
|
14
14
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
-
variant?: "nav" | "text" | "outlined" | "contained" | undefined;
|
|
15
|
+
variant?: "nav" | "text" | "outlined" | "contained" | "activeNav" | undefined;
|
|
16
16
|
} & Omit<{
|
|
17
17
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
18
18
|
centerRipple?: boolean | undefined;
|
|
@@ -9,6 +9,7 @@ export const Navigation = styled(DXNavigation) `
|
|
|
9
9
|
margin: 0;
|
|
10
10
|
justify-content: flex-start;
|
|
11
11
|
|
|
12
|
+
.MuiButton-activeNav,
|
|
12
13
|
.MuiButton-nav {
|
|
13
14
|
${textBodyLarge500};
|
|
14
15
|
justify-content: space-between;
|
|
@@ -22,6 +23,7 @@ export const Navigation = styled(DXNavigation) `
|
|
|
22
23
|
export const DrawerNavigation = styled(Navigation) `
|
|
23
24
|
gap: 0;
|
|
24
25
|
|
|
26
|
+
.MuiButton-activeNav,
|
|
25
27
|
.MuiButton-nav {
|
|
26
28
|
${textBody500};
|
|
27
29
|
padding: 14px 24px;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { ComponentsConfig } from "../../../../../../../../../../../../config/entities";
|
|
2
3
|
export interface DialogTitleProps {
|
|
3
4
|
actions?: ReactNode;
|
|
4
|
-
|
|
5
|
+
announcements?: ComponentsConfig;
|
|
5
6
|
authenticationEnabled?: boolean;
|
|
6
|
-
|
|
7
|
+
logo?: ReactNode;
|
|
7
8
|
onClose: () => void;
|
|
8
9
|
searchEnabled?: boolean;
|
|
9
10
|
searchURL?: string;
|
|
10
11
|
}
|
|
11
|
-
export declare const Toolbar: ({ actions,
|
|
12
|
+
export declare const Toolbar: ({ actions, announcements, authenticationEnabled, logo, onClose, searchEnabled, searchURL, }: DialogTitleProps) => JSX.Element;
|
|
@@ -1,14 +1,15 @@
|
|
|
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 { Announcements } from "../../../../../../../Announcements/announcements";
|
|
4
5
|
import { Actions } from "../../../../actions";
|
|
5
6
|
import { Authentication } from "../../../Authentication/authentication";
|
|
6
7
|
import { Search } from "../../../Search/search";
|
|
7
|
-
export const Toolbar = ({ actions,
|
|
8
|
+
export const Toolbar = ({ actions, announcements, authenticationEnabled, logo, onClose, searchEnabled, searchURL, }) => {
|
|
8
9
|
return (React.createElement(Fragment, null,
|
|
9
|
-
Announcements,
|
|
10
|
+
React.createElement(Announcements, { announcements: announcements }),
|
|
10
11
|
React.createElement(MToolbar, null,
|
|
11
|
-
|
|
12
|
+
logo,
|
|
12
13
|
React.createElement(Actions, null,
|
|
13
14
|
React.createElement(Search, { closeMenu: onClose, searchEnabled: searchEnabled, searchURL: searchURL }),
|
|
14
15
|
React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: onClose }),
|
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
import MenuRoundedIcon from "@mui/icons-material/MenuRounded";
|
|
2
2
|
import { Dialog as MDialog, Fade, IconButton } from "@mui/material";
|
|
3
|
-
import React, { forwardRef, useEffect } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { SWITCH_TRANSITION_PROPS } from "../../../../../../common/constants";
|
|
7
|
-
import { flattenNavigationLinks } from "../../../../../../common/utils";
|
|
3
|
+
import React, { forwardRef, Fragment, useEffect } from "react";
|
|
4
|
+
import { useBreakpoint } from "../../../../../../../../../../hooks/useBreakpoint";
|
|
5
|
+
import { getMenuNavigationLinks } from "../../../../../../common/utils";
|
|
8
6
|
import { AppBar } from "../../../../../../header.styles";
|
|
9
7
|
import { Content } from "../../../../content.styles";
|
|
10
8
|
import { Slogan } from "../../../Slogan/slogan";
|
|
11
9
|
import { Navigation } from "./components/Content/components/Navigation/navigation.styles";
|
|
12
10
|
import { Socials } from "./components/Content/components/Socials/socials.styles";
|
|
13
11
|
import { Toolbar } from "./components/Toolbar/toolbar";
|
|
14
|
-
export const Menu = forwardRef(function HeaderMenu({ closeMenu, headerProps, open, openMenu, style }, ref) {
|
|
15
|
-
const {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
// Set drawer open state to false on change of media breakpoint from mobile to "small desktop".
|
|
12
|
+
export const Menu = forwardRef(function HeaderMenu({ closeMenu, headerProps, open, openMenu, pathname, style }, ref) {
|
|
13
|
+
const { navigation, slogan, socialMedia } = headerProps;
|
|
14
|
+
const { breakpoint, smDown } = useBreakpoint();
|
|
15
|
+
// Set drawer open state to false on change of media breakpoint from small desktop "md" and up.
|
|
19
16
|
useEffect(() => {
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, [closeMenu,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
if (smDown)
|
|
18
|
+
return;
|
|
19
|
+
closeMenu();
|
|
20
|
+
}, [closeMenu, smDown]);
|
|
21
|
+
if (!smDown)
|
|
22
|
+
return null;
|
|
23
|
+
return (React.createElement(Fragment, null,
|
|
24
|
+
React.createElement(IconButton, { color: "ink", onClick: openMenu, ref: ref, style: style },
|
|
25
|
+
React.createElement(MenuRoundedIcon, null)),
|
|
26
|
+
React.createElement(MDialog, { disableScrollLock: true, fullScreen: true, hideBackdrop: true, keepMounted: false, onClose: closeMenu, open: open, PaperProps: { elevation: 0 }, TransitionComponent: Fade, transitionDuration: smDown ? 600 : 0, TransitionProps: { easing: "ease-out" } },
|
|
29
27
|
React.createElement(AppBar, { component: "div", elevation: 0 },
|
|
30
28
|
React.createElement(Toolbar, { onClose: closeMenu, ...headerProps })),
|
|
31
29
|
React.createElement(Content, null,
|
|
32
30
|
slogan && React.createElement(Slogan, { slogan: slogan }),
|
|
33
|
-
React.createElement(Navigation, { closeAncestor: closeMenu, headerProps: headerProps, links:
|
|
31
|
+
React.createElement(Navigation, { closeAncestor: closeMenu, headerProps: headerProps, links: getMenuNavigationLinks(navigation, breakpoint), pathname: pathname }),
|
|
34
32
|
socialMedia && (React.createElement(Socials, { buttonSize: "xlarge", socials: socialMedia.socials }))))));
|
|
35
33
|
});
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IconButton } from "@mui/material";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { DESKTOP_SM } from "../../../../../../../../../../../../theme/common/breakpoints";
|
|
3
|
+
import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
|
|
5
4
|
import { SearchIcon } from "../../../../../../../../../../../common/CustomIcon/components/SearchIcon/searchIcon";
|
|
6
|
-
import { SWITCH_TRANSITION_PROPS } from "../../../../../../../../common/constants";
|
|
7
5
|
import { Button } from "./searchButton.styles";
|
|
8
6
|
export const SearchButton = ({ openSearch }) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
React.createElement(Fade, { in: smDesktop, ...switchProps },
|
|
13
|
-
React.createElement(Button, { onClick: openSearch, startIcon: React.createElement(SearchIcon, null), variant: "nav" }, "Search")),
|
|
14
|
-
React.createElement(Fade, { in: !smDesktop, ...switchProps },
|
|
15
|
-
React.createElement(IconButton, { color: "ink", onClick: openSearch },
|
|
16
|
-
React.createElement(SearchIcon, { fontSize: "medium" })))));
|
|
7
|
+
const { mdUp } = useBreakpoint();
|
|
8
|
+
return mdUp ? (React.createElement(Button, { onClick: openSearch, startIcon: React.createElement(SearchIcon, null), variant: "nav" }, "Search")) : (React.createElement(IconButton, { color: "ink", onClick: openSearch },
|
|
9
|
+
React.createElement(SearchIcon, { fontSize: "medium" })));
|
|
17
10
|
};
|
|
@@ -12,7 +12,7 @@ export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
|
12
12
|
size?: "large" | "medium" | "small" | undefined;
|
|
13
13
|
startIcon?: import("react").ReactNode;
|
|
14
14
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
-
variant?: "nav" | "text" | "outlined" | "contained" | undefined;
|
|
15
|
+
variant?: "nav" | "text" | "outlined" | "contained" | "activeNav" | undefined;
|
|
16
16
|
} & Omit<{
|
|
17
17
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
18
18
|
centerRipple?: boolean | undefined;
|
|
@@ -6,5 +6,6 @@ export interface NavigationDrawerProps {
|
|
|
6
6
|
headerProps?: HeaderProps;
|
|
7
7
|
menuItems: MenuItem[];
|
|
8
8
|
menuLabel: ReactNode;
|
|
9
|
+
pathname?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare const NavigationDrawer: ({ closeAncestor, headerProps, menuItems, menuLabel, }: NavigationDrawerProps) => JSX.Element;
|
|
11
|
+
export declare const NavigationDrawer: ({ closeAncestor, headerProps, menuItems, menuLabel, pathname, }: NavigationDrawerProps) => JSX.Element;
|
|
@@ -8,7 +8,7 @@ import { DrawerNavigation as Navigation } from "../../../Actions/components/Menu
|
|
|
8
8
|
import { Toolbar } from "../../../Actions/components/Menu/components/Toolbar/toolbar";
|
|
9
9
|
import { Slide } from "./components/Slide/slide";
|
|
10
10
|
import { Button as BackButton, Content } from "./navigationDrawer.styles";
|
|
11
|
-
export const NavigationDrawer = ({ closeAncestor, headerProps, menuItems, menuLabel, }) => {
|
|
11
|
+
export const NavigationDrawer = ({ closeAncestor, headerProps, menuItems, menuLabel, pathname, }) => {
|
|
12
12
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
13
13
|
const openDrawer = () => {
|
|
14
14
|
setDrawerOpen(true);
|
|
@@ -27,5 +27,5 @@ export const NavigationDrawer = ({ closeAncestor, headerProps, menuItems, menuLa
|
|
|
27
27
|
React.createElement(Toolbar, { onClose: closeDrawers, ...headerProps })),
|
|
28
28
|
React.createElement(Content, null,
|
|
29
29
|
React.createElement(BackButton, { fullWidth: true, onClick: closeDrawer, StartIcon: BackArrowIcon, variant: "nav" }, menuLabel),
|
|
30
|
-
React.createElement(Navigation, { closeAncestor: closeDrawers, headerProps: headerProps, links: menuItems })))));
|
|
30
|
+
React.createElement(Navigation, { closeAncestor: closeDrawers, headerProps: headerProps, links: menuItems, pathname: pathname })))));
|
|
31
31
|
};
|
|
@@ -6,5 +6,6 @@ export interface NavLinkMenuProps {
|
|
|
6
6
|
closeAncestor?: () => void;
|
|
7
7
|
menuItems: MenuItem[];
|
|
8
8
|
menuLabel: ReactNode;
|
|
9
|
+
pathname?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare const NavigationMenu: ({ anchorOrigin, closeAncestor, menuItems, menuLabel, }: NavLinkMenuProps) => JSX.Element;
|
|
11
|
+
export declare const NavigationMenu: ({ anchorOrigin, closeAncestor, menuItems, menuLabel, pathname, }: NavLinkMenuProps) => JSX.Element;
|