import React from 'react'; import dynamic from 'next/dynamic'; import { EditorMode, useEditorMode, } from '~/stores/ui'; import { TagLabelsSkeleton } from '../Page/TagLabels'; import PagePathNav from '../PagePathNav'; import DrawerToggler from './DrawerToggler'; import styles from './GrowiSubNavigation.module.scss'; const TagLabels = dynamic(() => import('../Page/TagLabels').then(mod => mod.TagLabels), { ssr: false, loading: TagLabelsSkeleton, }); export type GrowiSubNavigationProps = { pagePath?: string, pageId?: string, isNotFound?: boolean, showDrawerToggler?: boolean, showTagLabel?: boolean, isTagLabelsDisabled?: boolean, isDrawerMode?: boolean, isCompactMode?: boolean, tags?: string[], tagsUpdatedHandler?: (newTags: string[]) => Promise | void, rightComponent?: React.FunctionComponent, additionalClasses?: string[], } export const GrowiSubNavigation = (props: GrowiSubNavigationProps): JSX.Element => { const { data: editorMode } = useEditorMode(); const { pageId, pagePath, showDrawerToggler, showTagLabel, isTagLabelsDisabled, isDrawerMode, isCompactMode, tags, tagsUpdatedHandler, rightComponent: RightComponent, additionalClasses = [], } = props; const isViewMode = editorMode === EditorMode.View; const isEditorMode = !isViewMode; const compactModeClasses = isCompactMode ? 'grw-subnav-compact d-print-none' : ''; return (
{/* Left side */}
{ (showDrawerToggler && isDrawerMode) && (
) }
{ (showTagLabel && !isCompactMode) && (
{ tags != null ? : }
) } { pagePath != null && ( ) }
{/* Right side. */} { RightComponent && ( ) }
); };