@jpmorganchase/mosaic-layouts 0.1.0-beta.9
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/.turbo/turbo-build.log +4 -0
- package/README.md +39 -0
- package/dist/Fade.d.ts +11 -0
- package/dist/Fade.js +1 -0
- package/dist/LayoutBase/index.css +1 -0
- package/dist/LayoutBase/index.d.ts +6 -0
- package/dist/LayoutBase/index.js +1 -0
- package/dist/LayoutBase/styles.css.css +1 -0
- package/dist/LayoutBase/styles.css.d.ts +8 -0
- package/dist/LayoutBase/styles.css.js +1 -0
- package/dist/LayoutColumns/index.css +1 -0
- package/dist/LayoutColumns/index.d.ts +7 -0
- package/dist/LayoutColumns/index.js +1 -0
- package/dist/LayoutColumns/styles.css.css +1 -0
- package/dist/LayoutColumns/styles.css.d.ts +9 -0
- package/dist/LayoutColumns/styles.css.js +1 -0
- package/dist/LayoutConfigProvider/index.d.ts +6 -0
- package/dist/LayoutConfigProvider/index.js +1 -0
- package/dist/LayoutFullWidth/index.css +1 -0
- package/dist/LayoutFullWidth/index.d.ts +7 -0
- package/dist/LayoutFullWidth/index.js +1 -0
- package/dist/LayoutFullWidth/styles.css.css +1 -0
- package/dist/LayoutFullWidth/styles.css.d.ts +4 -0
- package/dist/LayoutFullWidth/styles.css.js +1 -0
- package/dist/LayoutProvider.css +1 -0
- package/dist/LayoutProvider.d.ts +10 -0
- package/dist/LayoutProvider.js +1 -0
- package/dist/Sidebars/Drawer.css +1 -0
- package/dist/Sidebars/Drawer.d.ts +5 -0
- package/dist/Sidebars/Drawer.js +1 -0
- package/dist/Sidebars/SidebarLeft.css +1 -0
- package/dist/Sidebars/SidebarLeft.d.ts +5 -0
- package/dist/Sidebars/SidebarLeft.js +1 -0
- package/dist/Sidebars/SidebarRight.css +1 -0
- package/dist/Sidebars/SidebarRight.d.ts +5 -0
- package/dist/Sidebars/SidebarRight.js +1 -0
- package/dist/Sidebars/index.css +1 -0
- package/dist/Sidebars/index.d.ts +2 -0
- package/dist/Sidebars/index.js +1 -0
- package/dist/Sidebars/styles.css.css +1 -0
- package/dist/Sidebars/styles.css.d.ts +13 -0
- package/dist/Sidebars/styles.css.js +1 -0
- package/dist/chunk-2Y7E2F4F.js +1 -0
- package/dist/chunk-365SCIKJ.js +1 -0
- package/dist/chunk-475WQFFV.js +0 -0
- package/dist/chunk-53T3BYR6.js +1 -0
- package/dist/chunk-5CMT2ZB7.js +1 -0
- package/dist/chunk-5UCWV6EJ.js +21 -0
- package/dist/chunk-6OVRDMTN.js +1 -0
- package/dist/chunk-7UEIPZZD.js +1 -0
- package/dist/chunk-B4T3CMOF.js +1 -0
- package/dist/chunk-BIWHBDPI.js +1 -0
- package/dist/chunk-BJ6T7WZV.js +1 -0
- package/dist/chunk-CQGMVPED.js +1 -0
- package/dist/chunk-DE36TWIF.js +1 -0
- package/dist/chunk-DQ7NCUDO.js +1 -0
- package/dist/chunk-DTW4UURD.js +1 -0
- package/dist/chunk-EHVQUK5M.js +1 -0
- package/dist/chunk-FTBY4K3Z.js +1 -0
- package/dist/chunk-H3KZTXVJ.js +1 -0
- package/dist/chunk-HANSMKYF.js +1 -0
- package/dist/chunk-IBOB6W4E.js +1 -0
- package/dist/chunk-IYWRLYME.js +1 -0
- package/dist/chunk-NDZQ5OZP.js +0 -0
- package/dist/chunk-OGKKALEL.js +1 -0
- package/dist/chunk-P34YRBM6.js +1 -0
- package/dist/chunk-PKAR7XZI.js +0 -0
- package/dist/chunk-PL34I4WI.js +1 -0
- package/dist/chunk-PL5OYTQO.js +1 -0
- package/dist/chunk-PNBJEM6G.js +1 -0
- package/dist/chunk-Q4PDOZVB.js +1 -0
- package/dist/chunk-RSL4VOEW.js +1 -0
- package/dist/chunk-RWSFNK3E.js +1 -0
- package/dist/chunk-TG7BCCJ4.js +1 -0
- package/dist/chunk-UA3BLLVS.js +1 -0
- package/dist/chunk-UAKGMBD2.js +1 -0
- package/dist/chunk-ULGDXPWY.js +1 -0
- package/dist/chunk-X2LSXOCH.js +1 -0
- package/dist/chunk-XSGX6KV2.js +1 -0
- package/dist/chunk-XVK33OXS.js +1 -0
- package/dist/chunk-ZXI72DLC.js +1 -0
- package/dist/hooks/useIsLoading.d.ts +6 -0
- package/dist/hooks/useIsLoading.js +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -0
- package/dist/layouts/App/index.css +1 -0
- package/dist/layouts/App/index.d.ts +3 -0
- package/dist/layouts/App/index.js +1 -0
- package/dist/layouts/App/styles.css.css +1 -0
- package/dist/layouts/App/styles.css.d.ts +4 -0
- package/dist/layouts/App/styles.css.js +1 -0
- package/dist/layouts/Detail/DetailContentOnly.css +1 -0
- package/dist/layouts/Detail/DetailContentOnly.d.ts +3 -0
- package/dist/layouts/Detail/DetailContentOnly.js +1 -0
- package/dist/layouts/Detail/DetailHighlight.css +1 -0
- package/dist/layouts/Detail/DetailHighlight.d.ts +3 -0
- package/dist/layouts/Detail/DetailHighlight.js +1 -0
- package/dist/layouts/Detail/DetailOverview.css +1 -0
- package/dist/layouts/Detail/DetailOverview.d.ts +3 -0
- package/dist/layouts/Detail/DetailOverview.js +1 -0
- package/dist/layouts/Detail/DetailTechnical.css +1 -0
- package/dist/layouts/Detail/DetailTechnical.d.ts +3 -0
- package/dist/layouts/Detail/DetailTechnical.js +1 -0
- package/dist/layouts/Detail/index.css +1 -0
- package/dist/layouts/Detail/index.d.ts +4 -0
- package/dist/layouts/Detail/index.js +1 -0
- package/dist/layouts/Detail/styles.css.css +1 -0
- package/dist/layouts/Detail/styles.css.d.ts +4 -0
- package/dist/layouts/Detail/styles.css.js +1 -0
- package/dist/layouts/Edit/index.css +1 -0
- package/dist/layouts/Edit/index.d.ts +3 -0
- package/dist/layouts/Edit/index.js +1 -0
- package/dist/layouts/Edit/styles.css.css +1 -0
- package/dist/layouts/Edit/styles.css.d.ts +5 -0
- package/dist/layouts/Edit/styles.css.js +1 -0
- package/dist/layouts/FullWidth/index.css +1 -0
- package/dist/layouts/FullWidth/index.d.ts +3 -0
- package/dist/layouts/FullWidth/index.js +1 -0
- package/dist/layouts/Landing/index.css +1 -0
- package/dist/layouts/Landing/index.d.ts +3 -0
- package/dist/layouts/Landing/index.js +1 -0
- package/dist/layouts/Newsletter/index.css +1 -0
- package/dist/layouts/Newsletter/index.d.ts +5 -0
- package/dist/layouts/Newsletter/index.js +1 -0
- package/dist/layouts/Product/ProductDiscover.css +1 -0
- package/dist/layouts/Product/ProductDiscover.d.ts +3 -0
- package/dist/layouts/Product/ProductDiscover.js +1 -0
- package/dist/layouts/Product/ProductPreview.css +1 -0
- package/dist/layouts/Product/ProductPreview.d.ts +3 -0
- package/dist/layouts/Product/ProductPreview.js +1 -0
- package/dist/layouts/Product/index.css +1 -0
- package/dist/layouts/Product/index.d.ts +2 -0
- package/dist/layouts/Product/index.js +1 -0
- package/dist/layouts/PythonDoc/index.css +1 -0
- package/dist/layouts/PythonDoc/index.d.ts +3 -0
- package/dist/layouts/PythonDoc/index.js +1 -0
- package/dist/layouts/PythonDoc/styles.css.css +1 -0
- package/dist/layouts/PythonDoc/styles.css.d.ts +12 -0
- package/dist/layouts/PythonDoc/styles.css.js +1 -0
- package/dist/layouts/TypeDoc/ExportsSidebar/index.css +1 -0
- package/dist/layouts/TypeDoc/ExportsSidebar/index.d.ts +9 -0
- package/dist/layouts/TypeDoc/ExportsSidebar/index.js +1 -0
- package/dist/layouts/TypeDoc/ExportsSidebar/styles.css.css +1 -0
- package/dist/layouts/TypeDoc/ExportsSidebar/styles.css.d.ts +6 -0
- package/dist/layouts/TypeDoc/ExportsSidebar/styles.css.js +1 -0
- package/dist/layouts/TypeDoc/index.css +1 -0
- package/dist/layouts/TypeDoc/index.d.ts +3 -0
- package/dist/layouts/TypeDoc/index.js +1 -0
- package/dist/layouts/TypeDoc/styles.css.css +1 -0
- package/dist/layouts/TypeDoc/styles.css.d.ts +7 -0
- package/dist/layouts/TypeDoc/styles.css.js +1 -0
- package/dist/layouts/index.css +1 -0
- package/dist/layouts/index.d.ts +9 -0
- package/dist/layouts/index.js +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.js +1 -0
- package/package.json +41 -0
- package/src/Fade.tsx +48 -0
- package/src/LayoutBase/index.tsx +35 -0
- package/src/LayoutBase/styles.css.ts +73 -0
- package/src/LayoutColumns/index.tsx +36 -0
- package/src/LayoutColumns/styles.css.ts +64 -0
- package/src/LayoutConfigProvider/index.tsx +22 -0
- package/src/LayoutFullWidth/index.tsx +22 -0
- package/src/LayoutFullWidth/styles.css.ts +17 -0
- package/src/LayoutProvider.tsx +35 -0
- package/src/Sidebars/Drawer.tsx +66 -0
- package/src/Sidebars/SidebarLeft.tsx +15 -0
- package/src/Sidebars/SidebarRight.tsx +13 -0
- package/src/Sidebars/index.tsx +2 -0
- package/src/Sidebars/styles.css.ts +101 -0
- package/src/hooks/useIsLoading.ts +75 -0
- package/src/index.ts +9 -0
- package/src/layouts/App/index.tsx +12 -0
- package/src/layouts/App/styles.css.ts +23 -0
- package/src/layouts/Detail/DetailContentOnly.tsx +15 -0
- package/src/layouts/Detail/DetailHighlight.tsx +24 -0
- package/src/layouts/Detail/DetailOverview.tsx +47 -0
- package/src/layouts/Detail/DetailTechnical.tsx +53 -0
- package/src/layouts/Detail/index.tsx +4 -0
- package/src/layouts/Detail/styles.css.ts +5 -0
- package/src/layouts/Edit/index.tsx +35 -0
- package/src/layouts/Edit/styles.css.ts +23 -0
- package/src/layouts/FullWidth/index.tsx +12 -0
- package/src/layouts/Landing/index.tsx +12 -0
- package/src/layouts/Newsletter/index.tsx +29 -0
- package/src/layouts/Product/ProductDiscover.tsx +15 -0
- package/src/layouts/Product/ProductPreview.tsx +12 -0
- package/src/layouts/Product/index.tsx +2 -0
- package/src/layouts/PythonDoc/index.tsx +86 -0
- package/src/layouts/PythonDoc/styles.css.ts +67 -0
- package/src/layouts/TypeDoc/ExportsSidebar/index.tsx +36 -0
- package/src/layouts/TypeDoc/ExportsSidebar/styles.css.ts +44 -0
- package/src/layouts/TypeDoc/icons.css +944 -0
- package/src/layouts/TypeDoc/icons.png +0 -0
- package/src/layouts/TypeDoc/icons@2x.png +0 -0
- package/src/layouts/TypeDoc/index.tsx +80 -0
- package/src/layouts/TypeDoc/style.css +689 -0
- package/src/layouts/TypeDoc/styles.css.ts +41 -0
- package/src/layouts/TypeDoc/widgets.png +0 -0
- package/src/layouts/TypeDoc/widgets@2x.png +0 -0
- package/src/layouts/index.ts +9 -0
- package/src/types/index.tsx +28 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
let LayoutContext;
|
|
4
|
+
|
|
5
|
+
export function LayoutConfigProvider({
|
|
6
|
+
children,
|
|
7
|
+
config
|
|
8
|
+
}: {
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
config: unknown;
|
|
11
|
+
}) {
|
|
12
|
+
LayoutContext = LayoutContext || React.createContext(config);
|
|
13
|
+
return children;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useLayoutConfig<T>() {
|
|
17
|
+
if (!LayoutContext) {
|
|
18
|
+
throw new Error('Trying to use `useLayoutConfig` outside of a `LayoutConfigContext`.');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return React.useContext<T>(LayoutContext);
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
|
|
4
|
+
import styles from './styles.css';
|
|
5
|
+
import { FooterProps } from '@jpmorganchase/mosaic-site-components';
|
|
6
|
+
|
|
7
|
+
export interface LayoutFullWidthProps {
|
|
8
|
+
Footer?: React.ReactElement;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const LayoutFullWidth: React.FC<LayoutFullWidthProps> = ({
|
|
14
|
+
Footer,
|
|
15
|
+
children = null,
|
|
16
|
+
className
|
|
17
|
+
}) => (
|
|
18
|
+
<div className={classnames(styles.root, className)}>
|
|
19
|
+
<main>{children}</main>
|
|
20
|
+
{Footer && Footer}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { config, responsiveSprinkles } from '@jpmorganchase/mosaic-theme';
|
|
2
|
+
import { style } from '@vanilla-extract/css';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
root: style([
|
|
6
|
+
style({
|
|
7
|
+
maxWidth: `${config.main.width}px`,
|
|
8
|
+
marginLeft: 'auto',
|
|
9
|
+
marginRight: 'auto'
|
|
10
|
+
}),
|
|
11
|
+
responsiveSprinkles({
|
|
12
|
+
marginTop: ['x10', 'x10', 'x20', 'x20'],
|
|
13
|
+
paddingLeft: ['x4', 'x6', 'x6', 'x6'],
|
|
14
|
+
paddingRight: ['x4', 'x6', 'x6', 'x6']
|
|
15
|
+
})
|
|
16
|
+
])
|
|
17
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import { useLayout } from '@jpmorganchase/mosaic-store';
|
|
3
|
+
import { usePageState } from '@jpmorganchase/mosaic-content-editor-plugin';
|
|
4
|
+
import { FullWidth } from './layouts/FullWidth';
|
|
5
|
+
|
|
6
|
+
import type { LayoutProps } from './types';
|
|
7
|
+
|
|
8
|
+
export type LayoutProviderProps = {
|
|
9
|
+
layoutComponents?: {
|
|
10
|
+
[name: string]: React.FC<LayoutProps> | undefined;
|
|
11
|
+
};
|
|
12
|
+
LayoutProps?: LayoutProps;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const LayoutProvider: FC<LayoutProviderProps> = ({
|
|
17
|
+
children,
|
|
18
|
+
layoutComponents,
|
|
19
|
+
LayoutProps = {}
|
|
20
|
+
}) => {
|
|
21
|
+
const { layout: layoutInStore = 'FullWidth' } = useLayout();
|
|
22
|
+
const { pageState } = usePageState();
|
|
23
|
+
const layout = pageState !== 'VIEW' ? 'EditLayout' : layoutInStore;
|
|
24
|
+
|
|
25
|
+
let LayoutComponent: FC<LayoutProps> | undefined = layoutComponents?.[layout] as FC<LayoutProps>;
|
|
26
|
+
if (!LayoutComponent) {
|
|
27
|
+
console.error(`Layout ${layout} is not supported, defaulting to FullWidth`);
|
|
28
|
+
LayoutComponent = FullWidth;
|
|
29
|
+
}
|
|
30
|
+
return LayoutComponent ? (
|
|
31
|
+
<LayoutComponent {...LayoutProps}>{children}</LayoutComponent>
|
|
32
|
+
) : (
|
|
33
|
+
<>children</>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { FC, ReactNode, useEffect, useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { LayerLayout } from '@jpmorganchase/uitk-core';
|
|
3
|
+
import { Icon, Button, useBreakpoint } from '@jpmorganchase/mosaic-components';
|
|
4
|
+
import styles from './styles.css';
|
|
5
|
+
|
|
6
|
+
export interface DrawerProps {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
11
|
+
|
|
12
|
+
export const Drawer: FC<DrawerProps> = ({ children }) => {
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
const [useDrawer, setUseDrawer] = useState(false);
|
|
15
|
+
const breakpoint = useBreakpoint();
|
|
16
|
+
|
|
17
|
+
const toggleDrawer = () => {
|
|
18
|
+
setOpen(old => !old);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
useIsomorphicLayoutEffect(() => {
|
|
22
|
+
setUseDrawer(breakpoint === 'mobile' || breakpoint === 'tablet');
|
|
23
|
+
}, [breakpoint]);
|
|
24
|
+
|
|
25
|
+
useIsomorphicLayoutEffect(() => {
|
|
26
|
+
// Close drawer whenever a page loads
|
|
27
|
+
setOpen(false);
|
|
28
|
+
}, [children]);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{useDrawer && (
|
|
33
|
+
<>
|
|
34
|
+
<LayerLayout
|
|
35
|
+
className={styles.drawerInner}
|
|
36
|
+
aria-label="Overlaid Drawer"
|
|
37
|
+
isOpen={open}
|
|
38
|
+
disableScrim
|
|
39
|
+
position="left"
|
|
40
|
+
>
|
|
41
|
+
<aside className={styles.sidebarLeftDrawer}>{children}</aside>
|
|
42
|
+
</LayerLayout>
|
|
43
|
+
<div className={styles.toggleDrawer}>
|
|
44
|
+
<Button
|
|
45
|
+
className={styles.toggleButton}
|
|
46
|
+
onClick={toggleDrawer}
|
|
47
|
+
variant="regular"
|
|
48
|
+
aria-label="show the secondary navigation"
|
|
49
|
+
>
|
|
50
|
+
{open ? (
|
|
51
|
+
<Icon aria-label="close the main navigation" name="close" />
|
|
52
|
+
) : (
|
|
53
|
+
<Icon aria-label="show the main navigation" name="menu" />
|
|
54
|
+
)}
|
|
55
|
+
</Button>
|
|
56
|
+
</div>
|
|
57
|
+
</>
|
|
58
|
+
)}
|
|
59
|
+
{!useDrawer && (
|
|
60
|
+
<aside className={styles.sidebarLeft}>
|
|
61
|
+
<div className={styles.sidebarStickyArea}>{children}</div>
|
|
62
|
+
</aside>
|
|
63
|
+
)}
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './styles.css';
|
|
4
|
+
import { Drawer } from './Drawer';
|
|
5
|
+
|
|
6
|
+
export interface SidebarLeftProps {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const SidebarLeft: FC<SidebarLeftProps> = ({ children }) => (
|
|
11
|
+
<>
|
|
12
|
+
{children && <Drawer>{children}</Drawer>}
|
|
13
|
+
{!children && <aside className={styles.sidebarLeftEmpty} />}
|
|
14
|
+
</>
|
|
15
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './styles.css';
|
|
4
|
+
|
|
5
|
+
export interface SidebarRightProps {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const SidebarRight: FC<SidebarRightProps> = ({ children }) => (
|
|
10
|
+
<aside className={styles.sidebarRight}>
|
|
11
|
+
{children && <div className={styles.sidebarStickyArea}>{children}</div>}
|
|
12
|
+
</aside>
|
|
13
|
+
);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { keyframes, style } from '@vanilla-extract/css';
|
|
2
|
+
import {
|
|
3
|
+
button,
|
|
4
|
+
neutralBorder,
|
|
5
|
+
responsiveSprinkles,
|
|
6
|
+
sidebar,
|
|
7
|
+
config
|
|
8
|
+
} from '@jpmorganchase/mosaic-theme';
|
|
9
|
+
|
|
10
|
+
const fadeIn = keyframes({
|
|
11
|
+
'0%': { opacity: 0 },
|
|
12
|
+
'100%': { opacity: 1 }
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
sidebarLeft: style([
|
|
17
|
+
style({
|
|
18
|
+
flexShrink: 0,
|
|
19
|
+
flexGrow: 0,
|
|
20
|
+
zIndex: 1,
|
|
21
|
+
width: `${config.sidebarLeft.width}px`
|
|
22
|
+
}),
|
|
23
|
+
neutralBorder({ variant: 'low', borderRightWidth: 'thin' }),
|
|
24
|
+
sidebar({ variant: 'left' })
|
|
25
|
+
]),
|
|
26
|
+
sidebarLeftDrawer: style([
|
|
27
|
+
responsiveSprinkles({
|
|
28
|
+
paddingTop: ['none', 'none', 'x6', 'x6']
|
|
29
|
+
})
|
|
30
|
+
]),
|
|
31
|
+
sidebarLeftEmpty: style([
|
|
32
|
+
style({
|
|
33
|
+
flexShrink: 0,
|
|
34
|
+
zIndex: 1
|
|
35
|
+
}),
|
|
36
|
+
sidebar({ variant: 'leftEmpty' })
|
|
37
|
+
]),
|
|
38
|
+
sidebarRight: style([
|
|
39
|
+
style({
|
|
40
|
+
flexShrink: 0,
|
|
41
|
+
zIndex: 3,
|
|
42
|
+
width: `${config.sidebarRight.width}px`
|
|
43
|
+
}),
|
|
44
|
+
sidebar({ variant: 'right' })
|
|
45
|
+
]),
|
|
46
|
+
sidebarStickyArea: style([
|
|
47
|
+
style({
|
|
48
|
+
position: 'sticky',
|
|
49
|
+
overflow: 'auto',
|
|
50
|
+
height: `calc(100vh - ${config.appHeader.height}px)`,
|
|
51
|
+
top: `${config.appHeader.height}px`
|
|
52
|
+
}),
|
|
53
|
+
responsiveSprinkles({
|
|
54
|
+
paddingTop: ['x10', 'x10', 'x20', 'x20'],
|
|
55
|
+
paddingBottom: ['x4', 'x4', 'x4', 'x4']
|
|
56
|
+
})
|
|
57
|
+
]),
|
|
58
|
+
toggleDrawer: style([
|
|
59
|
+
{
|
|
60
|
+
display: 'block',
|
|
61
|
+
position: 'fixed',
|
|
62
|
+
zIndex: 5
|
|
63
|
+
},
|
|
64
|
+
responsiveSprinkles({
|
|
65
|
+
bottom: ['x6', 'x6', 'x6', 'x6'],
|
|
66
|
+
right: ['x6', 'x6', 'x6', 'x6']
|
|
67
|
+
})
|
|
68
|
+
]),
|
|
69
|
+
toggleButton: button({ variant: 'square' }),
|
|
70
|
+
closeDrawerButtonWrapper: style([
|
|
71
|
+
{
|
|
72
|
+
display: 'block',
|
|
73
|
+
position: 'fixed',
|
|
74
|
+
opacity: 0,
|
|
75
|
+
animationDuration: '100ms',
|
|
76
|
+
animationDelay: '225ms',
|
|
77
|
+
animationFillMode: 'forwards',
|
|
78
|
+
animationName: fadeIn
|
|
79
|
+
},
|
|
80
|
+
responsiveSprinkles({
|
|
81
|
+
bottom: ['x6', 'x6', 'x6', 'x6'],
|
|
82
|
+
right: ['x6', 'x6', 'x6', 'x6']
|
|
83
|
+
})
|
|
84
|
+
]),
|
|
85
|
+
drawerInner: style([
|
|
86
|
+
style({
|
|
87
|
+
bottom: 0,
|
|
88
|
+
overflowY: 'scroll',
|
|
89
|
+
top: `${config.appHeader.height}px`,
|
|
90
|
+
height: `calc(100% - ${config.appHeader.height}px)`
|
|
91
|
+
}),
|
|
92
|
+
sidebar({ variant: 'drawer' }),
|
|
93
|
+
responsiveSprinkles({
|
|
94
|
+
paddingTop: ['x6', 'x6', 'none', 'none'],
|
|
95
|
+
paddingBottom: ['x6', 'x6', 'none', 'none']
|
|
96
|
+
})
|
|
97
|
+
]),
|
|
98
|
+
drawerButton: style({
|
|
99
|
+
display: 'none'
|
|
100
|
+
})
|
|
101
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useRouter } from 'next/router';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns an array with a boolean for `isLoading` and a boolean for `isBaseRouteChanging`
|
|
6
|
+
*/
|
|
7
|
+
export function useIsLoading({ loadingDelay }: { loadingDelay?: number } = {}) {
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
const [isLoading, setIsLoading] = React.useState<[boolean, boolean]>([!router.isReady, false]);
|
|
10
|
+
const isLoadingRef = React.useRef(isLoading[0]);
|
|
11
|
+
const lastBaseRootRef = React.useRef(router.asPath.split('/')[1]);
|
|
12
|
+
const deferredStateTimerIdRef = React.useRef<NodeJS.Timeout | null>();
|
|
13
|
+
|
|
14
|
+
const clearDeferredStateTimer = React.useCallback(() => {
|
|
15
|
+
if (deferredStateTimerIdRef.current) {
|
|
16
|
+
clearTimeout(deferredStateTimerIdRef.current);
|
|
17
|
+
deferredStateTimerIdRef.current = null;
|
|
18
|
+
}
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
const handleRouteChangeStart = React.useCallback(
|
|
22
|
+
newRoute => {
|
|
23
|
+
const newBaseRoute = newRoute.split('/')[1];
|
|
24
|
+
const isBaseRouteChanging = newBaseRoute !== lastBaseRootRef.current;
|
|
25
|
+
|
|
26
|
+
isLoadingRef.current = true;
|
|
27
|
+
|
|
28
|
+
clearDeferredStateTimer();
|
|
29
|
+
|
|
30
|
+
if (loadingDelay) {
|
|
31
|
+
deferredStateTimerIdRef.current = setTimeout(() => {
|
|
32
|
+
if (isLoadingRef.current) {
|
|
33
|
+
setIsLoading([true, isBaseRouteChanging]);
|
|
34
|
+
}
|
|
35
|
+
}, loadingDelay);
|
|
36
|
+
} else {
|
|
37
|
+
setIsLoading([true, isBaseRouteChanging]);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[loadingDelay, clearDeferredStateTimer]
|
|
41
|
+
);
|
|
42
|
+
const handleRouteChangeError = React.useCallback(() => {
|
|
43
|
+
clearDeferredStateTimer();
|
|
44
|
+
if (isLoadingRef.current) {
|
|
45
|
+
setIsLoading([false, false]);
|
|
46
|
+
}
|
|
47
|
+
isLoadingRef.current = false;
|
|
48
|
+
}, [clearDeferredStateTimer]);
|
|
49
|
+
const handleRouteChangeComplete = React.useCallback(
|
|
50
|
+
newRoute => {
|
|
51
|
+
clearDeferredStateTimer();
|
|
52
|
+
if (isLoadingRef.current) {
|
|
53
|
+
setIsLoading([false, false]);
|
|
54
|
+
}
|
|
55
|
+
isLoadingRef.current = false;
|
|
56
|
+
lastBaseRootRef.current = newRoute.split('/')[1];
|
|
57
|
+
},
|
|
58
|
+
[clearDeferredStateTimer]
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
router.events.on('routeChangeStart', handleRouteChangeStart);
|
|
63
|
+
router.events.on('routeChangeError', handleRouteChangeError);
|
|
64
|
+
router.events.on('routeChangeComplete', handleRouteChangeComplete);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
router.events.off('routeChangeStart', handleRouteChangeStart);
|
|
68
|
+
router.events.off('routeChangeError', handleRouteChangeError);
|
|
69
|
+
router.events.off('routeChangeComplete', handleRouteChangeComplete);
|
|
70
|
+
};
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
return isLoading;
|
|
75
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './LayoutBase';
|
|
2
|
+
export * from './LayoutColumns';
|
|
3
|
+
export * from './LayoutFullWidth';
|
|
4
|
+
export * from './Sidebars';
|
|
5
|
+
export * from './hooks/useIsLoading';
|
|
6
|
+
export * from './LayoutConfigProvider';
|
|
7
|
+
export * from './LayoutProvider';
|
|
8
|
+
|
|
9
|
+
export * as layouts from './layouts';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AppHeader } from '@jpmorganchase/mosaic-site-components';
|
|
3
|
+
|
|
4
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
5
|
+
import type { LayoutProps } from '../../types';
|
|
6
|
+
import styles from './styles.css';
|
|
7
|
+
|
|
8
|
+
export const AppLayout: React.FC<LayoutProps> = ({ children }) => (
|
|
9
|
+
<LayoutBase Header={<AppHeader />}>
|
|
10
|
+
<div className={styles.root}>{children}</div>
|
|
11
|
+
</LayoutBase>
|
|
12
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { responsiveSprinkles, vars, config } from '@jpmorganchase/mosaic-theme';
|
|
2
|
+
import { style, globalStyle } from '@vanilla-extract/css';
|
|
3
|
+
|
|
4
|
+
const root = style([
|
|
5
|
+
style({
|
|
6
|
+
maxWidth: '100vw',
|
|
7
|
+
marginLeft: vars.space.horizontal.x10,
|
|
8
|
+
marginRight: vars.space.horizontal.x10
|
|
9
|
+
}),
|
|
10
|
+
responsiveSprinkles({
|
|
11
|
+
marginTop: ['x6', 'x6', 'x10', 'x10']
|
|
12
|
+
})
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
globalStyle(`${root} > footer`, {
|
|
16
|
+
maxWidth: `${config.main.width}px`,
|
|
17
|
+
marginLeft: 'auto',
|
|
18
|
+
marginRight: 'auto'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
root
|
|
23
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AppHeader, Breadcrumbs, Footer } from '@jpmorganchase/mosaic-site-components';
|
|
3
|
+
|
|
4
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
5
|
+
import { LayoutFullWidth } from '../../LayoutFullWidth';
|
|
6
|
+
import type { LayoutProps } from '../../types';
|
|
7
|
+
|
|
8
|
+
export const DetailContentOnly: React.FC<LayoutProps> = ({ FooterProps, children }) => (
|
|
9
|
+
<LayoutBase Header={<AppHeader />}>
|
|
10
|
+
<LayoutFullWidth Footer={<Footer {...FooterProps} />}>
|
|
11
|
+
<Breadcrumbs />
|
|
12
|
+
{children}
|
|
13
|
+
</LayoutFullWidth>
|
|
14
|
+
</LayoutBase>
|
|
15
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AppHeader,
|
|
4
|
+
Breadcrumbs,
|
|
5
|
+
Footer,
|
|
6
|
+
TableOfContents
|
|
7
|
+
} from '@jpmorganchase/mosaic-site-components';
|
|
8
|
+
|
|
9
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
10
|
+
import { LayoutColumns } from '../../LayoutColumns';
|
|
11
|
+
import type { LayoutProps } from '../../types';
|
|
12
|
+
|
|
13
|
+
export const DetailHighlight: React.FC<LayoutProps> = ({ FooterProps, children }) => (
|
|
14
|
+
<LayoutBase Header={<AppHeader />}>
|
|
15
|
+
<LayoutColumns
|
|
16
|
+
PrimarySidebar={null}
|
|
17
|
+
SecondarySidebar={<TableOfContents />}
|
|
18
|
+
Footer={<Footer {...FooterProps} />}
|
|
19
|
+
>
|
|
20
|
+
<Breadcrumbs />
|
|
21
|
+
{children}
|
|
22
|
+
</LayoutColumns>
|
|
23
|
+
</LayoutBase>
|
|
24
|
+
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HelpLinks } from '@jpmorganchase/mosaic-components';
|
|
3
|
+
import {
|
|
4
|
+
AppHeader,
|
|
5
|
+
BackLink,
|
|
6
|
+
Breadcrumbs,
|
|
7
|
+
DocPaginator,
|
|
8
|
+
Footer,
|
|
9
|
+
VerticalNavigation
|
|
10
|
+
} from '@jpmorganchase/mosaic-site-components';
|
|
11
|
+
|
|
12
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
13
|
+
import { LayoutColumns } from '../../LayoutColumns';
|
|
14
|
+
import type { LayoutProps } from '../../types';
|
|
15
|
+
import styles from './styles.css';
|
|
16
|
+
|
|
17
|
+
export const DetailOverview: React.FC<LayoutProps> = ({
|
|
18
|
+
BackLinkProps,
|
|
19
|
+
SidebarProps,
|
|
20
|
+
FooterProps,
|
|
21
|
+
children
|
|
22
|
+
}) => {
|
|
23
|
+
const Sidebar = (
|
|
24
|
+
<>
|
|
25
|
+
{BackLinkProps && (
|
|
26
|
+
<header className={styles.sidebarHeader}>
|
|
27
|
+
<BackLink {...BackLinkProps} />
|
|
28
|
+
</header>
|
|
29
|
+
)}
|
|
30
|
+
<VerticalNavigation />
|
|
31
|
+
{SidebarProps?.helpLinks && <HelpLinks subTitle="Need help?" {...SidebarProps.helpLinks} />}
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
return (
|
|
35
|
+
<LayoutBase Header={<AppHeader />}>
|
|
36
|
+
<LayoutColumns
|
|
37
|
+
PrimarySidebar={Sidebar}
|
|
38
|
+
SecondarySidebar={null}
|
|
39
|
+
Footer={<Footer {...FooterProps} />}
|
|
40
|
+
>
|
|
41
|
+
<Breadcrumbs />
|
|
42
|
+
{children}
|
|
43
|
+
<DocPaginator />
|
|
44
|
+
</LayoutColumns>
|
|
45
|
+
</LayoutBase>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HelpLinks } from '@jpmorganchase/mosaic-components';
|
|
3
|
+
import {
|
|
4
|
+
AppHeader,
|
|
5
|
+
DocPaginator,
|
|
6
|
+
BackLink,
|
|
7
|
+
Breadcrumbs,
|
|
8
|
+
Footer,
|
|
9
|
+
TableOfContents,
|
|
10
|
+
VerticalNavigation
|
|
11
|
+
} from '@jpmorganchase/mosaic-site-components';
|
|
12
|
+
|
|
13
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
14
|
+
import { LayoutColumns } from '../../LayoutColumns';
|
|
15
|
+
import type { LayoutProps } from '../../types';
|
|
16
|
+
import styles from './styles.css';
|
|
17
|
+
|
|
18
|
+
export const DetailTechnical: React.FC<LayoutProps> = ({
|
|
19
|
+
BackLinkProps,
|
|
20
|
+
FooterProps,
|
|
21
|
+
SidebarProps,
|
|
22
|
+
children
|
|
23
|
+
}) => {
|
|
24
|
+
const Header = <AppHeader />;
|
|
25
|
+
|
|
26
|
+
const PrimarySidebar = (
|
|
27
|
+
<>
|
|
28
|
+
{BackLinkProps && (
|
|
29
|
+
<header className={styles.sidebarHeader}>
|
|
30
|
+
<BackLink {...BackLinkProps} />
|
|
31
|
+
</header>
|
|
32
|
+
)}
|
|
33
|
+
<VerticalNavigation />
|
|
34
|
+
{SidebarProps?.helpLinks && <HelpLinks subTitle="Need help?" {...SidebarProps.helpLinks} />}
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const SecondarySidebar = <TableOfContents />;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<LayoutBase Header={Header}>
|
|
42
|
+
<LayoutColumns
|
|
43
|
+
PrimarySidebar={PrimarySidebar}
|
|
44
|
+
SecondarySidebar={SecondarySidebar}
|
|
45
|
+
Footer={<Footer {...FooterProps} />}
|
|
46
|
+
>
|
|
47
|
+
<Breadcrumbs />
|
|
48
|
+
{children}
|
|
49
|
+
<DocPaginator />
|
|
50
|
+
</LayoutColumns>
|
|
51
|
+
</LayoutBase>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useRouter } from 'next/router';
|
|
3
|
+
import { useContentEditor } from '@jpmorganchase/mosaic-content-editor-plugin';
|
|
4
|
+
import { AppHeader } from '@jpmorganchase/mosaic-site-components';
|
|
5
|
+
|
|
6
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
7
|
+
import type { LayoutProps } from '../../types';
|
|
8
|
+
import styles from './styles.css';
|
|
9
|
+
|
|
10
|
+
export const EditLayout: React.FC<LayoutProps> = ({ children }) => {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const { pageState, stopEditing } = useContentEditor();
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const handleRouteChange = () => {
|
|
16
|
+
if (pageState === 'EDIT') {
|
|
17
|
+
stopEditing();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
router.events.on('routeChangeStart', handleRouteChange);
|
|
22
|
+
|
|
23
|
+
return () => {
|
|
24
|
+
router.events.off('routeChangeStart', handleRouteChange);
|
|
25
|
+
};
|
|
26
|
+
}, [pageState, router.events, stopEditing]);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<LayoutBase className={styles.base} Header={<AppHeader />}>
|
|
30
|
+
<div id="edit-layout" className={styles.root}>
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
</LayoutBase>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { responsiveSprinkles, vars, config } from '@jpmorganchase/mosaic-theme';
|
|
2
|
+
import { globalStyle, style } from '@vanilla-extract/css';
|
|
3
|
+
|
|
4
|
+
const base = style({});
|
|
5
|
+
|
|
6
|
+
globalStyle(`${base} > main`, {
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
height: `calc(100% + ${config.appHeader.height}px)`
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
root: style([
|
|
13
|
+
style({
|
|
14
|
+
maxWidth: '100vw',
|
|
15
|
+
marginLeft: vars.space.horizontal.x10,
|
|
16
|
+
marginRight: vars.space.horizontal.x10
|
|
17
|
+
}),
|
|
18
|
+
responsiveSprinkles({
|
|
19
|
+
marginTop: ['x6', 'x6', 'x10', 'x10']
|
|
20
|
+
})
|
|
21
|
+
]),
|
|
22
|
+
base
|
|
23
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AppHeader, Footer } from '@jpmorganchase/mosaic-site-components';
|
|
3
|
+
|
|
4
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
5
|
+
import { LayoutFullWidth } from '../../LayoutFullWidth';
|
|
6
|
+
import type { LayoutProps } from '../../types';
|
|
7
|
+
|
|
8
|
+
export const FullWidth: React.FC<LayoutProps> = ({ FooterProps, children }) => (
|
|
9
|
+
<LayoutBase Header={<AppHeader />}>
|
|
10
|
+
<LayoutFullWidth>{children}</LayoutFullWidth>
|
|
11
|
+
</LayoutBase>
|
|
12
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AppHeader, Footer } from '@jpmorganchase/mosaic-site-components';
|
|
3
|
+
|
|
4
|
+
import { LayoutBase } from '../../LayoutBase';
|
|
5
|
+
import { LayoutFullWidth } from '../../LayoutFullWidth';
|
|
6
|
+
import type { LayoutProps } from '../../types';
|
|
7
|
+
|
|
8
|
+
export const Landing: React.FC<LayoutProps> = ({ FooterProps, children }) => (
|
|
9
|
+
<LayoutBase Header={<AppHeader />}>
|
|
10
|
+
<LayoutFullWidth Footer={<Footer {...FooterProps} />}>{children}</LayoutFullWidth>
|
|
11
|
+
</LayoutBase>
|
|
12
|
+
);
|