Skip to content

Commit

Permalink
Merge branch '466-improve-the-transaction-dialog-confirmation-to-enha…
Browse files Browse the repository at this point in the history
…nce-its-responsiveness-and-user-experience' into 'dev'

Resolve "Improve the transaction dialog confirmation to enhance its responsiveness and user experience"

Closes #466

See merge request ergo/rosen-bridge/ui!389
  • Loading branch information
zargarzadehm committed Dec 15, 2024
2 parents df17a94 + cdf4069 commit c4aca04
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 79 deletions.
6 changes: 6 additions & 0 deletions .changeset/rude-ads-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rosen-bridge/ui-kit': minor
---

- Revise the default layout to incorporate toolbar buttons into the sidebar for mobile devices
- Create an improved dialogue that aligns with our Figma design and ensures responsiveness
5 changes: 5 additions & 0 deletions .changeset/small-baboons-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/rosen-app': minor
---

Improve the transaction dialog confirmation to enhance its responsiveness and user experience
153 changes: 80 additions & 73 deletions apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {
Amount,
Box,
Card,
Dialog,
DialogActions,
DialogContent,
Divider,
EnhancedDialog,
EnhancedDialogTitle,
Grid,
LoadingButton,
Expand Down Expand Up @@ -121,87 +122,93 @@ export const ConnectOrSubmitButton = ({
>
{!selectedWallet ? 'CONNECT WALLET' : 'SUBMIT'}
</LoadingButton>
<Dialog open={open} maxWidth="tablet" onClose={() => setOpen(false)}>
<EnhancedDialog
open={open}
maxWidth="tablet"
scroll="paper"
onClose={() => setOpen(false)}
>
<EnhancedDialogTitle
icon={<CommentAltExclamation />}
onClose={() => setOpen(false)}
>
Confirm Transaction
</EnhancedDialogTitle>
<Card
sx={{
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.primary.light
: theme.palette.primary.dark,
px: 2,
py: 3,
mx: 3,
}}
>
<Grid container justifyContent="center">
<Amount
value={amountValue || 0}
size="large"
unit={tokenInfo?.tokenName}
/>
</Grid>
<Box
<DialogContent sx={{ py: 0 }}>
<Card
sx={{
display: 'grid',
gridTemplateColumns: 'auto auto auto',
justifyContent: 'center',
columnGap: 2,
rowGap: 0.5,
my: 3,
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.primary.light
: theme.palette.primary.dark,
px: 2,
py: 3,
}}
>
<Grid container alignItems="center" gap={1}>
{SourceLogo && (
<SvgIcon>
<SourceLogo />
</SvgIcon>
)}
<Typography color="text.primary">{source?.label}</Typography>
</Grid>
<SvgIcon>
<ArrowRight />
</SvgIcon>
<Grid container alignItems="center" gap={1}>
{TargetLogo && (
<SvgIcon>
<TargetLogo />
</SvgIcon>
)}
<Typography color="text.primary">{target?.label}</Typography>
<Grid container justifyContent="center">
<Amount
value={amountValue || 0}
size="large"
unit={tokenInfo?.tokenName}
/>
</Grid>
</Box>
<Divider sx={{ my: 2 }} />
<Amount
title="Transaction Fee"
value={networkFeeRaw}
unit={tokenInfo?.tokenName}
/>
<Box sx={{ my: 2 }} />
<Amount
title="Bridge Fee"
value={bridgeFeeRaw}
unit={tokenInfo?.tokenName}
/>
<Box sx={{ my: 2 }} />
<Amount
title="Received amount"
value={receivingAmountRaw}
unit={targetTokenInfo?.name}
/>
<Divider sx={{ my: 2 }} />
<Typography variant="body2" color="text.secondary">
Destination address
</Typography>
<Typography sx={{ wordBreak: 'break-all' }}>
{walletAddressValue}
</Typography>
</Card>
<Box
sx={{
display: 'grid',
gridTemplateColumns: 'auto auto auto',
justifyContent: 'center',
columnGap: 2,
rowGap: 0.5,
my: 3,
}}
>
<Grid container alignItems="center" gap={1}>
{SourceLogo && (
<SvgIcon>
<SourceLogo />
</SvgIcon>
)}
<Typography color="text.primary">{source?.label}</Typography>
</Grid>
<SvgIcon>
<ArrowRight />
</SvgIcon>
<Grid container alignItems="center" gap={1}>
{TargetLogo && (
<SvgIcon>
<TargetLogo />
</SvgIcon>
)}
<Typography color="text.primary">{target?.label}</Typography>
</Grid>
</Box>
<Divider sx={{ my: 2 }} />
<Amount
title="Transaction Fee"
value={networkFeeRaw}
unit={tokenInfo?.tokenName}
/>
<Box sx={{ my: 2 }} />
<Amount
title="Bridge Fee"
value={bridgeFeeRaw}
unit={tokenInfo?.tokenName}
/>
<Box sx={{ my: 2 }} />
<Amount
title="Received amount"
value={receivingAmountRaw}
unit={targetTokenInfo?.name}
/>
<Divider sx={{ my: 2 }} />
<Typography variant="body2" color="text.secondary">
Destination address
</Typography>
<Typography sx={{ wordBreak: 'break-all' }}>
{walletAddressValue}
</Typography>
</Card>
</DialogContent>
<DialogActions>
<LoadingButton
color="secondary"
Expand All @@ -222,7 +229,7 @@ export const ConnectOrSubmitButton = ({
Confirm
</LoadingButton>
</DialogActions>
</Dialog>
</EnhancedDialog>
</>
);
};
25 changes: 22 additions & 3 deletions packages/ui-kit/src/components/common/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ReactNode } from 'react';

import { SnackbarProvider } from '../../contexts';
import { useMediaQuery } from '../../hooks';
import { ThemeProvider, ThemeProviderProps } from '../../Providers';
import { styled } from '../../styling';
import { CssBaseline } from '../base';
import { Box, CssBaseline } from '../base';
import { AppSnackbar } from './AppSnackbar';

const Root = styled('div', {
Expand Down Expand Up @@ -49,15 +50,33 @@ interface AppProps {
}

export const App = ({ children, sideBar, theme, toolbar }: AppProps) => {
const isMobile = useMediaQuery(
('light' in theme ? theme.light : theme).breakpoints.down('tablet'),
);
return (
<ThemeProvider theme={theme}>
<>
<CssBaseline />
<SnackbarProvider>
<Root>
{sideBar}
{isMobile ? (
<Box
display="flex"
alignItems="center"
justifyContent="space-between"
>
{sideBar}
{toolbar}
</Box>
) : (
sideBar
)}
<Main>
<div style={{ position: 'relative', zIndex: '1' }}>{toolbar}</div>
{!isMobile && (
<div style={{ position: 'relative', zIndex: '1' }}>
{toolbar}
</div>
)}
{children}
</Main>
<AppSnackbar />
Expand Down
18 changes: 18 additions & 0 deletions packages/ui-kit/src/components/common/EnhancedDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { styled } from '../../styling';
import { Dialog } from '../base';

/**
* renders an enhanced version of material ui Dialog
*/
export const EnhancedDialog = styled(Dialog)(({ theme }) => ({
[theme.breakpoints.down('tablet')]: {
'& > .MuiDialog-container': {
'alignItems': 'end',
'& > .MuiPaper-root': {
margin: 0,
borderBottomRightRadius: 0,
borderBottomLeftRadius: 0,
},
},
},
}));
14 changes: 11 additions & 3 deletions packages/ui-kit/src/components/common/EnhancedDialogTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { styled } from '@mui/material';
import { Times } from '@rosen-bridge/icons';

import { useIsMobile } from '../../hooks';
import { DialogTitle, DialogTitleProps, IconButton, SvgIcon } from '../base';

const IconContainer = styled('div')(({ theme }) => ({
Expand All @@ -25,15 +26,22 @@ export const EnhancedDialogTitle = ({
onClose,
...props
}: EnhancedDialogTitleProps) => {
const isMobile = useIsMobile();
return (
<DialogTitle {...props} display="flex" alignItems="center" gap={2}>
{icon && (
<DialogTitle
{...props}
display="flex"
alignItems="center"
flexDirection={isMobile ? 'column' : 'row'}
gap={2}
>
{!isMobile && icon && (
<IconContainer>
<SvgIcon sx={{ height: 20, width: 20 }}>{icon}</SvgIcon>
</IconContainer>
)}
<span style={{ flexGrow: 1 }}>{props.children}</span>
{onClose && (
{!isMobile && onClose && (
<IconButton onClick={onClose}>
<SvgIcon>
<Times />
Expand Down
10 changes: 10 additions & 0 deletions packages/ui-kit/src/components/common/Toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

import { useIsMobile } from '../../hooks';
import { isLegacyTheme, useTheme } from '../../hooks/useTheme';
import { styled } from '../../styling';
import { Typography, Stack, Grid } from '../base';
Expand Down Expand Up @@ -40,6 +41,15 @@ export const Toolbar: React.FC<ToolbarProps> = (props) => {
const theme = useTheme();
const textAlign = isCentered ? 'center' : 'inherit';

const isMobile = useIsMobile();

if (isMobile)
return (
<div className="toolbar">
<Stack direction="row">{toolbarActions}</Stack>
</div>
);

return (
<Header>
<Grid container alignItems={isLegacyTheme(theme) ? 'stretch' : 'center'}>
Expand Down
1 change: 1 addition & 0 deletions packages/ui-kit/src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './ApiKeyModal';
export * from './App';
export * from './AppBar';
export * from './AppLogo';
export * from './EnhancedDialog';
export * from './EnhancedDialogTitle';
export * from './EnhancedTable';
export * from './EnhancedTableCell';
Expand Down

0 comments on commit c4aca04

Please sign in to comment.