ant-design/components/avatar/SizeContext.tsx

22 lines
627 B
TypeScript
Raw Normal View History

import * as React from 'react';
import type { ScreenSizeMap } from '../_util/responsiveObserver';
export type AvatarSize = 'large' | 'small' | 'default' | number | ScreenSizeMap;
const SizeContext = React.createContext<AvatarSize>('default');
export interface SizeContextProps {
size?: AvatarSize;
children?: React.ReactNode;
}
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
<SizeContext.Consumer>
{(originSize) => (
<SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>
)}
</SizeContext.Consumer>
);
export default SizeContext;