diff --git a/frontend/packages/app/src/components/placeholder-box.tsx b/frontend/packages/app/src/components/placeholder-box.tsx index 9c34969384..ef28ee4c36 100644 --- a/frontend/packages/app/src/components/placeholder-box.tsx +++ b/frontend/packages/app/src/components/placeholder-box.tsx @@ -12,7 +12,7 @@ export const Placeholder = ({ ) diff --git a/frontend/packages/app/src/components/titlebar/index.tsx b/frontend/packages/app/src/components/titlebar/index.tsx index e6a1045bb0..17cd43c8b0 100644 --- a/frontend/packages/app/src/components/titlebar/index.tsx +++ b/frontend/packages/app/src/components/titlebar/index.tsx @@ -1,5 +1,6 @@ -import {lazy} from 'react' -import {useAppContext} from '@mintter/app/src/app-context' +import {AppPlatform, useAppContext} from '@mintter/app/src/app-context' +import {TitlebarWrapper} from '@mintter/ui' +import {Suspense, lazy, useMemo} from 'react' var TitleBarMacos = lazy(() => import('./macos')) var TitleBarWindows = lazy(() => import('./windows')) @@ -12,9 +13,24 @@ export interface TitleBarProps { export function TitleBar(props: TitleBarProps) { const {platform} = useAppContext() - if (platform == 'darwin') return - if (platform == 'win32') return - if (platform == 'linux') return - console.warn(`Titlebar: unsupported platform: ${platform}`) - return + let Component = useMemo(() => getComponent(platform), [platform]) + return ( + }> + + + ) +} + +function getComponent(platform: AppPlatform) { + switch (platform) { + case 'win32': + return TitleBarWindows + case 'linux': + return TitleBarLinux + case 'darwin': + return TitleBarMacos + default: + console.warn(`Titlebar: unsupported platform: ${platform}`) + return TitleBarMacos + } } diff --git a/frontend/packages/app/src/editor/editor.tsx b/frontend/packages/app/src/editor/editor.tsx index ca898882ec..a62453542e 100644 --- a/frontend/packages/app/src/editor/editor.tsx +++ b/frontend/packages/app/src/editor/editor.tsx @@ -1,17 +1,13 @@ import '@mintter/app/src/blocknote-core/style.css' -import {BlockNoteView} from '@mintter/app/src/blocknote-react' -import {HyperDocsEditor} from '@mintter/app/src/models/documents' -import {Container, YStack} from '@mintter/ui' +import { BlockNoteView } from '@mintter/app/src/blocknote-react' +import { HyperDocsEditor } from '@mintter/app/src/models/documents' +import { YStack } from '@mintter/ui' import './editor.css' -export function HyperDocsEditorView({editor}: {editor: HyperDocsEditor}) { +export function HyperMediaEditorView({editor}: {editor: HyperDocsEditor}) { return } export function HDEditorContainer({children}: {children: React.ReactNode}) { - return ( - <> - {children} - - ) + return {children} } diff --git a/frontend/packages/app/src/pages/document-placeholder.tsx b/frontend/packages/app/src/pages/document-placeholder.tsx new file mode 100644 index 0000000000..6e183a30c0 --- /dev/null +++ b/frontend/packages/app/src/pages/document-placeholder.tsx @@ -0,0 +1,32 @@ +import {YStack} from '@mintter/ui' +import {Placeholder} from '../components/placeholder-box' + +export function DocumentPlaceholder() { + // TODO: update shell + return ( + + + + + + + + ) +} + +function BlockPlaceholder() { + return ( + + + + + + + ) +} diff --git a/frontend/packages/app/src/pages/main.tsx b/frontend/packages/app/src/pages/main.tsx index 12b25b31a9..885152fe44 100644 --- a/frontend/packages/app/src/pages/main.tsx +++ b/frontend/packages/app/src/pages/main.tsx @@ -10,10 +10,11 @@ import { } from '@mintter/app/src/utils/navigation' import {YStack} from '@mintter/ui' import {ProsemirrorAdapterProvider} from '@prosemirror-adapter/react' -import {lazy, useMemo} from 'react' +import {lazy, Suspense, useMemo} from 'react' import {ErrorBoundary} from 'react-error-boundary' import {NotFoundPage} from './base' import './polyfills' +import {DocumentPlaceholder} from './document-placeholder' var PublicationList = lazy( () => import('@mintter/app/src/pages/publication-list-page'), @@ -34,32 +35,72 @@ var QuickSwitcher = lazy( () => import('@mintter/app/src/components/quick-switcher'), ) +function BaseLoading() { + return Loading... +} + function getPageComponent(navRoute: NavRoute) { switch (navRoute.key) { case 'home': - return PublicationList + return { + PageComponent: PublicationList, + Fallback: BaseLoading, + } case 'groups': - return Groups + return { + PageComponent: Groups, + Fallback: BaseLoading, + } case 'group': - return Group + return { + PageComponent: Group, + Fallback: BaseLoading, + } case 'drafts': - return DraftList + return { + PageComponent: DraftList, + Fallback: BaseLoading, + } case 'site': - return Site + return { + PageComponent: Site, + Fallback: BaseLoading, + } case 'contacts': - return Contacts + return { + PageComponent: Contacts, + Fallback: BaseLoading, + } case 'account': - return Account + return { + PageComponent: Account, + Fallback: BaseLoading, + } case 'publication': - return Publication + return { + PageComponent: Publication, + Fallback: DocumentPlaceholder, + } case 'draft': - return Draft + return { + PageComponent: Draft, + Fallback: DocumentPlaceholder, + } case 'settings': - return Settings + return { + PageComponent: Settings, + Fallback: BaseLoading, + } case 'global-publications': - return GlobalPublicationList + return { + PageComponent: GlobalPublicationList, + Fallback: BaseLoading, + } default: - return NotFoundPage + return { + PageComponent: NotFoundPage, + Fallback: BaseLoading, + } } } @@ -67,7 +108,10 @@ export default function Main() { const navR = useNavRoute() const isSettings = navR.key == 'settings' const navigate = useNavigate() - const PageComponent = useMemo(() => getPageComponent(navR), [navR.key]) + const {PageComponent, Fallback} = useMemo( + () => getPageComponent(navR), + [navR.key], + ) const routeKey = useMemo(() => getRouteKey(navR), [navR]) useListen( 'open_route', @@ -78,20 +122,22 @@ export default function Main() { [navigate], ) return ( - + - { - window.location.reload() - }} - > - - - - {!isSettings ? : null} - {/* */} - + }> + { + window.location.reload() + }} + > + + + + {!isSettings ? : null} + {/* */} + + ) }