You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
509 B
20 lines
509 B
5 years ago
|
import * as React from 'react';
|
||
|
|
||
|
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
||
|
|
||
|
const SizeContext = React.createContext<SizeType>(undefined);
|
||
|
|
||
|
export interface SizeContextProps {
|
||
|
size?: SizeType;
|
||
|
}
|
||
|
|
||
|
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
|
||
|
<SizeContext.Consumer>
|
||
|
{originSize => (
|
||
|
<SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>
|
||
|
)}
|
||
|
</SizeContext.Consumer>
|
||
|
);
|
||
|
|
||
|
export default SizeContext;
|