Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
1efc4a6
Adding storybook
nicosampler Aug 4, 2020
5604d44
new layout components
nicosampler Aug 4, 2020
1699ae0
add preview body
alongoni Aug 4, 2020
86fc97a
add styles
alongoni Aug 5, 2020
883b3ce
extract walletInfo to a separated component
nicosampler Aug 5, 2020
c4a0c8c
remove unused component
nicosampler Aug 5, 2020
6ddbe76
New Layout componentes refactor
nicosampler Aug 5, 2020
ac5a8d9
Return type in Root
nicosampler Aug 5, 2020
ee96919
change story name
nicosampler Aug 5, 2020
f788d4a
adding back OpenHoc
nicosampler Aug 5, 2020
3e1055c
sort import
nicosampler Aug 6, 2020
f224dc2
fix margins
alongoni Aug 7, 2020
455fff9
split layout
nicosampler Aug 7, 2020
52b4ecb
Move Layout related components to /components/SidebarLayout
nicosampler Aug 7, 2020
be4e957
Adding new layout for real
nicosampler Aug 7, 2020
8ee16e9
Some changes and refactor
nicosampler Aug 10, 2020
48179d2
Move Modals from safe to sidebar
nicosampler Aug 11, 2020
c1ea04f
move safeAddress logic from safe to sidebar
nicosampler Aug 11, 2020
08ade9d
move safe container from components
nicosampler Aug 12, 2020
525bd1a
List refactor
nicosampler Aug 12, 2020
3271387
sidebar navigation
nicosampler Aug 13, 2020
87446cb
selected item
nicosampler Aug 13, 2020
663386e
list selected example
nicosampler Aug 13, 2020
4ea5878
add styles
alongoni Aug 13, 2020
5a30801
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni Aug 13, 2020
01d7d5d
add text component to new tx button
alongoni Aug 13, 2020
f598a0d
Sidebar without walletInfo
nicosampler Aug 13, 2020
94ad1c3
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
nicosampler Aug 13, 2020
b1aeae9
fix footer and body margins
alongoni Aug 13, 2020
8b96b3d
add logo Safe Multisig
alongoni Aug 13, 2020
6783e76
update safe-react-components
nicosampler Aug 14, 2020
af7e9e2
List colors and List Icon
nicosampler Aug 14, 2020
fb33f25
fix subItem
nicosampler Aug 14, 2020
ffe91b8
update safe-react-components
nicosampler Aug 14, 2020
5eb406f
fix logo margin, add notConnected icon and badge Read Only
alongoni Aug 14, 2020
944a978
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni Aug 14, 2020
25fcd2a
Merge branch 'development' into new-layout
nicosampler Aug 14, 2020
4bcc913
fix merge problems
nicosampler Aug 14, 2020
79d814d
add sidebar styles and icon notConnected
alongoni Aug 14, 2020
63c1284
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni Aug 14, 2020
bb3e7c0
fix readOnly
nicosampler Aug 14, 2020
286f2ab
fix QR tooltip info
alongoni Aug 18, 2020
98eb663
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni Aug 18, 2020
3b498ba
add Help Center link and fix margins
alongoni Aug 18, 2020
6ac8be9
Remove 'No safe loaded' text
alongoni Aug 18, 2020
144acfe
Merge branch 'development' into new-layout
nicosampler Aug 18, 2020
d692be9
review changes
nicosampler Aug 18, 2020
aad68d6
fix import
nicosampler Aug 18, 2020
3bc7993
fix Help center margin
alongoni Aug 19, 2020
13cbc56
add styles to address
alongoni Aug 19, 2020
e224620
replace empty div with FlexSpacer component
nicosampler Aug 19, 2020
c8b3e59
rename Sidebar by SafeListSidebar
nicosampler Aug 19, 2020
998dc4a
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
nicosampler Aug 19, 2020
e1fa575
fix load and create safe position (top-left)
alongoni Aug 19, 2020
556821d
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni Aug 19, 2020
450ffd4
Add comment to FlexSpacer
Aug 19, 2020
03f4060
fix Title margin Safe Creation Progress
alongoni Aug 19, 2020
e408c10
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni Aug 19, 2020
e32f973
fix Read Only line-height
alongoni Aug 20, 2020
98b6f14
Merge branch 'development' into new-layout
nicosampler Aug 21, 2020
64b274c
review fixes
nicosampler Aug 21, 2020
dd7e514
review fixes
nicosampler Aug 24, 2020
1117899
rename component
nicosampler Aug 24, 2020
7656cc2
fix Help Center styles
alongoni Aug 24, 2020
8bfc563
return type in DefaultBadge
nicosampler Aug 25, 2020
83b9003
Fix types for list component (still wip)
mmv08 Aug 25, 2020
6c8e9f5
move sidebarList to a hook
nicosampler Aug 25, 2020
0a0b940
Merge branches 'new-layout' and 'new-layout' of github.com:gnosis/saf…
nicosampler Aug 25, 2020
d88f343
Merge branch 'development' of github.com:gnosis/safe-react into new-l…
mmv08 Aug 26, 2020
8f8918c
fix safe route container
mmv08 Aug 26, 2020
a958100
fix src version
mmv08 Aug 26, 2020
08f6d32
fix list typescript issue
mmv08 Aug 26, 2020
46ef9bd
rename sidebarlayout to applayout
mmv08 Aug 26, 2020
614ebe3
Merge branch 'development' of github.com:gnosis/safe-react into new-l…
mmv08 Aug 26, 2020
cd7e4e0
sidebar fixes wip
mmv08 Aug 26, 2020
99ad632
sidebar fixes wip
mmv08 Aug 26, 2020
c55ef6d
remove unused function
nicosampler Aug 26, 2020
3f08e76
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
mmv08 Aug 26, 2020
8de6da7
Merge branch 'development' into new-layout
mmv08 Aug 27, 2020
1009b21
lift sidebar items state up
mmv08 Aug 27, 2020
0d6a62e
fix broken imports
mmv08 Aug 27, 2020
cca64c9
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
mmv08 Aug 27, 2020
023a50f
remove unused files
mmv08 Aug 27, 2020
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
8 changes: 8 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
stories: ['../src/**/*.stories.tsx'],
addons: [
'@storybook/preset-create-react-app',
'@storybook/addon-actions',
'@storybook/addon-links',
],
};
6 changes: 6 additions & 0 deletions .storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<style>
html, body, #root {
height: 100%;
margin: 0;
}
</style>
26 changes: 26 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react'
import { MemoryRouter } from 'react-router-dom'
import { addDecorator } from '@storybook/react'
import { ThemeProvider, createGlobalStyle } from 'styled-components'
import { theme } from '@gnosis.pm/safe-react-components'

