forked from spacedriveapp/spacedrive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eng 142 fix interface hot reload (spacedriveapp#252)
* fix interface hot reloading * AppPropsContext exsiting in App.tsx was the issue :D * type export fix
- Loading branch information
Showing
26 changed files
with
256 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import clsx from 'clsx'; | ||
import React, { useContext } from 'react'; | ||
import { Outlet } from 'react-router-dom'; | ||
|
||
import { AppPropsContext } from './AppPropsContext'; | ||
import { Sidebar } from './components/file/Sidebar'; | ||
|
||
export function AppLayout() { | ||
const appProps = useContext(AppPropsContext); | ||
|
||
const isWindowRounded = appProps?.platform === 'macOS'; | ||
const hasWindowBorder = appProps?.platform !== 'browser' && appProps?.platform !== 'windows'; | ||
|
||
return ( | ||
<div | ||
onContextMenu={(e) => { | ||
// TODO: allow this on some UI text at least / disable default browser context menu | ||
e.preventDefault(); | ||
return false; | ||
}} | ||
className={clsx( | ||
'flex flex-row h-screen overflow-hidden text-gray-900 select-none dark:text-white', | ||
isWindowRounded && 'rounded-xl', | ||
hasWindowBorder && 'border border-gray-200 dark:border-gray-500' | ||
)} | ||
> | ||
<Sidebar /> | ||
<div className="flex flex-col w-full min-h-full"> | ||
<div className="relative flex w-full min-h-full bg-white dark:bg-gray-650"> | ||
<Outlet /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { BaseTransport } from '@sd/client'; | ||
import { createContext } from 'react'; | ||
|
||
export const AppPropsContext = createContext<AppProps | null>(null); | ||
|
||
export type Platform = 'browser' | 'macOS' | 'windows' | 'linux'; | ||
|
||
export interface AppProps { | ||
transport: BaseTransport; | ||
platform: Platform; | ||
convertFileSrc: (url: string) => string; | ||
openDialog: (options: { directory?: boolean }) => Promise<string | string[] | null>; | ||
onClose?: () => void; | ||
onMinimize?: () => void; | ||
onFullscreen?: () => void; | ||
onOpen?: (path: string) => void; | ||
isFocused?: boolean; | ||
demoMode?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { useEffect } from 'react'; | ||
import { Route, Routes, useLocation } from 'react-router-dom'; | ||
|
||
import { AppLayout } from './AppLayout'; | ||
import { NotFound } from './NotFound'; | ||
import { ContentScreen } from './screens/Content'; | ||
import { DebugScreen } from './screens/Debug'; | ||
import { ExplorerScreen } from './screens/Explorer'; | ||
import { OverviewScreen } from './screens/Overview'; | ||
import { PhotosScreen } from './screens/Photos'; | ||
import { RedirectPage } from './screens/Redirect'; | ||
import { SettingsScreen } from './screens/Settings'; | ||
import { TagScreen } from './screens/Tag'; | ||
import AppearanceSettings from './screens/settings/AppearanceSettings'; | ||
import ContactsSettings from './screens/settings/ContactsSettings'; | ||
import ExperimentalSettings from './screens/settings/ExperimentalSettings'; | ||
import GeneralSettings from './screens/settings/GeneralSettings'; | ||
import KeysSettings from './screens/settings/KeysSetting'; | ||
import LibrarySettings from './screens/settings/LibrarySettings'; | ||
import LocationSettings from './screens/settings/LocationSettings'; | ||
import SecuritySettings from './screens/settings/SecuritySettings'; | ||
import SharingSettings from './screens/settings/SharingSettings'; | ||
import SyncSettings from './screens/settings/SyncSettings'; | ||
import TagsSettings from './screens/settings/TagsSettings'; | ||
|
||
export function AppRouter() { | ||
let location = useLocation(); | ||
let state = location.state as { backgroundLocation?: Location }; | ||
|
||
useEffect(() => { | ||
console.log({ url: location.pathname }); | ||
}, [state]); | ||
|
||
return ( | ||
<> | ||
<Routes location={state?.backgroundLocation || location}> | ||
<Route path="/" element={<AppLayout />}> | ||
<Route index element={<RedirectPage to="/overview" />} /> | ||
<Route path="overview" element={<OverviewScreen />} /> | ||
<Route path="content" element={<ContentScreen />} /> | ||
<Route path="photos" element={<PhotosScreen />} /> | ||
<Route path="debug" element={<DebugScreen />} /> | ||
<Route path={'settings'} element={<SettingsScreen />}> | ||
<Route index element={<GeneralSettings />} /> | ||
<Route path="appearance" element={<AppearanceSettings />} /> | ||
<Route path="contacts" element={<ContactsSettings />} /> | ||
<Route path="experimental" element={<ExperimentalSettings />} /> | ||
<Route path="general" element={<GeneralSettings />} /> | ||
<Route path="keys" element={<KeysSettings />} /> | ||
<Route path="library" element={<LibrarySettings />} /> | ||
<Route path="security" element={<SecuritySettings />} /> | ||
<Route path="locations" element={<LocationSettings />} /> | ||
<Route path="sharing" element={<SharingSettings />} /> | ||
<Route path="sync" element={<SyncSettings />} /> | ||
<Route path="tags" element={<TagsSettings />} /> | ||
</Route> | ||
<Route path="explorer/:id" element={<ExplorerScreen />} /> | ||
<Route path="tag/:id" element={<TagScreen />} /> | ||
<Route path="*" element={<NotFound />} /> | ||
</Route> | ||
</Routes> | ||
</> | ||
); | ||
} |
Oops, something went wrong.