Skip to content

Commit 640b895

Browse files
committed
display a placeholder while loading the ad
1 parent d18f1b7 commit 640b895

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/assets/App.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,15 +973,16 @@ Producthunt item
973973
border-radius: 4px;
974974
}
975975
.adCardPlaceholder {
976-
max-width: 300px;
976+
width: 300px;
977977
column-gap: 16px;
978978
display: flex;
979979
flex-direction: row;
980+
margin:0 auto;
980981
}
981982
.adCardPlaceholder .image {
982983
background: var(--placeholder-background-color);
983-
flex: 0 0 120px;
984-
height: 90px
984+
flex: 0 0 130px;
985+
height: 100px
985986
}
986987

987988
.floatingFilter {

src/features/ads/components/BannerAd.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@
2424
display: block;
2525
overflow: hidden;
2626
}
27-
#bannerads .carbon-wrap {
27+
#bannerads .wrap {
2828
display: flex;
2929
}
30-
#bannerads .carbon-img {
30+
#bannerads .img {
3131
display: block;
3232
margin: 0;
3333
line-height: 1;
3434
}
35-
#bannerads .carbon-img img {
35+
#bannerads .img img {
3636
display: block;
3737
}
38-
#bannerads .carbon-text {
38+
#bannerads .text {
3939
font-size: 13px;
4040
padding: 10px;
4141
margin-bottom: 16px;
4242
line-height: 1.5;
4343
text-align: left;
4444
}
45-
#bannerads .carbon-poweredby {
45+
#bannerads .poweredby {
4646
display: block;
4747
padding: 6px 8px;
4848
background: inherit;

src/features/ads/components/BannerAd.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import './BannerAd.css'
22
import { useGetAd } from '../api/getAd'
3+
import { AdPlaceholder } from 'src/components/placeholders'
34

45
export const BannerAd = () => {
5-
const { data: ad, isError } = useGetAd({
6+
const {
7+
data: ad,
8+
isLoading,
9+
isError,
10+
} = useGetAd({
611
config: {
712
cacheTime: 0,
813
staleTime: 0,
9-
}
14+
},
1015
})
1116

17+
if (isLoading) {
18+
return <AdPlaceholder />
19+
}
20+
1221
if (isError || !ad) {
1322
return null
1423
}

0 commit comments

Comments
 (0)