Skip to content

Commit

Permalink
feat: Breadcrumbs (#175)
Browse files Browse the repository at this point in the history
* chore: Add svg file support

* fix: Add breadcrumbs to all pages

* chore: Fix lint and svg mocks in tests

* chore: Move / into breadcrumbs component

* refactor: Remove paper elevation 0

* style: Remove address book header flex justify-content property

* style: Move breadcrumbs out of the table
  • Loading branch information
usame-algan authored Jul 14, 2022
1 parent 081a582 commit 6574834
Show file tree
Hide file tree
Showing 30 changed files with 1,223 additions and 87 deletions.
5 changes: 3 additions & 2 deletions components/address-book/AddressBookTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useIsSafeOwner from '@/hooks/useIsSafeOwner'
import TokenTransferModal from '@/components/tx/modals/TokenTransferModal'
import css from './styles.module.css'
import EthHashInfo from '@/components/common/EthHashInfo'
import Box from '@mui/material/Box'

const headCells = [
{ id: 'name', label: 'Name' },
Expand Down Expand Up @@ -94,7 +95,7 @@ const AddressBookTable = () => {
}))

return (
<>
<Box marginTop={['0', '-46px']}>
<div className={css.headerButtonWrapper}>
<Button
onClick={handleOpenModal(ModalType.EXPORT)}
Expand Down Expand Up @@ -134,7 +135,7 @@ const AddressBookTable = () => {
initialData={[{ recipient: selectedAddress }]}
/>
)}
</>
</Box>
)
}

Expand Down
1 change: 1 addition & 0 deletions components/address-book/AddressBookTable/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.headerButtonWrapper {
display: flex;
justify-content: flex-end;
align-items: flex-start;
gap: 8px;
margin-bottom: 8px;
}
18 changes: 18 additions & 0 deletions components/common/Breadcrumbs/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import { Typography } from '@mui/material'
import css from './styles.module.css'

type Props = {
Icon: React.FC<React.SVGProps<SVGSVGElement>>
first: string
second?: string
}
export const Breadcrumbs = ({ Icon, first, second }: Props) => {
return (
<div className={css.container}>
<Icon className={css.icon} />
<Typography className={css.text}>{first}</Typography>
{second && <Typography className={css.secondaryText}>/ {second}</Typography>}
</div>
)
}
23 changes: 23 additions & 0 deletions components/common/Breadcrumbs/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.icon path {
fill: var(--color-primary-main);
}

.text {
font-size: 12px;
color: var(--color-primary-main);
font-weight: bold;
text-transform: uppercase;
}

.secondaryText {
font-size: 12px;
color: var(--color-secondary-light);
text-transform: uppercase;
}

.container {
display: flex;
align-items: center;
gap: 4px;
margin-bottom: var(--space-3);
}
5 changes: 3 additions & 2 deletions components/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Typography } from '@mui/material'
import { NewSafeModal } from '@/components/home/NewSafeModal'
import { Breadcrumbs } from '@/components/common/Breadcrumbs'
import HomeIcon from '@/public/images/sidebar/home.svg'

