ant-design/components/config-provider/SizeContext.tsx
二货机器人 5ebac5f9d6
feat: Form & ConfigProvider support component size (#20570)
* feat: Support form & ConfigProvider set component size

* update snapshot

* fix lint

* rm only

* update doc

* Table & Card support sizing

* Update snapshot

* fix lint

* update snapshot

* flush rest snapshot
2020-01-03 13:38:16 +08:00

20 lines
509 B
TypeScript

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