Skip to content
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

feat: webwallet connector theme option #158

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/connectors/webwallet/helpers/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ const appRouter = t.router({
}),
connect: t.procedure.mutation(async () => ""),
connectWebwallet: t.procedure
.input(
z.object({
theme: z.enum(["light", "dark", "auto"]).optional(),
}),
)
.output(
z.object({
account: z.string().array().optional(),
Expand Down
8 changes: 6 additions & 2 deletions src/connectors/webwallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ import {
import { DEFAULT_WEBWALLET_ICON, DEFAULT_WEBWALLET_URL } from "./constants"
import { openWebwallet } from "./helpers/openWebwallet"
import { setPopupOptions } from "./helpers/trpc"
import type { WebWalletStarknetWindowObject } from "./starknetWindowObject/argentStarknetWindowObject"
import type {
Theme,
WebWalletStarknetWindowObject,
} from "./starknetWindowObject/argentStarknetWindowObject"

let _wallet: StarknetWindowObject | null = null
let _address: string | null = null

interface WebWalletConnectorOptions {
url?: string
theme?: Theme
ssoToken?: string
authorizedPartyId?: string
}
Expand Down Expand Up @@ -125,7 +129,7 @@ export class WebWalletConnector extends Connector {
} else {
const connectResponse = await (
this._wallet as WebWalletStarknetWindowObject
).connectWebwallet()
).connectWebwallet({ theme: this._options.theme })
account = connectResponse.account
chainId = connectResponse.chainId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ export type LoginStatus = {
isPreauthorized?: boolean
}

export type Theme = "light" | "dark"

type ConnectWebwalletProps = {
theme?: Theme
}

export type WebWalletStarknetWindowObject = StarknetWindowObject & {
getLoginStatus(): Promise<LoginStatus>
connectWebwallet(): Promise<{
connectWebwallet(props?: ConnectWebwalletProps): Promise<{
account?: string[]
chainId?: string
}>
Expand All @@ -57,8 +63,9 @@ export const getArgentStarknetWindowObject = (
getLoginStatus: () => {
return proxyLink.getLoginStatus.mutate()
},
connectWebwallet: () => {
return proxyLink.connectWebwallet.mutate()
connectWebwallet: (props = {}) => {
const { theme } = props
return proxyLink.connectWebwallet.mutate({ theme })
},
connectWebwalletSSO: (token, authorizedPartyId) => {
return proxyLink.connectWebwalletSSO.mutate({ token, authorizedPartyId })
Expand Down
1 change: 0 additions & 1 deletion src/connectors/webwallet/starknetWindowObject/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const applyModalStyle = (iframe: HTMLIFrameElement) => {
background.style.left = "0"
background.style.right = "0"
background.style.bottom = "0"
background.style.backgroundColor = "rgba(0, 0, 0, 0.5)"
background.style.zIndex = "99999"
;(background.style as any).backdropFilter = "blur(4px)"

Expand Down