@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UseCurrentBreakpoint } from "./useCurrentBreakpoint";
|
|
2
|
+
export declare type UseBreakpoint = {
|
|
3
|
+
breakpoint?: UseCurrentBreakpoint;
|
|
4
|
+
lg: boolean;
|
|
5
|
+
lgDown: boolean;
|
|
6
|
+
lgUp: boolean;
|
|
7
|
+
md: boolean;
|
|
8
|
+
mdDown: boolean;
|
|
9
|
+
mdUp: boolean;
|
|
10
|
+
sm: boolean;
|
|
11
|
+
smDown: boolean;
|
|
12
|
+
smUp: boolean;
|
|
13
|
+
xs: boolean;
|
|
14
|
+
xsDown: boolean;
|
|
15
|
+
xsUp: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const useBreakpoint: () => UseBreakpoint;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useCurrentBreakpoint, } from "./useCurrentBreakpoint";
|
|
2
|
+
export const useBreakpoint = () => {
|
|
3
|
+
const breakpoint = useCurrentBreakpoint();
|
|
4
|
+
// Current breakpoint.
|
|
5
|
+
const xs = breakpoint === "xs";
|
|
6
|
+
const sm = breakpoint === "sm";
|
|
7
|
+
const md = breakpoint === "md";
|
|
8
|
+
const lg = breakpoint === "lg";
|
|
9
|
+
// Current breakpoint, down.
|
|
10
|
+
const xsDown = xs;
|
|
11
|
+
const smDown = xs || sm;
|
|
12
|
+
const mdDown = xs || sm || md;
|
|
13
|
+
const lgDown = xs || sm || md || lg;
|
|
14
|
+
// Current breakpoint, up.
|
|
15
|
+
const xsUp = xs || sm || md || lg;
|
|
16
|
+
const smUp = sm || md || lg;
|
|
17
|
+
const mdUp = md || lg;
|
|
18
|
+
const lgUp = lg;
|
|
19
|
+
return {
|
|
20
|
+
breakpoint,
|
|
21
|
+
lg,
|
|
22
|
+
lgDown,
|
|
23
|
+
lgUp,
|
|
24
|
+
md,
|
|
25
|
+
mdDown,
|
|
26
|
+
mdUp,
|
|
27
|
+
sm,
|
|
28
|
+
smDown,
|
|
29
|
+
smUp,
|
|
30
|
+
xs,
|
|
31
|
+
xsDown,
|
|
32
|
+
xsUp,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -9,6 +9,6 @@ export declare enum BREAKPOINT_FN_NAME {
|
|
|
9
9
|
UP = "up"
|
|
10
10
|
}
|
|
11
11
|
declare type BreakpointFnName = BREAKPOINT_FN_NAME;
|
|
12
|
-
declare type BreakpointKey = Breakpoint;
|
|
12
|
+
export declare type BreakpointKey = Breakpoint;
|
|
13
13
|
export declare const useBreakpointHelper: (fnName: BreakpointFnName, breakpointKey: BreakpointKey) => boolean;
|
|
14
14
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "./useBreakpointHelper";
|
|
3
|
+
const breakpointKeys = ["xs", "sm", "md", "lg"];
|
|
4
|
+
export const useCurrentBreakpoint = () => {
|
|
5
|
+
const xs = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "xs");
|
|
6
|
+
const sm = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "sm");
|
|
7
|
+
const md = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "md");
|
|
8
|
+
const lg = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "lg");
|
|
9
|
+
const breakpoints = useMemo(() => ({ lg, md, sm, xs }), [lg, md, sm, xs]);
|
|
10
|
+
return breakpointKeys.find((key) => breakpoints[key]);
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Menu functionality for menu dropdown.
|
|
4
|
+
* @returns menu functionality.
|
|
5
|
+
*/
|
|
6
|
+
export const useMenu = () => {
|
|
7
|
+
const [open, setOpen] = useState(false);
|
|
8
|
+
// Closes header menu.
|
|
9
|
+
const onClose = useCallback(() => {
|
|
10
|
+
setOpen(false);
|
|
11
|
+
}, []);
|
|
12
|
+
// Opens header menu.
|
|
13
|
+
const onOpen = useCallback(() => {
|
|
14
|
+
setOpen(true);
|
|
15
|
+
}, []);
|
|
16
|
+
return { onClose, onOpen, open };
|
|
17
|
+
};
|
|
@@ -383,6 +383,23 @@ export const MuiButton = (theme) => {
|
|
|
383
383
|
},
|
|
384
384
|
},
|
|
385
385
|
variants: [
|
|
386
|
+
{
|
|
387
|
+
props: {
|
|
388
|
+
variant: "activeNav", // associated with "nav" variant.
|
|
389
|
+
},
|
|
390
|
+
style: {
|
|
391
|
+
...theme.typography[TEXT_BODY_500],
|
|
392
|
+
backgroundColor: theme.palette.smoke.light,
|
|
393
|
+
color: theme.palette.ink.main,
|
|
394
|
+
minWidth: 0,
|
|
395
|
+
textTransform: "capitalize",
|
|
396
|
+
whiteSpace: "nowrap",
|
|
397
|
+
// eslint-disable-next-line sort-keys -- disabling key order for readability
|
|
398
|
+
"&:hover": {
|
|
399
|
+
backgroundColor: theme.palette.smoke.light,
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
},
|
|
386
403
|
{
|
|
387
404
|
props: {
|
|
388
405
|
variant: "nav",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { useRouter } from "next/router";
|
|
2
1
|
import React, { useEffect, useMemo, useState } from "react";
|
|
3
2
|
import { track } from "../../common/analytics/analytics";
|
|
4
3
|
import { EVENT_NAME, EVENT_PARAM } from "../../common/analytics/entities";
|
|
5
|
-
import { Tabs } from "../../components/common/Tabs/tabs";
|
|
6
4
|
import { ComponentCreator } from "../../components/ComponentCreator/ComponentCreator";
|
|
7
5
|
import { ClearAllFilters } from "../../components/Filter/components/ClearAllFilters/clearAllFilters";
|
|
8
6
|
import { Filters, } from "../../components/Filter/components/Filters/filters";
|
|
9
7
|
import { SearchAllFilters } from "../../components/Filter/components/SearchAllFilters/searchAllFilters";
|
|
8
|
+
import { Tabs } from "../../components/Index/components/Tabs/tabs";
|
|
10
9
|
import { Index as IndexView } from "../../components/Index/index";
|
|
11
10
|
import { SidebarButton } from "../../components/Layout/components/Sidebar/components/SidebarButton/sidebarButton";
|
|
12
11
|
import { SidebarLabel } from "../../components/Layout/components/Sidebar/components/SidebarLabel/sidebarLabel";
|
|
@@ -21,30 +20,15 @@ import { useSummary } from "../../hooks/useSummary";
|
|
|
21
20
|
import { ExploreActionKind } from "../../providers/exploreState";
|
|
22
21
|
import { SELECT_CATEGORY_KEY } from "../../providers/exploreState/constants";
|
|
23
22
|
import { DESKTOP_SM } from "../../theme/common/breakpoints";
|
|
24
|
-
/**
|
|
25
|
-
* Returns tabs to be used as a prop for the Tabs component.
|
|
26
|
-
* @param entities - Entities config.
|
|
27
|
-
* @returns tabs list.
|
|
28
|
-
*/
|
|
29
|
-
function getTabs(entities) {
|
|
30
|
-
return entities.map(({ label, route, tabIcon: icon, tabIconPosition: iconPosition }) => ({
|
|
31
|
-
icon,
|
|
32
|
-
iconPosition,
|
|
33
|
-
label,
|
|
34
|
-
value: route,
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
23
|
export const ExploreView = (props) => {
|
|
38
24
|
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
|
39
25
|
const tabletDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, DESKTOP_SM);
|
|
40
26
|
const { config, entityConfig } = useConfig(); // Get app level config.
|
|
41
27
|
const { exploreDispatch, exploreState } = useExploreState(); // Get the useReducer state and dispatch for "Explore".
|
|
42
|
-
const {
|
|
28
|
+
const { explorerTitle, summaryConfig, trackingConfig } = config;
|
|
43
29
|
const { listView } = entityConfig;
|
|
44
30
|
const { listHero, subTitleHero } = listView || {};
|
|
45
|
-
const { categoryGroups, categoryViews, filterCount
|
|
46
|
-
const { push } = useRouter();
|
|
47
|
-
const tabs = getTabs(entities);
|
|
31
|
+
const { categoryGroups, categoryViews, filterCount } = exploreState;
|
|
48
32
|
const { response: summaryResponse } = useSummary(); // Fetch summary.
|
|
49
33
|
useEntityList(props); // Fetch entities.
|
|
50
34
|
const { entityListType } = props;
|
|
@@ -98,15 +82,6 @@ export const ExploreView = (props) => {
|
|
|
98
82
|
const onOpenDrawer = () => {
|
|
99
83
|
setIsDrawerOpen(true);
|
|
100
84
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Callback fired when selected tab value changes.
|
|
103
|
-
* - Sets state tabsValue to selected tab value.
|
|
104
|
-
* - Executes a pushState and resets pagination.
|
|
105
|
-
* @param tabValue - Selected tab value.
|
|
106
|
-
*/
|
|
107
|
-
const onTabChange = (tabValue) => {
|
|
108
|
-
push(`/${tabValue}`);
|
|
109
|
-
};
|
|
110
85
|
/**
|
|
111
86
|
* Dispatch a SelectedEntityType action when entityListType changes.
|
|
112
87
|
*/
|
|
@@ -128,7 +103,7 @@ export const ExploreView = (props) => {
|
|
|
128
103
|
React.createElement(ClearAllFilters, null),
|
|
129
104
|
React.createElement(SearchAllFilters, { categoryViews: categoryViews, drawerOpen: isDrawerOpen, onFilter: onFilterChange.bind(null, true) })),
|
|
130
105
|
React.createElement(Filters, { categoryFilters: categoryFilters, closeAncestor: onCloseDrawer, onFilter: onFilterChange.bind(null, false), trackFilterOpened: trackingConfig?.trackFilterOpened }))),
|
|
131
|
-
React.createElement(IndexView, { className: props.className, List: renderList(exploreState, entityConfig, entityListType), ListHero: renderComponent(listHero), SideBarButton: tabletDown ? (React.createElement(SidebarButton, { count: filterCount, label: "Filter", onClick: onOpenDrawer })) : undefined, SubTitleHero: renderComponent(subTitleHero), Summaries: renderSummary(summaryConfig, summaryResponse), Tabs: React.createElement(Tabs,
|
|
106
|
+
React.createElement(IndexView, { className: props.className, List: renderList(exploreState, entityConfig, entityListType), ListHero: renderComponent(listHero), SideBarButton: tabletDown ? (React.createElement(SidebarButton, { count: filterCount, label: "Filter", onClick: onOpenDrawer })) : undefined, SubTitleHero: renderComponent(subTitleHero), Summaries: renderSummary(summaryConfig, summaryResponse), Tabs: React.createElement(Tabs, null), title: entityConfig.explorerTitle || explorerTitle })));
|
|
132
107
|
};
|
|
133
108
|
/**
|
|
134
109
|
* Builds the category views into category views grouped by the given category group configuration.
|
package/package.json
CHANGED
package/src/common/entities.ts
CHANGED
|
@@ -17,17 +17,6 @@ export interface CategoryTag {
|
|
|
17
17
|
*/
|
|
18
18
|
export type CategoryValueKey = string;
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Element alignment.
|
|
22
|
-
*/
|
|
23
|
-
export enum ELEMENT_ALIGNMENT {
|
|
24
|
-
CENTER = "CENTER",
|
|
25
|
-
LEFT = "LEFT",
|
|
26
|
-
RIGHT = "RIGHT",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type ElementAlignment = ELEMENT_ALIGNMENT;
|
|
30
|
-
|
|
31
20
|
/**
|
|
32
21
|
* Set of selected category values.
|
|
33
22
|
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EntityConfig } from "../../../../../config/entities";
|
|
2
|
+
import { Tab } from "../../../../common/Tabs/tabs";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns entity list tabs list for the tabs component.
|
|
6
|
+
* @param entities - Entities config.
|
|
7
|
+
* @returns tabs list.
|
|
8
|
+
*/
|
|
9
|
+
export function getEntityListTabs(entities: EntityConfig[]): Tab[] {
|
|
10
|
+
return entities.reduce(
|
|
11
|
+
(
|
|
12
|
+
acc: Tab[],
|
|
13
|
+
{
|
|
14
|
+
label,
|
|
15
|
+
listView: { enableTab = true } = {},
|
|
16
|
+
route,
|
|
17
|
+
tabIcon: icon,
|
|
18
|
+
tabIconPosition: iconPosition,
|
|
19
|
+
}
|
|
20
|
+
) => {
|
|
21
|
+
if (enableTab) {
|
|
22
|
+
acc.push({
|
|
23
|
+
icon,
|
|
24
|
+
iconPosition,
|
|
25
|
+
label,
|
|
26
|
+
value: route,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return acc;
|
|
30
|
+
},
|
|
31
|
+
[]
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Router from "next/router";
|
|
2
|
+
import React, { useCallback, useMemo } from "react";
|
|
3
|
+
import { useConfig } from "../../../../hooks/useConfig";
|
|
4
|
+
import { useExploreState } from "../../../../hooks/useExploreState";
|
|
5
|
+
import { Tabs as DXTabs, TabValue } from "../../../common/Tabs/tabs";
|
|
6
|
+
import { getEntityListTabs } from "./common/utils";
|
|
7
|
+
|
|
8
|
+
export const Tabs = (): JSX.Element | null => {
|
|
9
|
+
const { config } = useConfig();
|
|
10
|
+
const { exploreState } = useExploreState();
|
|
11
|
+
const { entities } = config;
|
|
12
|
+
const { tabValue } = exploreState;
|
|
13
|
+
const tabs = useMemo(() => getEntityListTabs(entities), [entities]);
|
|
14
|
+
|
|
15
|
+
// Callback fired when selected tab value changes.
|
|
16
|
+
const onTabChange = useCallback(async (tabValue: TabValue): Promise<void> => {
|
|
17
|
+
await Router.push(`/${tabValue}`);
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
if (tabs.length <= 1) return null;
|
|
21
|
+
|
|
22
|
+
return <DXTabs onTabChange={onTabChange} tabs={tabs} value={tabValue} />;
|
|
23
|
+
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
AppBarProps as MAppBarProps,
|
|
3
|
+
ToolbarProps as MToolbarProps,
|
|
4
|
+
} from "@mui/material";
|
|
3
5
|
|
|
4
|
-
export const
|
|
5
|
-
timeout: HEADER_FADE_TIMEOUT,
|
|
6
|
-
unmountOnExit: true,
|
|
7
|
-
};
|
|
6
|
+
export const HEADER_HEIGHT = 56;
|
|
8
7
|
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export const APP_BAR_PROPS: Partial<MAppBarProps> = {
|
|
9
|
+
elevation: 1,
|
|
10
|
+
position: "fixed",
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
export const
|
|
13
|
+
export const FADE_TRANSITION_PROPS = {
|
|
14
|
+
appear: false,
|
|
15
15
|
timeout: 0,
|
|
16
16
|
unmountOnExit: true,
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
export const TOOLBAR_PROPS: Partial<MToolbarProps> = {
|
|
20
|
+
variant: "dense",
|
|
21
|
+
};
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { Social } from "../../../../common/Socials/socials";
|
|
3
|
+
import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
|
|
4
|
+
|
|
5
|
+
export type Navigation = [
|
|
6
|
+
NavLinkItem[] | undefined,
|
|
7
|
+
NavLinkItem[] | undefined,
|
|
8
|
+
NavLinkItem[] | undefined
|
|
9
|
+
]; // [LEFT, CENTER, RIGHT]
|
|
3
10
|
|
|
4
11
|
export interface SocialMedia {
|
|
5
12
|
label: ReactNode;
|
|
@@ -1,84 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RenderComponent } from "../../../../ComponentCreator/components/RenderComponent/renderComponent";
|
|
3
|
-
import { ANCHOR_TARGET } from "../../../../Links/common/entities";
|
|
4
|
-
import { MenuItem } from "../components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems";
|
|
1
|
+
import { Breakpoint } from "@mui/material";
|
|
5
2
|
import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
|
|
6
|
-
import {
|
|
7
|
-
import { SocialMedia } from "./entities";
|
|
3
|
+
import { Navigation } from "./entities";
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
|
-
* Returns the navigation links
|
|
11
|
-
* @param
|
|
12
|
-
* @
|
|
6
|
+
* Returns the configured menu navigation links, for the current breakpoint.
|
|
7
|
+
* @param navigation - Navigation links.
|
|
8
|
+
* @param breakpoint - Current breakpoint.
|
|
9
|
+
* @returns navigation links.
|
|
13
10
|
*/
|
|
14
|
-
export function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export function getMenuNavigationLinks(
|
|
12
|
+
navigation?: Navigation,
|
|
13
|
+
breakpoint?: Breakpoint
|
|
14
|
+
): NavLinkItem[] {
|
|
15
|
+
if (!navigation) return [];
|
|
16
|
+
const navLinkItems = navigation.reduce((acc: NavLinkItem[], navLinkItems) => {
|
|
17
|
+
if (!navLinkItems) return acc;
|
|
18
|
+
acc.push(...navLinkItems);
|
|
19
|
+
return acc;
|
|
20
|
+
}, []);
|
|
21
|
+
return getNavigationLinks(navLinkItems, breakpoint);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns configured navigation links, for the current breakpoint.
|
|
26
|
+
* @param navigationLinks - Navigation links.
|
|
27
|
+
* @param breakpoint - Current breakpoint.
|
|
28
|
+
* @returns navigation links.
|
|
29
|
+
*/
|
|
30
|
+
export function getNavigationLinks(
|
|
31
|
+
navigationLinks?: NavLinkItem[],
|
|
32
|
+
breakpoint?: Breakpoint
|
|
33
|
+
): NavLinkItem[] {
|
|
34
|
+
if (!navigationLinks) return [];
|
|
35
|
+
return navigationLinks.reduce(
|
|
36
|
+
(acc: NavLinkItem[], navLinkItem: NavLinkItem) => {
|
|
37
|
+
const processedNavLink = processNavLinkItem(navLinkItem, breakpoint);
|
|
38
|
+
if (processedNavLink) {
|
|
39
|
+
acc.push(...processedNavLink);
|
|
19
40
|
}
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
return acc;
|
|
42
|
+
},
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
24
45
|
}
|
|
25
46
|
|
|
26
47
|
/**
|
|
27
|
-
* Returns
|
|
28
|
-
* @param
|
|
29
|
-
* @
|
|
48
|
+
* Returns true if the link is flattened at the current breakpoint.
|
|
49
|
+
* @param navLinkItem - Navigation link.
|
|
50
|
+
* @param breakpoint - Current breakpoint.
|
|
51
|
+
* @returns true if the link is flattened.
|
|
30
52
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
function isLinkFlattened(
|
|
54
|
+
navLinkItem: NavLinkItem,
|
|
55
|
+
breakpoint?: Breakpoint
|
|
56
|
+
): boolean {
|
|
57
|
+
if (!breakpoint) return false; // Default is not flattened.
|
|
58
|
+
if (!navLinkItem.flatten) return false; // Default is not flattened.
|
|
59
|
+
return navLinkItem.flatten[breakpoint] === true;
|
|
38
60
|
}
|
|
39
61
|
|
|
40
62
|
/**
|
|
41
|
-
* Returns
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @
|
|
45
|
-
* @returns header navigation links.
|
|
63
|
+
* Returns true if the link is visible at the current breakpoint.
|
|
64
|
+
* @param navLinkItem - Navigation link.
|
|
65
|
+
* @param breakpoint - Current breakpoint.
|
|
66
|
+
* @returns true if the link is visible.
|
|
46
67
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
if (socialMedia) {
|
|
55
|
-
navLinks.push({
|
|
56
|
-
label: socialMedia.label,
|
|
57
|
-
menuItems: getFollowUsMenuItems(socialMedia.socials),
|
|
58
|
-
url: "",
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return navLinks;
|
|
62
|
-
}
|
|
63
|
-
// Return the links without the "More" or "Follow Us" menu.
|
|
64
|
-
return flattenMoreLink(links);
|
|
68
|
+
function isLinkVisible(
|
|
69
|
+
navLinkItem: NavLinkItem,
|
|
70
|
+
breakpoint?: Breakpoint
|
|
71
|
+
): boolean {
|
|
72
|
+
if (!breakpoint) return true; // Default is visible.
|
|
73
|
+
if (!navLinkItem.visible) return true; // Default is visible.
|
|
74
|
+
return navLinkItem.visible[breakpoint] !== false;
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
/**
|
|
68
|
-
* Returns
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
78
|
+
* Returns the processed navigation link item.
|
|
79
|
+
* Flattens menu items, and removes items that are not visible for the current breakpoint.
|
|
80
|
+
* @param navLinkItem - Navigation link.
|
|
81
|
+
* @param breakpoint - Current breakpoint.
|
|
82
|
+
* @returns processed navigation link item.
|
|
71
83
|
*/
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
function processNavLinkItem(
|
|
85
|
+
navLinkItem: NavLinkItem,
|
|
86
|
+
breakpoint?: Breakpoint
|
|
87
|
+
): NavLinkItem[] | undefined {
|
|
88
|
+
if (isLinkVisible(navLinkItem, breakpoint)) {
|
|
89
|
+
const cloneLink = { ...navLinkItem };
|
|
90
|
+
// Recursively process menu items.
|
|
91
|
+
if (cloneLink.menuItems) {
|
|
92
|
+
const menuItems = getNavigationLinks(navLinkItem.menuItems, breakpoint);
|
|
93
|
+
// Remove menu items if empty.
|
|
94
|
+
if (menuItems.length === 0) {
|
|
95
|
+
delete cloneLink.menuItems;
|
|
96
|
+
} else {
|
|
97
|
+
// Flatten the menu items if the navigation is flattened.
|
|
98
|
+
if (isLinkFlattened(cloneLink, breakpoint)) {
|
|
99
|
+
return menuItems;
|
|
100
|
+
} else {
|
|
101
|
+
cloneLink.menuItems = menuItems;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return [cloneLink];
|
|
106
|
+
}
|
|
84
107
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ComponentsConfig } from "../../../../../../config/entities";
|
|
3
|
+
import { ComponentCreator } from "../../../../../ComponentCreator/ComponentCreator";
|
|
4
|
+
|
|
5
|
+
export interface AnnouncementsProps {
|
|
6
|
+
announcements?: ComponentsConfig;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const Announcements = ({
|
|
10
|
+
announcements,
|
|
11
|
+
}: AnnouncementsProps): JSX.Element | null => {
|
|
12
|
+
if (!announcements) return null;
|
|
13
|
+
return <ComponentCreator components={announcements} response={{}} />;
|
|
14
|
+
};
|
package/src/components/Layout/components/Header/components/Content/components/Actions/actions.tsx
CHANGED
|
@@ -3,12 +3,8 @@ import { HeaderActions } from "./actions.styles";
|
|
|
3
3
|
|
|
4
4
|
export interface ActionsProps {
|
|
5
5
|
children: ReactNode | ReactNode[];
|
|
6
|
-
showActions?: boolean;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
export const Actions = ({
|
|
10
|
-
children
|
|
11
|
-
showActions = true,
|
|
12
|
-
}: ActionsProps): JSX.Element => {
|
|
13
|
-
return <>{showActions && <HeaderActions>{children}</HeaderActions>}</>;
|
|
8
|
+
export const Actions = ({ children }: ActionsProps): JSX.Element => {
|
|
9
|
+
return <HeaderActions>{children}</HeaderActions>;
|
|
14
10
|
};
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import LoginRoundedIcon from "@mui/icons-material/LoginRounded";
|
|
2
|
-
import {
|
|
2
|
+
import { IconButton as MIconButton } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
5
|
-
BREAKPOINT_FN_NAME,
|
|
6
|
-
useBreakpointHelper,
|
|
7
|
-
} from "../../../../../../../../../../../../hooks/useBreakpointHelper";
|
|
8
|
-
import { DESKTOP_SM } from "../../../../../../../../../../../../theme/common/breakpoints";
|
|
9
|
-
import { SWITCH_TRANSITION_PROPS } from "../../../../../../../../common/constants";
|
|
4
|
+
import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
|
|
10
5
|
import { Button } from "./requestAuthentication.styles";
|
|
11
6
|
|
|
12
7
|
export interface RequestAuthenticationProps {
|
|
@@ -18,30 +13,24 @@ export const RequestAuthentication = ({
|
|
|
18
13
|
closeMenu,
|
|
19
14
|
requestAuthorization,
|
|
20
15
|
}: RequestAuthenticationProps): JSX.Element => {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
<LoginRoundedIcon />
|
|
43
|
-
</IconButton>
|
|
44
|
-
</Fade>
|
|
45
|
-
</>
|
|
16
|
+
const { mdUp } = useBreakpoint();
|
|
17
|
+
return mdUp ? (
|
|
18
|
+
<Button
|
|
19
|
+
onClick={requestAuthorization}
|
|
20
|
+
startIcon={<LoginRoundedIcon />}
|
|
21
|
+
variant="nav"
|
|
22
|
+
>
|
|
23
|
+
Sign in
|
|
24
|
+
</Button>
|
|
25
|
+
) : (
|
|
26
|
+
<MIconButton
|
|
27
|
+
color="ink"
|
|
28
|
+
onClick={(): void => {
|
|
29
|
+
closeMenu();
|
|
30
|
+
requestAuthorization();
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<LoginRoundedIcon />
|
|
34
|
+
</MIconButton>
|
|
46
35
|
);
|
|
47
36
|
};
|
|
@@ -13,6 +13,7 @@ export const Navigation = styled(DXNavigation)`
|
|
|
13
13
|
margin: 0;
|
|
14
14
|
justify-content: flex-start;
|
|
15
15
|
|
|
16
|
+
.MuiButton-activeNav,
|
|
16
17
|
.MuiButton-nav {
|
|
17
18
|
${textBodyLarge500};
|
|
18
19
|
justify-content: space-between;
|
|
@@ -27,6 +28,7 @@ export const Navigation = styled(DXNavigation)`
|
|
|
27
28
|
export const DrawerNavigation = styled(Navigation)`
|
|
28
29
|
gap: 0;
|
|
29
30
|
|
|
31
|
+
.MuiButton-activeNav,
|
|
30
32
|
.MuiButton-nav {
|
|
31
33
|
${textBody500};
|
|
32
34
|
padding: 14px 24px;
|