This repository was archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.d.ts
69 lines (50 loc) · 1.55 KB
/
index.d.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { Component, FC, ReactElement, ReactNode } from "react";
type BreakpointNames = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
type InitialBreakpoints = BreakpointNames | '_initial'
type MediaQueries = {
[mq in InitialBreakpoints]?: string
}
type MediaTypeMapping = boolean
type IsCalculated = boolean
type MediaTypeMap = {
[mt in InitialBreakpoints]?: MediaTypeMapping
}
type Orientation = 'portrait' | 'landscape' | null
interface ResponsiveContext {
isCalculated: IsCalculated,
mediaType: InitialBreakpoints,
lessThan: MediaTypeMap,
greaterThan: MediaTypeMap,
is: MediaTypeMap,
orientation: Orientation,
}
interface IsMobile {
isCalculated: IsCalculated,
isMobile: MediaTypeMapping,
}
type Breakpoints = {
[bp in BreakpointNames]?: string
}
interface ResponsiveProps {
children: ReactNode,
}
interface ResponsiveProviderProps {
initialMediaType?: InitialBreakpoints,
defaultOrientation?: Orientation,
children: ReactNode,
breakpoints?: Breakpoints,
breakpointsMax?: Breakpoints,
mediaQueries?: MediaQueries,
mobileBreakpoint?: BreakpointNames,
}
interface WithResponsiveProps {
responsive: ResponsiveContext
}
export const ResponsiveProvider: FC<ResponsiveProviderProps>
export const useResponsive: () => ResponsiveContext
export const Responsive: FC<ResponsiveProps>
export const withResponsive: <P = {}>(Component: Component) =>
(props: P) => ReactElement<P & WithResponsiveProps>
export const withIsMobile: <P = {}>(Component: Component) =>
(props: P) => ReactElement<P & IsMobile>
export const useIsMobile: () => IsMobile