mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
ea8ed28209
* chore: unified import method * fix lint
18 lines
521 B
TypeScript
18 lines
521 B
TypeScript
import React from 'react';
|
|
|
|
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
|
|
|
const SizeContext = React.createContext<SizeType>(undefined);
|
|
|
|
export interface SizeContextProps {
|
|
size?: SizeType;
|
|
children?: React.ReactNode;
|
|
}
|
|
|
|
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => {
|
|
const originSize = React.useContext<SizeType>(SizeContext);
|
|
return <SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>;
|
|
};
|
|
|
|
export default SizeContext;
|