2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2023-05-12 14:53:47 +08:00
|
|
|
import useSize from './hooks/useSize';
|
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-05-12 14:53:47 +08:00
|
|
|
const mergedSize = useSize(size);
|
|
|
|
return <SizeContext.Provider value={mergedSize}>{children}</SizeContext.Provider>;
|
2023-01-01 21:17:05 +08:00
|
|
|
};
|
2020-01-03 13:38:16 +08:00
|
|
|
|
|
|
|
export default SizeContext;
|