@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
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded";
|
|
2
2
|
import React, { useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { DESKTOP_SM } from "../../../../../../../../../../theme/common/breakpoints";
|
|
3
|
+
import { useBreakpoint } from "../../../../../../../../../../hooks/useBreakpoint";
|
|
5
4
|
import { NavigationMenuItems, } from "../NavigationMenuItems/navigationMenuItems";
|
|
6
5
|
import { Button, Menu } from "./navigationMenu.styles";
|
|
7
|
-
export const NavigationMenu = ({ anchorOrigin = { horizontal: "left", vertical: "bottom" }, closeAncestor, menuItems, menuLabel, }) => {
|
|
8
|
-
const
|
|
6
|
+
export const NavigationMenu = ({ anchorOrigin = { horizontal: "left", vertical: "bottom" }, closeAncestor, menuItems, menuLabel, pathname, }) => {
|
|
7
|
+
const { mdUp } = useBreakpoint();
|
|
9
8
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
10
9
|
const open = Boolean(anchorEl);
|
|
11
10
|
const openMenu = (event) => {
|
|
@@ -17,9 +16,9 @@ export const NavigationMenu = ({ anchorOrigin = { horizontal: "left", vertical:
|
|
|
17
16
|
};
|
|
18
17
|
return (React.createElement(React.Fragment, null,
|
|
19
18
|
React.createElement(Button, { EndIcon: ArrowDropDownRoundedIcon, isActive: open, onClick: openMenu, variant: "nav" }, menuLabel),
|
|
20
|
-
React.createElement(Menu, { anchorEl: anchorEl, anchorOrigin: anchorOrigin, onClose: closeMenu, open:
|
|
19
|
+
React.createElement(Menu, { anchorEl: anchorEl, anchorOrigin: anchorOrigin, onClose: closeMenu, open: mdUp && open, slotProps: { paper: { variant: "menu" } }, transformOrigin: {
|
|
21
20
|
horizontal: "left",
|
|
22
21
|
vertical: "top",
|
|
23
22
|
} },
|
|
24
|
-
React.createElement(NavigationMenuItems, { closeMenu: closeMenu, menuItems: menuItems }))));
|
|
23
|
+
React.createElement(NavigationMenuItems, { closeMenu: closeMenu, menuItems: menuItems, pathname: pathname }))));
|
|
25
24
|
};
|
|
@@ -1,10 +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 { inkLight, smokeLight, smokeMain, } from "../../../../../../../../../../styles/common/mixins/colors";
|
|
4
5
|
import { Button as DXButton } from "../../../../../../../../../common/Button/button";
|
|
5
6
|
export const Menu = styled(MMenu) `
|
|
6
7
|
.MuiPaper-menu {
|
|
7
|
-
border-color: ${
|
|
8
|
+
border-color: ${smokeMain};
|
|
8
9
|
margin: 4px 0;
|
|
9
10
|
max-width: 324px;
|
|
10
11
|
min-width: 204px;
|
|
@@ -31,12 +32,17 @@ export const Menu = styled(MMenu) `
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
.MuiListItemText-secondary {
|
|
34
|
-
color: ${
|
|
35
|
+
color: ${inkLight};
|
|
35
36
|
white-space: normal;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
|
|
40
|
+
&.Mui-selected {
|
|
41
|
+
background-color: ${smokeLight};
|
|
42
|
+
}
|
|
38
43
|
}
|
|
39
44
|
|
|
45
|
+
.MuiButton-activeNav,
|
|
40
46
|
.MuiButton-nav {
|
|
41
47
|
font-weight: 400;
|
|
42
48
|
justify-content: space-between;
|
|
@@ -57,8 +63,8 @@ export const Button = styled(DXButton, {
|
|
|
57
63
|
shouldForwardProp: (prop) => prop !== "isActive",
|
|
58
64
|
}) `
|
|
59
65
|
// Button is "active" i.e. menu is open.
|
|
60
|
-
${(
|
|
66
|
+
${(props) => props.isActive &&
|
|
61
67
|
css `
|
|
62
|
-
background-color: ${
|
|
68
|
+
background-color: ${smokeLight(props)};
|
|
63
69
|
`};
|
|
64
70
|
`;
|
|
@@ -7,5 +7,6 @@ export interface MenuItem extends NavLinkItem {
|
|
|
7
7
|
export interface NavLinkMenuProps {
|
|
8
8
|
closeMenu: () => void;
|
|
9
9
|
menuItems: MenuItem[];
|
|
10
|
+
pathname?: string;
|
|
10
11
|
}
|
|
11
|
-
export declare const NavigationMenuItems: ({ closeMenu, menuItems, }: NavLinkMenuProps) => JSX.Element;
|
|
12
|
+
export declare const NavigationMenuItems: ({ closeMenu, menuItems, pathname, }: NavLinkMenuProps) => JSX.Element;
|
|
@@ -5,15 +5,15 @@ import { TEXT_BODY_400, TEXT_BODY_500, TEXT_BODY_SMALL_400_2_LINES, } from "../.
|
|
|
5
5
|
import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
|
|
6
6
|
import { isClientSideNavigation } from "../../../../../../../../../Links/common/utils";
|
|
7
7
|
import { NavigationMenu } from "../NavigationMenu/navigationMenu";
|
|
8
|
-
export const NavigationMenuItems = ({ closeMenu, menuItems, }) => {
|
|
8
|
+
export const NavigationMenuItems = ({ closeMenu, menuItems, pathname, }) => {
|
|
9
9
|
const router = useRouter();
|
|
10
|
-
return (React.createElement(React.Fragment, null, menuItems.map(({ description, divider, icon, label, menuItems: nestedMenuItems, target = ANCHOR_TARGET.SELF, url, }, i) => nestedMenuItems ? (React.createElement(NavigationMenu, { key: i, anchorOrigin: { horizontal: "right", vertical: "top" }, closeAncestor: closeMenu, menuItems: nestedMenuItems, menuLabel: label })) : (React.createElement(Fragment, { key: i },
|
|
10
|
+
return (React.createElement(React.Fragment, null, menuItems.map(({ description, divider, icon, label, menuItems: nestedMenuItems, target = ANCHOR_TARGET.SELF, url, }, i) => nestedMenuItems ? (React.createElement(NavigationMenu, { key: i, anchorOrigin: { horizontal: "right", vertical: "top" }, closeAncestor: closeMenu, menuItems: nestedMenuItems, menuLabel: label, pathname: pathname })) : (React.createElement(Fragment, { key: i },
|
|
11
11
|
React.createElement(MMenuItem, { onClick: () => {
|
|
12
12
|
closeMenu();
|
|
13
13
|
isClientSideNavigation(url)
|
|
14
14
|
? router.push(url)
|
|
15
15
|
: window.open(url, target, "noopener noreferrer");
|
|
16
|
-
} },
|
|
16
|
+
}, selected: url === pathname },
|
|
17
17
|
icon && React.createElement(ListItemIcon, null, icon),
|
|
18
18
|
React.createElement(ListItemText, { primary: label, primaryTypographyProps: {
|
|
19
19
|
variant: description ? TEXT_BODY_500 : TEXT_BODY_400,
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { BreakpointKey } from "../../../../../../../../hooks/useBreakpointHelper";
|
|
3
3
|
import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
|
|
4
4
|
import { HeaderProps } from "../../../../header";
|
|
5
5
|
import { MenuItem } from "./components/NavigationMenuItems/navigationMenuItems";
|
|
6
6
|
export interface NavLinkItem {
|
|
7
7
|
divider?: boolean;
|
|
8
|
-
flatten?: boolean
|
|
8
|
+
flatten?: Partial<Record<BreakpointKey, boolean>>;
|
|
9
9
|
label: ReactNode;
|
|
10
10
|
menuItems?: MenuItem[];
|
|
11
11
|
target?: ANCHOR_TARGET;
|
|
12
12
|
url: string;
|
|
13
|
+
visible?: Partial<Record<BreakpointKey, boolean>>;
|
|
13
14
|
}
|
|
14
15
|
export interface NavigationProps {
|
|
15
|
-
alignment?: ElementAlignment;
|
|
16
16
|
className?: string;
|
|
17
17
|
closeAncestor?: () => void;
|
|
18
18
|
headerProps?: HeaderProps;
|
|
19
19
|
links: NavLinkItem[];
|
|
20
|
+
pathname?: string;
|
|
20
21
|
style?: CSSProperties;
|
|
21
22
|
}
|
|
22
23
|
export declare const Navigation: React.ForwardRefExoticComponent<NavigationProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { Button, Divider } from "@mui/material";
|
|
2
2
|
import { useRouter } from "next/router";
|
|
3
3
|
import React, { forwardRef, Fragment } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../../../../../hooks/useBreakpointHelper";
|
|
6
|
-
import { DESKTOP_SM } from "../../../../../../../../theme/common/breakpoints";
|
|
4
|
+
import { useBreakpoint } from "../../../../../../../../hooks/useBreakpoint";
|
|
7
5
|
import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
|
|
8
6
|
import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
|
|
9
7
|
import { NavigationDrawer } from "./components/NavigationDrawer/navigationDrawer";
|
|
10
8
|
import { NavigationMenu } from "./components/NavigationMenu/navigationMenu";
|
|
11
9
|
import { Navigation as Links } from "./navigation.styles";
|
|
12
|
-
export const Navigation = forwardRef(function Navigation({
|
|
13
|
-
const
|
|
10
|
+
export const Navigation = forwardRef(function Navigation({ className, closeAncestor, headerProps, links, pathname, style, }, ref) {
|
|
11
|
+
const { mdUp } = useBreakpoint();
|
|
14
12
|
const router = useRouter();
|
|
15
|
-
return (React.createElement(Links, { ref: ref,
|
|
16
|
-
|
|
13
|
+
return (React.createElement(Links, { ref: ref, className: className, style: style }, links.map(({ divider, label, menuItems, target = ANCHOR_TARGET.SELF, url }, i) => menuItems ? (React.createElement(Fragment, { key: i },
|
|
14
|
+
mdUp ? (React.createElement(NavigationMenu, { closeAncestor: closeAncestor, menuItems: menuItems, menuLabel: label, pathname: pathname })) : (React.createElement(NavigationDrawer, { closeAncestor: closeAncestor, headerProps: headerProps, menuItems: menuItems, menuLabel: label, pathname: pathname })),
|
|
17
15
|
divider && React.createElement(Divider, null))) : (React.createElement(Fragment, { key: i },
|
|
18
16
|
React.createElement(Button, { onClick: () => {
|
|
19
17
|
isClientSideNavigation(url)
|
|
20
18
|
? router.push(url)
|
|
21
19
|
: window.open(url, target, "noopener noreferrer");
|
|
22
20
|
closeAncestor?.();
|
|
23
|
-
}, variant: "nav" }, label),
|
|
21
|
+
}, variant: url === pathname ? "activeNav" : "nav" }, label),
|
|
24
22
|
divider && React.createElement(Divider, null))))));
|
|
25
23
|
});
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ElementAlignment } from "../../../../../../../../common/entities";
|
|
3
|
-
interface Props {
|
|
4
|
-
alignment: ElementAlignment;
|
|
5
|
-
}
|
|
6
2
|
export declare const Navigation: import("@emotion/styled").StyledComponent<{
|
|
7
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
8
4
|
as?: import("react").ElementType<any> | undefined;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { css } from "@emotion/react";
|
|
2
1
|
import styled from "@emotion/styled";
|
|
3
|
-
import { ELEMENT_ALIGNMENT, } from "../../../../../../../../common/entities";
|
|
4
2
|
import { mediaDesktopSmallUp } from "../../../../../../../../styles/common/mixins/breakpoints";
|
|
5
3
|
import { textBody500 } from "../../../../../../../../styles/common/mixins/fonts";
|
|
6
4
|
export const Navigation = styled("div") `
|
|
@@ -10,24 +8,12 @@ export const Navigation = styled("div") `
|
|
|
10
8
|
gap: 8px;
|
|
11
9
|
justify-content: flex-start;
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`};
|
|
18
|
-
|
|
19
|
-
// Center alignment.
|
|
20
|
-
${({ alignment }) => alignment === ELEMENT_ALIGNMENT.CENTER &&
|
|
21
|
-
css `
|
|
22
|
-
justify-content: center;
|
|
23
|
-
`};
|
|
24
|
-
|
|
25
|
-
// Right alignment.
|
|
26
|
-
${({ alignment }) => alignment === ELEMENT_ALIGNMENT.RIGHT &&
|
|
27
|
-
css `
|
|
28
|
-
justify-content: flex-end;
|
|
29
|
-
`};
|
|
11
|
+
${mediaDesktopSmallUp} {
|
|
12
|
+
flex: unset;
|
|
13
|
+
justify-content: inherit;
|
|
14
|
+
}
|
|
30
15
|
|
|
16
|
+
.MuiButton-activeNav,
|
|
31
17
|
.MuiButton-nav {
|
|
32
18
|
${textBody500};
|
|
33
19
|
padding: 6px 12px;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { SocialMedia } from "./common/entities";
|
|
4
|
-
import { NavLinkItem } from "./components/Content/components/Navigation/navigation";
|
|
2
|
+
import { ComponentsConfig } from "../../../../config/entities";
|
|
3
|
+
import { Navigation, SocialMedia } from "./common/entities";
|
|
5
4
|
export interface HeaderProps {
|
|
6
5
|
actions?: ReactNode;
|
|
7
|
-
|
|
6
|
+
announcements?: ComponentsConfig;
|
|
8
7
|
authenticationEnabled?: boolean;
|
|
9
8
|
className?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
navLinks: NavLinkItem[];
|
|
9
|
+
logo: ReactNode;
|
|
10
|
+
navigation?: Navigation;
|
|
13
11
|
searchEnabled?: boolean;
|
|
14
12
|
searchURL?: string;
|
|
15
13
|
slogan?: ReactNode;
|
|
@@ -1,69 +1,48 @@
|
|
|
1
1
|
import { Fade, Toolbar } from "@mui/material";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { FADE_TRANSITION_PROPS } from "./common/constants";
|
|
10
|
-
import { getHeaderNavigationLinks } from "./common/utils";
|
|
2
|
+
import { usePathname } from "next/navigation";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useBreakpoint } from "../../../../hooks/useBreakpoint";
|
|
5
|
+
import { useMenu } from "../../../../hooks/useMenu";
|
|
6
|
+
import { APP_BAR_PROPS, FADE_TRANSITION_PROPS, TOOLBAR_PROPS, } from "./common/constants";
|
|
7
|
+
import { getNavigationLinks } from "./common/utils";
|
|
8
|
+
import { Announcements } from "./components/Announcements/announcements";
|
|
11
9
|
import { Actions } from "./components/Content/components/Actions/actions";
|
|
12
10
|
import { Authentication } from "./components/Content/components/Actions/components/Authentication/authentication";
|
|
13
11
|
import { Menu } from "./components/Content/components/Actions/components/Menu/menu";
|
|
14
12
|
import { Search } from "./components/Content/components/Actions/components/Search/search";
|
|
15
|
-
import { Navigation
|
|
13
|
+
import { Navigation as DXNavigation } from "./components/Content/components/Navigation/navigation";
|
|
16
14
|
import { Slogan } from "./components/Content/components/Slogan/slogan";
|
|
17
15
|
import { Divider } from "./components/Content/components/Slogan/slogan.styles";
|
|
18
16
|
import { Socials } from "./components/Content/components/Socials/socials.styles";
|
|
19
|
-
import { AppBar
|
|
17
|
+
import { AppBar, Center, Left, Right } from "./header.styles";
|
|
18
|
+
import { useHeaderVisibility } from "./hooks/useHeaderVisibility";
|
|
19
|
+
import { useMeasureHeader } from "./hooks/useMeasureHeader";
|
|
20
20
|
export const Header = ({ ...headerProps }) => {
|
|
21
|
-
const {
|
|
22
|
-
const {
|
|
23
|
-
const headerRef =
|
|
24
|
-
const {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
payload: height,
|
|
49
|
-
type: LayoutActionKind.UpdateHeaderHeight,
|
|
50
|
-
});
|
|
51
|
-
}, [height, layoutDispatch]);
|
|
52
|
-
return (React.createElement(AppBar, { ref: headerRef, className: className, elevation: 1, position: "fixed" },
|
|
53
|
-
Announcements,
|
|
54
|
-
React.createElement(Toolbar, { variant: "dense" },
|
|
55
|
-
Logo,
|
|
56
|
-
React.createElement(Fade, { in: isSloganIn, style: { transitionDelay: isSloganIn ? "50ms" : "0ms" }, ...fadeProps },
|
|
57
|
-
React.createElement(Divider, { orientation: "vertical" })),
|
|
58
|
-
React.createElement(Fade, { in: isSloganIn, style: { transitionDelay: isSloganIn ? "50ms" : "0ms" }, ...fadeProps },
|
|
59
|
-
React.createElement(Slogan, { slogan: slogan })),
|
|
60
|
-
React.createElement(Fade, { in: isNavigationIn, ...fadeProps },
|
|
61
|
-
React.createElement(Navigation, { alignment: navAlignment, headerProps: headerProps, links: getHeaderNavigationLinks(navLinks, socialMedia, onlySmDesktop) })),
|
|
62
|
-
socialMedia && (React.createElement(Fade, { in: isSocialsIn, ...fadeProps },
|
|
63
|
-
React.createElement(Socials, { buttonSize: "small", socials: socialMedia.socials }))),
|
|
64
|
-
React.createElement(Actions, { showActions: showActions },
|
|
65
|
-
React.createElement(Search, { closeMenu: closeMenu, searchEnabled: searchEnabled, searchURL: searchURL }),
|
|
66
|
-
React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: closeMenu }),
|
|
67
|
-
actions,
|
|
68
|
-
React.createElement(Menu, { closeMenu: closeMenu, headerProps: headerProps, open: menuOpen, openMenu: openMenu })))));
|
|
21
|
+
const { breakpoint } = useBreakpoint();
|
|
22
|
+
const { isIn } = useHeaderVisibility(headerProps);
|
|
23
|
+
const { headerRef } = useMeasureHeader();
|
|
24
|
+
const { onClose, onOpen, open } = useMenu();
|
|
25
|
+
const pathname = usePathname();
|
|
26
|
+
const { actions, announcements, authenticationEnabled, className, logo, navigation: [navItemsL, navItemsC, navItemsR] = [], searchEnabled, searchURL, slogan, socialMedia, } = headerProps;
|
|
27
|
+
const navigationProps = { headerProps, pathname };
|
|
28
|
+
return (React.createElement(AppBar, { ...APP_BAR_PROPS, ref: headerRef, className: className },
|
|
29
|
+
React.createElement(Announcements, { announcements: announcements }),
|
|
30
|
+
React.createElement(Toolbar, { ...TOOLBAR_PROPS },
|
|
31
|
+
React.createElement(Fade, { ...FADE_TRANSITION_PROPS, in: isIn.isLeftGroupIn },
|
|
32
|
+
React.createElement(Left, null,
|
|
33
|
+
logo,
|
|
34
|
+
isIn.isSloganIn && React.createElement(Divider, { flexItem: true, orientation: "vertical" }),
|
|
35
|
+
isIn.isSloganIn && React.createElement(Slogan, { slogan: slogan }),
|
|
36
|
+
isIn.isLeftNavigationIn && (React.createElement(DXNavigation, { ...navigationProps, links: getNavigationLinks(navItemsL, breakpoint) })))),
|
|
37
|
+
React.createElement(Fade, { ...FADE_TRANSITION_PROPS, in: isIn.isCenterGroupIn },
|
|
38
|
+
React.createElement(Center, null, isIn.isCenterNavigationIn && (React.createElement(DXNavigation, { ...navigationProps, links: getNavigationLinks(navItemsC, breakpoint) })))),
|
|
39
|
+
React.createElement(Fade, { ...FADE_TRANSITION_PROPS, in: isIn.isRightGroupIn },
|
|
40
|
+
React.createElement(Right, null,
|
|
41
|
+
isIn.isRightNavigationIn && (React.createElement(DXNavigation, { ...navigationProps, links: getNavigationLinks(navItemsR) })),
|
|
42
|
+
isIn.isSocialsIn && (React.createElement(Socials, { buttonSize: "small", socials: socialMedia?.socials || [] })),
|
|
43
|
+
isIn.isActionsIn && (React.createElement(Actions, null,
|
|
44
|
+
React.createElement(Search, { closeMenu: onClose, searchEnabled: searchEnabled, searchURL: searchURL }),
|
|
45
|
+
React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: onClose }),
|
|
46
|
+
actions,
|
|
47
|
+
React.createElement(Menu, { ...navigationProps, closeMenu: onClose, open: open, openMenu: onOpen }))))))));
|
|
69
48
|
};
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ELEMENT_ALIGNMENT } from "../../../../common/entities";
|
|
3
2
|
import logo from "../../../../images/logo.svg";
|
|
4
3
|
import { DiscourseIcon } from "../../../common/CustomIcon/components/DiscourseIcon/discourseIcon";
|
|
5
4
|
import { GitHubIcon } from "../../../common/CustomIcon/components/GitHubIcon/gitHubIcon";
|
|
6
5
|
import { XIcon } from "../../../common/CustomIcon/components/XIcon/xIcon";
|
|
7
6
|
import { YouTubeIcon } from "../../../common/CustomIcon/components/YouTubeIcon/youTubeIcon";
|
|
8
|
-
import { HEADER_NAVIGATION_LABEL } from "./common/constants";
|
|
9
7
|
import { Logo } from "./components/Content/components/Logo/logo";
|
|
10
8
|
import { Header } from "./header";
|
|
11
9
|
export default {
|
|
12
10
|
argTypes: {
|
|
13
|
-
Logo: { control: { disable: true } },
|
|
14
11
|
authenticationEnabled: { control: "boolean" },
|
|
15
|
-
|
|
16
|
-
control: "select",
|
|
17
|
-
options: [ELEMENT_ALIGNMENT.LEFT, ELEMENT_ALIGNMENT.CENTER],
|
|
18
|
-
},
|
|
12
|
+
logo: { control: { disable: true } },
|
|
19
13
|
navLinks: { control: "array" },
|
|
20
14
|
searchEnabled: { control: "boolean" },
|
|
21
15
|
slogan: { control: "text" },
|
|
@@ -30,45 +24,48 @@ export default {
|
|
|
30
24
|
const url = "/";
|
|
31
25
|
export const HeaderStory = {
|
|
32
26
|
args: {
|
|
33
|
-
Logo: React.createElement(Logo, { alt: "Logo", height: 40, link: "/", src: logo }),
|
|
34
27
|
authenticationEnabled: false,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
28
|
+
logo: React.createElement(Logo, { alt: "Logo", height: 40, link: "/", src: logo }),
|
|
29
|
+
navigation: [
|
|
30
|
+
undefined,
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
label: "Overview",
|
|
34
|
+
url,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "Learn",
|
|
38
|
+
url,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "Datasets",
|
|
42
|
+
url,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: "More",
|
|
46
|
+
menuItems: [
|
|
47
|
+
{
|
|
48
|
+
label: "Team",
|
|
49
|
+
url,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: "FAQ",
|
|
53
|
+
url,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: "Help",
|
|
57
|
+
url,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
url: "",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
undefined,
|
|
67
64
|
],
|
|
68
65
|
searchEnabled: true,
|
|
69
66
|
slogan: "Header Slogan",
|
|
70
67
|
socialMedia: {
|
|
71
|
-
label:
|
|
68
|
+
label: "Follow Us",
|
|
72
69
|
socials: [
|
|
73
70
|
{
|
|
74
71
|
Icon: XIcon,
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const AppBar: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").AppBarTypeMap<{}, "header">>;
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const Left: import("@emotion/styled").StyledComponent<{
|
|
4
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
5
|
+
as?: import("react").ElementType<any> | undefined;
|
|
6
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
7
|
+
export declare const Center: import("@emotion/styled").StyledComponent<{
|
|
8
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
9
|
+
as?: import("react").ElementType<any> | undefined;
|
|
10
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
11
|
+
export declare const Right: import("@emotion/styled").StyledComponent<{
|
|
12
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
13
|
+
as?: import("react").ElementType<any> | undefined;
|
|
14
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -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";
|
|
@@ -14,8 +15,27 @@ export const AppBar = styled(MAppBar) `
|
|
|
14
15
|
min-height: unset;
|
|
15
16
|
}
|
|
16
17
|
`;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const group = css `
|
|
19
|
+
align-items: center;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex: 1;
|
|
22
|
+
`;
|
|
23
|
+
export const Left = styled.div `
|
|
24
|
+
${group};
|
|
25
|
+
gap: 16px;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
|
|
28
|
+
.MuiButton-navPrimary {
|
|
29
|
+
&:first-of-type {
|
|
30
|
+
margin-left: 24px;
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
33
|
`;
|
|
34
|
+
export const Center = styled.div `
|
|
35
|
+
${group};
|
|
36
|
+
justify-content: center;
|
|
37
|
+
`;
|
|
38
|
+
export const Right = styled.div `
|
|
39
|
+
${group};
|
|
40
|
+
justify-content: flex-end;
|
|
41
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HeaderProps } from "../header";
|
|
2
|
+
export interface UseHeaderVisibility {
|
|
3
|
+
isIn: {
|
|
4
|
+
isActionsIn: boolean;
|
|
5
|
+
isCenterGroupIn: boolean;
|
|
6
|
+
isCenterNavigationIn: boolean;
|
|
7
|
+
isLeftGroupIn: boolean;
|
|
8
|
+
isLeftNavigationIn: boolean;
|
|
9
|
+
isRightGroupIn: boolean;
|
|
10
|
+
isRightNavigationIn: boolean;
|
|
11
|
+
isSloganIn: boolean;
|
|
12
|
+
isSocialsIn: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns header component visibility for header related rendering logic.
|
|
17
|
+
* @param headerProps - Header component props.
|
|
18
|
+
* @returns header component visibility.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useHeaderVisibility: (headerProps: HeaderProps) => UseHeaderVisibility;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useBreakpoint } from "../../../../../hooks/useBreakpoint";
|
|
2
|
+
/**
|
|
3
|
+
* Returns header component visibility for header related rendering logic.
|
|
4
|
+
* @param headerProps - Header component props.
|
|
5
|
+
* @returns header component visibility.
|
|
6
|
+
*/
|
|
7
|
+
export const useHeaderVisibility = (headerProps) => {
|
|
8
|
+
const { lgUp, mdUp } = useBreakpoint();
|
|
9
|
+
// Header configuration.
|
|
10
|
+
const { actions, authenticationEnabled, logo, navigation: [navItemsL, navItemsC, navItemsR] = [], searchEnabled, slogan, socialMedia, } = headerProps;
|
|
11
|
+
// Header content.
|
|
12
|
+
const hasActions = Boolean(actions);
|
|
13
|
+
const hasLogo = Boolean(logo);
|
|
14
|
+
const hasMenu = !mdUp;
|
|
15
|
+
const hasNavItemsC = Boolean(navItemsC);
|
|
16
|
+
const hasNavItemsL = Boolean(navItemsL);
|
|
17
|
+
const hasNavItemsR = Boolean(navItemsR);
|
|
18
|
+
const hasSlogan = Boolean(slogan);
|
|
19
|
+
const hasSocials = Boolean(socialMedia);
|
|
20
|
+
// Determines header content visibility.
|
|
21
|
+
const isActionsIn = hasActions || searchEnabled || authenticationEnabled || hasMenu;
|
|
22
|
+
const isNavigationIn = mdUp;
|
|
23
|
+
const isSloganIn = hasSlogan && mdUp;
|
|
24
|
+
const isSocialsIn = hasSocials && lgUp;
|
|
25
|
+
// Determines navigation visibility.
|
|
26
|
+
const isCenterNavigationIn = isNavigationIn && hasNavItemsC;
|
|
27
|
+
const isLeftNavigationIn = isNavigationIn && hasNavItemsL;
|
|
28
|
+
const isRightNavigationIn = isNavigationIn && hasNavItemsR;
|
|
29
|
+
// Determines group visibility.
|
|
30
|
+
const isLeftGroupIn = hasLogo || isSocialsIn || isLeftNavigationIn;
|
|
31
|
+
const isCenterGroupIn = isCenterNavigationIn;
|
|
32
|
+
const isRightGroupIn = isRightNavigationIn || isSocialsIn || isActionsIn;
|
|
33
|
+
return {
|
|
34
|
+
isIn: {
|
|
35
|
+
isActionsIn,
|
|
36
|
+
isCenterGroupIn,
|
|
37
|
+
isCenterNavigationIn,
|
|
38
|
+
isLeftGroupIn,
|
|
39
|
+
isLeftNavigationIn,
|
|
40
|
+
isRightGroupIn,
|
|
41
|
+
isRightNavigationIn,
|
|
42
|
+
isSloganIn,
|
|
43
|
+
isSocialsIn,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useLayoutState } from "../../../../../hooks/useLayoutState";
|
|
3
|
+
import { getBorderBoxSizeHeight, useResizeObserver, } from "../../../../../hooks/useResizeObserver";
|
|
4
|
+
import { LayoutActionKind } from "../../../../../providers/layoutState";
|
|
5
|
+
export const useMeasureHeader = () => {
|
|
6
|
+
const { layoutDispatch } = useLayoutState();
|
|
7
|
+
const headerRef = useRef(null);
|
|
8
|
+
const { height } = useResizeObserver(headerRef, getBorderBoxSizeHeight) || {};
|
|
9
|
+
// Updates layout state header height.
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!height)
|
|
12
|
+
return;
|
|
13
|
+
layoutDispatch({
|
|
14
|
+
payload: height,
|
|
15
|
+
type: LayoutActionKind.UpdateHeaderHeight,
|
|
16
|
+
});
|
|
17
|
+
}, [height, layoutDispatch]);
|
|
18
|
+
return { headerRef };
|
|
19
|
+
};
|
package/lib/config/entities.d.ts
CHANGED
|
@@ -128,6 +128,7 @@ export interface EntityConfig<T = any, I = any> extends TabConfig {
|
|
|
128
128
|
detail: BackPageConfig;
|
|
129
129
|
entityMapper?: EntityMapper<T, I>;
|
|
130
130
|
exploreMode: ExploreMode;
|
|
131
|
+
explorerTitle?: SiteConfig["explorerTitle"];
|
|
131
132
|
getId?: GetIdFunction<T>;
|
|
132
133
|
getTitle?: GetTitleFunction<T>;
|
|
133
134
|
list: ListConfig;
|
|
@@ -212,6 +213,7 @@ export interface ListViewConfig {
|
|
|
212
213
|
enableDownload?: boolean;
|
|
213
214
|
enableRowPreview?: boolean;
|
|
214
215
|
enableRowSelection?: boolean;
|
|
216
|
+
enableTab?: boolean;
|
|
215
217
|
listHero?: ComponentsConfig;
|
|
216
218
|
rowPreviewView?: ComponentsConfig;
|
|
217
219
|
rowSelectionView?: ComponentsConfig;
|