mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
|
|
|
export interface TypographyProps {
|
|
id?: string;
|
|
prefixCls?: string;
|
|
className?: string;
|
|
style?: React.CSSProperties;
|
|
children?: React.ReactNode;
|
|
['aria-label']?: string;
|
|
}
|
|
|
|
interface InternalTypographyProps extends TypographyProps {
|
|
component?: string;
|
|
setContentRef?: (node: HTMLElement) => void;
|
|
}
|
|
|
|
const Typography: React.SFC<InternalTypographyProps> = ({
|
|
prefixCls: customizePrefixCls,
|
|
component = 'article',
|
|
className,
|
|
'aria-label': ariaLabel,
|
|
setContentRef,
|
|
children,
|
|
...restProps
|
|
}) => (
|
|
<ConfigConsumer>
|
|
{({ getPrefixCls }: ConfigConsumerProps) => {
|
|
const Component = component as any;
|
|
const prefixCls = getPrefixCls('typography', customizePrefixCls);
|
|
|
|
return (
|
|
<Component
|
|
className={classNames(prefixCls, className)}
|
|
aria-label={ariaLabel}
|
|
ref={setContentRef}
|
|
{...restProps}
|
|
>
|
|
{children}
|
|
</Component>
|
|
);
|
|
}}
|
|
</ConfigConsumer>
|
|
);
|
|
|
|
export default Typography;
|