Select.styled.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import styled from 'styled-components';
  2. interface Props {
  3. selectSize: 'M' | 'L';
  4. isLive?: boolean;
  5. minWidth?: string;
  6. disabled?: boolean;
  7. }
  8. interface OptionProps {
  9. disabled?: boolean;
  10. }
  11. export const Select = styled.ul<Props>`
  12. position: relative;
  13. list-style: none;
  14. display: flex;
  15. gap: ${(props) => (props.isLive ? '5px' : '0')};
  16. align-items: center;
  17. height: ${(props) => (props.selectSize === 'M' ? '32px' : '40px')};
  18. border: 1px
  19. ${({ theme, disabled }) =>
  20. disabled
  21. ? theme.select.borderColor.disabled
  22. : theme.select.borderColor.normal}
  23. solid;
  24. border-radius: 4px;
  25. font-size: 14px;
  26. width: fit-content;
  27. padding-left: 16px;
  28. padding-right: 16px;
  29. color: ${({ theme, disabled }) =>
  30. disabled ? theme.select.color.disabled : theme.select.color.normal};
  31. min-width: ${({ minWidth }) => minWidth || 'auto'};
  32. background-image: ${({ disabled }) =>
  33. `url('data:image/svg+xml,%3Csvg width="10" height="6" viewBox="0 0 10 6" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M1 1L5 5L9 1" stroke="${
  34. disabled ? '%23ABB5BA' : '%23454F54'
  35. }"/%3E%3C/svg%3E%0A') !important`};
  36. background-repeat: no-repeat !important;
  37. background-position-x: calc(100% - 8px) !important;
  38. background-position-y: 55% !important;
  39. cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
  40. &:hover:enabled {
  41. color: ${(props) => props.theme.select.color.hover};
  42. border-color: ${(props) => props.theme.select.borderColor.hover};
  43. }
  44. &:focus {
  45. outline: none;
  46. color: ${(props) => props.theme.select.color.active};
  47. border-color: ${(props) => props.theme.select.borderColor.active};
  48. }
  49. &:disabled {
  50. color: ${(props) => props.theme.select.color.disabled};
  51. border-color: ${(props) => props.theme.select.borderColor.disabled};
  52. }
  53. `;
  54. export const OptionList = styled.ul`
  55. position: absolute;
  56. top: 100%;
  57. left: 0;
  58. max-height: 228px;
  59. margin-top: 4px;
  60. background-color: ${(props) => props.theme.select.backgroundColor.normal};
  61. border: 1px ${(props) => props.theme.select.borderColor.normal} solid;
  62. border-radius: 4px;
  63. font-size: 14px;
  64. line-height: 18px;
  65. color: ${(props) => props.theme.select.color.normal};
  66. overflow-y: auto;
  67. z-index: 10;
  68. max-width: 300px;
  69. min-width: 100%;
  70. &::-webkit-scrollbar {
  71. -webkit-appearance: none;
  72. width: 7px;
  73. }
  74. &::-webkit-scrollbar-thumb {
  75. border-radius: 4px;
  76. background-color: ${(props) =>
  77. props.theme.select.optionList.scrollbar.backgroundColor};
  78. }
  79. &::-webkit-scrollbar:horizontal {
  80. height: 7px;
  81. }
  82. `;
  83. export const Option = styled.li<OptionProps>`
  84. display: flex;
  85. list-style: none;
  86. padding: 10px 12px;
  87. transition: all 0.2s ease-in-out;
  88. cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
  89. gap: 5px;
  90. color: ${(props) =>
  91. props.theme.select.color[props.disabled ? 'disabled' : 'normal']};
  92. &:hover {
  93. background-color: ${(props) =>
  94. props.theme.select.backgroundColor[props.disabled ? 'normal' : 'hover']};
  95. }
  96. &:active {
  97. background-color: ${(props) => props.theme.select.backgroundColor.active};
  98. }
  99. `;
  100. export const SelectedOption = styled.li`
  101. padding-right: 16px;
  102. list-style-position: inside;
  103. white-space: nowrap;
  104. overflow: hidden;
  105. text-overflow: ellipsis;
  106. `;