mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +08:00
ea8ed28209
* chore: unified import method * fix lint
19 lines
609 B
TypeScript
19 lines
609 B
TypeScript
import 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 }) => {
|
|
const originSize = React.useContext<AvatarSize>(SizeContext);
|
|
return <SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>;
|
|
};
|
|
|
|
export default SizeContext;
|