index.tsx 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from 'react';
  2. import {
  3. NormalButton,
  4. DisableButton,
  5. } from './styled';
  6. export type Props = {
  7. appearance?: 'default' | 'primary' | 'primary-hollow' | 'default-hollow' | 'dark' | 'link' | 'danger-link';
  8. id?: string;
  9. isDisabled?: boolean;
  10. onClick?: (e: any) => void;
  11. onBlur?: () => void;
  12. onFocus?: () => void;
  13. shouldFitContainer?: boolean;
  14. align?: 'left' | 'center' | 'right';
  15. children: React.ReactNode;
  16. style?: {};
  17. isActive?: boolean;
  18. tabIndex?: number;
  19. };
  20. const Button: React.FunctionComponent<Props> = ({
  21. children,
  22. isDisabled,
  23. onClick,
  24. ...rest
  25. }: Props): React.ReactElement => (
  26. isDisabled ? (
  27. <DisableButton>
  28. {children}
  29. </DisableButton>
  30. ) : (
  31. <NormalButton
  32. {...rest}
  33. onMouseDown={onClick}
  34. >
  35. {children}
  36. </NormalButton>
  37. )
  38. );
  39. Button.defaultProps = {
  40. appearance: 'default',
  41. align: 'center',
  42. shouldFitContainer: false,
  43. isDisabled: false,
  44. isActive: false,
  45. onFocus: (): void => {},
  46. };
  47. export default Button;