-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add capsule client check before rendering provider-ui components…
… inside examples
- Loading branch information
1 parent
2b01d7f
commit a2a386d
Showing
6 changed files
with
131 additions
and
55 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
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,44 @@ | ||
import "@leapwallet/cosmos-social-login-capsule-provider-ui/styles.css"; | ||
|
||
import { useColorMode } from "@chakra-ui/react"; | ||
import { useCapsule } from "graz"; | ||
import dynamic from "next/dynamic"; | ||
import React from "react"; | ||
|
||
const LeapSocialLogin = dynamic( | ||
() => import("@leapwallet/cosmos-social-login-capsule-provider-ui").then((m) => m.CustomCapsuleModalView), | ||
{ ssr: false }, | ||
); | ||
|
||
const TransactionSigningModal = dynamic( | ||
() => import("@leapwallet/cosmos-social-login-capsule-provider-ui").then((m) => m.TransactionSigningModal), | ||
{ ssr: false }, | ||
); | ||
|
||
const CapsuleModals = () => { | ||
const { client, modalState, onAfterLoginSuccessful, setModalState, onLoginFailure } = useCapsule(); | ||
const { colorMode } = useColorMode(); | ||
|
||
return client ? ( | ||
<div className="leap-ui"> | ||
<LeapSocialLogin | ||
// @ts-expect-error - use capsule version mismatch error | ||
capsule={client.getClient()} | ||
// @ts-expect-error - type error | ||
oAuthMethods={["GOOGLE", "FACEBOOK", "TWITTER", "DISCORD", "APPLE"]} | ||
onAfterLoginSuccessful={() => { | ||
void onAfterLoginSuccessful?.(); | ||
}} | ||
onLoginFailure={() => { | ||
onLoginFailure(); | ||
}} | ||
setShowCapsuleModal={setModalState} | ||
showCapsuleModal={modalState} | ||
theme={colorMode} | ||
/> | ||
<TransactionSigningModal dAppInfo={{ name: "Graz Example" }} /> | ||
</div> | ||
) : null; | ||
}; | ||
|
||
export default CapsuleModals; |
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
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,44 @@ | ||
import "@leapwallet/cosmos-social-login-capsule-provider-ui/styles.css"; | ||
|
||
import { useColorMode } from "@chakra-ui/react"; | ||
import { useCapsule } from "graz"; | ||
import dynamic from "next/dynamic"; | ||
import React from "react"; | ||
|
||
const LeapSocialLogin = dynamic( | ||
() => import("@leapwallet/cosmos-social-login-capsule-provider-ui").then((m) => m.CustomCapsuleModalView), | ||
{ ssr: false }, | ||
); | ||
|
||
const TransactionSigningModal = dynamic( | ||
() => import("@leapwallet/cosmos-social-login-capsule-provider-ui").then((m) => m.TransactionSigningModal), | ||
{ ssr: false }, | ||
); | ||
|
||
const CapsuleModals = () => { | ||
const { client, modalState, onAfterLoginSuccessful, setModalState, onLoginFailure } = useCapsule(); | ||
const { colorMode } = useColorMode(); | ||
|
||
return client ? ( | ||
<div className="leap-ui"> | ||
<LeapSocialLogin | ||
// @ts-expect-error - use capsule version mismatch error | ||
capsule={client.getClient()} | ||
// @ts-expect-error - type error | ||
oAuthMethods={["GOOGLE", "FACEBOOK", "TWITTER", "DISCORD", "APPLE"]} | ||
onAfterLoginSuccessful={() => { | ||
void onAfterLoginSuccessful?.(); | ||
}} | ||
onLoginFailure={() => { | ||
onLoginFailure(); | ||
}} | ||
setShowCapsuleModal={setModalState} | ||
showCapsuleModal={modalState} | ||
theme={colorMode} | ||
/> | ||
<TransactionSigningModal dAppInfo={{ name: "Graz Example" }} /> | ||
</div> | ||
) : null; | ||
}; | ||
|
||
export default CapsuleModals; |
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
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,31 @@ | ||
import "@leapwallet/cosmos-social-login-capsule-provider-ui/styles.css"; | ||
|
||
import { CustomCapsuleModalView, TransactionSigningModal } from "@leapwallet/cosmos-social-login-capsule-provider-ui"; | ||
import { useCapsule } from "graz"; | ||
import React from "react"; | ||
|
||
const CapsuleModals = () => { | ||
const { client, modalState, onAfterLoginSuccessful, setModalState, onLoginFailure } = useCapsule(); | ||
return client ? ( | ||
<div className="leap-ui"> | ||
<CustomCapsuleModalView | ||
// @ts-expect-error - use capsule version mismatch error | ||
capsule={client.getClient()} | ||
// @ts-expect-error - type error | ||
oAuthMethods={["GOOGLE", "FACEBOOK", "TWITTER", "DISCORD", "APPLE"]} | ||
onAfterLoginSuccessful={() => { | ||
void onAfterLoginSuccessful?.(); | ||
}} | ||
onLoginFailure={() => { | ||
onLoginFailure(); | ||
}} | ||
setShowCapsuleModal={setModalState} | ||
showCapsuleModal={modalState} | ||
theme="light" | ||
/> | ||
<TransactionSigningModal dAppInfo={{ name: "Graz Example" }} /> | ||
</div> | ||
) : null; | ||
}; | ||
|
||
export default CapsuleModals; |