2020-01-03 13:38:16 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
|
|
|
|
|
|
|
const SizeContext = React.createContext<SizeType>(undefined);
|
|
|
|
|
|
|
|
export interface SizeContextProps {
|
|
|
|
size?: SizeType;
|
2022-04-08 22:55:42 +08:00
|
|
|
children?: React.ReactNode;
|
2020-01-03 13:38:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
|
|
|
|
<SizeContext.Consumer>
|
2022-11-19 13:47:33 +08:00
|
|
|
{(originSize) => (
|
2020-01-03 13:38:16 +08:00
|
|
|
<SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>
|
|
|
|
)}
|
|
|
|
</SizeContext.Consumer>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default SizeContext;
|