index.tsx 1.1 KB

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