2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2020-01-03 13:38:16 +08:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-01-01 21:17:05 +08:00
|
|
|
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => {
|
2023-06-25 10:14:41 +08:00
|
|
|
const originSize = React.useContext<SizeType>(SizeContext);
|
|
|
|
return <SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>;
|
2023-01-01 21:17:05 +08:00
|
|
|
};
|
2020-01-03 13:38:16 +08:00
|
|
|
|
|
|
|
export default SizeContext;
|