deprecatedInput.tsx 2.1 KB

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