deprecatedInput.tsx 2.1 KB

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