-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
136 changed files
with
13,995 additions
and
5,092 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 |
---|---|---|
|
@@ -33,3 +33,6 @@ yarn-error.log* | |
|
||
# vercel | ||
.vercel | ||
|
||
# Sentry Config File | ||
.env.sentry-build-plugin |
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,4 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
} |
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 { Flex, Image, Text } from '@chakra-ui/react' | ||
import NextImage, { StaticImageData } from 'next/image' | ||
|
||
type AboutCardProps = { | ||
image: string | StaticImageData | ||
title: string | ||
description: string | ||
} | ||
|
||
export default function AboutCard({ | ||
image, | ||
title, | ||
description, | ||
}: AboutCardProps) { | ||
return ( | ||
<Flex gap={4} maxW="22rem" alignItems="center"> | ||
<Image | ||
as={NextImage} | ||
src={image as any} | ||
alt={title} | ||
boxSize="3rem" | ||
borderRadius="xl" | ||
/> | ||
|
||
<Flex direction="column" textAlign="left" gap={1}> | ||
<Text textStyle="body2Bold">{title}</Text> | ||
<Text textStyle="body2">{description}</Text> | ||
</Flex> | ||
</Flex> | ||
) | ||
} |
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,83 @@ | ||
import { | ||
Box, | ||
ButtonProps, | ||
Flex, | ||
Heading, | ||
Image, | ||
SimpleGrid, | ||
Stack, | ||
Text, | ||
} from '@chakra-ui/react' | ||
import NextImage from 'next/image' | ||
import { isDataURL } from '../helpers/urls' | ||
import HybridButton from './HybridButton' | ||
|
||
type ActionCardProps = { | ||
icon: string | ||
title: string | ||
description: string | ||
button: { | ||
text: string | ||
} & ( | ||
| { | ||
href: string | ||
} | ||
| { | ||
onClick: () => void | ||
} | ||
) & | ||
ButtonProps | ||
} | ||
|
||
export default function ActionCard({ | ||
icon, | ||
title, | ||
description, | ||
button: { text: buttonText, ...buttonProps }, | ||
}: ActionCardProps) { | ||
return ( | ||
<Flex | ||
borderRadius="2xl" | ||
flex={1} | ||
width="100%" | ||
justifyContent="center" | ||
alignItems="center" | ||
p={6} | ||
> | ||
<SimpleGrid | ||
columns={2} | ||
w="xs" | ||
gap={4} | ||
templateColumns={'auto 1fr'} | ||
templateRows={'auto 1fr'} | ||
alignItems="center" | ||
> | ||
<Image | ||
as={isDataURL(icon) ? 'img' : NextImage} | ||
src={icon} | ||
alt={title} | ||
boxSize="4.5rem" | ||
borderRadius="xl" | ||
my="auto" | ||
/> | ||
<Stack pt={1}> | ||
<Text textStyle="body1Bold">{title}</Text> | ||
<Text textStyle="body2">{description}</Text> | ||
</Stack> | ||
|
||
{/* Placeholder for grid */} | ||
<Box></Box> | ||
|
||
<HybridButton | ||
variant="primary" | ||
size="sm" | ||
borderRadius="full" | ||
mr="auto" | ||
{...buttonProps} | ||
> | ||
{buttonText} | ||
</HybridButton> | ||
</SimpleGrid> | ||
</Flex> | ||
) | ||
} |
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,19 @@ | ||
import { useColorMode, useColorModePreference } from '@chakra-ui/react' | ||
import { useEffect } from 'react' | ||
|
||
// Used to keep users color mode in sync with their preferred color mode | ||
// Chakra is supposed to do it, but when the system color mode is changed | ||
// when the app is closed, Chakra never updates the color mode, so this | ||
// helps keep it in sync. | ||
export function ColorModeSync() { | ||
const preferredColorMode = useColorModePreference() | ||
const { setColorMode, colorMode } = useColorMode() | ||
|
||
useEffect(() => { | ||
if (!preferredColorMode) return | ||
if (colorMode === preferredColorMode) return | ||
setColorMode(preferredColorMode) | ||
}, [preferredColorMode]) | ||
|
||
return null | ||
} |
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,78 @@ | ||
import { Wallet } from '../data/wallets' | ||
import { FCL_SERVICE_METHODS } from '../helpers/constants' | ||
import { Service } from '../types' | ||
import ActionCard from './ActionCard' | ||
import { useDevice } from '../contexts/DeviceContext' | ||
import { DeviceType } from '../helpers/device' | ||
import { getBrowserInfo } from '../helpers/browsers' | ||
import { useRpc } from '../contexts/FclContext' | ||
|
||
export type ConnectCardProps = { | ||
onConnect: () => void | ||
wallet: Wallet | ||
serviceIdx: number | ||
} | ||
|
||
export function ConnectCard({ | ||
onConnect, | ||
wallet, | ||
serviceIdx, | ||
}: ConnectCardProps) { | ||
const info = useConnectCardInfo(wallet, wallet.services[serviceIdx]) | ||
if (!info) { | ||
return null | ||
} | ||
|
||
const { title, description, buttonText, icon } = info | ||
return ( | ||
<ActionCard | ||
icon={icon} | ||
title={title} | ||
description={description} | ||
button={{ | ||
text: buttonText, | ||
onClick: onConnect, | ||
}} | ||
></ActionCard> | ||
) | ||
} | ||
|
||
function useConnectCardInfo(wallet: Wallet, service: Service) { | ||
const { deviceInfo } = useDevice() | ||
const { rpcEnabled } = useRpc() | ||
|
||
let title: string, description: string, buttonText: string, icon: string | ||
switch (service.method) { | ||
case FCL_SERVICE_METHODS.WC: | ||
title = `${wallet.name} Mobile` | ||
description = `Confirm the connection in the mobile app` | ||
if (deviceInfo.type === DeviceType.MOBILE) { | ||
buttonText = `Open Wallet` | ||
} else { | ||
// Older FCL clients may skip scanning QR and use existing session | ||
buttonText = rpcEnabled ? `Scan QR Code` : `Connect` | ||
} | ||
icon = wallet.icon | ||
break | ||
case FCL_SERVICE_METHODS.EXT: | ||
title = `${wallet.name} Extension` | ||
description = `Confirm the connection in the browser extension` | ||
buttonText = `Connect` | ||
icon = getBrowserInfo(deviceInfo.browser).icon | ||
break | ||
case FCL_SERVICE_METHODS.HTTP: | ||
case FCL_SERVICE_METHODS.POP: | ||
case FCL_SERVICE_METHODS.IFRAME: | ||
case FCL_SERVICE_METHODS.TAB: | ||
title = `Connect to ${wallet.name}` | ||
description = `Confirm the connection in the web app` | ||
buttonText = `Connect` | ||
icon = getBrowserInfo(deviceInfo.browser).icon | ||
break | ||
default: | ||
title = `Connect to ${wallet.name}` | ||
description = `Confirm the connection in your wallet` | ||
buttonText = `Connect` | ||
} | ||
return { title, description, buttonText, icon } | ||
} |
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,48 @@ | ||
import { IconButton } from '@chakra-ui/react' | ||
import CopyIcon from './icons/CopyIcon' | ||
import { ComponentProps, useRef, useState } from 'react' | ||
import { CheckIcon } from '@chakra-ui/icons' | ||
|
||
type CopyButtonProps = { | ||
text: string | ||
} & Partial<ComponentProps<typeof IconButton>> | ||
|
||
export default function CopyButton({ text, ...props }: CopyButtonProps) { | ||
const size = '1.75rem' | ||
const checkSize = '1.15rem' | ||
|
||
const [showCheck, setShowCheck] = useState(false) | ||
const checkTimeoutRef = useRef<NodeJS.Timeout | null>(null) | ||
const icon = showCheck ? ( | ||
<CheckIcon boxSize={checkSize} /> | ||
) : ( | ||
<CopyIcon boxSize={size} /> | ||
) | ||
|
||
function onClick() { | ||
navigator.clipboard.writeText(text) | ||
setShowCheck(true) | ||
if (checkTimeoutRef.current) { | ||
clearTimeout(checkTimeoutRef.current) | ||
} | ||
checkTimeoutRef.current = setTimeout(() => { | ||
setShowCheck(false) | ||
}, 1000) | ||
} | ||
|
||
return ( | ||
<IconButton | ||
variant="ghost" | ||
color="foreground.60%" | ||
size="sm" | ||
borderRadius="full" | ||
aria-label="Copy" | ||
minW={0} | ||
boxSize={size} | ||
icon={icon} | ||
onClick={onClick} | ||
isRound | ||
{...props} | ||
></IconButton> | ||
) | ||
} |
Oops, something went wrong.