mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 07:39:36 +08:00
20 lines
509 B
TypeScript
20 lines
509 B
TypeScript
|
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;
|