styled.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import styled, { css } from 'styled-components';
  2. const align: { [index: string]: string } = {
  3. left: 'flex-start',
  4. center: 'center',
  5. right: 'flex-end',
  6. };
  7. const staticStyles = css`
  8. border-width: 0;
  9. border-radius: 4px;
  10. box-sizing: border-box;
  11. font-size: 1.2rem;
  12. font-style: normal;
  13. transition: all 0.3s linear;
  14. cursor: pointer;
  15. outline: none;
  16. padding: 5px 20px;
  17. min-width: 80px;
  18. `;
  19. const btnTheme: { [index: string]: any } = {
  20. default: css`
  21. color: black;
  22. background-color: transparent;
  23. border: 1.5px solid transparent;
  24. &:hover {
  25. background-color: ${({ theme }) => theme.colors['soft-blue']};
  26. }
  27. `,
  28. primary: css`
  29. color: white;
  30. background-color: ${({ theme }) => theme.colors.primary};
  31. border: 1.5px solid ${({ theme }) => theme.colors.primary};
  32. &:hover {
  33. background-color: ${({ theme }) => theme.colors['french-blue']};
  34. border: 1.5px solid ${({ theme }) => theme.colors['french-blue']};
  35. }
  36. `,
  37. 'primary-hollow': css`
  38. color: black;
  39. background-color: white;
  40. border: 1.5px solid ${({ theme }) => theme.colors.primary};
  41. &:hover {
  42. background-color: ${({ theme }) => theme.colors['primary-light']};
  43. }
  44. `,
  45. 'danger-hollow': css`
  46. color: ${({ theme }) => theme.colors.danger};
  47. background-color: white;
  48. border: 1.5px solid ${({ theme }) => theme.colors.danger};
  49. &:hover {
  50. background-color: white;
  51. }
  52. `,
  53. 'default-hollow': css`
  54. color: black;
  55. background-color: white;
  56. border: 1.5px solid ${({ theme }) => theme.colors.black56};
  57. &:hover {
  58. color: white;
  59. background-color: ${({ theme }) => theme.colors.black38};
  60. }
  61. `,
  62. link: css`
  63. color: ${({ theme }) => theme.colors.primary};
  64. background-color: transparent;
  65. border: none;
  66. text-decoration: underline;
  67. padding: 5px 0;
  68. `,
  69. 'danger-link': css`
  70. color: ${({ theme }) => theme.colors.error};
  71. background-color: transparent;
  72. border: none;
  73. text-decoration: underline;
  74. padding: 5px 0;
  75. `,
  76. dark: css`
  77. color: #ffffff;
  78. background-color: #000000;
  79. border: 1.5px solid #000000;
  80. &:hover {
  81. background-color: #333333;
  82. border: 1.5px solid #333333;
  83. }
  84. `,
  85. };
  86. const activeTheme: { [index: string]: any } = {
  87. default: css`
  88. background-color: ${({ theme }) => theme.colors['soft-blue']};
  89. `,
  90. primary: css`
  91. background-color: ${({ theme }) => theme.colors['french-blue']};
  92. border: 1.5px solid ${({ theme }) => theme.colors['french-blue']};
  93. `,
  94. 'primary-hollow': css`
  95. background-color: ${({ theme }) => theme.colors['primary-light']};
  96. `,
  97. 'default-hollow': css`
  98. background-color: ${({ theme }) => theme.colors.black38};
  99. `,
  100. };
  101. export const NormalButton = styled('div')<{
  102. appearance?: string;
  103. shouldFitContainer?: boolean;
  104. align?: string;
  105. isActive?: boolean;
  106. }>`
  107. ${staticStyles}
  108. ${props => btnTheme[props.appearance || 'default']};
  109. ${props =>
  110. props.shouldFitContainer
  111. ? css`
  112. width: 100%;
  113. `
  114. : null}
  115. ${props =>
  116. props.isActive
  117. ? activeTheme[props.appearance || 'default']
  118. : null}
  119. display: inline-flex;
  120. justify-content: ${props => align[props.align || 'center']};
  121. align-items: center;
  122. `;
  123. export const DisableButton = styled.button`
  124. ${staticStyles}
  125. color: ${({ theme }) => theme.colors.black38};
  126. background-color: #eeeff3;
  127. cursor: not-allowed;
  128. `;