GrowiSubNavigation.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React from 'react';
  2. import {
  3. EditorMode, useEditorMode,
  4. } from '~/stores/ui';
  5. import PagePathNav from '../PagePathNav';
  6. import styles from './GrowiSubNavigation.module.scss';
  7. export type GrowiSubNavigationProps = {
  8. pagePath?: string,
  9. pageId?: string,
  10. isNotFound?: boolean,
  11. isTagLabelsDisabled?: boolean,
  12. tags?: string[],
  13. rightComponent?: React.FunctionComponent,
  14. additionalClasses?: string[],
  15. }
  16. export const GrowiSubNavigation = (props: GrowiSubNavigationProps): JSX.Element => {
  17. const { data: editorMode } = useEditorMode();
  18. const {
  19. pageId, pagePath,
  20. rightComponent: RightComponent,
  21. additionalClasses = [],
  22. } = props;
  23. const isViewMode = editorMode === EditorMode.View;
  24. const isEditorMode = !isViewMode;
  25. return (
  26. <div className={`
  27. grw-subnav ${styles['grw-subnav']} d-flex align-items-center justify-content-between
  28. ${additionalClasses.join(' ')}`}
  29. >
  30. {/* Left side */}
  31. <div className="d-flex grw-subnav-start-side">
  32. <div className="grw-path-nav-container">
  33. { pagePath != null && (
  34. <PagePathNav pageId={pageId} pagePath={pagePath} isSingleLineMode={isEditorMode} />
  35. ) }
  36. </div>
  37. </div>
  38. {/* Right side. */}
  39. { RightComponent && (
  40. <RightComponent />
  41. ) }
  42. </div>
  43. );
  44. };