styled.ts 2.9 KB

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