export const Dashboard = () => {
return (
<main>
<Typography variant="h1">Dashboard</Typography>
<Breadcrumbs Icon={HomeIcon} first="Dashboard" />
<NewSafeModal />
</main>
)
Expand Down
2 changes: 1 addition & 1 deletion components/settings/SafeModules/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ModuleDisplay = ({ moduleAddress, chainId }: { moduleAddress: string; chai
const SafeModules = () => {
const { safe } = useSafeInfo()
return (
<Paper elevation={0} sx={{ padding: 4 }}>
<Paper sx={{ padding: 4 }} variant="outlined">
<Grid container direction="row" justifyContent="space-between">
<Grid item>
<Typography variant="h4" fontWeight={700}>
Expand Down
2 changes: 1 addition & 1 deletion components/settings/SpendingLimits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Paper, Grid, Typography, Box, Button } from '@mui/material'

const SpendingLimits = () => {
return (
<Paper elevation={0} sx={{ padding: 4 }}>
<Paper sx={{ padding: 4 }} variant="outlined">
<Grid container direction="row" justifyContent="space-between">
<Grid item>
<Typography variant="h4" fontWeight={700}>
Expand Down
2 changes: 1 addition & 1 deletion components/settings/TransactionGuards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const TransactionGuards = () => {
}

return (
<Paper elevation={0} sx={{ padding: 4 }}>
<Paper sx={{ padding: 4 }} variant="outlined">
<Grid container direction="row" justifyContent="space-between">
<Grid item>
<Typography variant="h4" fontWeight={700}>
Expand Down
7 changes: 7 additions & 0 deletions definitions.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import { BeamerConfig, BeamerMethods } from '@services/beamer/types'

declare global {
Expand All @@ -7,4 +8,10 @@ declare global {
}
}

declare module '*.svg' {
const content: any
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
export default content
}

export {}
2 changes: 1 addition & 1 deletion hooks/wallets/useOnboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const useInitOnboard = () => {
return () => {
walletSubscription.unsubscribe()
}
}, [onboard, dispatch, setLastWallet])
}, [onboard, dispatch])
}

export default useOnboard
1 change: 1 addition & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const customJestConfig = {
moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon)
'^@/(.*)$': '<rootDir>/$1',
'^.+\\.(svg)$': '<rootDir>/mocks/svg.js',
},
testEnvironment: 'jest-environment-jsdom',
testEnvironmentOptions: { url: 'http://localhost/balances?safe=rin:0xb3b83bf204C458B461de9B0CD2739DB152b4fa5A' },
Expand Down
3 changes: 3 additions & 0 deletions mocks/svg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const content = 'mock-icon'
export const ReactComponent = content
export default content
14 changes: 0 additions & 14 deletions next.config.cjs

This file was deleted.

41 changes: 41 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
eslint: {
dirs: ['pages', 'services', 'store', 'components', 'config', 'utils', 'hooks', 'tests'],
},
experimental: {
images: {
unoptimized: true,
},
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: { and: [/\.(js|ts|md)x?$/] },
use: [
{
loader: '@svgr/webpack',
options: {
prettier: false,
svgo: true,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: { removeViewBox: false },
},
},
],
},
titleProp: true,
},
},
],
})
return config
},
}

