index.tsx 668 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import { Title, Subtitle, Body } from './styled';
  3. type Props = {
  4. variant?: 'title' | 'subtitle' | 'body';
  5. light?: boolean;
  6. children: string | number;
  7. style?: {};
  8. };
  9. const Typography: React.FunctionComponent<Props> = ({
  10. variant = 'title',
  11. children,
  12. ...rest
  13. }: Props) => {
  14. const getComponent = (): React.FunctionComponent => {
  15. if (variant === 'title') {
  16. return Title;
  17. }
  18. if (variant === 'subtitle') {
  19. return Subtitle;
  20. }
  21. return Body;
  22. };
  23. const Component = getComponent();
  24. return (
  25. <Component
  26. {...rest}
  27. >
  28. {children}
  29. </Component>
  30. );
  31. };
  32. export default Typography;