input.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {css} from '@emotion/react';
  2. import {Theme} from 'app/utils/theme';
  3. export const INPUT_PADDING = 10;
  4. type Props = {
  5. disabled?: boolean;
  6. monospace?: boolean;
  7. readOnly?: boolean;
  8. theme: Theme;
  9. };
  10. const inputStyles = (props: Props) =>
  11. css`
  12. color: ${props.disabled ? props.theme.disabled : props.theme.formText};
  13. display: block;
  14. width: 100%;
  15. background: ${props.theme.background};
  16. border: 1px solid ${props.theme.border};
  17. border-radius: ${props.theme.borderRadius};
  18. box-shadow: inset ${props.theme.dropShadowLight};
  19. padding: ${INPUT_PADDING}px;
  20. transition: border 0.1s linear;
  21. resize: vertical;
  22. height: 40px;
  23. ${props.monospace ? `font-family: ${props.theme.text.familyMono}` : ''};
  24. ${props.readOnly
  25. ? css`
  26. cursor: default;
  27. `
  28. : ''};
  29. &:focus {
  30. outline: none;
  31. }
  32. &:hover,
  33. &:focus,
  34. &:active {
  35. border: 1px solid ${props.theme.border};
  36. }
  37. &::placeholder {
  38. color: ${props.theme.formPlaceholder};
  39. }
  40. &[disabled] {
  41. background: ${props.theme.backgroundSecondary};
  42. color: ${props.theme.gray300};
  43. border: 1px solid ${props.theme.border};
  44. cursor: not-allowed;
  45. &::placeholder {
  46. color: ${props.theme.disabled};
  47. }
  48. }
  49. &.focus-visible {
  50. box-shadow: rgba(209, 202, 216, 0.5) 0 0 0 3px;
  51. }
  52. `;
  53. export {inputStyles};