This repository was archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 357
New layout #1201
Merged
Merged
New layout #1201
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
1efc4a6
Adding storybook
nicosampler 5604d44
new layout components
nicosampler 1699ae0
add preview body
alongoni 86fc97a
add styles
alongoni 883b3ce
extract walletInfo to a separated component
nicosampler c4a0c8c
remove unused component
nicosampler 6ddbe76
New Layout componentes refactor
nicosampler ac5a8d9
Return type in Root
nicosampler ee96919
change story name
nicosampler f788d4a
adding back OpenHoc
nicosampler 3e1055c
sort import
nicosampler f224dc2
fix margins
alongoni 455fff9
split layout
nicosampler 52b4ecb
Move Layout related components to /components/SidebarLayout
nicosampler be4e957
Adding new layout for real
nicosampler 8ee16e9
Some changes and refactor
nicosampler 48179d2
Move Modals from safe to sidebar
nicosampler c1ea04f
move safeAddress logic from safe to sidebar
nicosampler 08ade9d
move safe container from components
nicosampler 525bd1a
List refactor
nicosampler 3271387
sidebar navigation
nicosampler 87446cb
selected item
nicosampler 663386e
list selected example
nicosampler 4ea5878
add styles
alongoni 5a30801
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni 01d7d5d
add text component to new tx button
alongoni f598a0d
Sidebar without walletInfo
nicosampler 94ad1c3
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
nicosampler b1aeae9
fix footer and body margins
alongoni 8b96b3d
add logo Safe Multisig
alongoni 6783e76
update safe-react-components
nicosampler af7e9e2
List colors and List Icon
nicosampler fb33f25
fix subItem
nicosampler ffe91b8
update safe-react-components
nicosampler 5eb406f
fix logo margin, add notConnected icon and badge Read Only
alongoni 944a978
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni 25fcd2a
Merge branch 'development' into new-layout
nicosampler 4bcc913
fix merge problems
nicosampler 79d814d
add sidebar styles and icon notConnected
alongoni 63c1284
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni bb3e7c0
fix readOnly
nicosampler 286f2ab
fix QR tooltip info
alongoni 98eb663
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni 3b498ba
add Help Center link and fix margins
alongoni 6ac8be9
Remove 'No safe loaded' text
alongoni 144acfe
Merge branch 'development' into new-layout
nicosampler d692be9
review changes
nicosampler aad68d6
fix import
nicosampler 3bc7993
fix Help center margin
alongoni 13cbc56
add styles to address
alongoni e224620
replace empty div with FlexSpacer component
nicosampler c8b3e59
rename Sidebar by SafeListSidebar
nicosampler 998dc4a
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
nicosampler e1fa575
fix load and create safe position (top-left)
alongoni 556821d
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni 450ffd4
Add comment to FlexSpacer
03f4060
fix Title margin Safe Creation Progress
alongoni e408c10
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
alongoni e32f973
fix Read Only line-height
alongoni 98b6f14
Merge branch 'development' into new-layout
nicosampler 64b274c
review fixes
nicosampler dd7e514
review fixes
nicosampler 1117899
rename component
nicosampler 7656cc2
fix Help Center styles
alongoni 8bfc563
return type in DefaultBadge
nicosampler 83b9003
Fix types for list component (still wip)
mmv08 6c8e9f5
move sidebarList to a hook
nicosampler 0a0b940
Merge branches 'new-layout' and 'new-layout' of github.com:gnosis/saf…
nicosampler d88f343
Merge branch 'development' of github.com:gnosis/safe-react into new-l…
mmv08 8f8918c
fix safe route container
mmv08 a958100
fix src version
mmv08 08f6d32
fix list typescript issue
mmv08 46ef9bd
rename sidebarlayout to applayout
mmv08 614ebe3
Merge branch 'development' of github.com:gnosis/safe-react into new-l…
mmv08 cd7e4e0
sidebar fixes wip
mmv08 99ad632
sidebar fixes wip
mmv08 c55ef6d
remove unused function
nicosampler 3f08e76
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
mmv08 8de6da7
Merge branch 'development' into new-layout
mmv08 1009b21
lift sidebar items state up
mmv08 0d6a62e
fix broken imports
mmv08 cca64c9
Merge branch 'new-layout' of github.com:gnosis/safe-react into new-la…
mmv08 023a50f
remove unused files
mmv08 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,8 @@ | ||
| module.exports = { | ||
| stories: ['../src/**/*.stories.tsx'], | ||
| addons: [ | ||
| '@storybook/preset-create-react-app', | ||
| '@storybook/addon-actions', | ||
| '@storybook/addon-links', | ||
| ], | ||
| }; |
This file contains hidden or 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 @@ | ||
| <style> | ||
| html, body, #root { | ||
| height: 100%; | ||
| margin: 0; | ||
| } | ||
| </style> |
This file contains hidden or 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,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> | ||
| )) |
This file contains hidden or 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
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains hidden or 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,157 @@ | ||
| import React, { useContext, useEffect } from 'react' | ||
| 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 | ||
This file contains hidden or 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 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> | ||
| ) | ||
| } |
This file contains hidden or 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
File renamed without changes
6 changes: 6 additions & 0 deletions
6
src/components/AppLayout/Header/assets/gnosis-safe-multisig-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
matchfrom the router and the array of sidebarItems?There was a problem hiding this comment.
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
Componentsfolder, should not contain any business logic. That's why I used a hook.