deprecatedInput.tsx 2.1 KB

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