deprecatedInput.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ${props.readOnly
  50. ? css`
  51. cursor: default;
  52. `
  53. : ''};
  54. &::placeholder {
  55. color: ${props.theme.formPlaceholder};
  56. }
  57. &[disabled] {
  58. background: ${props.theme.backgroundSecondary};
  59. color: ${props.theme.gray300};
  60. border: 1px solid ${props.theme.border};
  61. cursor: not-allowed;
  62. &::placeholder {
  63. color: ${props.theme.disabled};
  64. }
  65. }
  66. &:focus,
  67. &:focus-visible {
  68. outline: none;
  69. border-color: ${props.theme.focusBorder};
  70. box-shadow: ${props.theme.focusBorder} 0 0 0 1px;
  71. }
  72. `;
  73. export {inputStyles};