export default nextConfig
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"devDependencies": {
"@gnosis.pm/safe-react-gateway-sdk": "^3.1.3",
"@sentry/types": "^7.1.1",
"@svgr/webpack": "^6.2.1",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.2.1",
Expand Down
5 changes: 3 additions & 2 deletions pages/safe/address-book.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import AddressBookTable from '@/components/address-book/AddressBookTable'
import type { NextPage } from 'next'
import { Breadcrumbs } from '@/components/common/Breadcrumbs'
import ABIcon from '@/public/images/sidebar/address-book.svg'

const AddressBook: NextPage = () => {
return (
<main>
<h2>Address Book</h2>

<Breadcrumbs Icon={ABIcon} first="Address Book" />
<AddressBookTable />
</main>
)
Expand Down
3 changes: 3 additions & 0 deletions pages/safe/apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { NextPage } from 'next'
import Grid from '@mui/material/Grid'
import { useSafeApps } from '@/hooks/useSafeApps'
import { AppCard } from '@/components/safe-apps/AppCard'
import { Breadcrumbs } from '@/components/common/Breadcrumbs'
import AppsIcon from '@/public/images/sidebar/apps.svg'

const Apps: NextPage = () => {
const [apps, error, loading] = useSafeApps()
Expand All @@ -16,6 +18,7 @@ const Apps: NextPage = () => {

return (
<main>
<Breadcrumbs Icon={AppsIcon} first="Apps" />
<Grid container rowSpacing={2} columnSpacing={2}>
{apps?.map((a) => (
<Grid key={a.url} item xs={12} sm={6} md={3} xl={1.5}>
Expand Down
4 changes: 3 additions & 1 deletion pages/safe/balances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Grid } from '@mui/material'
import AssetsTable from '@/components/balances/AssetsTable'
import CurrencySelect from '@/components/balances/CurrencySelect'
import useBalances from '@/hooks/useBalances'
import { Breadcrumbs } from '@/components/common/Breadcrumbs'
import AssetsIcon from '@/public/images/sidebar/assets.svg'

const Balances: NextPage = () => {
const { balances } = useBalances()
Expand All @@ -12,7 +14,7 @@ const Balances: NextPage = () => {
<main>
<Grid container spacing={2}>
<Grid item xs>
<h2 style={{ margin: 0 }}>Balances</h2>
<Breadcrumbs Icon={AssetsIcon} first="Assets" second="Coins" />
</Grid>

<Grid item>
Expand Down
4 changes: 3 additions & 1 deletion pages/safe/balances/nfts.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import type { NextPage } from 'next'
import useCollectibles from '@/hooks/useCollectibles'
import { NftGrid } from '@/components/nfts'
import { Breadcrumbs } from '@/components/common/Breadcrumbs'
import AssetsIcon from '@/public/images/sidebar/assets.svg'

const NFTs: NextPage = () => {
const { collectibles } = useCollectibles()

return (
<main>
<h2>NFTs</h2>
<Breadcrumbs Icon={AssetsIcon} first="Assets" second="NFTs" />
<NftGrid collectibles={collectibles} />
</main>
)
Expand Down
54 changes: 31 additions & 23 deletions pages/safe/settings/appearance.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Checkbox, FormControlLabel, FormGroup, Link, Typography } from '@mui/material'
import { Checkbox, FormControlLabel, FormGroup, Link, Paper, Typography } from '@mui/material'
import type { ChangeEvent } from 'react'
import type { NextPage } from 'next'

import { useAppDispatch, useAppSelector } from '@/store'
import { selectSettings, setCopyShortName, setDarkMode, setShowShortName } from '@/store/settingsSlice'
import { Breadcrumbs } from '@/components/common/Breadcrumbs'
import SettingsIcon from '@/public/images/sidebar/settings.svg'

const Appearance: NextPage = () => {
const dispatch = useAppDispatch()
Expand All @@ -17,30 +19,36 @@ const Appearance: NextPage = () => {

return (
<main>
<Typography variant="h2">Settings / Appearance</Typography>
<Typography variant="h4">Chain-specific addresses</Typography>
<Typography>
You can choose whether to prepend{' '}
<Link href="https://eips.ethereum.org/EIPS/eip-3770" target="_blank" rel="noopener noreferrer">
EIP-3770
</Link>{' '}
address prefixes across all Safes.
</Typography>
<FormGroup>
<Breadcrumbs Icon={SettingsIcon} first="Settings" second="Appearance" />
<Paper sx={{ padding: 4 }} variant="outlined">
<Typography variant="h4" fontWeight="bold" mb={1}>
Chain-specific addresses
</Typography>
<Typography mb={2}>
You can choose whether to prepend{' '}
<Link href="https://eips.ethereum.org/EIPS/eip-3770" target="_blank" rel="noopener noreferrer">
EIP-3770
</Link>{' '}
address prefixes across all Safes.
</Typography>
<FormGroup>
<FormControlLabel
control={<Checkbox checked={settings.shortName.show} onChange={handleToggle(setShowShortName)} />}
label="Prepend chain prefix to addresses"
/>
<FormControlLabel
control={<Checkbox checked={settings.shortName.copy} onChange={handleToggle(setCopyShortName)} />}
label="Copy addresses with chain prefix"
/>
</FormGroup>
<Typography variant="h4" fontWeight="bold" mt={2}>
Theme
</Typography>
<FormControlLabel
control={<Checkbox checked={settings.shortName.show} onChange={handleToggle(setShowShortName)} />}
label="Prepend chain prefix to addresses"
control={<Checkbox checked={settings.theme.darkMode} onChange={handleToggle(setDarkMode)} disabled />}
label="Dark mode"
/>
<FormControlLabel
control={<Checkbox checked={settings.shortName.copy} onChange={handleToggle(setCopyShortName)} />}
label="Copy addresses with chain prefix"
/>
</FormGroup>
<Typography variant="h4">Theme</Typography>
<FormControlLabel
control={<Checkbox checked={settings.theme.darkMode} onChange={handleToggle(setDarkMode)} disabled />}
label="Dark mode"
/>
</Paper>
</main>
)
}
Expand Down
6 changes: 4 additions & 2 deletions pages/safe/settings/modules.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import SafeModules from '@/components/settings/SafeModules'
import SpendingLimits from '@/components/settings/SpendingLimits'
import TransactionGuards from '@/components/settings/TransactionGuards'
import { Grid, Typography } from '@mui/material'
import { Grid } from '@mui/material'
import type { NextPage } from 'next'
import { Breadcrumbs } from '@/components/common/Breadcrumbs'
import SettingsIcon from '@/public/images/sidebar/settings.svg'

const Modules: NextPage = () => {
return (
<main>
<Typography variant="h2">Settings / Modules</Typography>
<Breadcrumbs Icon={SettingsIcon} first="Settings" second="Modules" />
<Grid container direction="column" spacing={2}>
<Grid item>
<SafeModules />
Expand Down
Loading

0 comments on commit 6574834

Please sign in to comment.