Skip to content

Commit

Permalink
Merge pull request #158 from argentlabs/feat/argent-webwallet-theme
Browse files Browse the repository at this point in the history
feat: webwallet connector theme option
  • Loading branch information
bluecco authored Nov 26, 2024
2 parents 0135584 + 210a16b commit 85ba513
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
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

0 comments on commit 85ba513

Please sign in to comment.