-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.d.ts
68 lines (61 loc) · 1.96 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
export interface ReactBreakpointsProps {
/**
* Your breakpoints object.
*/
breakpoints: { [k: string]: number };
/**
* The type of unit that your breakpoints should use - px or em.
*/
breakpointUnit?: 'px' | 'em';
/**
* When rendering on the server, you can do your own magic with for example UA
* to guess which viewport width a user probably has.
*/
guessedBreakpoint?: number;
/**
* In case you don't want to default to mobile on SSR and no guessedBreakpoint
* is passed, use defaultBreakpoint to set your own value.
*/
defaultBreakpoint?: number;
/**
* If you don't want the resize listener to be debounced, set to false. Defaults to false
* when snapMode is true.
*/
debounceResize?: boolean;
/**
* Set a custom delay for how long the debounce timeout should be.
*/
debounceDelay?: number;
/**
* Replaces breakpoints.current with screenWidth, disabling re-render only
* when breakpoint changes, instead potentially re-rendering when
* calculateCurrentBreakpoint returns a new value.
*/
snapMode?: boolean;
}
/**
* Pass in the keys of your breakpoints as K
*/
export interface WithBreakpointsProps<K> {
breakpoints: { [key in K]: number };
currentBreakpoint?: K;
screenWidth?: number;
}
/**
* HOC for providing breakpoints as props
*/
export declare function withBreakpoints<P = any>(C: React.ComponentType<P>): React.ComponentType<P>;
// Media Component unfortunately can't use Abstract types like in
// the withBreakPoints because it's type is React.Consumer and it only
// accepts 1 Abstract type for the props. So using generic types
// is the only sane solution for now.
/**
* React Component providing breakpoints using Render Props
*/
export declare const Media: React.Consumer<{
breakpoints: { [key: string]: number };
currentBreakpoint?: string;
screenWidth?: number;
}>;
declare const ReactBreakpoints: React.ComponentClass<ReactBreakpointsProps>;
export default ReactBreakpoints;