2019-02-19 11:42:05 +08:00
|
|
|
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;
|
2019-03-05 13:48:38 +08:00
|
|
|
setContentRef?: (node: HTMLElement) => void;
|
2019-02-19 11:42:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const Typography: React.SFC<InternalTypographyProps> = ({
|
|
|
|
prefixCls: customizePrefixCls,
|
|
|
|
component = 'article',
|
|
|
|
className,
|
2019-08-05 18:38:10 +08:00
|
|
|
'aria-label': ariaLabel,
|
2019-02-19 11:42:05 +08:00
|
|
|
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;
|