feat: report buttons

This commit is contained in:
TrèsAbhi committed 2024-10-14 10:27:42 -05:00
1 parent ec9a3cb2ce
commit ea70033b08
6 files changed
+23 -58

No files matched your search

+4 -45
View File
@@ -1,44 +1,11 @@
import { Box, type BoxProps } from '@radix-ui/themes';
import { useEffect } from 'react';
import type { Vector2Tuple } from 'three';
export type AdProps = BoxProps & {
id: string;
commonHeight: 250;
};
export enum MaxAdSize {
Size728x90,
Size970x90,
Size970x250,
Size300x250,
Size336x280,
Size320x50,
Size320x100,
Size320x480,
Size160x600,
Size300x600,
}
const MAX_AD_SIZES: Record<MaxAdSize, Vector2Tuple> = {
[MaxAdSize.Size728x90]: [728, 90],
[MaxAdSize.Size970x90]: [970, 90],
[MaxAdSize.Size970x250]: [970, 250],
[MaxAdSize.Size300x250]: [300, 250],
[MaxAdSize.Size336x280]: [336, 280],
[MaxAdSize.Size320x50]: [320, 50],
[MaxAdSize.Size320x100]: [320, 100],
[MaxAdSize.Size320x480]: [320, 480],
[MaxAdSize.Size160x600]: [160, 600],
[MaxAdSize.Size300x600]: [300, 600],
};
export function Ad({ id, commonHeight, ...props }: AdProps) {
// const [width, height] =
// maxAdSize === undefined
// ? [undefined, undefined]
// : MAX_AD_SIZES[maxAdSize].map((dimension) => `${dimension}px`);
export function Ad({ id, ...props }: AdProps) {
useEffect(() => {
(window as any).nitroAds.createAd(id, {
refreshTime: 30,
@@ -46,21 +13,13 @@ export function Ad({ id, commonHeight, ...props }: AdProps) {
renderVisibleOnly: true,
delayLoading: true,
report: {
enabled: false,
enabled: true,
icon: true,
wording: 'Report Ad',
position: 'top-right',
position: 'top-right-side',
},
});
}, [id]);
return (
<Box
id={id}
width="100%"
className="ad-container"
height={commonHeight ? `${commonHeight}px` : 'auto'}
{...props}
/>
);
return <Box id={id} className="ad-container" {...props} />;
}
@@ -0,0 +1,7 @@
import { Ad, type AdProps } from './Ad';
type AdResponsiveHorizontal = AdProps;
export function AdResponsiveHorizontal(props: AdResponsiveHorizontal) {
return <Ad height="250px" width="100%" {...props} />;
}
@@ -1,5 +1,5 @@
import { Flex, Table } from '@radix-ui/themes';
import { Ad } from './Ad';
import { AdResponsiveHorizontal } from './AdResponsiveHorizontal';
interface AdStickyTableRowProps {
id: string;
@@ -16,7 +16,7 @@ export function AdStickyTableRow({ id }: AdStickyTableRowProps) {
width="100%"
left="0"
>
<Ad commonHeight={250} id={id} />
<AdResponsiveHorizontal id={id} />
</Flex>
</Table.Row>
</Table.Body>
@@ -23,7 +23,7 @@ import {
SORT_UNITS,
} from '../../stores/tankopediaPersistent/constants';
import { $tankopediaSort } from '../../stores/tankopediaSort';
import { Ad } from '../Ad';
import { AdResponsiveHorizontal } from '../AdResponsiveHorizontal';
import { ExperimentIcon } from '../ExperimentIcon';
import { FilterControl } from './components/FilterControl';
import { NoResults } from './components/NoResults';
@@ -476,8 +476,7 @@ export const TankSearch = memo<TankSearchProps>(
hasAd &&
index !== tanks.length - 1 && (
<Flex gridColumn="1 / -1">
<Ad
commonHeight={250}
<AdResponsiveHorizontal
id={`tankopedia-search-${adId}`}
/>
</Flex>