Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
7a0ef608
Commit
7a0ef608
authored
Nov 29, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom header for home page
parent
44ef777d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
62 deletions
+82
-62
_app.tsx
pages/_app.tsx
+10
-1
LatestTxs.tsx
ui/home/LatestTxs.tsx
+1
-1
Home.tsx
ui/pages/Home.tsx
+26
-12
Page.tsx
ui/shared/Page/Page.tsx
+14
-24
PageContent.tsx
ui/shared/Page/PageContent.tsx
+3
-3
ColorModeToggler.tsx
ui/snippets/header/ColorModeToggler.tsx
+5
-3
Header.tsx
ui/snippets/header/Header.tsx
+23
-18
No files found.
pages/_app.tsx
View file @
7a0ef608
...
@@ -4,16 +4,21 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
...
@@ -4,16 +4,21 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import
type
{
AppProps
}
from
'
next/app
'
;
import
type
{
AppProps
}
from
'
next/app
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
appConfig
from
'
configs/app/config
'
;
import
{
AppContextProvider
}
from
'
lib/appContext
'
;
import
{
AppContextProvider
}
from
'
lib/appContext
'
;
import
{
Chakra
}
from
'
lib/Chakra
'
;
import
{
Chakra
}
from
'
lib/Chakra
'
;
import
useConfigSentry
from
'
lib/hooks/useConfigSentry
'
;
import
useConfigSentry
from
'
lib/hooks/useConfigSentry
'
;
import
type
{
ErrorType
}
from
'
lib/hooks/useFetch
'
;
import
type
{
ErrorType
}
from
'
lib/hooks/useFetch
'
;
import
useScrollDirection
from
'
lib/hooks/useScrollDirection
'
;
import
{
SocketProvider
}
from
'
lib/socket/context
'
;
import
theme
from
'
theme
'
;
import
theme
from
'
theme
'
;
import
ScrollDirectionContext
from
'
ui/ScrollDirectionContext
'
;
import
AppError
from
'
ui/shared/AppError/AppError
'
;
import
AppError
from
'
ui/shared/AppError/AppError
'
;
import
ErrorBoundary
from
'
ui/shared/ErrorBoundary
'
;
import
ErrorBoundary
from
'
ui/shared/ErrorBoundary
'
;
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
useConfigSentry
();
useConfigSentry
();
const
directionContext
=
useScrollDirection
();
const
[
queryClient
]
=
useState
(()
=>
new
QueryClient
({
const
[
queryClient
]
=
useState
(()
=>
new
QueryClient
({
defaultOptions
:
{
defaultOptions
:
{
...
@@ -57,7 +62,11 @@ function MyApp({ Component, pageProps }: AppProps) {
...
@@ -57,7 +62,11 @@ function MyApp({ Component, pageProps }: AppProps) {
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
onError=
{
handleError
}
>
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
onError=
{
handleError
}
>
<
AppContextProvider
pageProps=
{
pageProps
}
>
<
AppContextProvider
pageProps=
{
pageProps
}
>
<
QueryClientProvider
client=
{
queryClient
}
>
<
QueryClientProvider
client=
{
queryClient
}
>
<
ScrollDirectionContext
.
Provider
value=
{
directionContext
}
>
<
SocketProvider
url=
{
`${ appConfig.api.socket }${ appConfig.api.basePath }/socket/v2`
}
>
<
Component
{
...
pageProps
}
/>
<
Component
{
...
pageProps
}
/>
</
SocketProvider
>
</
ScrollDirectionContext
.
Provider
>
<
ReactQueryDevtools
/>
<
ReactQueryDevtools
/>
</
QueryClientProvider
>
</
QueryClientProvider
>
</
AppContextProvider
>
</
AppContextProvider
>
...
...
ui/home/LatestTxs.tsx
View file @
7a0ef608
...
@@ -27,7 +27,7 @@ const LatestTransactions = () => {
...
@@ -27,7 +27,7 @@ const LatestTransactions = () => {
if
(
isLoading
)
{
if
(
isLoading
)
{
content
=
(
content
=
(
<>
<>
<
Skeleton
h=
"56px"
w=
"100%"
/>
<
Skeleton
h=
"56px"
w=
"100%"
borderBottomLeftRadius=
{
0
}
borderBottomRightRadius=
{
0
}
/>
{
Array
.
from
(
Array
(
txsCount
)).
map
((
item
,
index
)
=>
<
LatestTxsItemSkeleton
key=
{
index
}
/>)
}
{
Array
.
from
(
Array
(
txsCount
)).
map
((
item
,
index
)
=>
<
LatestTxsItemSkeleton
key=
{
index
}
/>)
}
</>
</>
);
);
...
...
ui/pages/Home.tsx
View file @
7a0ef608
...
@@ -6,28 +6,42 @@ import LatestBlocks from 'ui/home/LatestBlocks';
...
@@ -6,28 +6,42 @@ import LatestBlocks from 'ui/home/LatestBlocks';
import
LatestTxs
from
'
ui/home/LatestTxs
'
;
import
LatestTxs
from
'
ui/home/LatestTxs
'
;
import
Stats
from
'
ui/home/Stats
'
;
import
Stats
from
'
ui/home/Stats
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
ColorModeToggler
from
'
ui/snippets/header/ColorModeToggler
'
;
import
ProfileMenuDesktop
from
'
ui/snippets/profileMenu/ProfileMenuDesktop
'
;
import
SearchBar
from
'
ui/snippets/searchBar/SearchBar
'
;
import
SearchBar
from
'
ui/snippets/searchBar/SearchBar
'
;
const
Home
=
()
=>
{
const
Home
=
()
=>
{
return
(
return
(
<
Page
hasSearch=
{
false
}
>
<
Page
isHomePage
>
<
Box
<
Box
w=
"100%"
w=
"100%"
backgroundImage=
"radial-gradient(farthest-corner at 0 0, rgba(183, 148, 244, 0.8) 0%, rgba(0, 163, 196, 0.8) 100%)"
backgroundImage=
"radial-gradient(farthest-corner at 0 0, rgba(183, 148, 244, 0.8) 0%, rgba(0, 163, 196, 0.8) 100%)"
borderRadius=
"24px"
borderRadius=
"24px"
padding=
{
{
base
:
'
24px
40px
'
,
lg
:
'
48px
'
}
}
padding=
{
{
base
:
'
24px
'
,
lg
:
'
48px
'
}
}
minW=
{
{
base
:
'
unset
'
,
lg
:
'
900px
'
}
}
minW=
{
{
base
:
'
unset
'
,
lg
:
'
900px
'
}
}
>
>
<
Flex
mb=
{
{
base
:
6
,
lg
:
8
}
}
justifyContent=
"space-between"
>
<
Heading
<
Heading
as=
"h1"
as=
"h1"
size=
{
{
base
:
'
lg
'
,
ld
:
'
xl
'
}
}
size=
{
{
base
:
'
md
'
,
lg
:
'
xl
'
}
}
fontWeight=
{
{
base
:
600
,
lg
:
500
}
}
lineHeight=
{
{
base
:
'
32px
'
,
lg
:
'
50px
'
}
}
fontWeight=
{
500
}
color=
"white"
color=
"white"
mb=
{
{
base
:
6
,
lg
:
8
}
}
>
>
Welcome to Blockscout explorer
Welcome to Blockscout explorer
</
Heading
>
</
Heading
>
<
LightMode
><
SearchBar
isHomepage
/></
LightMode
>
<
Flex
alignItems=
"center"
display=
{
{
base
:
'
none
'
,
lg
:
'
flex
'
}
}
columnGap=
{
12
}
>
<
ColorModeToggler
trackBg=
"whiteAlpha.500"
/>
<
ProfileMenuDesktop
/>
</
Flex
>
</
Flex
>
<
LightMode
>
<
SearchBar
isHomepage
/>
</
LightMode
>
</
Box
>
</
Box
>
<
Stats
/>
<
Stats
/>
<
ChainIndicators
/>
<
ChainIndicators
/>
...
...
ui/shared/Page/Page.tsx
View file @
7a0ef608
...
@@ -4,12 +4,8 @@ import React from 'react';
...
@@ -4,12 +4,8 @@ import React from 'react';
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
appConfig
from
'
configs/app/config
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useScrollDirection
from
'
lib/hooks/useScrollDirection
'
;
import
{
SocketProvider
}
from
'
lib/socket/context
'
;
import
ScrollDirectionContext
from
'
ui/ScrollDirectionContext
'
;
import
AppError
from
'
ui/shared/AppError/AppError
'
;
import
AppError
from
'
ui/shared/AppError/AppError
'
;
import
ErrorBoundary
from
'
ui/shared/ErrorBoundary
'
;
import
ErrorBoundary
from
'
ui/shared/ErrorBoundary
'
;
import
PageContent
from
'
ui/shared/Page/PageContent
'
;
import
PageContent
from
'
ui/shared/Page/PageContent
'
;
...
@@ -20,14 +16,14 @@ interface Props {
...
@@ -20,14 +16,14 @@ interface Props {
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
wrapChildren
?:
boolean
;
wrapChildren
?:
boolean
;
hideMobileHeaderOnScrollDown
?:
boolean
;
hideMobileHeaderOnScrollDown
?:
boolean
;
hasSearch
?:
boolean
;
isHomePage
?:
boolean
;
}
}
const
Page
=
({
const
Page
=
({
children
,
children
,
wrapChildren
=
true
,
wrapChildren
=
true
,
hideMobileHeaderOnScrollDown
,
hideMobileHeaderOnScrollDown
,
hasSearch
=
tru
e
,
isHomePag
e
,
}:
Props
)
=>
{
}:
Props
)
=>
{
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
...
@@ -35,32 +31,26 @@ const Page = ({
...
@@ -35,32 +31,26 @@ const Page = ({
enabled
:
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
)),
enabled
:
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
)),
});
});
const
directionContext
=
useScrollDirection
();
const
renderErrorScreen
=
React
.
useCallback
(()
=>
{
const
renderErrorScreen
=
React
.
useCallback
(()
=>
{
return
wrapChildren
?
return
wrapChildren
?
<
PageContent
hasSearch=
{
hasSearch
}
><
AppError
statusCode=
{
500
}
mt=
"50px"
/></
PageContent
>
:
<
PageContent
isHomePage=
{
isHomePage
}
><
AppError
statusCode=
{
500
}
mt=
"50px"
/></
PageContent
>
:
<
AppError
statusCode=
{
500
}
/>;
<
AppError
statusCode=
{
500
}
/>;
},
[
wrapChildren
,
hasSearch
]);
},
[
isHomePage
,
wrapChildren
]);
const
renderedChildren
=
wrapChildren
?
(
const
renderedChildren
=
wrapChildren
?
(
<
PageContent
hasSearch=
{
hasSearch
}
>
{
children
}
</
PageContent
>
<
PageContent
isHomePage=
{
isHomePage
}
>
{
children
}
</
PageContent
>
)
:
children
;
)
:
children
;
return
(
return
(
<
SocketProvider
url=
{
`${ appConfig.api.socket }${ appConfig.api.basePath }/socket/v2`
}
>
<
ScrollDirectionContext
.
Provider
value=
{
directionContext
}
>
<
Flex
w=
"100%"
minH=
"100vh"
alignItems=
"stretch"
>
<
Flex
w=
"100%"
minH=
"100vh"
alignItems=
"stretch"
>
<
NavigationDesktop
/>
<
NavigationDesktop
/>
<
Flex
flexDir=
"column"
width=
"100%"
>
<
Flex
flexDir=
"column"
width=
"100%"
>
<
Header
hasSearch=
{
hasSearch
}
hideOnScrollDown=
{
hideMobileHeaderOnScrollDown
}
/>
<
Header
isHomePage=
{
isHomePage
}
hideOnScrollDown=
{
hideMobileHeaderOnScrollDown
}
/>
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
>
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
>
{
renderedChildren
}
{
renderedChildren
}
</
ErrorBoundary
>
</
ErrorBoundary
>
</
Flex
>
</
Flex
>
</
Flex
>
</
Flex
>
</
ScrollDirectionContext
.
Provider
>
</
SocketProvider
>
);
);
};
};
...
...
ui/shared/Page/PageContent.tsx
View file @
7a0ef608
...
@@ -3,17 +3,17 @@ import React from 'react';
...
@@ -3,17 +3,17 @@ import React from 'react';
interface
Props
{
interface
Props
{
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
hasSearch
?:
boolean
;
isHomePage
?:
boolean
;
}
}
const
PageContent
=
({
children
,
hasSearch
}:
Props
)
=>
{
const
PageContent
=
({
children
,
isHomePage
}:
Props
)
=>
{
return
(
return
(
<
Box
<
Box
as=
"main"
as=
"main"
w=
"100%"
w=
"100%"
paddingX=
{
{
base
:
4
,
lg
:
12
}
}
paddingX=
{
{
base
:
4
,
lg
:
12
}
}
paddingBottom=
{
10
}
paddingBottom=
{
10
}
paddingTop=
{
{
base
:
hasSearch
?
'
138px
'
:
'
88px
'
,
lg
:
0
}
}
paddingTop=
{
{
base
:
isHomePage
?
'
88px
'
:
'
138px
'
,
lg
:
isHomePage
?
9
:
0
}
}
>
>
{
children
}
{
children
}
</
Box
>
</
Box
>
...
...
ui/snippets/header/ColorModeToggler.tsx
View file @
7a0ef608
...
@@ -21,7 +21,9 @@ import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps';
...
@@ -21,7 +21,9 @@ import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps';
export
interface
ColorModeTogglerProps
export
interface
ColorModeTogglerProps
extends
Omit
<
UseCheckboxProps
,
'
isIndeterminate
'
>
,
extends
Omit
<
UseCheckboxProps
,
'
isIndeterminate
'
>
,
Omit
<
HTMLChakraProps
<
'
label
'
>
,
keyof
UseCheckboxProps
>
,
Omit
<
HTMLChakraProps
<
'
label
'
>
,
keyof
UseCheckboxProps
>
,
ThemingProps
<
'
Switch
'
>
{}
ThemingProps
<
'
Switch
'
>
{
trackBg
?:
string
;
}
const
ColorModeToggler
=
forwardRef
<
ColorModeTogglerProps
,
'
input
'
>
((
props
,
ref
)
=>
{
const
ColorModeToggler
=
forwardRef
<
ColorModeTogglerProps
,
'
input
'
>
((
props
,
ref
)
=>
{
const
ownProps
=
omitThemingProps
(
props
);
const
ownProps
=
omitThemingProps
(
props
);
...
@@ -39,7 +41,7 @@ const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((props, ref)
...
@@ -39,7 +41,7 @@ const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((props, ref)
const
transitionProps
=
getDefaultTransitionProps
();
const
transitionProps
=
getDefaultTransitionProps
();
const
trackStyles
:
SystemStyleObject
=
React
.
useMemo
(()
=>
({
const
trackStyles
:
SystemStyleObject
=
React
.
useMemo
(()
=>
({
bg
:
trackBg
,
bg
Color
:
props
.
trackBg
||
trackBg
,
width
:
'
72px
'
,
width
:
'
72px
'
,
height
:
'
32px
'
,
height
:
'
32px
'
,
borderRadius
:
'
full
'
,
borderRadius
:
'
full
'
,
...
@@ -50,7 +52,7 @@ const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((props, ref)
...
@@ -50,7 +52,7 @@ const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((props, ref)
cursor
:
'
pointer
'
,
cursor
:
'
pointer
'
,
...
transitionProps
,
...
transitionProps
,
transitionDuration
:
'
ultra-slow
'
,
transitionDuration
:
'
ultra-slow
'
,
}),
[
trackBg
,
transitionProps
]);
}),
[
props
.
trackBg
,
trackBg
,
transitionProps
]);
const
thumbStyles
:
SystemStyleObject
=
React
.
useMemo
(()
=>
({
const
thumbStyles
:
SystemStyleObject
=
React
.
useMemo
(()
=>
({
bg
:
thumbBg
,
bg
:
thumbBg
,
...
...
ui/snippets/header/Header.tsx
View file @
7a0ef608
...
@@ -11,11 +11,11 @@ import Burger from './Burger';
...
@@ -11,11 +11,11 @@ import Burger from './Burger';
import
ColorModeToggler
from
'
./ColorModeToggler
'
;
import
ColorModeToggler
from
'
./ColorModeToggler
'
;
type
Props
=
{
type
Props
=
{
hasSearch
:
boolean
;
isHomePage
?
:
boolean
;
hideOnScrollDown
?:
boolean
;
hideOnScrollDown
?:
boolean
;
}
}
const
Header
=
({
hideOnScrollDown
,
hasSearch
}:
Props
)
=>
{
const
Header
=
({
hideOnScrollDown
,
isHomePage
}:
Props
)
=>
{
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
return
(
return
(
...
@@ -43,8 +43,10 @@ const Header = ({ hideOnScrollDown, hasSearch }: Props) => {
...
@@ -43,8 +43,10 @@ const Header = ({ hideOnScrollDown, hasSearch }: Props) => {
<
NetworkLogo
/>
<
NetworkLogo
/>
<
ProfileMenuMobile
/>
<
ProfileMenuMobile
/>
</
Flex
>
</
Flex
>
{
hasSearch
&&
<
SearchBar
withShadow=
{
!
hideOnScrollDown
}
/>
}
{
!
isHomePage
&&
<
SearchBar
withShadow=
{
!
hideOnScrollDown
}
/>
}
</
Box
><
HStack
</
Box
>
{
!
isHomePage
&&
(
<
HStack
as=
"header"
as=
"header"
width=
"100%"
width=
"100%"
alignItems=
"center"
alignItems=
"center"
...
@@ -55,10 +57,13 @@ const Header = ({ hideOnScrollDown, hasSearch }: Props) => {
...
@@ -55,10 +57,13 @@ const Header = ({ hideOnScrollDown, hasSearch }: Props) => {
paddingTop=
{
9
}
paddingTop=
{
9
}
paddingBottom=
"52px"
paddingBottom=
"52px"
>
>
<
Box
width=
"100%"
>
{
hasSearch
&&
<
SearchBar
/>
}
</
Box
>
<
Box
width=
"100%"
>
<
SearchBar
/>
</
Box
>
<
ColorModeToggler
/>
<
ColorModeToggler
/>
<
ProfileMenuDesktop
/>
<
ProfileMenuDesktop
/>
</
HStack
>
</
HStack
>
)
}
</>
</>
)
}
)
}
</
ScrollDirectionContext
.
Consumer
>
</
ScrollDirectionContext
.
Consumer
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment