-
Notifications
You must be signed in to change notification settings - Fork 188
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
refactor: pull header & wallet components out of Swap component #123
base: wallet-connect-flow
Are you sure you want to change the base?
refactor: pull header & wallet components out of Swap component #123
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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 change would couple src/components/Header to src/components/Swap. Header needs to be updated so that it does not couple Swap, in case we want to use it for other widgets in the future.
<Row gap={1}>{children}</Row> | ||
<Row gap={0.5}> | ||
<ThemedText.Subhead1> | ||
<Trans>Swap</Trans> |
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.
Should widgets expand past Swap
, this will need to be configurable.
Can you keep passing title
into the header?
@@ -14,11 +15,12 @@ export type { DefaultAddress, TokenDefaults } from 'hooks/swap/useSyncTokenDefau | |||
export type { Theme } from 'theme' | |||
export { darkTheme, defaultTheme, lightTheme } from 'theme' | |||
|
|||
export type SwapWidgetProps = SwapProps & WidgetProps | |||
export type SwapWidgetProps = HeaderProps & SwapProps & WidgetProps |
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 should be an interface extending the existing props:
export interface SwapWidgetProps extends HeaderProps, SwapProps, WidgetProps {}
This is slightly easier on the type system: it reduces time for type checking and it surfaces better types downstream.
const onSupportedNetwork = useOnSupportedNetwork() | ||
const isDisabled = !(isActive && onSupportedNetwork) | ||
|
||
const [onConnectWalletClick, setOnConnectWalletClick] = useAtom(onConnectWalletClickAtom) |
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.
You should be able to set this without referencing the already-set value:
const setOnConnectWalletClick = useSetAtom(onConnectWalletClickAtom)
useEffect(() => setOnConnectWalletClick(props.onConnectWalletClick), [props.onConnectWalletClick, setOnConnectWalletClick])
</Row> | ||
<Row gap={1}> | ||
<Wallet disabled={props.hideConnectionUI} /> | ||
<Settings disabled={isDisabled} /> |
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.
Settings is specific to the Swap widget (similar to the title) - this either needs to be a prop, or a callback to activate the Swap's settings.
Wallet connection + swap are two separate concerns, so should be two separate components imo
Refactoring to pull wallet out of the swap component