2019-10-13 02:41:42 +07:00
|
|
|
import React, { forwardRef } from 'react';
|
|
|
|
import { default as MaterialUITypography, TypographyProps } from '@material-ui/core/Typography';
|
|
|
|
|
|
|
|
type TextType = 'subtitle1' | 'subtitle2' | 'body1' | 'body2';
|
2019-10-31 14:12:18 +07:00
|
|
|
type TextRef = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
2019-10-13 02:41:42 +07:00
|
|
|
|
2019-10-31 14:12:18 +07:00
|
|
|
export interface TextProps extends Omit<TypographyProps, 'variant'> {
|
2019-10-13 02:41:42 +07:00
|
|
|
variant?: TextType;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The reference is already from type of the Component, so the any below is not a problem
|
2019-10-31 14:12:18 +07:00
|
|
|
const Text = forwardRef<TextRef, TextProps>(function Text(props, ref) {
|
2019-10-13 02:41:42 +07:00
|
|
|
return <MaterialUITypography {...props} ref={ref} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
Text.defaultProps = {
|
|
|
|
variant: 'subtitle1',
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Text;
|