Skip to content

Commit

Permalink
Merge branch '401-add-title-to-guard-and-watcher-2' into 'dev'
Browse files Browse the repository at this point in the history
Resolve "add title to Guard and Watcher"

Closes #401

See merge request ergo/rosen-bridge/ui!339
  • Loading branch information
vorujack committed Nov 5, 2024
2 parents d233ab8 + 72e03d0 commit 39f4d0d
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 91 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-islands-drum.md
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
6 changes: 6 additions & 0 deletions .changeset/many-ducks-give.md
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
5 changes: 5 additions & 0 deletions apps/guard/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react';
import { Metadata } from 'next';

import App from './App';

export const metadata: Metadata = {
title: 'Rosen Guard',
};

const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
/**
Expand Down
120 changes: 120 additions & 0 deletions apps/watcher/app/App.tsx
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;
97 changes: 6 additions & 91 deletions apps/watcher/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,10 @@
'use client';

import React 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 App from './App';
import { Metadata } from 'next';

import mockedData from './_mock/mockedData';

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,
},
}));
export const metadata: Metadata = {
title: 'Watcher',
};

const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
Expand All @@ -74,32 +14,7 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => {
*/
<html lang="en">
<body>
<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>
<App>{children}</App>
</body>
</html>
);
Expand Down

0 comments on commit 39f4d0d

Please sign in to comment.