@databiosphere/findable-ui 9.1.0 → 10.1.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.
- package/lib/components/Layout/components/Header/common/entities.d.ts +2 -2
- package/lib/components/Layout/components/Header/common/utils.d.ts +2 -3
- package/lib/components/Layout/components/Header/common/utils.js +94 -6
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.js +2 -2
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.d.ts +3 -10
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.js +9 -15
- 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 +10 -15
- 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 +4 -4
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.js +2 -2
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.d.ts +3 -2
- package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +3 -3
- package/lib/components/Layout/components/Header/header.js +13 -10
- package/lib/components/Layout/components/Header/header.stories.js +0 -1
- package/lib/components/Layout/components/Header/hooks/useHeaderNavigation.d.ts +6 -0
- package/lib/components/Layout/components/Header/hooks/useHeaderNavigation.js +10 -0
- package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.js +3 -3
- package/lib/components/Layout/components/Header/hooks/useMenu.d.ts +10 -0
- package/lib/components/Layout/components/Header/hooks/useMenu.js +17 -0
- package/lib/components/Layout/components/Sidebar/components/SidebarPositioner/sidebarPositioner.styles.js +1 -0
- package/lib/components/common/Dialog/hooks/useDialog.d.ts +11 -0
- package/lib/components/common/Dialog/hooks/useDialog.js +18 -0
- package/lib/components/common/Menu/hooks/useMenu.d.ts +14 -0
- package/lib/components/common/Menu/hooks/useMenu.js +33 -0
- package/package.json +1 -1
- package/src/components/Filter/components/Filter/filter.styles.ts +2 -1
- package/src/components/Filter/components/Filter/filter.tsx +1 -0
- package/src/components/Filter/components/FilterLabel/filterLabel.stories.tsx +2 -0
- package/src/components/Filter/components/FilterLabel/filterLabel.styles.ts +25 -5
- package/src/components/Filter/components/FilterLabel/filterLabel.tsx +3 -0
- package/src/components/Filter/components/FilterTags/filterTags.styles.ts +2 -7
- package/src/components/Filter/components/Filters/filters.styles.ts +10 -17
- package/src/components/Filter/components/Filters/filters.tsx +2 -20
- package/src/components/Layout/components/Header/common/entities.ts +5 -2
- package/src/components/Layout/components/Header/common/utils.ts +107 -14
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/authentication.tsx +50 -12
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/Button/button.styles.ts +8 -0
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/common/constants.ts +9 -0
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +10 -2
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.tsx +18 -14
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.ts +8 -0
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/search.tsx +41 -6
- package/src/components/Layout/components/Header/components/Content/components/Navigation/common/utils.ts +9 -17
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/common/constants.ts +9 -0
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.tsx +17 -21
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/common/constants.ts +12 -20
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.ts +48 -46
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.tsx +66 -35
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/common/constants.ts +5 -0
- package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.tsx +6 -9
- package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.ts +14 -12
- package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +21 -11
- package/src/components/Layout/components/Header/header.stories.tsx +0 -1
- package/src/components/Layout/components/Header/header.styles.ts +2 -1
- package/src/components/Layout/components/Header/header.tsx +33 -22
- package/src/components/Layout/components/Header/hooks/useHeaderNavigation.ts +19 -0
- package/src/components/Layout/components/Header/hooks/useHeaderVisibility.ts +14 -9
- package/src/{hooks → components/Layout/components/Header/hooks}/useMenu.ts +2 -2
- package/src/components/Layout/components/Sidebar/components/SidebarPositioner/sidebarPositioner.styles.ts +1 -0
- package/src/components/common/CustomIcon/components/InProgressIcon/inProgressIcon.tsx +22 -0
- package/src/components/common/Dialog/hooks/useDialog.ts +28 -0
- package/src/{hooks/useMenuWithPosition.ts → components/common/Menu/hooks/useMenu.ts} +21 -7
- package/src/hooks/useBreakpoint.ts +9 -8
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.ts +0 -10
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.tsx +0 -36
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.ts +0 -10
- package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx +0 -22
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Button, Divider } from "@mui/material";
|
|
2
2
|
import { useRouter } from "next/router";
|
|
3
3
|
import React, { CSSProperties, forwardRef, Fragment, ReactNode } from "react";
|
|
4
|
-
import { useBreakpoint } from "../../../../../../../../hooks/useBreakpoint";
|
|
5
4
|
import { BreakpointKey } from "../../../../../../../../hooks/useBreakpointHelper";
|
|
6
5
|
import {
|
|
7
6
|
ANCHOR_TARGET,
|
|
8
7
|
REL_ATTRIBUTE,
|
|
9
8
|
} from "../../../../../../../Links/common/entities";
|
|
10
9
|
import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
|
|
11
|
-
import {
|
|
10
|
+
import { SelectedMatch } from "../../../../common/entities";
|
|
12
11
|
import { HeaderProps } from "../../../../header";
|
|
13
12
|
import { isNavigationLinkSelected } from "./common/utils";
|
|
14
13
|
import { NavigationButtonLabel } from "./components/NavigationButtonLabel/navigationButtonLabel";
|
|
@@ -22,7 +21,8 @@ export interface NavLinkItem {
|
|
|
22
21
|
flatten?: Partial<Record<BreakpointKey, boolean>>;
|
|
23
22
|
label: ReactNode;
|
|
24
23
|
menuItems?: MenuItem[];
|
|
25
|
-
selectedMatch?:
|
|
24
|
+
selectedMatch?: SelectedMatch;
|
|
25
|
+
selectedPatterns?: string[];
|
|
26
26
|
target?: ANCHOR_TARGET;
|
|
27
27
|
url: string;
|
|
28
28
|
visible?: Partial<Record<BreakpointKey, boolean>>;
|
|
@@ -32,6 +32,7 @@ export interface NavigationProps {
|
|
|
32
32
|
className?: string;
|
|
33
33
|
closeAncestor?: () => void;
|
|
34
34
|
headerProps?: HeaderProps;
|
|
35
|
+
isMenuIn?: boolean;
|
|
35
36
|
links: NavLinkItem[];
|
|
36
37
|
pathname?: string;
|
|
37
38
|
style?: CSSProperties; // Required for Fade component. See https://mui.com/material-ui/transitions/#child-requirement.
|
|
@@ -43,23 +44,23 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
|
|
|
43
44
|
className,
|
|
44
45
|
closeAncestor,
|
|
45
46
|
headerProps,
|
|
47
|
+
isMenuIn = false,
|
|
46
48
|
links,
|
|
47
49
|
pathname,
|
|
48
50
|
style,
|
|
49
51
|
}: NavigationProps,
|
|
50
52
|
ref
|
|
51
53
|
): JSX.Element {
|
|
52
|
-
const { mdUp } = useBreakpoint();
|
|
53
54
|
const router = useRouter();
|
|
54
55
|
return (
|
|
55
|
-
<Links ref={ref} className={className} style={style}>
|
|
56
|
+
<Links ref={ref} className={className} isMenuIn={isMenuIn} style={style}>
|
|
56
57
|
{links.map(
|
|
57
58
|
(
|
|
58
59
|
{
|
|
59
60
|
divider,
|
|
60
61
|
label,
|
|
61
62
|
menuItems,
|
|
62
|
-
|
|
63
|
+
selectedPatterns,
|
|
63
64
|
target = ANCHOR_TARGET.SELF,
|
|
64
65
|
url,
|
|
65
66
|
},
|
|
@@ -67,17 +68,26 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
|
|
|
67
68
|
) =>
|
|
68
69
|
menuItems ? (
|
|
69
70
|
<Fragment key={i}>
|
|
70
|
-
{
|
|
71
|
-
<
|
|
71
|
+
{isMenuIn ? (
|
|
72
|
+
<NavigationDrawer
|
|
72
73
|
closeAncestor={closeAncestor}
|
|
74
|
+
headerProps={headerProps}
|
|
75
|
+
isMenuIn={isMenuIn}
|
|
76
|
+
isSelected={isNavigationLinkSelected(
|
|
77
|
+
pathname,
|
|
78
|
+
selectedPatterns
|
|
79
|
+
)}
|
|
73
80
|
menuItems={menuItems}
|
|
74
81
|
menuLabel={label}
|
|
75
82
|
pathname={pathname}
|
|
76
83
|
/>
|
|
77
84
|
) : (
|
|
78
|
-
<
|
|
85
|
+
<NavigationMenu
|
|
79
86
|
closeAncestor={closeAncestor}
|
|
80
|
-
|
|
87
|
+
isSelected={isNavigationLinkSelected(
|
|
88
|
+
pathname,
|
|
89
|
+
selectedPatterns
|
|
90
|
+
)}
|
|
81
91
|
menuItems={menuItems}
|
|
82
92
|
menuLabel={label}
|
|
83
93
|
pathname={pathname}
|
|
@@ -100,7 +110,7 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
|
|
|
100
110
|
);
|
|
101
111
|
}}
|
|
102
112
|
variant={
|
|
103
|
-
isNavigationLinkSelected(
|
|
113
|
+
isNavigationLinkSelected(pathname, selectedPatterns)
|
|
104
114
|
? "activeNav"
|
|
105
115
|
: "nav"
|
|
106
116
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { css } from "@emotion/react";
|
|
2
2
|
import styled from "@emotion/styled";
|
|
3
3
|
import { AppBar as MAppBar } from "@mui/material";
|
|
4
|
+
import { smokeMain } from "../../../../styles/common/mixins/colors";
|
|
4
5
|
import { HEADER_HEIGHT } from "./common/constants";
|
|
5
6
|
|
|
6
7
|
export const AppBar = styled(MAppBar)`
|
|
7
|
-
border-bottom: 1px solid ${
|
|
8
|
+
border-bottom: 1px solid ${smokeMain};
|
|
8
9
|
|
|
9
10
|
&.MuiPaper-elevation0 {
|
|
10
11
|
border-bottom: 1px solid transparent;
|
|
@@ -2,27 +2,34 @@ import { Fade, Toolbar } from "@mui/material";
|
|
|
2
2
|
import { usePathname } from "next/navigation";
|
|
3
3
|
import React, { ReactNode } from "react";
|
|
4
4
|
import { ComponentsConfig } from "../../../../config/entities";
|
|
5
|
-
import { useBreakpoint } from "../../../../hooks/useBreakpoint";
|
|
6
|
-
import { useMenu } from "../../../../hooks/useMenu";
|
|
7
5
|
import {
|
|
8
6
|
APP_BAR_PROPS,
|
|
9
7
|
FADE_TRANSITION_PROPS,
|
|
10
8
|
TOOLBAR_PROPS,
|
|
11
9
|
} from "./common/constants";
|
|
12
10
|
import { Navigation, SocialMedia } from "./common/entities";
|
|
13
|
-
import { getNavigationLinks } from "./common/utils";
|
|
14
11
|
import { Announcements } from "./components/Announcements/announcements";
|
|
15
12
|
import { Actions } from "./components/Content/components/Actions/actions";
|
|
16
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Authentication,
|
|
15
|
+
renderButton as renderAuthenticationButton,
|
|
16
|
+
renderIconButton as renderAuthenticationIconButton,
|
|
17
|
+
} from "./components/Content/components/Actions/components/Authentication/authentication";
|
|
17
18
|
import { Menu } from "./components/Content/components/Actions/components/Menu/menu";
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
renderButton as renderSearchButton,
|
|
21
|
+
renderIconButton as renderSearchIconButton,
|
|
22
|
+
Search,
|
|
23
|
+
} from "./components/Content/components/Actions/components/Search/search";
|
|
19
24
|
import { Navigation as DXNavigation } from "./components/Content/components/Navigation/navigation";
|
|
20
25
|
import { Slogan } from "./components/Content/components/Slogan/slogan";
|
|
21
26
|
import { Divider } from "./components/Content/components/Slogan/slogan.styles";
|
|
22
27
|
import { Socials } from "./components/Content/components/Socials/socials.styles";
|
|
23
28
|
import { AppBar, Center, Left, Right } from "./header.styles";
|
|
29
|
+
import { useHeaderNavigation } from "./hooks/useHeaderNavigation";
|
|
24
30
|
import { useHeaderVisibility } from "./hooks/useHeaderVisibility";
|
|
25
31
|
import { useMeasureHeader } from "./hooks/useMeasureHeader";
|
|
32
|
+
import { useMenu } from "./hooks/useMenu";
|
|
26
33
|
|
|
27
34
|
export interface HeaderProps {
|
|
28
35
|
actions?: ReactNode;
|
|
@@ -38,8 +45,8 @@ export interface HeaderProps {
|
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
|
|
41
|
-
const {
|
|
42
|
-
const { isIn } = useHeaderVisibility(headerProps);
|
|
48
|
+
const { navigation } = useHeaderNavigation(headerProps);
|
|
49
|
+
const { isIn } = useHeaderVisibility({ ...headerProps, navigation });
|
|
43
50
|
const { headerRef } = useMeasureHeader();
|
|
44
51
|
const { onClose, onOpen, open } = useMenu();
|
|
45
52
|
const pathname = usePathname() ?? "";
|
|
@@ -49,14 +56,16 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
|
|
|
49
56
|
authenticationEnabled,
|
|
50
57
|
className,
|
|
51
58
|
logo,
|
|
52
|
-
navigation: [navItemsL, navItemsC, navItemsR] = [],
|
|
53
59
|
searchEnabled,
|
|
54
60
|
searchURL,
|
|
55
61
|
slogan,
|
|
56
62
|
socialMedia,
|
|
57
63
|
} = headerProps;
|
|
58
|
-
const
|
|
59
|
-
|
|
64
|
+
const [navItemsL, navItemsC, navItemsR] = navigation;
|
|
65
|
+
const navigationProps = {
|
|
66
|
+
headerProps: { ...headerProps, navigation },
|
|
67
|
+
pathname,
|
|
68
|
+
};
|
|
60
69
|
return (
|
|
61
70
|
<AppBar {...APP_BAR_PROPS} ref={headerRef} className={className}>
|
|
62
71
|
{/* Announcements */}
|
|
@@ -74,10 +83,7 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
|
|
|
74
83
|
{isIn.isSloganIn && <Slogan slogan={slogan} />}
|
|
75
84
|
{/* Left navigation */}
|
|
76
85
|
{isIn.isLeftNavigationIn && (
|
|
77
|
-
<DXNavigation
|
|
78
|
-
{...navigationProps}
|
|
79
|
-
links={getNavigationLinks(navItemsL, breakpoint)}
|
|
80
|
-
/>
|
|
86
|
+
<DXNavigation {...navigationProps} links={navItemsL} />
|
|
81
87
|
)}
|
|
82
88
|
</Left>
|
|
83
89
|
</Fade>
|
|
@@ -86,10 +92,7 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
|
|
|
86
92
|
<Center>
|
|
87
93
|
{/* Center navigation */}
|
|
88
94
|
{isIn.isCenterNavigationIn && (
|
|
89
|
-
<DXNavigation
|
|
90
|
-
{...navigationProps}
|
|
91
|
-
links={getNavigationLinks(navItemsC, breakpoint)}
|
|
92
|
-
/>
|
|
95
|
+
<DXNavigation {...navigationProps} links={navItemsC} />
|
|
93
96
|
)}
|
|
94
97
|
</Center>
|
|
95
98
|
</Fade>
|
|
@@ -98,10 +101,7 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
|
|
|
98
101
|
<Right>
|
|
99
102
|
{/* Navigation */}
|
|
100
103
|
{isIn.isRightNavigationIn && (
|
|
101
|
-
<DXNavigation
|
|
102
|
-
{...navigationProps}
|
|
103
|
-
links={getNavigationLinks(navItemsR)}
|
|
104
|
-
/>
|
|
104
|
+
<DXNavigation {...navigationProps} links={navItemsR} />
|
|
105
105
|
)}
|
|
106
106
|
{/* Socials */}
|
|
107
107
|
{isIn.isSocialsIn && (
|
|
@@ -115,12 +115,22 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
|
|
|
115
115
|
<Actions>
|
|
116
116
|
{/* Search */}
|
|
117
117
|
<Search
|
|
118
|
+
Button={({ ...props }): JSX.Element =>
|
|
119
|
+
isIn.isMenuIn
|
|
120
|
+
? renderSearchIconButton(props)
|
|
121
|
+
: renderSearchButton(props)
|
|
122
|
+
}
|
|
118
123
|
closeMenu={onClose}
|
|
119
124
|
searchEnabled={searchEnabled}
|
|
120
125
|
searchURL={searchURL}
|
|
121
126
|
/>
|
|
122
127
|
{/* Authentication */}
|
|
123
128
|
<Authentication
|
|
129
|
+
Button={({ ...props }): JSX.Element =>
|
|
130
|
+
isIn.isMenuIn
|
|
131
|
+
? renderAuthenticationIconButton(props)
|
|
132
|
+
: renderAuthenticationButton(props)
|
|
133
|
+
}
|
|
124
134
|
authenticationEnabled={authenticationEnabled}
|
|
125
135
|
closeMenu={onClose}
|
|
126
136
|
/>
|
|
@@ -130,6 +140,7 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
|
|
|
130
140
|
<Menu
|
|
131
141
|
{...navigationProps}
|
|
132
142
|
closeMenu={onClose}
|
|
143
|
+
isMenuIn={isIn.isMenuIn}
|
|
133
144
|
open={open}
|
|
134
145
|
openMenu={onOpen}
|
|
135
146
|
/>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useBreakpoint } from "../../../../../hooks/useBreakpoint";
|
|
2
|
+
import { getNavigationLinks } from "../common/utils";
|
|
3
|
+
import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
|
|
4
|
+
import { HeaderProps } from "../header";
|
|
5
|
+
|
|
6
|
+
export interface UseHeaderNavigation {
|
|
7
|
+
navigation: [NavLinkItem[], NavLinkItem[], NavLinkItem[]];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useHeaderNavigation = (
|
|
11
|
+
headerProps: HeaderProps
|
|
12
|
+
): UseHeaderNavigation => {
|
|
13
|
+
const { breakpoint } = useBreakpoint();
|
|
14
|
+
const { navigation: [navL, navC, navR] = [] } = headerProps;
|
|
15
|
+
const navItemsL = getNavigationLinks(navL, breakpoint);
|
|
16
|
+
const navItemsC = getNavigationLinks(navC, breakpoint);
|
|
17
|
+
const navItemsR = getNavigationLinks(navR, breakpoint);
|
|
18
|
+
return { navigation: [navItemsL, navItemsC, navItemsR] };
|
|
19
|
+
};
|
|
@@ -8,6 +8,7 @@ export interface UseHeaderVisibility {
|
|
|
8
8
|
isCenterNavigationIn: boolean;
|
|
9
9
|
isLeftGroupIn: boolean;
|
|
10
10
|
isLeftNavigationIn: boolean;
|
|
11
|
+
isMenuIn: boolean;
|
|
11
12
|
isRightGroupIn: boolean;
|
|
12
13
|
isRightNavigationIn: boolean;
|
|
13
14
|
isSloganIn: boolean;
|
|
@@ -23,7 +24,7 @@ export interface UseHeaderVisibility {
|
|
|
23
24
|
export const useHeaderVisibility = (
|
|
24
25
|
headerProps: HeaderProps
|
|
25
26
|
): UseHeaderVisibility => {
|
|
26
|
-
const { lgUp, mdUp } = useBreakpoint();
|
|
27
|
+
const { breakpoint, lgUp, mdUp, smDown, smUp } = useBreakpoint();
|
|
27
28
|
// Header configuration.
|
|
28
29
|
const {
|
|
29
30
|
actions,
|
|
@@ -34,19 +35,23 @@ export const useHeaderVisibility = (
|
|
|
34
35
|
slogan,
|
|
35
36
|
socialMedia,
|
|
36
37
|
} = headerProps;
|
|
38
|
+
// Breakpoint.
|
|
39
|
+
const hasBreakpoint = Boolean(breakpoint);
|
|
37
40
|
// Header content.
|
|
38
41
|
const hasActions = Boolean(actions);
|
|
39
42
|
const hasLogo = Boolean(logo);
|
|
40
|
-
const hasMenu =
|
|
41
|
-
const hasNavItemsC = Boolean(navItemsC);
|
|
42
|
-
const hasNavItemsL = Boolean(navItemsL);
|
|
43
|
-
const hasNavItemsR = Boolean(navItemsR);
|
|
43
|
+
const hasMenu = smDown;
|
|
44
|
+
const hasNavItemsC = Boolean(navItemsC && navItemsC.length > 0);
|
|
45
|
+
const hasNavItemsL = Boolean(navItemsL && navItemsL.length > 0);
|
|
46
|
+
const hasNavItemsR = Boolean(navItemsR && navItemsR.length > 0);
|
|
44
47
|
const hasSlogan = Boolean(slogan);
|
|
45
48
|
const hasSocials = Boolean(socialMedia);
|
|
46
49
|
// Determines header content visibility.
|
|
47
50
|
const isActionsIn =
|
|
48
|
-
hasActions || searchEnabled || authenticationEnabled || hasMenu
|
|
49
|
-
|
|
51
|
+
(hasActions || searchEnabled || authenticationEnabled || hasMenu) &&
|
|
52
|
+
hasBreakpoint;
|
|
53
|
+
const isNavigationIn = smUp;
|
|
54
|
+
const isMenuIn = hasMenu;
|
|
50
55
|
const isSloganIn = hasSlogan && mdUp;
|
|
51
56
|
const isSocialsIn = hasSocials && lgUp;
|
|
52
57
|
// Determines navigation visibility.
|
|
@@ -54,10 +59,9 @@ export const useHeaderVisibility = (
|
|
|
54
59
|
const isLeftNavigationIn = isNavigationIn && hasNavItemsL;
|
|
55
60
|
const isRightNavigationIn = isNavigationIn && hasNavItemsR;
|
|
56
61
|
// Determines group visibility.
|
|
57
|
-
const isLeftGroupIn = hasLogo ||
|
|
62
|
+
const isLeftGroupIn = hasLogo || isSloganIn || isLeftNavigationIn;
|
|
58
63
|
const isCenterGroupIn = isCenterNavigationIn;
|
|
59
64
|
const isRightGroupIn = isRightNavigationIn || isSocialsIn || isActionsIn;
|
|
60
|
-
|
|
61
65
|
return {
|
|
62
66
|
isIn: {
|
|
63
67
|
isActionsIn,
|
|
@@ -65,6 +69,7 @@ export const useHeaderVisibility = (
|
|
|
65
69
|
isCenterNavigationIn,
|
|
66
70
|
isLeftGroupIn,
|
|
67
71
|
isLeftNavigationIn,
|
|
72
|
+
isMenuIn,
|
|
68
73
|
isRightGroupIn,
|
|
69
74
|
isRightNavigationIn,
|
|
70
75
|
isSloganIn,
|
|
@@ -13,12 +13,12 @@ export interface UseMenu {
|
|
|
13
13
|
export const useMenu = (): UseMenu => {
|
|
14
14
|
const [open, setOpen] = useState<boolean>(false);
|
|
15
15
|
|
|
16
|
-
// Closes
|
|
16
|
+
// Closes menu.
|
|
17
17
|
const onClose = useCallback((): void => {
|
|
18
18
|
setOpen(false);
|
|
19
19
|
}, []);
|
|
20
20
|
|
|
21
|
-
// Opens
|
|
21
|
+
// Opens menu.
|
|
22
22
|
const onOpen = useCallback((): void => {
|
|
23
23
|
setOpen(true);
|
|
24
24
|
}, []);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvgIcon } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CustomSVGIconProps } from "../../common/entities";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Custom in-progress icon.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const InProgressIcon = ({
|
|
10
|
+
fontSize = "xsmall",
|
|
11
|
+
viewBox = "0 0 18 18",
|
|
12
|
+
...props /* Spread props to allow for Mui SvgIconProps specific prop overrides e.g. "htmlColor". */
|
|
13
|
+
}: CustomSVGIconProps): JSX.Element => {
|
|
14
|
+
return (
|
|
15
|
+
<SvgIcon fontSize={fontSize} viewBox={viewBox} {...props}>
|
|
16
|
+
<path
|
|
17
|
+
d="M9 16.5C7.9625 16.5 6.9875 16.3031 6.075 15.9094C5.1625 15.5156 4.36875 14.9812 3.69375 14.3062C3.01875 13.6312 2.48437 12.8375 2.09062 11.925C1.69687 11.0125 1.5 10.0375 1.5 9C1.5 7.9625 1.69687 6.9875 2.09062 6.075C2.48437 5.1625 3.01875 4.36875 3.69375 3.69375C4.36875 3.01875 5.1625 2.48437 6.075 2.09062C6.9875 1.69687 7.9625 1.5 9 1.5C10.0375 1.5 11.0125 1.69687 11.925 2.09062C12.8375 2.48437 13.6312 3.01875 14.3062 3.69375C14.9812 4.36875 15.5156 5.1625 15.9094 6.075C16.3031 6.9875 16.5 7.9625 16.5 9C16.5 10.0375 16.3031 11.0125 15.9094 11.925C15.5156 12.8375 14.9812 13.6312 14.3062 14.3062C13.6312 14.9812 12.8375 15.5156 11.925 15.9094C11.0125 16.3031 10.0375 16.5 9 16.5ZM9 15C9.8 15 10.5687 14.85 11.3062 14.55C12.0437 14.25 12.6937 13.8187 13.2562 13.2562L9 9V3C7.325 3 5.90625 3.58125 4.74375 4.74375C3.58125 5.90625 3 7.325 3 9C3 10.675 3.58125 12.0937 4.74375 13.2562C5.90625 14.4187 7.325 15 9 15Z"
|
|
18
|
+
fill="currentColor"
|
|
19
|
+
/>
|
|
20
|
+
</SvgIcon>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export interface UseDialog {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onOpen: () => void;
|
|
6
|
+
open: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Dialog functionality.
|
|
11
|
+
* @param isOpen - Open state (initial).
|
|
12
|
+
* @returns dialog functionality.
|
|
13
|
+
*/
|
|
14
|
+
export const useDialog = (isOpen = false): UseDialog => {
|
|
15
|
+
const [open, setOpen] = useState<boolean>(isOpen);
|
|
16
|
+
|
|
17
|
+
// Closes dialog.
|
|
18
|
+
const onClose = useCallback((): void => {
|
|
19
|
+
setOpen(false);
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
// Opens dialog
|
|
23
|
+
const onOpen = useCallback((): void => {
|
|
24
|
+
setOpen(true);
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return { onClose, onOpen, open };
|
|
28
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PopperProps as MPopperProps } from "@mui/material";
|
|
2
2
|
import { MouseEvent, useCallback, useMemo, useState } from "react";
|
|
3
3
|
|
|
4
|
-
export interface
|
|
5
|
-
anchorEl:
|
|
4
|
+
export interface UseMenu {
|
|
5
|
+
anchorEl: MPopperProps["anchorEl"];
|
|
6
6
|
onClose: () => void;
|
|
7
|
+
onDisableScrollLock: () => void;
|
|
8
|
+
onEnableScrollLock: () => void;
|
|
7
9
|
onOpen: (event: MouseEvent<HTMLElement>) => void;
|
|
8
10
|
onToggleOpen: (event: MouseEvent<HTMLElement>) => void;
|
|
9
11
|
open: boolean;
|
|
@@ -13,16 +15,26 @@ export interface UseMenuWithPosition {
|
|
|
13
15
|
* Menu functionality for menu dropdown, with menu position.
|
|
14
16
|
* @returns menu functionality.
|
|
15
17
|
*/
|
|
16
|
-
export const
|
|
17
|
-
const [anchorEl, setAnchorEl] = useState<
|
|
18
|
+
export const useMenu = (): UseMenu => {
|
|
19
|
+
const [anchorEl, setAnchorEl] = useState<MPopperProps["anchorEl"]>(null);
|
|
18
20
|
const open = useMemo(() => Boolean(anchorEl), [anchorEl]);
|
|
19
21
|
|
|
20
|
-
// Closes
|
|
22
|
+
// Closes menu.
|
|
21
23
|
const onClose = useCallback((): void => {
|
|
22
24
|
setAnchorEl(null);
|
|
23
25
|
}, []);
|
|
24
26
|
|
|
25
|
-
//
|
|
27
|
+
// Disables scroll lock.
|
|
28
|
+
const onDisableScrollLock = useCallback((): void => {
|
|
29
|
+
document.body.style.removeProperty("overflow");
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
// Enables scroll lock.
|
|
33
|
+
const onEnableScrollLock = useCallback((): void => {
|
|
34
|
+
document.body.style.setProperty("overflow", "hidden");
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
// Opens menu.
|
|
26
38
|
const onOpen = useCallback((event: MouseEvent<HTMLElement>): void => {
|
|
27
39
|
setAnchorEl(event.currentTarget);
|
|
28
40
|
}, []);
|
|
@@ -42,6 +54,8 @@ export const useMenuWithPosition = (): UseMenuWithPosition => {
|
|
|
42
54
|
return {
|
|
43
55
|
anchorEl,
|
|
44
56
|
onClose,
|
|
57
|
+
onDisableScrollLock,
|
|
58
|
+
onEnableScrollLock,
|
|
45
59
|
onOpen,
|
|
46
60
|
onToggleOpen,
|
|
47
61
|
open,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BREAKPOINT_FN_NAME, useBreakpointHelper } from "./useBreakpointHelper";
|
|
1
2
|
import {
|
|
2
3
|
UseCurrentBreakpoint,
|
|
3
4
|
useCurrentBreakpoint,
|
|
@@ -27,15 +28,15 @@ export const useBreakpoint = (): UseBreakpoint => {
|
|
|
27
28
|
const md = breakpoint === "md";
|
|
28
29
|
const lg = breakpoint === "lg";
|
|
29
30
|
// Current breakpoint, down.
|
|
30
|
-
const xsDown = xs;
|
|
31
|
-
const smDown =
|
|
32
|
-
const mdDown =
|
|
33
|
-
const lgDown =
|
|
31
|
+
const xsDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, "xs");
|
|
32
|
+
const smDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, "sm");
|
|
33
|
+
const mdDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, "md");
|
|
34
|
+
const lgDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, "lg");
|
|
34
35
|
// Current breakpoint, up.
|
|
35
|
-
const xsUp = xs
|
|
36
|
-
const smUp = sm
|
|
37
|
-
const mdUp = md
|
|
38
|
-
const lgUp = lg;
|
|
36
|
+
const xsUp = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, "xs");
|
|
37
|
+
const smUp = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, "sm");
|
|
38
|
+
const mdUp = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, "md");
|
|
39
|
+
const lgUp = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, "lg");
|
|
39
40
|
return {
|
|
40
41
|
breakpoint,
|
|
41
42
|
lg,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import styled from "@emotion/styled";
|
|
2
|
-
import { Button as MButton } from "@mui/material";
|
|
3
|
-
import { textBody500 } from "../../../../../../../../../../../../styles/common/mixins/fonts";
|
|
4
|
-
|
|
5
|
-
export const Button = styled(MButton)`
|
|
6
|
-
& {
|
|
7
|
-
${textBody500};
|
|
8
|
-
padding: 6px 12px;
|
|
9
|
-
}
|
|
10
|
-
`;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import LoginRoundedIcon from "@mui/icons-material/LoginRounded";
|
|
2
|
-
import { IconButton as MIconButton } from "@mui/material";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
|
|
5
|
-
import { Button } from "./requestAuthentication.styles";
|
|
6
|
-
|
|
7
|
-
export interface RequestAuthenticationProps {
|
|
8
|
-
closeMenu: () => void;
|
|
9
|
-
requestAuthorization: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const RequestAuthentication = ({
|
|
13
|
-
closeMenu,
|
|
14
|
-
requestAuthorization,
|
|
15
|
-
}: RequestAuthenticationProps): JSX.Element => {
|
|
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>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import styled from "@emotion/styled";
|
|
2
|
-
import { Button as MButton } from "@mui/material";
|
|
3
|
-
import { textBody500 } from "../../../../../../../../../../../../styles/common/mixins/fonts";
|
|
4
|
-
|
|
5
|
-
export const Button = styled(MButton)`
|
|
6
|
-
& {
|
|
7
|
-
${textBody500};
|
|
8
|
-
padding: 6px 12px;
|
|
9
|
-
}
|
|
10
|
-
`;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { IconButton } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
|
|
4
|
-
import { SearchIcon } from "../../../../../../../../../../../common/CustomIcon/components/SearchIcon/searchIcon";
|
|
5
|
-
import { Button } from "./searchButton.styles";
|
|
6
|
-
|
|
7
|
-
export interface SearchProps {
|
|
8
|
-
openSearch: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const SearchButton = ({ openSearch }: SearchProps): JSX.Element => {
|
|
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>
|
|
21
|
-
);
|
|
22
|
-
};
|