forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPageContext.tsx
More file actions
30 lines (25 loc) · 914 Bytes
/
PageContext.tsx
File metadata and controls
30 lines (25 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { createContext } from 'react';
import { getBreakpoint, getVerticalBreakpoint } from '../../helpers/util';
export interface PageContextProps {
isManagedSidebar: boolean;
onSidebarToggle: () => void;
isSidebarOpen: boolean;
isMobile: boolean;
width: number;
height: number;
getBreakpoint: (width: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
getVerticalBreakpoint: (height: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
}
export const pageContextDefaults: PageContextProps = {
isManagedSidebar: false,
isSidebarOpen: false,
onSidebarToggle: () => null,
isMobile: false,
width: null,
height: null,
getBreakpoint,
getVerticalBreakpoint
};
export const PageContext = createContext<PageContextProps>(pageContextDefaults);
export const PageContextProvider = PageContext.Provider;
export const PageContextConsumer = PageContext.Consumer;