Skip to content

Commit

Permalink
Merge pull request #4524 from thematters/fix/billboard-size
Browse files Browse the repository at this point in the history
fix(billboard): fix responsive issue
  • Loading branch information
robertu7 authored Jun 6, 2024
2 parents 3d09a8b + f7ebac5 commit f4362c0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 44 deletions.
74 changes: 35 additions & 39 deletions src/components/Billboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
BillboardDialog,
BillboardExposureTracker,
Icon,
Spinner,
TextIcon,
} from '~/components'

Expand All @@ -34,7 +33,7 @@ export const Billboard = ({ tokenId, type }: BillboardProps) => {
cacheTime: 60_000,
})

if (!id || isError || !data || !data.contentURI) {
if (!id || isError || isLoading || !data || !data.contentURI) {
return null
}

Expand All @@ -43,43 +42,40 @@ export const Billboard = ({ tokenId, type }: BillboardProps) => {
{({ openDialog: openBillboardDialog }) => {
return (
<div className={styles.billboard}>
{isLoading && <Spinner />}
{!isLoading && (
<>
<a
href={data.redirectURI}
target="_blank"
onClick={() =>
analytics.trackEvent('click_billboard', {
id,
type,
target: data.redirectURI,
})
}
>
<img src={data.contentURI} alt="ad" />
</a>
<button
className={styles.button}
type="button"
aria-label={intl.formatMessage({
defaultMessage: "What's this?",
id: '4wOWfp',
description: 'src/components/Billboard/index.tsx',
})}
onClick={openBillboardDialog}
>
<TextIcon icon={<Icon icon={IconInfo} />} size={12}>
<FormattedMessage
defaultMessage="What's this?"
id="4wOWfp"
description="src/components/Billboard/index.tsx"
/>
</TextIcon>
</button>
<BillboardExposureTracker id={id} type={type} />
</>
)}
<a
href={data.redirectURI}
target="_blank"
onClick={() =>
analytics.trackEvent('click_billboard', {
id,
type,
target: data.redirectURI,
})
}
>
<img src={data.contentURI} alt="ad" />
</a>

<button
className={styles.button}
type="button"
aria-label={intl.formatMessage({
defaultMessage: "What's this?",
id: '4wOWfp',
description: 'src/components/Billboard/index.tsx',
})}
onClick={openBillboardDialog}
>
<TextIcon icon={<Icon icon={IconInfo} />} size={12}>
<FormattedMessage
defaultMessage="What's this?"
id="4wOWfp"
description="src/components/Billboard/index.tsx"
/>
</TextIcon>
</button>

<BillboardExposureTracker id={id} type={type} />
</div>
)
}}
Expand Down
24 changes: 19 additions & 5 deletions src/components/Billboard/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
.billboard {
display: block;
max-width: 21.4375rem;
max-width: 100%;

@media (--sm-up) {
max-width: 50%;
}

@media (--md-up) {
max-width: 100%;
}

& a {
@mixin flex-center-all;

line-height: 0;
position: relative;

&::after {
display: block;
padding-bottom: 56.06%;
content: '';
}

& img {
width: 100%;
max-height: 10.5rem;
@mixin object-fit-cover;

border-radius: 1.25rem;
}
}

& .button {
margin-top: var(--sp8);
color: var(--color-grey);
}
}

0 comments on commit f4362c0

Please sign in to comment.