Button.styled.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import styled from 'styled-components';
  2. export interface ButtonProps {
  3. buttonType: 'primary' | 'secondary';
  4. buttonSize: 'S' | 'M' | 'L';
  5. isInverted?: boolean;
  6. }
  7. const StyledButton = styled.button<ButtonProps>`
  8. display: flex;
  9. flex-direction: row;
  10. align-items: center;
  11. justify-content: center;
  12. padding: 0 12px;
  13. border: none;
  14. border-radius: 4px;
  15. white-space: nowrap;
  16. background: ${({ isInverted, buttonType, theme }) =>
  17. isInverted
  18. ? 'transparent'
  19. : theme.button[buttonType].backgroundColor.normal};
  20. color: ${({ isInverted, buttonType, theme }) =>
  21. isInverted
  22. ? theme.button[buttonType].invertedColors.normal
  23. : theme.button[buttonType].color.normal};
  24. font-size: ${({ theme, buttonSize }) => theme.button.fontSize[buttonSize]};
  25. font-weight: 500;
  26. height: ${({ theme, buttonSize }) => theme.button.height[buttonSize]};
  27. &:hover:enabled {
  28. background: ${({ isInverted, buttonType, theme }) =>
  29. isInverted
  30. ? 'transparent'
  31. : theme.button[buttonType].backgroundColor.hover};
  32. color: ${({ isInverted, buttonType, theme }) =>
  33. isInverted
  34. ? theme.button[buttonType].invertedColors.hover
  35. : theme.button[buttonType].color};
  36. cursor: pointer;
  37. }
  38. &:active:enabled {
  39. background: ${({ isInverted, buttonType, theme }) =>
  40. isInverted
  41. ? 'transparent'
  42. : theme.button[buttonType].backgroundColor.active};
  43. color: ${({ isInverted, buttonType, theme }) =>
  44. isInverted
  45. ? theme.button[buttonType].invertedColors.active
  46. : theme.button[buttonType].color};
  47. }
  48. &:disabled {
  49. opacity: 0.5;
  50. cursor: not-allowed;
  51. background: ${({ buttonType, theme }) =>
  52. theme.button[buttonType].backgroundColor.disabled};
  53. color: ${({ buttonType, theme }) =>
  54. theme.button[buttonType].color.disabled};
  55. }
  56. & a {
  57. color: ${({ theme }) => theme.button.primary.color};
  58. }
  59. & svg {
  60. margin-right: 7px;
  61. fill: ${({ theme, disabled, buttonType }) =>
  62. disabled
  63. ? theme.button[buttonType].color.disabled
  64. : theme.button[buttonType].color.normal};
  65. }
  66. `;
  67. export default StyledButton;