Skip to content

Major Change: Routing #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 74 additions & 24 deletions Eplant/Eplant.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,90 @@
// import useStateWithStorage from '@eplant/util/useStateWithStorage'
import { Route, Routes } from 'react-router-dom'

import { CssBaseline, ThemeProvider } from '@mui/material'
import { useEffect } from 'react'

import { Box, CircularProgress, CssBaseline, useTheme } from '@mui/material'
import { ThemeProvider } from '@mui/material/styles'

import { dark, light } from './css/theme'
import Sidebar from './UI/Sidebar'
import { URLStateProvider } from './state/URLStateProvider'
import { ViewContainer } from './UI/Layout/ViewContainer'
import Sidebar, { collapsedSidebarWidth, sidebarWidth } from './UI/Sidebar'
import { useConfig } from './config'
import EplantLayout from './EplantLayout'
import { useDarkMode } from './state'
import {
useActiveGeneId,
useActiveViewId,
useDarkMode,
useGeneticElements,
usePageLoad,
useSidebarState,
} from './state'
import { updateColors } from './updateColors'
export type EplantProps = Record<string, never>
export default function Eplant() {
const { rootPath } = useConfig()
const [darkMode] = useDarkMode()

return (
<ThemeProvider theme={darkMode ? dark : light}>
<CssBaseline />
<Routes>
<Route path={rootPath}>
<Route index element={<MainEplant />} />
</Route>
</Routes>
</ThemeProvider>
)
}
/**
* The main Eplant component. This is the root of the application. It contains the left nav and the layout.
* @returns {JSX.Element} The rendered Eplant component
*/
const Eplant = () => {
const [darkMode] = useDarkMode()
const [isCollapse, setIsCollapse] = useSidebarState()
const [activeGeneId, setActiveGeneId] = useActiveGeneId()
const [activeViewId, setActiveViewId] = useActiveViewId()
const theme = useTheme()
const [globalProgress, loaded] = usePageLoad()
const config = useConfig()
useEffect(() => {
if (loaded) {
updateColors(theme)
}
}, [theme, loaded])

// SideBar and EplantLayout children
export function MainEplant() {
return (
<>
<ThemeProvider theme={darkMode ? dark : light}>
<CssBaseline />
<Sidebar />
<EplantLayout />
</>
<URLStateProvider>
<Box
sx={(theme) => ({
height: `calc(100% - ${theme.spacing(1)})`,
left: `${isCollapse ? collapsedSidebarWidth : sidebarWidth}px`,
right: '0px',
position: 'absolute',
marginTop: '0.5rem',
boxSizing: 'border-box',
transition: 'left 1s ease-out',
backgroundColor: theme.palette.background.paper,
})}
>
<Box
sx={{
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'stretch',
justifyContent: 'stretch',
}}
>
<div />
{loaded ? (
<ViewContainer
sx={{
width: '100%',
height: '100%',
}}
></ViewContainer>
) : (
<div>
<CircularProgress
variant='indeterminate'
value={globalProgress * 100}
/>
</div>
)}
</Box>
</Box>
</URLStateProvider>
</ThemeProvider>
)
}
export default Eplant
93 changes: 0 additions & 93 deletions Eplant/EplantLayout.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions Eplant/GeneticElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ export default class GeneticElement {
export type SpeciesApi = {
searchGene: (term: string) => Promise<GeneticElement | null>
autocomplete: (term: string) => Promise<string[]>
loaders: {
[key: string]: (
gene: GeneticElement,
loadEvent: (amount: number) => void
) => Promise<any>
}
}

/**
Expand Down
6 changes: 0 additions & 6 deletions Eplant/Species/arabidopsis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ import axios from 'axios'
import { Species } from '@eplant/GeneticElement'
import GeneticElement from '@eplant/GeneticElement'

import GeneInfoViewLoader from './loaders/GeneInfoView'
import ArabidopsisPublicationViewer from './loaders/PublicationViewer'
const arabidopsis: Species = new Species('Arabidopsis', {
autocomplete,
searchGene,
loaders: {
'gene-info': GeneInfoViewLoader,
'publication-viewer': ArabidopsisPublicationViewer,
},
})
async function autocomplete(s: string) {
return (
Expand Down
104 changes: 0 additions & 104 deletions Eplant/Species/arabidopsis/loaders/GeneInfoView/index.ts

This file was deleted.

51 changes: 0 additions & 51 deletions Eplant/Species/arabidopsis/loaders/PublicationViewer/index.ts

This file was deleted.

Loading