helpSearchModal.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {ClassNames, css, useTheme} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import {ModalRenderProps} from 'sentry/actionCreators/modal';
  4. import HelpSearch from 'sentry/components/helpSearch';
  5. import Hook from 'sentry/components/hook';
  6. import {t} from 'sentry/locale';
  7. import space from 'sentry/styles/space';
  8. import {Organization} from 'sentry/types';
  9. import withOrganization from 'sentry/utils/withOrganization';
  10. type Props = ModalRenderProps & {
  11. organization: Organization;
  12. placeholder?: string;
  13. };
  14. function HelpSearchModal({
  15. Body,
  16. closeModal,
  17. organization,
  18. placeholder = t('Search for documentation, FAQs, blog posts...'),
  19. ...props
  20. }: Props) {
  21. const theme = useTheme();
  22. return (
  23. <Body>
  24. <ClassNames>
  25. {({css: injectedCss}) => (
  26. <HelpSearch
  27. {...props}
  28. entryPoint="sidebar_help"
  29. dropdownClassName={injectedCss`
  30. width: 100%;
  31. border: transparent;
  32. border-top-left-radius: 0;
  33. border-top-right-radius: 0;
  34. position: initial;
  35. box-shadow: none;
  36. border-top: 1px solid ${theme.border};
  37. `}
  38. renderInput={({getInputProps}) => (
  39. <InputWrapper>
  40. <Input autoFocus {...getInputProps({type: 'text', placeholder})} />
  41. </InputWrapper>
  42. )}
  43. resultFooter={
  44. <Hook name="help-modal:footer" {...{organization, closeModal}} />
  45. }
  46. />
  47. )}
  48. </ClassNames>
  49. </Body>
  50. );
  51. }
  52. const InputWrapper = styled('div')`
  53. padding: ${space(0.25)};
  54. `;
  55. const Input = styled('input')`
  56. width: 100%;
  57. padding: ${space(1)};
  58. border: none;
  59. border-radius: 8px;
  60. outline: none;
  61. &:focus {
  62. outline: none;
  63. }
  64. `;
  65. export const modalCss = css`
  66. [role='document'] {
  67. padding: 0;
  68. }
  69. `;
  70. export default withOrganization(HelpSearchModal);