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
5fcde0f5
Commit
5fcde0f5
authored
Aug 05, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New homepage layout loading bug on mobile
Fixes #2137
parent
02556490
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
15 deletions
+45
-15
.env.base
configs/envs/.env.base
+1
-1
Home.tsx
ui/pages/Home.tsx
+2
-5
AdbutlerBanner.tsx
ui/shared/ad/AdbutlerBanner.tsx
+24
-5
CoinzillaBanner.tsx
ui/shared/ad/CoinzillaBanner.tsx
+18
-4
No files found.
configs/envs/.env.base
View file @
5fcde0f5
...
...
@@ -11,7 +11,7 @@ NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
# Instance ENVs
NEXT_PUBLIC_AD_ADBUTLER_CONFIG_DESKTOP={ "id": "728301", "width": "728", "height": "90" }
NEXT_PUBLIC_AD_ADBUTLER_CONFIG_MOBILE={ "id": "72830
1
", "width": "320", "height": "100" }
NEXT_PUBLIC_AD_ADBUTLER_CONFIG_MOBILE={ "id": "72830
2
", "width": "320", "height": "100" }
NEXT_PUBLIC_AD_BANNER_ADDITIONAL_PROVIDER=adbutler
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://admin-rs.services.blockscout.com
NEXT_PUBLIC_API_BASE_PATH=/
...
...
ui/pages/Home.tsx
View file @
5fcde0f5
...
...
@@ -2,7 +2,6 @@ import { Box, Flex, Heading } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
config
from
'
configs/app
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
ChainIndicators
from
'
ui/home/indicators/ChainIndicators
'
;
import
LatestBlocks
from
'
ui/home/LatestBlocks
'
;
import
LatestZkEvmL2Batches
from
'
ui/home/LatestZkEvmL2Batches
'
;
...
...
@@ -16,8 +15,6 @@ import WalletMenuDesktop from 'ui/snippets/walletMenu/WalletMenuDesktop';
const
rollupFeature
=
config
.
features
.
rollup
;
const
Home
=
()
=>
{
const
isMobile
=
useIsMobile
();
return
(
<
Box
as=
"main"
>
<
Flex
...
...
@@ -53,13 +50,13 @@ const Home = () => {
</
Flex
>
<
SearchBar
isHomepage
/>
</
Box
>
{
!
isMobile
&&
<
AdBanner
platform=
"mobile"
w=
"fit-content"
flexShrink=
{
0
}
borderRadius=
"md"
overflow=
"hidden"
/>
}
<
AdBanner
platform=
"mobile"
w=
"fit-content"
flexShrink=
{
0
}
borderRadius=
"md"
overflow=
"hidden"
display=
{
{
base
:
'
none
'
,
lg
:
'
block
'
}
}
/>
</
Flex
>
<
Flex
flexDir=
{
{
base
:
'
column
'
,
lg
:
'
row
'
}
}
columnGap=
{
2
}
rowGap=
{
1
}
mt=
{
3
}
_empty=
{
{
mt
:
0
}
}
>
<
Stats
/>
<
ChainIndicators
/>
</
Flex
>
{
isMobile
&&
<
AdBanner
mt=
{
6
}
mx=
"auto"
display=
"flex"
justifyContent=
"center"
/>
}
<
AdBanner
mt=
{
6
}
mx=
"auto"
display=
{
{
base
:
'
flex
'
,
lg
:
'
none
'
}
}
justifyContent=
"center"
/>
<
Flex
mt=
{
8
}
direction=
{
{
base
:
'
column
'
,
lg
:
'
row
'
}
}
columnGap=
{
12
}
rowGap=
{
6
}
>
{
rollupFeature
.
isEnabled
&&
rollupFeature
.
type
===
'
zkEvm
'
?
<
LatestZkEvmL2Batches
/>
:
<
LatestBlocks
/>
}
<
Box
flexGrow=
{
1
}
>
...
...
ui/shared/ad/AdbutlerBanner.tsx
View file @
5fcde0f5
...
...
@@ -14,14 +14,27 @@ const feature = config.features.adsBanner;
const
AdbutlerBanner
=
({
className
,
platform
}:
BannerProps
)
=>
{
const
router
=
useRouter
();
const
isMobileViewport
=
useIsMobile
();
const
isMobile
=
platform
===
'
mobile
'
||
isMobileViewport
;
// On the home page there are two ad banners
// - one in the stats section with prop "platform === mobile", should be hidden on mobile devices
// - another - a regular ad banner, should be hidden on desktop devices
// The Adbutler provider doesn't work properly with 2 banners with the same id on the page
// So we use this flag to skip ad initialization for the first home page banner on mobile devices
// For all other pages this is not the case
const
isHidden
=
(
isMobileViewport
&&
platform
===
'
mobile
'
);
React
.
useEffect
(()
=>
{
if
(
!
(
'
adButler
'
in
feature
))
{
return
;
}
if
(
isHidden
)
{
return
;
}
if
(
isBrowser
()
&&
window
.
AdButler
)
{
const
abkw
=
window
.
abkw
||
''
;
if
(
!
window
.
AdButler
.
ads
)
{
...
...
@@ -47,7 +60,7 @@ const AdbutlerBanner = ({ className, platform }: BannerProps) => {
);
},
opt
:
{
place
:
plc
++
,
keywords
:
abkw
,
domain
:
'
servedbyadbutler.com
'
,
click
:
'
CLICK_MACRO_PLACEHOLDER
'
}
});
}
},
[
router
,
isMobile
]);
},
[
router
,
isMobile
,
isHidden
]);
if
(
!
(
'
adButler
'
in
feature
))
{
return
null
;
...
...
@@ -73,11 +86,17 @@ const AdbutlerBanner = ({ className, platform }: BannerProps) => {
}
})()
??
{
width
:
'
0
'
,
height
:
'
0
'
};
const
getElementId
=
(
id
:
string
)
=>
id
+
(
platform
?
`_
${
platform
}
`
:
''
);
return
(
<
Flex
className=
{
className
}
id=
"adBanner"
h=
{
height
}
w=
{
width
}
>
<
Flex
className=
{
className
}
id=
{
getElementId
(
'
adBanner
'
)
}
h=
{
height
}
w=
{
width
}
>
{
!
isHidden
&&
(
<>
<
Script
strategy=
"lazyOnload"
id=
"ad-butler-1"
>
{
connectAdbutler
}
</
Script
>
<
Script
strategy=
"lazyOnload"
id=
"ad-butler-2"
>
{
placeAd
(
platform
)
}
</
Script
>
<
div
id=
"ad-banner"
></
div
>
</>
)
}
</
Flex
>
);
};
...
...
ui/shared/ad/CoinzillaBanner.tsx
View file @
5fcde0f5
...
...
@@ -4,10 +4,20 @@ import React from 'react';
import
type
{
BannerProps
}
from
'
./types
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
const
CoinzillaBanner
=
({
className
,
platform
}:
BannerProps
)
=>
{
const
isInBrowser
=
isBrowser
();
const
isMobileViewport
=
useIsMobile
();
// On the home page there are two ad banners
// - one in the stats section with prop "platform === mobile", should be hidden on mobile devices
// - another - a regular ad banner, should be hidden on desktop devices
// The Coinzilla provider doesn't work properly with 2 banners with the same id on the page
// So we use this flag to skip ad initialization for the first home page banner on mobile devices
// For all other pages this is not the case
const
isHidden
=
(
isMobileViewport
&&
platform
===
'
mobile
'
);
const
{
width
,
height
}
=
(()
=>
{
switch
(
platform
)
{
...
...
@@ -22,7 +32,7 @@ const CoinzillaBanner = ({ className, platform }: BannerProps) => {
})();
React
.
useEffect
(()
=>
{
if
(
isInBrowser
)
{
if
(
isInBrowser
&&
!
isHidden
)
{
window
.
coinzilla_display
=
window
.
coinzilla_display
||
[];
const
cDisplayPreferences
=
{
zone
:
'
26660bf627543e46851
'
,
...
...
@@ -31,7 +41,7 @@ const CoinzillaBanner = ({ className, platform }: BannerProps) => {
};
window
.
coinzilla_display
.
push
(
cDisplayPreferences
);
}
},
[
height
,
isInBrowser
,
width
]);
},
[
height
,
isInBrowser
,
isHidden
,
width
]);
return
(
<
Flex
...
...
@@ -40,8 +50,12 @@ const CoinzillaBanner = ({ className, platform }: BannerProps) => {
h=
{
height
?
`${ height }px`
:
{
base
:
'
100px
'
,
lg
:
'
90px
'
}
}
w=
{
width
?
`${ width }px`
:
undefined
}
>
{
!
isHidden
&&
(
<>
<
Script
strategy=
"lazyOnload"
src=
"https://coinzillatag.com/lib/display.js"
/>
<
div
className=
"coinzilla"
data
-
zone=
"C-26660bf627543e46851"
></
div
>
</>
)
}
</
Flex
>
);
};
...
...
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