Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

refactor: pull header & wallet components out of Swap component#123

Open
kristiehuang wants to merge 3 commits intowallet-connect-flowfrom
wcf/refactor-wallet-connection-header
Open

refactor: pull header & wallet components out of Swap component#123
kristiehuang wants to merge 3 commits intowallet-connect-flowfrom
wcf/refactor-wallet-connection-header

Conversation

@kristiehuang
Copy link
Copy Markdown
Contributor

@kristiehuang kristiehuang commented Aug 3, 2022

Wallet connection + swap are two separate concerns, so should be two separate components imo

Refactoring to pull wallet out of the swap component

@vercel
Copy link
Copy Markdown

vercel Bot commented Aug 3, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
widgets ✅ Ready (Inspect) Visit Preview Aug 3, 2022 at 4:13PM (UTC)

@kristiehuang kristiehuang changed the base branch from main to wallet-connect-flow August 3, 2022 15:57
@vercel vercel Bot temporarily deployed to Preview August 3, 2022 16:01 Inactive
@kristiehuang kristiehuang changed the title Wcf/refactor wallet connection header refactor: pull header & wallet components out of Swap component Aug 3, 2022
Comment thread src/index.tsx Outdated
@JFrankfurt JFrankfurt requested a review from zzmp August 3, 2022 16:08
@kristiehuang kristiehuang marked this pull request as ready for review August 3, 2022 16:08
@vercel vercel Bot temporarily deployed to Preview August 3, 2022 16:13 Inactive
Copy link
Copy Markdown
Contributor

@zzmp zzmp left a 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.

Comment thread src/components/Header.tsx
<Row gap={1}>{children}</Row>
<Row gap={0.5}>
<ThemedText.Subhead1>
<Trans>Swap</Trans>
Copy link
Copy Markdown
Contributor

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?

Comment thread src/index.tsx
export { darkTheme, defaultTheme, lightTheme } from 'theme'

export type SwapWidgetProps = SwapProps & WidgetProps
export type SwapWidgetProps = HeaderProps & SwapProps & WidgetProps
Copy link
Copy Markdown
Contributor

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.

Comment thread src/components/Header.tsx
const onSupportedNetwork = useOnSupportedNetwork()
const isDisabled = !(isActive && onSupportedNetwork)

const [onConnectWalletClick, setOnConnectWalletClick] = useAtom(onConnectWalletClickAtom)
Copy link
Copy Markdown
Contributor

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])

Comment thread src/components/Header.tsx
</Row>
<Row gap={1}>
<Wallet disabled={props.hideConnectionUI} />
<Settings disabled={isDisabled} />
Copy link
Copy Markdown
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants