mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
5b8e4e51e9
* chore: bump types def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: free --legacy-peer-deps * chore: ignore peer * chore: fix ts logic * chore: use fork docsearch * chore: fix demo ts
22 lines
619 B
TypeScript
22 lines
619 B
TypeScript
import * as React from 'react';
|
|
import { ScreenSizeMap } from '../_util/responsiveObserve';
|
|
|
|
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;
|