-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-wallet): Create app layout with left nav and app bar (#3941)
* feat(react-wallet): Create app layout with left nav and app bar * feat(react-wallet): Fix font family quote usage
- Loading branch information
1 parent
5c9f5f0
commit 18807af
Showing
16 changed files
with
374 additions
and
59 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,22 +1,85 @@ | ||
/* eslint-disable react/display-name */ | ||
import React from 'react'; | ||
import { Switch, Route } from 'react-router-dom'; | ||
import { CssBaseline } from '@material-ui/core'; | ||
import { | ||
createTheme, | ||
makeStyles, | ||
ThemeProvider, | ||
} from '@material-ui/core/styles'; | ||
|
||
import WalletConnection from './components/WalletConnection'; | ||
import AppBar from './components/AppBar'; | ||
import NavMenu from './components/NavMenu'; | ||
import Contacts from './views/Contacts.js'; | ||
import Dapps from './views/Dapps.js'; | ||
import Dashboard from './views/Dashboard.js'; | ||
import Purses from './views/Purses.js'; | ||
import Issuers from './views/Issuers.js'; | ||
|
||
import './App.css'; | ||
import { withApplicationContext } from './contexts/Application'; | ||
const appBarHeight = '64px'; | ||
const navMenuWidth = '240px'; | ||
|
||
const App = ({ connectionState }) => { | ||
const appTheme = createTheme({ | ||
palette: { | ||
background: { | ||
default: '#ffffff', | ||
}, | ||
}, | ||
typography: { | ||
fontFamily: ['Roboto', 'Helvetica', 'Arial', 'sans-serif'].join(','), | ||
fontWeightRegular: 500, | ||
h1: { | ||
fontFamily: ['Montserrat', 'Arial', 'sans-serif'].join(','), | ||
fontSize: '32px', | ||
fontWeight: '700', | ||
letterSpacing: '-1.5px', | ||
lineHeight: '48px', | ||
margin: 0, | ||
}, | ||
}, | ||
appBarHeight, | ||
navMenuWidth, | ||
}); | ||
|
||
const useStyles = makeStyles(_ => ({ | ||
main: { | ||
boxSizing: 'border-box', | ||
padding: '32px', | ||
marginLeft: navMenuWidth, | ||
position: 'absolute', | ||
width: `calc(100vw - ${navMenuWidth})`, | ||
top: appBarHeight, | ||
}, | ||
})); | ||
|
||
const App = () => { | ||
const classes = useStyles(); | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
Connection Status: {connectionState} | ||
</header> | ||
<WalletConnection></WalletConnection> | ||
</div> | ||
<ThemeProvider theme={appTheme}> | ||
<CssBaseline /> | ||
<NavMenu /> | ||
<main className={classes.main}> | ||
<Switch> | ||
<Route path="/purses"> | ||
<Purses /> | ||
</Route> | ||
<Route path="/dapps"> | ||
<Dapps /> | ||
</Route> | ||
<Route path="/contacts"> | ||
<Contacts /> | ||
</Route> | ||
<Route path="/issuers"> | ||
<Issuers /> | ||
</Route> | ||
<Route path="/"> | ||
<Dashboard /> | ||
</Route> | ||
</Switch> | ||
</main> | ||
<AppBar /> | ||
</ThemeProvider> | ||
); | ||
}; | ||
|
||
export default withApplicationContext(App, context => ({ | ||
connectionState: context.connectionState, | ||
})); | ||
export default App; |
61 changes: 61 additions & 0 deletions
61
packages/dapp-svelte-wallet/react-ui/src/components/AppBar.js
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,61 @@ | ||
import { makeStyles, useTheme } from '@material-ui/core/styles'; | ||
|
||
import WalletConnection from './WalletConnection'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
header: { | ||
backgroundColor: theme.palette.background.default, | ||
borderBottom: '1px solid #eaecef', | ||
margin: 'auto', | ||
position: 'fixed', | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
height: theme.appBarHeight, | ||
display: 'flex', | ||
alignItems: 'center', | ||
flexShrink: 0, | ||
justifyContent: 'space-between', | ||
flexDirection: 'row', | ||
flexWrap: 'nowrap', | ||
}, | ||
productLink: { | ||
marginLeft: '16px', | ||
alignItems: 'center', | ||
display: 'flex', | ||
}, | ||
productLogo: { | ||
transform: 'scale(0.85)', | ||
}, | ||
appBarSection: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
padding: '4px', | ||
height: '100%', | ||
}, | ||
})); | ||
|
||
const AppBar = () => { | ||
const classes = useStyles(useTheme()); | ||
return ( | ||
<header className={classes.header}> | ||
<div className={classes.appBarSection}> | ||
<a href="https://agoric.com" className={classes.productLink}> | ||
<img | ||
src="https://agoric.com/wp-content/themes/agoric_2021_theme/assets/img/logo.svg" | ||
className={classes.productLogo} | ||
alt="Agoric" | ||
width="200" | ||
/> | ||
</a> | ||
</div> | ||
<div className={classes.appBarSection}> | ||
<div className={classes.connector}> | ||
<WalletConnection></WalletConnection> | ||
</div> | ||
</div> | ||
</header> | ||
); | ||
}; | ||
|
||
export default AppBar; |
80 changes: 80 additions & 0 deletions
80
packages/dapp-svelte-wallet/react-ui/src/components/NavMenu.js
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,80 @@ | ||
import { useMemo, forwardRef } from 'react'; | ||
import { Link, useRouteMatch } from 'react-router-dom'; | ||
import { makeStyles, useTheme } from '@material-ui/core/styles'; | ||
import List from '@material-ui/core/List'; | ||
import ListItem from '@material-ui/core/ListItem'; | ||
import { ListItemText, ListItemIcon } from '@material-ui/core'; | ||
import DashboardIcon from '@material-ui/icons/Dashboard'; | ||
import AccountBalanceWallet from '@material-ui/icons/AccountBalanceWallet'; | ||
import Apps from '@material-ui/icons/Apps'; | ||
import People from '@material-ui/icons/People'; | ||
import AddCircle from '@material-ui/icons/AddCircle'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
nav: { | ||
position: 'fixed', | ||
top: theme.appBarHeight, | ||
width: theme.navMenuWidth, | ||
height: `calc(100vh - ${theme.appBarHeight})`, | ||
overflowY: 'auto', | ||
}, | ||
sectionHeader: { | ||
padding: '16px', | ||
fontFamily: ['Montserrat', 'Arial', 'sans-serif'].join(','), | ||
fontWeight: 700, | ||
letterSpacing: '0.15px', | ||
fontSize: '16px', | ||
}, | ||
})); | ||
|
||
const ListItemLink = ({ icon, primary, to }) => { | ||
const match = useRouteMatch({ | ||
path: to, | ||
exact: true, | ||
}); | ||
|
||
const renderLink = useMemo( | ||
() => | ||
forwardRef((itemProps, ref) => { | ||
return <Link to={to} ref={ref} {...itemProps} role={undefined} />; | ||
}), | ||
[to], | ||
); | ||
|
||
return ( | ||
<li> | ||
<ListItem | ||
selected={match !== null} | ||
button | ||
style={{ borderRadius: '0 32px 32px 0' }} | ||
component={renderLink} | ||
> | ||
{icon ? <ListItemIcon>{icon}</ListItemIcon> : null} | ||
<ListItemText primary={primary} /> | ||
</ListItem> | ||
</li> | ||
); | ||
}; | ||
|
||
const NavMenu = () => { | ||
const styles = useStyles(useTheme()); | ||
|
||
return ( | ||
<nav className={styles.nav}> | ||
<div className={styles.sectionHeader}>Wallet</div> | ||
<List> | ||
<ListItemLink to="/" primary="Dashboard" icon={<DashboardIcon />} /> | ||
<ListItemLink | ||
to="/purses" | ||
primary="Purses" | ||
icon={<AccountBalanceWallet />} | ||
/> | ||
<ListItemLink to="/dapps" primary="Dapps" icon={<Apps />} /> | ||
<ListItemLink to="/contacts" primary="Contacts" icon={<People />} /> | ||
<ListItemLink to="/issuers" primary="Issuers" icon={<AddCircle />} /> | ||
</List> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default NavMenu; |
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
Oops, something went wrong.