helpSearchModal.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. dropdownStyle={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
  41. autoFocus
  42. {...getInputProps({type: 'text', label: placeholder, placeholder})}
  43. />
  44. </InputWrapper>
  45. )}
  46. resultFooter={
  47. <Hook name="help-modal:footer" {...{organization, closeModal}} />
  48. }
  49. />
  50. )}
  51. </ClassNames>
  52. </Body>
  53. );
  54. }
  55. const InputWrapper = styled('div')`
  56. padding: ${space(0.25)};
  57. `;
  58. const Input = styled('input')`
  59. width: 100%;
  60. padding: ${space(1)};
  61. border: none;
  62. border-radius: 8px;
  63. outline: none;
  64. &:focus {
  65. outline: none;
  66. }
  67. `;
  68. export const modalCss = css`
  69. [role='document'] {
  70. padding: 0;
  71. }
  72. `;
  73. export default withOrganization(HelpSearchModal);