styled.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. 'default-hollow': css`
  47. color: black;
  48. background-color: white;
  49. border: 1.5px solid ${color.black56};
  50. &:hover {
  51. color: white;
  52. background-color: ${color.black38};
  53. }
  54. `,
  55. link: css`
  56. color: ${color.primary};
  57. background-color: transparent;
  58. border: none;
  59. text-decoration: underline;
  60. padding: 5px 0;
  61. `,
  62. 'danger-link': css`
  63. color: ${color.error};
  64. background-color: transparent;
  65. border: none;
  66. text-decoration: underline;
  67. padding: 5px 0;
  68. `,
  69. dark: css`
  70. color: #ffffff;
  71. background-color: #000000;
  72. border: 1.5px solid #000000;
  73. &:hover {
  74. background-color: #333333;
  75. border: 1.5px solid #333333;
  76. }
  77. `,
  78. };
  79. const activeTheme: {[index: string]: any} = {
  80. default: css`
  81. background-color: ${color['soft-blue']};
  82. `,
  83. primary: css`
  84. background-color: ${color['french-blue']};
  85. border: 1.5px solid ${color['french-blue']};
  86. `,
  87. 'primary-hollow': css`
  88. background-color: ${color['primary-light']};
  89. `,
  90. 'default-hollow': css`
  91. background-color: ${color.black38};
  92. `,
  93. };
  94. export const NormalButton = styled('div')<{appearance?: string; shouldFitContainer?: boolean; align?: string; isActive?: boolean}>`
  95. ${staticStyles}
  96. ${props => theme[props.appearance || 'default']};
  97. ${props => (props.shouldFitContainer ? css`
  98. width: 100%;
  99. ` : null)}
  100. ${props => (props.isActive ? activeTheme[props.appearance || 'default'] : null)}
  101. display: inline-flex;
  102. justify-content: ${props => align[props.align || 'center']};
  103. align-items: center;
  104. `;
  105. export const DisableButton = styled.button`
  106. ${staticStyles}
  107. color: ${color.black38};
  108. background-color: #eeeff3;
  109. cursor: not-allowed;
  110. `;