styled.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. `;
  19. const theme: {[index: string]: any} = {
  20. default: css`
  21. color: black;
  22. background-color: transparent;
  23. border: 1.5px solid transparent;
  24. &:hover {
  25. background-color: ${color['soft-blue']};
  26. }
  27. &:focus, &:active {
  28. background-color: ${color['soft-blue']};
  29. }
  30. `,
  31. primary: css`
  32. color: white;
  33. background-color: ${color.primary};
  34. border: 1.5px solid ${color.primary};
  35. &:hover {
  36. background-color: ${color['french-blue']};
  37. border: 1.5px solid ${color['french-blue']};
  38. }
  39. &:focus, &:active {
  40. background-color: ${color['french-blue']};
  41. border: 1.5px solid ${color['french-blue']};
  42. }
  43. `,
  44. 'primary-hollow': css`
  45. color: black;
  46. background-color: white;
  47. border: 1.5px solid ${color.primary};
  48. &:hover {
  49. background-color: ${color['primary-light']};
  50. }
  51. &:focus, &:active {
  52. background-color: ${color['primary-light']};
  53. }
  54. `,
  55. 'default-hollow': css`
  56. color: black;
  57. background-color: white;
  58. border: 1.5px solid ${color.black56};
  59. &:hover {
  60. background-color: ${color.black38};
  61. }
  62. &:focus, &:active {
  63. background-color: ${color.black38};
  64. }
  65. `,
  66. link: css`
  67. color: ${color.primary};
  68. background-color: transparent;
  69. border: none;
  70. text-decoration: underline;
  71. padding: 5px 0;
  72. &:hover {
  73. }
  74. &:focus, &:active {
  75. }
  76. `,
  77. 'danger-link': css`
  78. color: ${color.error};
  79. background-color: transparent;
  80. border: none;
  81. text-decoration: underline;
  82. padding: 5px 0;
  83. &:hover {
  84. }
  85. &:focus, &:active {
  86. }
  87. `,
  88. };
  89. export const NormalButton = styled('button')<{appearance?: string; shouldFitContainer?: boolean; align?: string}>`
  90. ${staticStyles}
  91. ${props => theme[props.appearance || 'default']};
  92. ${props => (props.shouldFitContainer ? css`
  93. width: 100%;
  94. ` : null)}
  95. display: inline-flex;
  96. justify-content: ${props => align[props.align || 'center']};
  97. align-items: center;
  98. `;
  99. export const DisableButton = styled.button`
  100. ${staticStyles}
  101. color: ${color.black38};
  102. background-color: #eeeff3;
  103. cursor: not-allowed;
  104. `;