You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
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;
|
|
|