-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Misc Sideshift page polish #667
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||
| import React, { Fragment, useEffect, useRef, useState } from 'react' | ||||||||||||||||||||||||||||||
| import React, { Fragment, useEffect, useMemo, useRef, useState } from 'react' | ||||||||||||||||||||||||||||||
| import { TextField, Select, MenuItem, InputLabel, FormControl, Box, CircularProgress } from '@mui/material' | ||||||||||||||||||||||||||||||
| import { styled } from '@mui/material/styles' | ||||||||||||||||||||||||||||||
| import { QRCodeSVG } from 'qrcode.react' | ||||||||||||||||||||||||||||||
|
|
@@ -377,38 +377,30 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const SideshiftCtn = styled('div')({ | ||||||||||||||||||||||||||||||
| const SideshiftCtn = useMemo(() => styled('div')({ | ||||||||||||||||||||||||||||||
| alignItems: 'center', | ||||||||||||||||||||||||||||||
| justifyContent: 'flex-start', | ||||||||||||||||||||||||||||||
| display: 'flex', | ||||||||||||||||||||||||||||||
| flexDirection: 'column', | ||||||||||||||||||||||||||||||
| boxSizing: 'border-box', | ||||||||||||||||||||||||||||||
| position: 'absolute', | ||||||||||||||||||||||||||||||
| zIndex: 9, | ||||||||||||||||||||||||||||||
| top: 0, | ||||||||||||||||||||||||||||||
| left: 0, | ||||||||||||||||||||||||||||||
| right: 0, | ||||||||||||||||||||||||||||||
| bottom: 0, | ||||||||||||||||||||||||||||||
| position: 'relative', | ||||||||||||||||||||||||||||||
| background: '#f5f5f7', | ||||||||||||||||||||||||||||||
| overflowY: 'auto', | ||||||||||||||||||||||||||||||
| overflowX: 'hidden', | ||||||||||||||||||||||||||||||
| width: '100%', | ||||||||||||||||||||||||||||||
| padding: '16px', | ||||||||||||||||||||||||||||||
| '@media (min-width: 760px)': { | ||||||||||||||||||||||||||||||
| padding: '24px', | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| }), []) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const LoadingCenter = styled('div')({ | ||||||||||||||||||||||||||||||
| position: 'absolute', | ||||||||||||||||||||||||||||||
| top: '50%', | ||||||||||||||||||||||||||||||
| left: '50%', | ||||||||||||||||||||||||||||||
| transform: 'translate(-50%, -50%)', | ||||||||||||||||||||||||||||||
| display: 'flex', | ||||||||||||||||||||||||||||||
| flexDirection: 'column', | ||||||||||||||||||||||||||||||
| alignItems: 'center', | ||||||||||||||||||||||||||||||
| justifyContent: 'center', | ||||||||||||||||||||||||||||||
| gap: '16px', | ||||||||||||||||||||||||||||||
| textAlign: 'center', | ||||||||||||||||||||||||||||||
| width: 'max-content', | ||||||||||||||||||||||||||||||
| width: '100%', | ||||||||||||||||||||||||||||||
| minHeight: '300px', | ||||||||||||||||||||||||||||||
| maxWidth: '100%', | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -419,11 +411,18 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const BackLink = styled('div')({ | ||||||||||||||||||||||||||||||
| fontSize: '14px', marginTop: '20px', cursor: 'pointer', | ||||||||||||||||||||||||||||||
| fontSize: '14px', cursor: 'pointer', | ||||||||||||||||||||||||||||||
| border: '1px solid #000', opacity: '0.7', padding: '2px 20px', | ||||||||||||||||||||||||||||||
| borderRadius: '3px', '&:hover': { opacity: '1' }, | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const BackRow = styled('div')({ | ||||||||||||||||||||||||||||||
| width: '100%', | ||||||||||||||||||||||||||||||
| display: 'flex', | ||||||||||||||||||||||||||||||
| justifyContent: 'center', | ||||||||||||||||||||||||||||||
| marginTop: '30px', | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const ShiftReady = styled('div')({ | ||||||||||||||||||||||||||||||
| width: '100%', display: 'flex', flexDirection: 'column', | ||||||||||||||||||||||||||||||
| minWidth: 0, | ||||||||||||||||||||||||||||||
|
|
@@ -479,8 +478,16 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const AmountError = styled('p')({ | ||||||||||||||||||||||||||||||
| position: 'absolute', bottom: '10px', textAlign: 'center', | ||||||||||||||||||||||||||||||
| background: '#00000014', padding: '10px', borderRadius: '5px' | ||||||||||||||||||||||||||||||
| margin: '12px auto 0', | ||||||||||||||||||||||||||||||
| textAlign: 'center', | ||||||||||||||||||||||||||||||
| background: '#00000014', | ||||||||||||||||||||||||||||||
| padding: '10px', | ||||||||||||||||||||||||||||||
| borderRadius: '5px', | ||||||||||||||||||||||||||||||
| minHeight: '28px', | ||||||||||||||||||||||||||||||
| display: 'flex', | ||||||||||||||||||||||||||||||
| alignItems: 'center', | ||||||||||||||||||||||||||||||
| justifyContent: 'center', | ||||||||||||||||||||||||||||||
| transition: 'opacity 120ms ease', | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const ErrorMsg = styled('p')({ | ||||||||||||||||||||||||||||||
|
|
@@ -699,6 +706,13 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const isAutoStart = Boolean(preselectedCoin) | ||||||||||||||||||||||||||||||
| const isAutoStartLoading = isAutoStart && !altpaymentShift && !altpaymentError | ||||||||||||||||||||||||||||||
| const showManualAmountBackButton = altpaymentEditable | ||||||||||||||||||||||||||||||
| const amountValidationMessage = | ||||||||||||||||||||||||||||||
| pairAmount && !isAboveMinimumAltpaymentAmount | ||||||||||||||||||||||||||||||
| ? 'Amount is below minimum.' | ||||||||||||||||||||||||||||||
| : pairAmount && !isBelowMaximumAltpaymentAmount | ||||||||||||||||||||||||||||||
| ? 'Amount is above maximum.' | ||||||||||||||||||||||||||||||
| : '' | ||||||||||||||||||||||||||||||
|
Comment on lines
+709
to
+715
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Do not treat uninitialized validation flags as failures. Both flags initially equal Proposed fix const amountValidationMessage =
- pairAmount && !isAboveMinimumAltpaymentAmount
+ pairAmount && isAboveMinimumAltpaymentAmount === false
? 'Amount is below minimum.'
- : pairAmount && !isBelowMaximumAltpaymentAmount
+ : pairAmount && isBelowMaximumAltpaymentAmount === false📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const renderLoading = (message: string) => ( | ||||||||||||||||||||||||||||||
| <LoadingCenter> | ||||||||||||||||||||||||||||||
|
|
@@ -717,12 +731,28 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
| </LoadingCenter> | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const backToWidget = () => { | ||||||||||||||||||||||||||||||
| setUseAltpayment(false) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+734
to
+736
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Reset parent-owned altpayment state before hiding the widget.
Clear the trade and loading state before leaving the widget. Proposed fix const backToWidget = () => {
+ resetTrade()
+ setLoadingPair(false)
+ setLoadingShift(false)
setUseAltpayment(false)
}Also applies to: 1004-1006 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const backToRateSelection = () => { | ||||||||||||||||||||||||||||||
| autoQuoteRequestedRef.current = false | ||||||||||||||||||||||||||||||
| setAltpaymentError(undefined) | ||||||||||||||||||||||||||||||
| setAltpaymentShift(undefined) | ||||||||||||||||||||||||||||||
| setLoadingShift(false) | ||||||||||||||||||||||||||||||
| setCoinPair(undefined) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <SideshiftCtn> | ||||||||||||||||||||||||||||||
| {altpaymentError ? ( | ||||||||||||||||||||||||||||||
| <Fragment> | ||||||||||||||||||||||||||||||
| <ErrorMsg>Error: {altpaymentError.errorMessage}</ErrorMsg> | ||||||||||||||||||||||||||||||
| <BackLink onClick={resetTrade}>Back</BackLink> | ||||||||||||||||||||||||||||||
| {showManualAmountBackButton ? ( | ||||||||||||||||||||||||||||||
| <BackRow> | ||||||||||||||||||||||||||||||
| <BackLink onClick={resetTrade}>Back</BackLink> | ||||||||||||||||||||||||||||||
| </BackRow> | ||||||||||||||||||||||||||||||
| ) : null} | ||||||||||||||||||||||||||||||
|
Comment on lines
748
to
+755
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Keep an exit or retry action available for every altpayment error. When Render a Back/Retry action for non-editable flows as well, using 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| </Fragment> | ||||||||||||||||||||||||||||||
| ) : isAutoStartLoading ? ( | ||||||||||||||||||||||||||||||
| renderLoading('Loading SideShift...') | ||||||||||||||||||||||||||||||
|
|
@@ -822,6 +852,11 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
| </CopyCtn> | ||||||||||||||||||||||||||||||
| </ShiftReadyMain> | ||||||||||||||||||||||||||||||
| </ShiftReadyBody> | ||||||||||||||||||||||||||||||
| {showManualAmountBackButton ? ( | ||||||||||||||||||||||||||||||
| <BackRow> | ||||||||||||||||||||||||||||||
| <BackLink onClick={resetTrade}>Back</BackLink> | ||||||||||||||||||||||||||||||
| </BackRow> | ||||||||||||||||||||||||||||||
| ) : null} | ||||||||||||||||||||||||||||||
| </ShiftReady> | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| ) : loadingShift ? ( | ||||||||||||||||||||||||||||||
|
|
@@ -870,12 +905,17 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
| animation={animation} | ||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| {pairAmount && !isAboveMinimumAltpaymentAmount && ( | ||||||||||||||||||||||||||||||
| <AmountError>Amount is below minimum.</AmountError> | ||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||
| {pairAmount && !isBelowMaximumAltpaymentAmount && ( | ||||||||||||||||||||||||||||||
| <AmountError>Amount is above maximum.</AmountError> | ||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||
| <AmountError | ||||||||||||||||||||||||||||||
| aria-live="polite" | ||||||||||||||||||||||||||||||
| style={amountValidationMessage ? { opacity: 1, visibility: 'visible' } : { opacity: 0, visibility: 'hidden' }} | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| {amountValidationMessage || '\u00A0'} | ||||||||||||||||||||||||||||||
| </AmountError> | ||||||||||||||||||||||||||||||
| {showManualAmountBackButton ? ( | ||||||||||||||||||||||||||||||
| <BackRow> | ||||||||||||||||||||||||||||||
| <BackLink onClick={backToRateSelection}>Back</BackLink> | ||||||||||||||||||||||||||||||
| </BackRow> | ||||||||||||||||||||||||||||||
| ) : null} | ||||||||||||||||||||||||||||||
| </Fragment> | ||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||
| <Fragment> | ||||||||||||||||||||||||||||||
|
|
@@ -961,7 +1001,9 @@ export const AltpaymentWidget: React.FunctionComponent<AltpaymentProps> = props | |||||||||||||||||||||||||||||
| animation={animation} | ||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||
| <BackLink onClick={() => {setUseAltpayment(false)}}>Back</BackLink> | ||||||||||||||||||||||||||||||
| <BackRow> | ||||||||||||||||||||||||||||||
| <BackLink onClick={backToWidget}>Back</BackLink> | ||||||||||||||||||||||||||||||
| </BackRow> | ||||||||||||||||||||||||||||||
| </Fragment> | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| // END: Altpayment region | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 5044
Make
BackLinkkeyboard-accessible.BackLinkis rendered as a clickable<div>without focusability or a keyboard handler, so keyboard and assistive-technology users cannot operate these navigation controls. Use a real<button type="button">or MUI button primitive while preserving the same styling and handling.🤖 Prompt for AI Agents