deprecatedInput.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {css} from '@emotion/react';
  2. import {Theme} from 'sentry/utils/theme';
  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) =>
  35. css`
  36. color: ${props.disabled ? props.theme.disabled : props.theme.formText};
  37. display: block;
  38. width: 100%;
  39. background: ${props.theme.background};
  40. border: 1px solid ${props.theme.border};
  41. border-radius: ${props.theme.borderRadius};
  42. box-shadow: inset ${props.theme.dropShadowLight};
  43. padding: ${INPUT_PADDING}px;
  44. resize: vertical;
  45. height: 40px;
  46. transition: border 0.1s, 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};