-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLayout.tsx
344 lines (329 loc) · 11 KB
/
Layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
import {observer} from 'mobx-react';
import dynamic from 'next/dynamic';
import Image from 'next/image';
import Link from 'next/link';
import {useRouter} from 'next/router';
import {useEffect, useState} from 'react';
import {useUserThemePreference} from '@/core/hooks/useUserThemePreference';
import {Bar} from '@/core/ui/Bar';
import {Icon} from '@/core/ui/Icon';
import {Box, styled} from '@/core/ui/system';
import {DesktopOnly, MobileOnly} from './PageLayout';
// The elements connected to wallet functionality need to be imported dynamically
// with ssr option set to false
//
// This is to avoid hydration errors (naturally the wallet providers are not available on the server
// so their server version would not match the client version)
const ConnectButtons = dynamic(() => import('./ConnectButtons').then((m) => m.ConnectButtons), {
ssr: false,
});
type AppMenuProps = {
isMenuOpen: boolean;
setIsMenuOpen: React.Dispatch<React.SetStateAction<boolean>>;
};
const NavLink = styled('a', {name: 'NavLink'})<{pathname?: string}>(({theme, pathname, href}) => ({
color: theme.palette.text.contrast,
cursor: 'pointer',
...theme.typography.p1,
...(pathname === href && {
color: theme.palette.text.primary,
}),
'&:hover': {
color: theme.palette.text.contrastHover,
},
}));
const Logo = styled(Image, {name: 'Logo'})(({theme}) => ({
filter: theme.palette.mode === 'light' ? 'invert(1)' : 'invert(0)',
}));
export const AppMenu = observer(() => {
const router = useRouter();
const {pathname} = router;
const {changeUserThemePreference} = useUserThemePreference();
const [isMenuOpen, setIsMenuOpen] = useState(false);
const logoStyle = {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
gap: '16px',
};
const handleMenuClick = () => {
setIsMenuOpen(!isMenuOpen);
};
useEffect(() => {
changeUserThemePreference('Telos Dark');
}, [changeUserThemePreference]);
return (
<>
<DesktopOnly>
<div
style={{
position: 'fixed',
top: 0,
left: 0,
bottom: 0,
width: '300px',
background: 'linear-gradient(0.4turn, #071033, #6039A4)',
}}
>
<div style={{zIndex: 1}}>
<div>
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '20px',
marginBottom: '50px',
}}
>
<Link href='/bridge' passHref legacyBehavior>
<NavLink
pathname={pathname}
style={logoStyle}
>
<Logo
src={'/static/telos-logo.png'}
width={95 * 1.5}
height={112 * 1.5}
alt='Telos Blockchain Logo'
priority={true}
/>
</NavLink>
</Link>
</div>
<div style={{display: 'flex', justifyContent: 'left', marginLeft: '30px'}}>
<NavLink
sx={{'margin-left': {xs: 'auto', md: 'unset'}, display: 'flex'}}
href='https://stakely.io/en/faucet/telos-evm-tlos'
target='_blank'
rel='noreferrer'
>
<Image
src='/static/icons/arrowup.svg'
alt='placeholder'
width={22}
height={22}
style={{filter: 'invert(100%)', marginRight: '10px'}}
/>
Faucet
</NavLink>
</div>
<div
style={{
display: 'flex',
justifyContent: 'left',
marginLeft: '30px',
marginTop: '20px',
}}
>
<NavLink
sx={{'margin-right': {xs: 'auto', md: 'unset'}, display: 'flex'}}
href='https://dapp.p.network/#/swap?asset=tlos&from=eth&to=telos'
target='_blank'
rel='noreferrer'
>
<Image
src='/static/icons/arrowup.svg'
alt='placeholder'
width={22}
height={22}
style={{filter: 'invert(100%)', marginRight: '10px'}}
/>
pToken Bridge (Deprecated)
</NavLink>
</div>
<div style={{position: 'absolute', bottom: '24px', left: '24px', width: '100%'}}>
<div
style={{
zIndex: 10,
display: 'flex',
alignItems: 'center',
gap: 12,
}}
>
<a href='https://layerzero.network' target='_blank' rel='noreferrer'>
<Logo src={'/static/layerzero.svg'} height={24} width={88} alt='logo' />
</a>
</div>
</div>
</div>
</div>
</div>
</DesktopOnly>
<MobileOnly>
{isMenuOpen ? (
<>
<div
style={{
position: 'fixed',
top: 0,
left: 0,
bottom: 0,
width: '100%',
background: 'rgba(0, 0, 0, 0.75)',
zIndex: 10,
}}
></div>
<div
style={{
position: 'fixed',
top: 0,
left: 0,
bottom: 0,
width: '300px',
background: 'linear-gradient(0.4turn, #071033, #6039A4)',
zIndex: 100,
}}
>
<div>
<div style={{display: 'flex', justifyContent: 'space-between'}}>
<div></div>
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '20px',
marginBottom: '50px',
}}
>
<Link href='/bridge' passHref legacyBehavior>
<NavLink
pathname={pathname}
style={logoStyle}
>
<Logo
src={'/static/telos-logo.png'}
width={95 * 1.5}
height={112 * 1.5}
alt='Telos Blockchain Logo'
priority={true}
/>
</NavLink>
</Link>
</div>
<div
style={{
display: 'flex',
justifyContent: 'right',
marginTop: '20px',
marginBottom: '50px',
}}
>
<div onClick={handleMenuClick} style={{cursor: 'pointer', marginRight: '24px'}}>
<Image
src='/static/icons/menu.svg'
alt='placeholder'
width={24}
height={24}
style={{filter: 'invert(100%)'}}
/>
</div>
</div>
</div>
<div style={{marginLeft: '30px'}}>
<NavLink
sx={{'margin-left': {xs: 'auto', md: 'unset'}, display: 'flex'}}
href='https://stakely.io/en/faucet/telos-evm-tlos'
target='_blank'
rel='noreferrer'
>
<Icon type='link' size={28} style={{marginRight: '10px'}} />
Faucet
</NavLink>
</div>
<div
style={{
marginLeft: '30px',
marginTop: '20px',
}}
>
<NavLink
sx={{'margin-right': {xs: 'auto', md: 'unset'}, display: 'flex'}}
href='https://dapp.p.network/#/swap?asset=tlos&from=eth&to=telos'
target='_blank'
rel='noreferrer'
>
<Icon type='link' size={28} style={{marginRight: '10px'}} />
pToken Bridge (Deprecated)
</NavLink>
</div>
<div style={{position: 'absolute', bottom: '24px', left: '24px', width: '100%'}}>
<div
style={{
zIndex: 10,
display: 'flex',
alignItems: 'center',
gap: 16,
}}
>
<Bar.Section>
<ConnectButtons />
</Bar.Section>
<a href='https://layerzero.network' target='_blank' rel='noreferrer'>
<Logo src={'/static/layerzero.svg'} height={24} width={88} alt='logo' />
</a>
</div>
</div>
</div>
</div>
</>
) : (
<>
<div style={{height: '40px'}}></div>
<div
onClick={handleMenuClick}
style={{cursor: 'pointer', flex: 1, position: 'absolute', top: 0, left: '24px'}}
>
<Image src='/static/icons/menu.svg' alt='placeholder' width={24} height={24} />
</div>
</>
)}
</MobileOnly>
</>
);
});
export const AppHeader = observer(() => {
const {changeUserThemePreference} = useUserThemePreference();
useEffect(() => {
changeUserThemePreference('Telos Dark');
}, [changeUserThemePreference]);
return (
<>
<Bar style={{zIndex: 1}}>
<Bar.Section></Bar.Section>
<Bar.Section>
<DesktopOnly>
<ConnectButtons />
</DesktopOnly>
</Bar.Section>
</Bar>
</>
);
});
export const AppFooter = () => {
return (
<Bar style={{display: 'flex', justifyContent: 'space-between'}}>
<Bar.Section style={{zIndex: 10}}>
</Bar.Section>
<Bar.Section sx={{typography: 'p3'}}>
<Box
component='a'
href='https://telos.net'
sx={{typography: 'link', display: 'flex', alignItems: 'center', gap: 1}}
target='_blank'
>
<Icon type='globe' size={16} />
telos.net
</Box>
<Box
component='a'
href='https://docs.telos.net/'
sx={{typography: 'link', display: 'flex', alignItems: 'center', gap: 1}}
target='_blank'
>
<Icon type='file' size={16} />
Telos Docs
</Box>
</Bar.Section>
</Bar>
);
};