outline-root.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from 'react'
  2. import PropTypes from 'prop-types'
  3. import { useTranslation } from 'react-i18next'
  4. import OutlineList from './outline-list'
  5. function OutlineRoot({ outline, jumpToLine, highlightedLine }) {
  6. const { t } = useTranslation()
  7. return (
  8. <div>
  9. {outline.length ? (
  10. <OutlineList
  11. outline={outline}
  12. jumpToLine={jumpToLine}
  13. isRoot
  14. highlightedLine={highlightedLine}
  15. />
  16. ) : (
  17. <div className="outline-body-no-elements">
  18. {t('we_cant_find_any_sections_or_subsections_in_this_file')}.{' '}
  19. <a
  20. href="/learn/how-to/Using_the_File_Outline_feature"
  21. className="outline-body-link"
  22. target="_blank"
  23. rel="noopener noreferrer"
  24. >
  25. {t('find_out_more_about_the_file_outline')}
  26. </a>
  27. </div>
  28. )}
  29. </div>
  30. )
  31. }
  32. OutlineRoot.propTypes = {
  33. outline: PropTypes.array.isRequired,
  34. jumpToLine: PropTypes.func.isRequired,
  35. highlightedLine: PropTypes.number
  36. }
  37. export default OutlineRoot