import averta from 'src/assets/fonts/Averta-normal.woff2'
import avertaBold from 'src/assets/fonts/Averta-ExtraBold.woff2'

const GlobalStyles = createGlobalStyle`
@font-face {
font-family: 'Averta';
src: local('Averta'), local('Averta Bold'),
url(${averta}) format('woff2'),
url(${avertaBold}) format('woff');
}
`

addDecorator((storyFn) => (
<ThemeProvider theme={theme}>
<MemoryRouter>
<GlobalStyles />
{storyFn()}
</MemoryRouter>
</ThemeProvider>
))
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
"start": "react-app-rewired start",
"test": "NODE_ENV=test && react-app-rewired test --env=jsdom",
"test:coverage": "yarn test --coverage --watchAll=false",
"coveralls": "cat ./coverage/lcov.info | coveralls"
"coveralls": "cat ./coverage/lcov.info | coveralls",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -164,7 +166,7 @@
"dependencies": {
"@gnosis.pm/safe-apps-sdk": "https://github.com/gnosis/safe-apps-sdk.git#development",
"@gnosis.pm/safe-contracts": "1.1.1-dev.2",
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#fd4498f",
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#development",
"@gnosis.pm/util-contracts": "2.0.6",
"@ledgerhq/hw-transport-node-hid": "5.19.1",
"@material-ui/core": "4.11.0",
Expand Down Expand Up @@ -229,6 +231,11 @@
"web3-utils": "^1.2.11"
},
"devDependencies": {
"@storybook/addon-actions": "^5.3.19",
"@storybook/addon-links": "^5.3.19",
"@storybook/addons": "^5.3.19",
"@storybook/preset-create-react-app": "^3.1.4",
"@storybook/react": "^5.3.19",
"@testing-library/jest-dom": "5.11.2",
"@testing-library/react": "10.4.8",
"@testing-library/user-event": "12.1.0",
Expand All @@ -237,7 +244,7 @@
"@types/jest": "^26.0.9",
"@types/lodash.memoize": "^4.1.6",
"@types/node": "14.6.0",
"@types/react": "^16.9.44",
"@types/react": "^16.9.47",
"@types/react-dom": "^16.9.6",
"@types/react-redux": "^7.1.9",
"@types/react-router-dom": "^5.1.5",
Expand All @@ -264,6 +271,7 @@
"node-sass": "^4.14.1",
"prettier": "2.0.5",
"react-app-rewired": "^2.1.6",
"react-docgen-typescript-loader": "^3.7.2",
"truffle": "5.1.36",
"typechain": "^2.0.0",
"typescript": "3.9.7",
Expand Down
157 changes: 157 additions & 0 deletions src/components/App/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import React, { useContext, useEffect } from 'react'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have so much logic unique ONLY for /safe route in top-level App component?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to move this into sidebar component directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what you mean, could you explain in more detail?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a top level component which renders the page. But it has a lot of logic which is not relevant for this component. Can it be moved closer to the place where it is actually used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the use of match from the router and the array of sidebarItems?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to a hook. I think components inside the Components folder, should not contain any business logic. That's why I used a hook.

import { makeStyles } from '@material-ui/core/styles'
import { SnackbarProvider } from 'notistack'
import { useSelector } from 'react-redux'
import { useRouteMatch, useHistory } from 'react-router-dom'
import styled from 'styled-components'

import AlertIcon from './assets/alert.svg'
import CheckIcon from './assets/check.svg'
import ErrorIcon from './assets/error.svg'
import InfoIcon from './assets/info.svg'

import AppLayout from 'src/components/AppLayout'
import SafeListSidebarProvider, { SafeListSidebarContext } from 'src/components/SafeListSidebar'
import CookiesBanner from 'src/components/CookiesBanner'
import Notifier from 'src/components/Notifier'
import Backdrop from 'src/components/layout/Backdrop'
import Img from 'src/components/layout/Img'
import { getNetwork } from 'src/config'
import { ETHEREUM_NETWORK } from 'src/logic/wallets/getWeb3'
import { networkSelector } from 'src/logic/wallets/store/selectors'
import { SAFELIST_ADDRESS, WELCOME_ADDRESS } from 'src/routes/routes'
import { safeNameSelector, safeParamAddressFromStateSelector } from 'src/logic/safe/store/selectors'
import Modal from 'src/components/Modal'
import SendModal from 'src/routes/safe/components/Balances/SendModal'
import { useLoadSafe } from 'src/logic/safe/hooks/useLoadSafe'
import { useSafeScheduledUpdates } from 'src/logic/safe/hooks/useSafeScheduledUpdates'
import useSafeActions from 'src/logic/safe/hooks/useSafeActions'
import { currentCurrencySelector, safeFiatBalancesTotalSelector } from 'src/logic/currencyValues/store/selectors/index'
import { formatAmountInUsFormat } from 'src/logic/tokens/utils/formatAmount'
import { grantedSelector } from 'src/routes/safe/container/selector'

import Receive from './ModalReceive'
import { useSidebarItems } from 'src/components/AppLayout/Sidebar/useSidebarItems'

const notificationStyles = {
success: {
background: '#fff',
},
error: {
background: '#ffe6ea',
},
warning: {
background: '#fff3e2',
},
info: {
background: '#fff',
},
}

const Frame = styled.div`
display: flex;
flex-direction: column;
flex: 1 1 auto;
max-width: 100%;
`

const desiredNetwork = getNetwork()

const useStyles = makeStyles(notificationStyles)

const App: React.FC = ({ children }) => {
const classes = useStyles()
const currentNetwork = useSelector(networkSelector)
const isWrongNetwork = currentNetwork !== ETHEREUM_NETWORK.UNKNOWN && currentNetwork !== desiredNetwork
const { toggleSidebar } = useContext(SafeListSidebarContext)
const matchSafe = useRouteMatch({ path: `${SAFELIST_ADDRESS}`, strict: false })
const history = useHistory()
const safeAddress = useSelector(safeParamAddressFromStateSelector)
const safeName = useSelector(safeNameSelector)
const { safeActionsState, onShow, onHide, showSendFunds, hideSendFunds } = useSafeActions()
const currentSafeBalance = useSelector(safeFiatBalancesTotalSelector)
const currentCurrency = useSelector(currentCurrencySelector)
const granted = useSelector(grantedSelector)
const sidebarItems = useSidebarItems()

useLoadSafe(safeAddress)
useSafeScheduledUpdates(safeAddress)

const sendFunds = safeActionsState.sendFunds as { isOpen: boolean; selectedToken: string }
const formattedTotalBalance = currentSafeBalance ? formatAmountInUsFormat(currentSafeBalance) : ''
const balance = !!formattedTotalBalance && !!currentCurrency ? `${formattedTotalBalance} ${currentCurrency}` : null

useEffect(() => {
if (matchSafe?.isExact) {
history.push(WELCOME_ADDRESS)
return
}
}, [matchSafe, history])

const onReceiveShow = () => onShow('Receive')
const onReceiveHide = () => onHide('Receive')

return (
<Frame>
<Backdrop isOpen={isWrongNetwork} />
<SnackbarProvider
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
classes={{
variantSuccess: classes.success,
variantError: classes.error,
variantWarning: classes.warning,
variantInfo: classes.info,
}}
iconVariant={{
error: <Img alt="Error" src={ErrorIcon} />,
info: <Img alt="Info" src={InfoIcon} />,
success: <Img alt="Success" src={CheckIcon} />,
warning: <Img alt="Warning" src={AlertIcon} />,
}}
maxSnack={5}
>
<>
<Notifier />

<AppLayout
sidebarItems={sidebarItems}
safeAddress={safeAddress}
safeName={safeName}
balance={balance}
granted={granted}
onToggleSafeList={toggleSidebar}
onReceiveClick={onReceiveShow}
onNewTransactionClick={() => showSendFunds('')}
>
{children}
</AppLayout>

<SendModal
activeScreenType="chooseTxType"
isOpen={sendFunds.isOpen}
onClose={hideSendFunds}
selectedToken={sendFunds.selectedToken}
/>

<Modal
description="Receive Tokens Form"
handleClose={onReceiveHide}
open={safeActionsState.showReceive as boolean}
title="Receive Tokens"
>
<Receive onClose={onReceiveHide} />
</Modal>
</>
</SnackbarProvider>
<CookiesBanner />
</Frame>
)
}

const WrapperAppWithSidebar: React.FC = ({ children }) => (
<SafeListSidebarProvider>
<App>{children}</App>
</SafeListSidebarProvider>
)

export default WrapperAppWithSidebar
61 changes: 61 additions & 0 deletions src/components/AppLayout/AppLayout.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react'

import { Icon } from '@gnosis.pm/safe-react-components'
import { ListItemType } from 'src/components/List'
import Layout from '.'

export default {
title: 'Layout',
component: Layout,
parameters: {
componentSubtitle: 'It provides a custom layout used in Safe Multisig',
},
}

const items: ListItemType[] = [
{
label: 'Assets',
icon: <Icon size="md" type="assets" />,
href: '#',
},
{
label: 'Settings',
icon: <Icon size="md" type="settings" />,
href: '#',
subItems: [
{
label: 'Safe Details',
href: '#',
},
{
label: 'Owners',
href: '#',
},
{
label: 'Policies',
href: '#',
},
{
label: 'Advanced',
href: '#',
},
],
},
]

export const Base = (): React.ReactElement => {
return (
<Layout
sidebarItems={items}
safeAddress="0xEE63624cC4Dd2355B16b35eFaadF3F7450A9438B"
safeName="someName"
granted={true}
balance={null}
onToggleSafeList={() => console.log}
onReceiveClick={() => console.log}
onNewTransactionClick={() => console.log}
>
<div>The content goes here</div>
</Layout>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const useStyles = makeStyles({

const appVersion = process.env.REACT_APP_APP_VERSION ? `v${process.env.REACT_APP_APP_VERSION} ` : 'Versions'

const Footer = () => {
const Footer = (): React.ReactElement => {
const date = new Date()
const classes = useStyles()
const dispatch = useDispatch()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import { withStyles } from '@material-ui/core/styles'
import * as React from 'react'
import { Link } from 'react-router-dom'

import NetworkLabel from './NetworkLabel'
import Provider from './Provider'
import SafeListHeader from './SafeListHeader'

import Spacer from 'src/components/Spacer'
import openHoc from 'src/components/hoc/OpenHoc'
import Col from 'src/components/layout/Col'
import Divider from 'src/components/layout/Divider'
import Img from 'src/components/layout/Img'
import Row from 'src/components/layout/Row'
import { border, headerHeight, md, screenSm, sm } from 'src/theme/variables'
Expand Down Expand Up @@ -41,11 +38,12 @@ const styles = () => ({
zIndex: 1301,
},
logo: {
flexBasis: '95px',
flexBasis: '114px',
flexShrink: '0',
flexGrow: '0',
maxWidth: '55px',
padding: sm,
marginTop: '4px',
[`@media (min-width: ${screenSm}px)`]: {
maxWidth: 'none',
paddingLeft: md,
Expand All @@ -61,13 +59,9 @@ const Layout = openHoc(({ classes, clickAway, open, providerDetails, providerInf
<Row className={classes.summary}>
<Col className={classes.logo} middle="xs" start="xs">
<Link to="/">
<Img alt="Gnosis Team Safe" height={32} src={logo} testId="heading-gnosis-logo" />
<Img alt="Gnosis Team Safe" height={36} src={logo} testId="heading-gnosis-logo" />
</Link>
</Col>
<Divider />
<SafeListHeader />
<Divider />
<NetworkLabel />
<Spacer />
<Provider
info={providerInfo}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withStyles } from '@material-ui/core/styles'
import * as React from 'react'

import ConnectButton from 'src/components/ConnectButton'
import CircleDot from 'src/components/Header/components/CircleDot'
import CircleDot from 'src/components/AppLayout/Header/components/CircleDot'
import Block from 'src/components/layout/Block'
import Paragraph from 'src/components/layout/Paragraph'
import Row from 'src/components/layout/Row'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { withStyles } from '@material-ui/core/styles'
import Dot from '@material-ui/icons/FiberManualRecord'
import classNames from 'classnames'
import * as React from 'react'
import { Identicon } from '@gnosis.pm/safe-react-components'
import { EthHashInfo } from '@gnosis.pm/safe-react-components'
import { EthHashInfo, Identicon } from '@gnosis.pm/safe-react-components'

import CircleDot from 'src/components/Header/components/CircleDot'
import CircleDot from 'src/components/AppLayout/Header/components/CircleDot'
import Spacer from 'src/components/Spacer'
import Block from 'src/components/layout/Block'
import Button from 'src/components/layout/Button'
Expand Down
Loading