-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '401-add-title-to-guard-and-watcher-2' into 'dev'
Resolve "add title to Guard and Watcher" Closes #401 See merge request ergo/rosen-bridge/ui!339
- Loading branch information
Showing
5 changed files
with
142 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rosen-bridge/watcher-app': major | ||
--- | ||
|
||
Split layout.tsx into layout.tsx and App.tsx files, Implemented a dynamic title feature to display the network |
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,6 @@ | ||
--- | ||
'@rosen-bridge/watcher-app': minor | ||
'@rosen-bridge/guard-app': minor | ||
--- | ||
|
||
Add a meta tag title to ensure an appropriate title is displayed in browsers |
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,120 @@ | ||
'use client'; | ||
|
||
import React, { useEffect } from 'react'; | ||
import SWRConfig from '@rosen-ui/swr-mock'; | ||
|
||
/** | ||
* FIXME: import NoSsr from ui-kit | ||
* local:ergo/rosen-bridge/ui#193 | ||
*/ | ||
import { NoSsr } from '@mui/material'; | ||
|
||
import { | ||
AppSnackbar, | ||
styled, | ||
SnackbarProvider, | ||
ThemeProvider, | ||
CssBaseline, | ||
} from '@rosen-bridge/ui-kit'; | ||
import { ApiKeyContextProvider } from '@rosen-bridge/shared-contexts'; | ||
|
||
import { SideBar } from './SideBar'; | ||
import Toolbar from './Toolbar'; | ||
|
||
import { theme } from './_theme/theme'; | ||
|
||
import mockedData from './_mock/mockedData'; | ||
import useInfo from './_hooks/useInfo'; | ||
import { upperFirst } from 'lodash-es'; | ||
|
||
const Root = styled('div')(({ theme }) => ({ | ||
width: '100vw', | ||
height: '100vh', | ||
display: 'flex', | ||
flexDirection: 'row', | ||
backgroundColor: theme.palette.secondary.dark, | ||
backgroundImage: | ||
theme.palette.mode === 'light' | ||
? `linear-gradient(180deg, ${theme.palette.gradient.a} 0%, ${theme.palette.gradient.b} 20%, ${theme.palette.gradient.c} 40%, ${theme.palette.gradient.d} 60%, ${theme.palette.gradient.e} 80%, ${theme.palette.gradient.f} 100%)` | ||
: 'none', | ||
[theme.breakpoints.down('tablet')]: { | ||
flexDirection: 'column', | ||
backgroundImage: | ||
theme.palette.mode === 'light' | ||
? `linear-gradient(90deg, ${theme.palette.gradient.a} 0%, ${theme.palette.gradient.b} 20%, ${theme.palette.gradient.c} 40%, ${theme.palette.gradient.d} 60%, ${theme.palette.gradient.e} 80%, ${theme.palette.gradient.f} 100%)` | ||
: 'none', | ||
}, | ||
})); | ||
|
||
const Main = styled('main')(({ theme }) => ({ | ||
flexGrow: 1, | ||
overflowY: 'auto', | ||
minHeight: '100%', | ||
backgroundColor: theme.palette.background.default, | ||
borderTopLeftRadius: theme.shape.borderRadius * 2, | ||
borderBottomLeftRadius: theme.shape.borderRadius * 2, | ||
paddingTop: theme.shape.borderRadius, | ||
paddingBottom: theme.shape.borderRadius * 3, | ||
paddingLeft: theme.shape.borderRadius * 2, | ||
paddingRight: theme.shape.borderRadius * 2, | ||
|
||
[theme.breakpoints.down('tablet')]: { | ||
backgroundColor: theme.palette.background.paper, | ||
borderTopRightRadius: theme.shape.borderRadius * 2, | ||
borderBottomLeftRadius: 0, | ||
paddingLeft: theme.spacing(2), | ||
paddingRight: theme.spacing(2), | ||
paddingBottom: theme.shape.borderRadius * 6, | ||
}, | ||
})); | ||
|
||
interface AppProps { | ||
children?: React.ReactNode; | ||
} | ||
|
||
const App = ({ children }: AppProps) => { | ||
const { data: info, isLoading } = useInfo(); | ||
|
||
/** | ||
* TODO: In the next phase, refactor this React hook to utilize SSR and data fetching | ||
* local:ergo/rosen-bridge/ui#408 | ||
*/ | ||
useEffect(() => { | ||
const networkTitle = isLoading | ||
? 'Watcher' | ||
: `[${info?.network ? upperFirst(info.network) : ''}] Watcher`; | ||
|
||
document.title = networkTitle; | ||
}, [isLoading, info]); | ||
|
||
return ( | ||
<NoSsr> | ||
<ThemeProvider theme={theme}> | ||
<> | ||
<CssBaseline /> | ||
<SnackbarProvider> | ||
<ApiKeyContextProvider> | ||
<Root> | ||
<SideBar /> | ||
<SWRConfig | ||
useMockedApis={ | ||
process.env.NEXT_PUBLIC_USE_MOCKED_APIS === 'true' | ||
} | ||
fakeData={mockedData} | ||
> | ||
<Main> | ||
<Toolbar /> | ||
{children} | ||
<AppSnackbar /> | ||
</Main> | ||
</SWRConfig> | ||
</Root> | ||
</ApiKeyContextProvider> | ||
</SnackbarProvider> | ||
</> | ||
</ThemeProvider> | ||
</NoSsr> | ||
); | ||
}; | ||
|
||
export default App; |
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