index.tsx 707 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. align?: 'left' | 'center' | 'right';
  9. };
  10. const Typography: React.FunctionComponent<Props> = ({
  11. variant = 'title',
  12. children,
  13. ...rest
  14. }: Props) => {
  15. const getComponent = (): React.FunctionComponent => {
  16. if (variant === 'title') {
  17. return Title;
  18. }
  19. if (variant === 'subtitle') {
  20. return Subtitle;
  21. }
  22. return Body;
  23. };
  24. const Component = getComponent();
  25. return (
  26. <Component
  27. {...rest}
  28. >
  29. {children}
  30. </Component>
  31. );
  32. };
  33. export default Typography;