Skip to content

Commit 7e5e3ae

Browse files
authored
Merge pull request #11249 from ethereum/sim-updates
Connect to Web3 sim updates
2 parents f16afc5 + e72629b commit 7e5e3ae

File tree

9 files changed

+277
-84
lines changed

9 files changed

+277
-84
lines changed

src/components/Simulator/PulseAnimation.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import React from "react"
22
import { Box } from "@chakra-ui/react"
33
import { motion } from "framer-motion"
4-
import { CIRCLE, FULL_BUTTON, NARROW_BUTTON } from "./constants"
4+
import {
5+
BASE_ANIMATION_DELAY_SEC,
6+
CIRCLE,
7+
FULL_BUTTON,
8+
NARROW_BUTTON,
9+
} from "./constants"
510
import type { PulseOption } from "./types"
611

712
const MotionBox = motion(Box)
@@ -14,8 +19,7 @@ export const PulseAnimation: React.FC<IProps> = ({ type = CIRCLE }) => {
1419
const scaleY = type === FULL_BUTTON ? 1.7 : type === NARROW_BUTTON ? 1.5 : 1.5
1520
const inset = type === NARROW_BUTTON ? -1 : 0
1621
const borderRadius = type === FULL_BUTTON ? "base" : "full"
17-
const BASE_DURATION = 2.5
18-
const delay = type === NARROW_BUTTON ? 0 : BASE_DURATION
22+
const delay = type === NARROW_BUTTON ? 0 : BASE_ANIMATION_DELAY_SEC
1923
return (
2024
<MotionBox
2125
position="absolute"
@@ -26,7 +30,7 @@ export const PulseAnimation: React.FC<IProps> = ({ type = CIRCLE }) => {
2630
initial={{ scale: 1 }}
2731
animate={{ scaleX, scaleY, opacity: [0, 1, 0] }}
2832
transition={{
29-
duration: 2.5,
33+
duration: BASE_ANIMATION_DELAY_SEC,
3034
repeat: Infinity,
3135
ease: "easeOut",
3236
delay,

src/components/Simulator/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ export const defaultTokenBalances: Array<TokenBalance> = [
4343
export const FALLBACK_ETH_PRICE = 1000
4444
export const USD_RECEIVE_AMOUNT = 50
4545
export const ETH_TRANSFER_FEE = 0.00042 // 21_000gas * 20gwei
46+
47+
export const BASE_ANIMATION_DELAY_SEC = 2.5
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import React, { useEffect, useState } from "react"
2+
import { Box, type FlexProps, Text, Icon, Flex } from "@chakra-ui/react"
3+
import { BsTriangle } from "react-icons/bs"
4+
import { PiMagnifyingGlass } from "react-icons/pi"
5+
import { TbWorldWww } from "react-icons/tb"
6+
import { IoEllipsisHorizontalSharp } from "react-icons/io5"
7+
import { motion } from "framer-motion"
8+
import { NotificationPopover } from "../../NotificationPopover"
9+
import { EXAMPLE_APP_URL } from "./constants"
10+
import { BASE_ANIMATION_DELAY_SEC } from "../../constants"
11+
12+
interface IProps extends FlexProps {
13+
progressStepper: () => void
14+
}
15+
export const Browser: React.FC<IProps> = ({ progressStepper, ...props }) => {
16+
const [typing, setTyping] = useState(false)
17+
useEffect(() => {
18+
const timeout = setTimeout(() => {
19+
setTyping(true)
20+
}, BASE_ANIMATION_DELAY_SEC * 1000)
21+
return () => clearTimeout(timeout)
22+
}, [])
23+
24+
const sentence = {
25+
hidden: { opacity: 1 },
26+
visible: {
27+
opacity: 1,
28+
transition: { staggerChildren: 0.12 },
29+
},
30+
}
31+
const letter = {
32+
hidden: { opacity: 0 },
33+
visible: { opacity: 1, transition: { duration: 0 } },
34+
}
35+
36+
return (
37+
<Flex direction="column" h="full" bg="body.light" {...props}>
38+
<Box bg="background.highlight" w="full" px={3} pt={9} pb={3}>
39+
<NotificationPopover
40+
title="Example walkthrough"
41+
content="Try logging into a real app with your wallet when finished here"
42+
>
43+
<Flex
44+
bg="background.base"
45+
borderRadius="base"
46+
px={3}
47+
py={2}
48+
align="center"
49+
color="disabled"
50+
cursor="default"
51+
>
52+
<Box
53+
borderInlineEnd="1px"
54+
borderColor="background.highlight"
55+
flex={1}
56+
>
57+
{typing ? (
58+
<Text
59+
as={motion.p}
60+
variants={sentence}
61+
initial="hidden"
62+
animate="visible"
63+
color="body.medium"
64+
>
65+
{EXAMPLE_APP_URL.split("").map((char, index) => (
66+
<motion.span key={char + "-" + index} variants={letter}>
67+
{char}
68+
</motion.span>
69+
))}
70+
</Text>
71+
) : (
72+
<Text>Search or enter website</Text>
73+
)}
74+
</Box>
75+
<Icon as={TbWorldWww} ms={3} />
76+
</Flex>
77+
</NotificationPopover>
78+
</Box>
79+
80+
<Flex flex={1} justify="center" pt={{ base: 20, md: 24 }}>
81+
<Icon as={TbWorldWww} fontSize="8xl" strokeWidth="1" color="disabled" />
82+
</Flex>
83+
84+
<Flex
85+
bg="background.highlight"
86+
w="full"
87+
px={3}
88+
pb={9}
89+
pt={4}
90+
justify="space-around"
91+
fontSize="xl"
92+
color="disabled"
93+
>
94+
<Icon as={BsTriangle} transform="rotate(-90deg)" />
95+
<Icon as={BsTriangle} transform="rotate(90deg)" />
96+
<Icon as={PiMagnifyingGlass} />
97+
<Icon as={IoEllipsisHorizontalSharp} />
98+
</Flex>
99+
</Flex>
100+
)
101+
}

src/components/Simulator/screens/ConnectWeb3/Slider.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
import { Box, Flex, Grid, Icon, Text } from "@chakra-ui/react"
1+
import { Box, Flex, Grid, Icon, Text, TextProps } from "@chakra-ui/react"
22
import React from "react"
33
import { motion } from "framer-motion"
44
import { EthGlyphIcon } from "../../icons"
55
import { PiCheckThin } from "react-icons/pi"
66

7-
interface IProps {
7+
interface IProps extends Pick<TextProps, "children"> {
88
isConnected: boolean
9+
displayUrl: string
910
}
10-
export const Slider: React.FC<IProps> = ({ isConnected }) => {
11+
export const Slider: React.FC<IProps> = ({
12+
isConnected,
13+
displayUrl,
14+
children,
15+
}) => {
1116
const ICON_SIZE = "4.5rem" as const
1217
return (
1318
<>
@@ -68,7 +73,7 @@ export const Slider: React.FC<IProps> = ({ isConnected }) => {
6873
</Flex>
6974
) : (
7075
<>
71-
<Text textAlign="center" fontWeight="bold" fontSize="lg">
76+
<Text textAlign="center" fontWeight="bold" fontSize="lg" mb={4}>
7277
Connect account?
7378
</Text>
7479
{/* URL Pill */}
@@ -96,14 +101,11 @@ export const Slider: React.FC<IProps> = ({ isConnected }) => {
96101
/>
97102
</Grid>
98103
<Text mb={0} me={0.5}>
99-
app.example.com
104+
{displayUrl}
100105
</Text>
101106
</Flex>
102107
{/* Information */}
103-
<Text>
104-
Connecting to the website will not share any personal
105-
information with the site owners.
106-
</Text>
108+
<Text>{children}</Text>
107109
</>
108110
)}
109111
</Flex>

src/components/Simulator/screens/ConnectWeb3/Web3App.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,49 @@ import {
88
} from "@chakra-ui/react"
99
import React from "react"
1010
import { GrMenu } from "react-icons/gr"
11+
import { FAKE_DEMO_ADDRESS } from "../../constants"
1112
import { EthGlyphIcon } from "../../icons"
1213
import { NotificationPopover } from "../../NotificationPopover"
1314

14-
interface IProps extends BoxProps {}
15-
export const Web3App: React.FC<IProps> = ({ children, ...boxProps }) => {
15+
interface IProps extends BoxProps {
16+
displayUrl: string
17+
appName?: string
18+
}
19+
export const Web3App: React.FC<IProps> = ({
20+
displayUrl,
21+
appName,
22+
children,
23+
...boxProps
24+
}) => {
1625
const bg = useColorModeValue("#e8e8e8", "#171717")
1726

1827
return (
1928
<Box h="full" w="full" bg="background.highlight" {...boxProps}>
2029
<Box p={1} bg={bg}>
2130
<Text textAlign="center" fontSize="xs" m={0}>
22-
app.example.com
31+
{displayUrl}
2332
</Text>
2433
</Box>
2534
<NotificationPopover
2635
title="Example walkthrough"
2736
content="Try out a real Ethereum application when finished here"
2837
>
29-
<Flex p={6} fontSize="4xl" justify="space-between">
38+
<Flex p={6} fontSize="4xl" gap={3} alignItems="center">
3039
<Icon as={EthGlyphIcon} />
40+
<Box flex={1} cursor="default">
41+
{appName && (
42+
<>
43+
<Text fontSize="md" fontWeight="bold">
44+
{appName}
45+
</Text>
46+
<Text fontSize="sm">{FAKE_DEMO_ADDRESS}</Text>
47+
</>
48+
)}
49+
</Box>
3150
<Icon as={GrMenu} sx={{ path: { stroke: "body.base" } }} />
3251
</Flex>
3352
</NotificationPopover>
34-
<>{children}</>
53+
{children}
3554
</Box>
3655
)
3756
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const EXAMPLE_APP_URL = "app.example.com"

0 commit comments

Comments
 (0)