deprecatedInput.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {css, Theme} from '@emotion/react';
  2. /**
  3. * Inner padding for inputs. This is deprecated. If necessary, use the values
  4. * in `theme.formPadding` instead. Be sure to specify the input size, e.g.
  5. * `theme.formPadding.md.paddingLeft`.
  6. *
  7. * @deprecated
  8. */
  9. export const INPUT_PADDING = 10;
  10. type Props = {
  11. theme: Theme;
  12. disabled?: boolean;
  13. monospace?: boolean;
  14. readOnly?: boolean;
  15. };
  16. /**
  17. * Styles for inputs/textareas. This is deprecated. Consider these
  18. * alternatives:
  19. *
  20. * - [Strongly Recommended] Use the existing form components, such as:
  21. * + <Input /> from 'sentry/components/input'
  22. * + <Textarea /> from 'sentry/components/forms/controls/textarea'
  23. * + <TextCopyInput /> from 'sentry/components/textCopyInput'
  24. * + …
  25. *
  26. * - Import `inputStyles` as a named import from 'sentry/components/input'.
  27. * This is only meant for use in core, reusable components. It should rarely
  28. * be used elsewhere (chances are you don't want all the styles that it comes
  29. * with).
  30. *
  31. * @deprecated
  32. */
  33. const inputStyles = (props: Props) => css`
  34. color: ${props.disabled ? props.theme.disabled : props.theme.formText};
  35. display: block;
  36. width: 100%;
  37. background: ${props.theme.background};
  38. border: 1px solid ${props.theme.border};
  39. border-radius: ${props.theme.borderRadius};
  40. box-shadow: inset ${props.theme.dropShadowMedium};
  41. padding: ${INPUT_PADDING}px;
  42. resize: vertical;
  43. height: 40px;
  44. transition:
  45. border 0.1s,
  46. box-shadow 0.1s;
  47. ${props.monospace ? `font-family: ${props.theme.text.familyMono}` : ''};
  48. ${props.readOnly
  49. ? css`
  50. cursor: default;
  51. `
  52. : ''};
  53. &::placeholder {
  54. color: ${props.theme.formPlaceholder};
  55. }
  56. &[disabled] {
  57. background: ${props.theme.backgroundSecondary};
  58. color: ${props.theme.gray300};
  59. border: 1px solid ${props.theme.border};
  60. cursor: not-allowed;
  61. &::placeholder {
  62. color: ${props.theme.disabled};
  63. }
  64. }
  65. &:focus,
  66. &.focus-visible {
  67. outline: none;
  68. border-color: ${props.theme.focusBorder};
  69. box-shadow: ${props.theme.focusBorder} 0 0 0 1px;
  70. }
  71. `;
  72. export {inputStyles};