Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: whole area clickable back buttons #1428

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 11 additions & 9 deletions src/components/Step/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type StepType = 'bridge' | 'onRamp';

export type StepProps = {
stepType: StepType;
title?: string;
title: string;
onBack?: () => void;
children: ReactNode;
titleAdornment?: ReactNode;
Expand All @@ -33,17 +33,19 @@ export const Step = memo<StepProps>(function ({

return (
<div className={classes.container}>
{title ? (
<div className={classes.titleBar}>
{onBack !== undefined ? (
<button onClick={onBack} className={classes.backButton}>
<div className={classes.titleBar}>
{onBack ? (
<a onClick={onBack} className={classes.backLink}>
<button className={classes.backButton}>
<BackArrow className={classes.backIcon} />
</button>
) : null}
{title}
</a>
Comment on lines +38 to +43
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't have <button> inside <a>, <a> without href or <button> without a click handler.

Maybe something like this?

Index: src/components/Step/Step.tsx
<+>UTF-8
===================================================================
@@ -37,10 +37,14 @@
         <div className={classes.titleBar}>
           {onBack !== undefined ? (
             <button onClick={onBack} className={classes.backButton}>
-              <BackArrow className={classes.backIcon} />
+              <div className={classes.backIconSizer}>
+                <BackArrow className={classes.backIcon} />
+              </div>
+              <div>{title}</div>
             </button>
-          ) : null}
-          <div>{title}</div>
+          ) : (
+            <div>{title}</div>
+          )}
           {titleAdornment ? <div className={classes.adornment}>{titleAdornment}</div> : null}
         </div>
       ) : null}
Index: src/components/Step/styles.tsx
<+>UTF-8
===================================================================
@@ -24,19 +24,28 @@
   backButton: {
     margin: 0,
     padding: 0,
-    borderRadius: '50%',
-    width: '24px',
-    height: '24px',
-    background: '#363B63',
+    font: 'inherit',
+    background: 'transparent',
     boxShadow: 'none',
     cursor: 'pointer',
     border: 'none',
-    color: '#F5F5FF',
+    color: 'inherit',
+    flexShrink: 0,
+    flexGrow: 0,
+    display: 'flex',
+    columnGap: '12px',
+    alignItems: 'center',
+  },
+  backIconSizer: {
     flexShrink: 0,
     flexGrow: 0,
     display: 'flex',
     alignItems: 'center',
     justifyContent: 'center',
+    background: '#363B63',
+    borderRadius: '50%',
+    width: '24px',
+    height: '24px',
   },
   backIcon: {
     fill: '#F5F5FF',

) : (
<div>{title}</div>
{titleAdornment ? <div className={classes.adornment}>{titleAdornment}</div> : null}
</div>
) : null}
)}
{titleAdornment ? <div className={classes.adornment}>{titleAdornment}</div> : null}
</div>
<div className={clsx(classes.content, contentClass, { [classes.noPadding]: noPadding })}>
{children}
</div>
Expand Down
13 changes: 7 additions & 6 deletions src/components/Step/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export const styles = (theme: Theme) => ({
columnGap: '12px',
alignItems: 'center',
},
backLink: {
flexShrink: 0,
flexGrow: 0,
display: 'flex',
columnGap: '12px',
cursor: 'pointer',
},
backButton: {
margin: 0,
padding: 0,
Expand All @@ -31,12 +38,6 @@ export const styles = (theme: Theme) => ({
boxShadow: 'none',
cursor: 'pointer',
border: 'none',
color: '#F5F5FF',
flexShrink: 0,
flexGrow: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
backIcon: {
fill: '#F5F5FF',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const UnsupportedCountryStep = memo(function () {
const { t } = useTranslation();

return (
<Step stepType="onRamp">
<Step stepType="onRamp" title={t('OnRamp-UnsupportedCountryStep-Title')}>
<ErrorIndicator
title={t('OnRamp-UnsupportedCountryStep-Title')}
content={t('OnRamp-UnsupportedCountryStep-Content')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const QuoteSelectStep = memo(function QuoteSelectStep() {

return (
<div className={classes.container}>
<StepHeader onBack={handleBack}>{t('Transact-SelectProvider')}</StepHeader>
<StepHeader onBack={handleBack} title={t('Transact-SelectProvider')} />
<div className={classes.select}>
<Scrollable className={classes.listContainer}>
<div className={classes.list}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@ const useStyles = makeStyles(styles);

export type StepHeaderProps = {
onBack?: () => void;
children: ReactNode;
title: string;
children?: ReactNode;
};
export const StepHeader = memo<StepHeaderProps>(function ({ onBack, children }) {
export const StepHeader = memo<StepHeaderProps>(function ({ onBack, title, children }) {
const classes = useStyles();

return (
<div className={classes.container}>
{onBack ? (
<button onClick={onBack} className={classes.backButton}>
<BackArrow className={classes.backIcon} />
</button>
) : null}
<div>
{onBack ? (
<a onClick={onBack} className={classes.backLink}>
<button className={classes.backButton}>
<BackArrow className={classes.backIcon} />
</button>
{title}
</a>
) : (
<div>{title}</div>
)}
</div>
{children}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export const styles = (theme: Theme) => ({
background: '#363B63',
},
},
backLink: {
flexShrink: 0,
flexGrow: 0,
display: 'flex',
columnGap: '12px',
cursor: 'pointer',
},
backButton: {
margin: 0,
padding: 0,
Expand All @@ -32,12 +39,6 @@ export const styles = (theme: Theme) => ({
boxShadow: 'none',
cursor: 'pointer',
border: 'none',
color: '#F5F5FF',
flexShrink: 0,
flexGrow: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
backIcon: {
fill: '#F5F5FF',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const TokenSelectStep = memo(function () {

return (
<div className={classes.container}>
<StepHeader onBack={handleBack}>{t('Transact-SelectToken')}</StepHeader>
<StepHeader onBack={handleBack} title={t('Transact-SelectToken')} />
{mode === TransactMode.Deposit ? <DepositTokenSelectList /> : <WithdrawTokenSelectList />}
</div>
);
Expand Down