forked from substrate-asia/hackathon-2023-winter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update style of wallet extension select view (#21)
* Update style of wallet extension select view * Update --------- Co-authored-by: notset <notset@email.com>
- Loading branch information
Showing
5 changed files
with
86 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,6 @@ next-env.d.ts | |
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
.yalc | ||
yalc.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
projects/16-open-qf/src/site/components/connect/connectWalletPopup/walletExtension.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import tw from "tailwind-styled-components"; | ||
import useInjectedWeb3 from "./useInjectedWeb3"; | ||
import { useIsMounted } from "@osn/common"; | ||
import { useEffect, useState } from "react"; | ||
import { ReactComponent as ArrowCaretRight } from "@/imgs/icons/arrow-caret-right.svg"; | ||
import { LoadingIcon } from "@osn/common-ui"; | ||
|
||
const Wrapper = tw.div` | ||
flex | ||
justify-between | ||
items-center | ||
py-[12px] | ||
px-[12px] | ||
border | ||
border-stroke-action-default | ||
${(p) => | ||
p.disabled | ||
? "border-none bg-fill-bg-tertiary pointer-events-none" | ||
: "cursor-pointer"} | ||
`; | ||
|
||
const ArrowCaretRightIcon = tw(ArrowCaretRight)` | ||
[&_path]:fill-text-secondary | ||
`; | ||
|
||
export default function WalletExtension({ wallet, onClick }) { | ||
const [installed, setInstalled] = useState(null); | ||
const { loading: loadingInjectedWeb3, injectedWeb3 } = useInjectedWeb3(); | ||
const isMounted = useIsMounted(); | ||
const Logo = wallet.logo; | ||
|
||
useEffect(() => { | ||
if (loadingInjectedWeb3) { | ||
return; | ||
} | ||
|
||
if (isMounted.current) { | ||
setInstalled(!!injectedWeb3?.[wallet?.extensionName]); | ||
} | ||
}, [loadingInjectedWeb3, injectedWeb3, wallet?.extensionName, isMounted]); | ||
|
||
const disabled = loadingInjectedWeb3 || !installed; | ||
|
||
return ( | ||
<Wrapper disabled={disabled} onClick={() => onClick(wallet)}> | ||
<div className="flex items-center gap-[8px]"> | ||
<Logo className={wallet.title} alt={wallet.title} /> | ||
<span className="text-text-primary text14medium">{wallet.title}</span> | ||
</div> | ||
<div> | ||
{loadingInjectedWeb3 ? ( | ||
<LoadingIcon width={24} height={24} /> | ||
) : installed ? ( | ||
<ArrowCaretRightIcon width={24} height={24} /> | ||
) : ( | ||
<span className="text12medium text-text-tertiary">Not installed</span> | ||
)} | ||
</div> | ||
</Wrapper> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
projects/16-open-qf/src/site/components/layouts/detailLayout.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import MainContainer from "../containers/main"; | ||
import AppLayout from "./appLayout"; | ||
|
||
export default function DetailLayout({ backdrop, children, ...props }) { | ||
return ( | ||
<AppLayout backdrop={backdrop} {...props}> | ||
<MainContainer>{children}</MainContainer> | ||
</AppLayout> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
projects/16-open-qf/src/site/imgs/icons/arrow-caret-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.