input.tsx 1.3 KB

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