Input.styled.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import styled, { css } from 'styled-components';
  2. export interface InputProps {
  3. inputSize?: 'S' | 'M' | 'L';
  4. search: boolean;
  5. }
  6. const INPUT_SIZES = {
  7. S: '24px',
  8. M: '32px',
  9. L: '40px',
  10. };
  11. export const Wrapper = styled.div`
  12. position: relative;
  13. &:hover {
  14. svg:first-child {
  15. fill: ${({ theme }) => theme.input.icon.hover};
  16. }
  17. }
  18. svg:first-child {
  19. position: absolute;
  20. top: 8px;
  21. line-height: 0;
  22. z-index: 1;
  23. left: 12px;
  24. right: unset;
  25. height: 16px;
  26. width: 16px;
  27. fill: ${({ theme }) => theme.input.icon.color};
  28. }
  29. `;
  30. export const Input = styled.input<InputProps>(
  31. ({ theme: { input }, inputSize, search }) => css`
  32. background-color: ${input.backgroundColor.normal};
  33. border: 1px ${input.borderColor.normal} solid;
  34. border-radius: 4px;
  35. color: ${input.color.normal};
  36. height: ${inputSize && INPUT_SIZES[inputSize]
  37. ? INPUT_SIZES[inputSize]
  38. : '40px'};
  39. width: 100%;
  40. padding-left: ${search ? '36px' : '12px'};
  41. font-size: 14px;
  42. &::placeholder {
  43. color: ${input.color.placeholder.normal};
  44. font-size: 14px;
  45. }
  46. &:hover {
  47. border-color: ${input.borderColor.hover};
  48. }
  49. &:focus {
  50. outline: none;
  51. border-color: ${input.borderColor.focus};
  52. &::placeholder {
  53. color: transparent;
  54. }
  55. }
  56. &:disabled {
  57. color: ${input.color.disabled};
  58. border-color: ${input.borderColor.disabled};
  59. background-color: ${input.backgroundColor.disabled};
  60. cursor: not-allowed;
  61. }
  62. &:read-only {
  63. color: ${input.color.readOnly};
  64. border: none;
  65. background-color: ${input.backgroundColor.readOnly};
  66. &:focus {
  67. &::placeholder {
  68. color: ${input.color.placeholder.readOnly};
  69. }
  70. }
  71. cursor: not-allowed;
  72. }
  73. `
  74. );
  75. export const FormError = styled.p`
  76. color: ${({ theme }) => theme.input.error};
  77. font-size: 12px;
  78. `;
  79. export const InputHint = styled.p`
  80. font-size: 0.85rem;
  81. margin-top: 0.25rem;
  82. color: ${({ theme }) => theme.clusterConfigForm.inputHintText.secondary};
  83. `;