-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
555 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { MediaBreakpointProps } from "./Media" | ||
/** | ||
* A union of possible breakpoint props. | ||
*/ | ||
export type BreakpointConstraintKey = keyof MediaBreakpointProps | ||
type ValueBreakpointPropsTuple<SizeValue, BreakpointKey> = [ | ||
SizeValue, | ||
MediaBreakpointProps<BreakpointKey> | ||
] | ||
export declare enum BreakpointConstraint { | ||
at = "at", | ||
lessThan = "lessThan", | ||
greaterThan = "greaterThan", | ||
greaterThanOrEqual = "greaterThanOrEqual", | ||
between = "between", | ||
} | ||
/** | ||
* Encapsulates all breakpoint data needed by the Media component. The data is | ||
* generated on initialization so no further runtime work is necessary. | ||
*/ | ||
export declare class Breakpoints<BreakpointKey extends string> { | ||
static validKeys(): BreakpointConstraint[] | ||
private _sortedBreakpoints | ||
private _breakpoints | ||
private _mediaQueries | ||
constructor(breakpoints: { [key: string]: number }) | ||
get sortedBreakpoints(): BreakpointKey[] | ||
get dynamicResponsiveMediaQueries(): {} | ||
get largestBreakpoint(): string | ||
findBreakpointsForWidths: ( | ||
fromWidth: number, | ||
throughWidth: number | ||
) => BreakpointKey[] | undefined | ||
findBreakpointAtWidth: (width: number) => BreakpointKey | undefined | ||
toVisibleAtBreakpointSet( | ||
breakpointProps: MediaBreakpointProps | ||
): BreakpointKey[] | ||
toRuleSets(keys?: BreakpointConstraint[]): string[] | ||
shouldRenderMediaQuery( | ||
breakpointProps: MediaBreakpointProps, | ||
onlyRenderAt: string[] | ||
): boolean | ||
valuesWithBreakpointProps: <SizeValue>( | ||
values: SizeValue[] | ||
) => ValueBreakpointPropsTuple<SizeValue, BreakpointKey>[] | ||
private _normalizeProps | ||
private _createBreakpointQuery | ||
private _createBreakpointQueries | ||
private _findNextBreakpoint | ||
} | ||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* TODO: This is the deprecated runtime media-query component from Reaction. | ||
* It can probably be simplified somewhat if we’re not going to be using | ||
* it directly any longer. | ||
*/ | ||
import React from "react" | ||
/** TODO */ | ||
export type MediaQueries<M extends string = string> = { [K in M]: string } | ||
/** TODO */ | ||
export interface MediaQueryMatchers { | ||
[key: string]: MediaQueryList | ||
} | ||
/** TODO */ | ||
export type MediaQueryMatches<M extends string = string> = { [K in M]: boolean } | ||
/** TODO */ | ||
export interface ResponsiveProviderProps<M extends string> { | ||
mediaQueries: MediaQueries<M> | ||
initialMatchingMediaQueries?: M[] | ||
children: React.ReactNode | ||
} | ||
/** TODO */ | ||
export interface ResponsiveProviderState { | ||
mediaQueryMatchers?: MediaQueryMatchers | ||
mediaQueryMatches: MediaQueryMatches | ||
} | ||
/** TODO */ | ||
export declare function createResponsiveComponents<M extends string>(): { | ||
Consumer: React.FunctionComponent<React.ConsumerProps<MediaQueryMatches<M>>> | ||
Provider: { | ||
new (props: ResponsiveProviderProps<M>): { | ||
isSupportedEnvironment: () => boolean | ||
/** | ||
* Create an array of media matchers that can validate each media query | ||
*/ | ||
setupMatchers: (mediaQueries: MediaQueries) => MediaQueryMatchers | ||
/** | ||
* Uses the matchers to build a map of the states of each media query | ||
*/ | ||
checkMatchers: ( | ||
mediaQueryMatchers: MediaQueryMatchers | ||
) => MediaQueryMatches | ||
/** | ||
* The function that will be called any time a media query status changes | ||
*/ | ||
mediaQueryStatusChangedCallback: () => void | ||
componentDidMount(): void | ||
componentWillUnmount(): void | ||
shouldComponentUpdate( | ||
nextProps: Readonly<ResponsiveProviderProps<M>>, | ||
nextState: Readonly<ResponsiveProviderState> | ||
): boolean | ||
render(): JSX.Element | ||
context: unknown | ||
setState<K extends keyof ResponsiveProviderState>( | ||
state: | ||
| ResponsiveProviderState | ||
| (( | ||
prevState: Readonly<ResponsiveProviderState>, | ||
props: Readonly<ResponsiveProviderProps<M>> | ||
) => | ||
| ResponsiveProviderState | ||
| Pick<ResponsiveProviderState, K> | ||
| null | ||
) | ||
| Pick<ResponsiveProviderState, K> | ||
| null, | ||
callback?: (() => void) | undefined | ||
): void | ||
forceUpdate(callback?: (() => void) | undefined): void | ||
readonly props: Readonly<ResponsiveProviderProps<M>> | ||
state: Readonly<ResponsiveProviderState> | ||
refs: { | ||
[key: string]: React.ReactInstance | ||
} | ||
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void | ||
getSnapshotBeforeUpdate?( | ||
prevProps: Readonly<ResponsiveProviderProps<M>>, | ||
prevState: Readonly<ResponsiveProviderState> | ||
): any | ||
componentDidUpdate?( | ||
prevProps: Readonly<ResponsiveProviderProps<M>>, | ||
prevState: Readonly<ResponsiveProviderState>, | ||
snapshot?: any | ||
): void | ||
componentWillMount?(): void | ||
UNSAFE_componentWillMount?(): void | ||
componentWillReceiveProps?( | ||
nextProps: Readonly<ResponsiveProviderProps<M>>, | ||
nextContext: any | ||
): void | ||
UNSAFE_componentWillReceiveProps?( | ||
nextProps: Readonly<ResponsiveProviderProps<M>>, | ||
nextContext: any | ||
): void | ||
componentWillUpdate?( | ||
nextProps: Readonly<ResponsiveProviderProps<M>>, | ||
nextState: Readonly<ResponsiveProviderState>, | ||
nextContext: any | ||
): void | ||
UNSAFE_componentWillUpdate?( | ||
nextProps: Readonly<ResponsiveProviderProps<M>>, | ||
nextState: Readonly<ResponsiveProviderState>, | ||
nextContext: any | ||
): void | ||
} | ||
contextType?: React.Context<any> | undefined | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export declare enum InteractionKey { | ||
interaction = "interaction", | ||
} | ||
/** | ||
* Encapsulates all interaction data needed by the Media component. The data is | ||
* generated on initialization so no further runtime work is necessary. | ||
*/ | ||
export declare class Interactions { | ||
static validKeys(): InteractionKey[] | ||
private _interactions | ||
constructor(interactions: { [name: string]: string }) | ||
toRuleSets(): string[] | ||
get interactions(): string[] | ||
get dynamicResponsiveMediaQueries(): {} | ||
shouldRenderMediaQuery(interaction: string, onlyMatch: string[]): boolean | ||
} |
Oops, something went wrong.