mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: in-table perforamnce ads
This commit is contained in:
1 parent
30cb319c1e
commit
0412eb478e
3 files changed
+21
-7
No files matched your search
@@ -11,7 +11,10 @@ export function TankTable() {
|
|||||||
<StickyTableRoot
|
<StickyTableRoot
|
||||||
size={{ initial: '1', sm: '2' }}
|
size={{ initial: '1', sm: '2' }}
|
||||||
variant="surface"
|
variant="surface"
|
||||||
style={{ maxWidth: '100%', maxHeight: 'calc(100vh - 256px)' }}
|
style={{
|
||||||
|
maxWidth: '100%',
|
||||||
|
// maxHeight: 'calc(100vh - 256px)'
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Header />
|
<Header />
|
||||||
<Suspense fallback={<BodyLoader />}>
|
<Suspense fallback={<BodyLoader />}>
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ import { fetchAverageDefinitions, fetchTankDefinitions } from '@blitzkit/core';
|
|||||||
import { useStore } from '@nanostores/react';
|
import { useStore } from '@nanostores/react';
|
||||||
import { Table } from '@radix-ui/themes';
|
import { Table } from '@radix-ui/themes';
|
||||||
import { times } from 'lodash-es';
|
import { times } from 'lodash-es';
|
||||||
import { Suspense, useEffect, useMemo, useState } from 'react';
|
import { Fragment, Suspense, useEffect, useMemo, useState } from 'react';
|
||||||
import { filterTank } from '../../core/blitzkit/filterTank';
|
import { filterTank } from '../../core/blitzkit/filterTank';
|
||||||
import { $tankFilters } from '../../stores/tankFilters';
|
import { $tankFilters } from '../../stores/tankFilters';
|
||||||
import { TankPerformancePersistent } from '../../stores/tankPerformancePersistent';
|
import { TankPerformancePersistent } from '../../stores/tankPerformancePersistent';
|
||||||
import { TankPerformanceSort } from '../../stores/tankPerformanceSort';
|
import { TankPerformanceSort } from '../../stores/tankPerformanceSort';
|
||||||
|
import { AdStickyTableRow } from '../AdStickyTableRow';
|
||||||
import { RowLoader } from './RowLoader';
|
import { RowLoader } from './RowLoader';
|
||||||
import { TankRow } from './TankRow';
|
import { TankRow } from './TankRow';
|
||||||
import { Total } from './Total';
|
import { Total } from './Total';
|
||||||
@@ -129,19 +130,28 @@ export function Tanks() {
|
|||||||
<Table.Body>
|
<Table.Body>
|
||||||
<Total tanks={tanks} />
|
<Total tanks={tanks} />
|
||||||
|
|
||||||
{tanks.slice(0, loadedRows).map((averages) => {
|
{tanks.slice(0, loadedRows).map((averages, index) => {
|
||||||
const tank = tankDefinitions.tanks[averages.id];
|
const tank = tankDefinitions.tanks[averages.id];
|
||||||
|
const hasAd = index % 16 === 0;
|
||||||
|
const adId = Math.floor(index / 16);
|
||||||
|
|
||||||
if (tank === undefined) return null;
|
if (tank === undefined) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense key={tank.id} fallback={<RowLoader />}>
|
<Fragment key={tank.id}>
|
||||||
<TankRow tank={tank} />
|
{hasAd && (
|
||||||
</Suspense>
|
<AdStickyTableRow id={`performance-${adId}-${tank.id}`} />
|
||||||
|
)}
|
||||||
|
<Suspense fallback={<RowLoader />}>
|
||||||
|
<TankRow tank={tank} />
|
||||||
|
</Suspense>
|
||||||
|
</Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{times(Math.min(PREVIEW_COUNT, tanks.length - loadedRows), (index) => {
|
{times(Math.min(PREVIEW_COUNT, tanks.length - loadedRows), (index) => {
|
||||||
|
console.log(index);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RowLoader
|
<RowLoader
|
||||||
key={index}
|
key={index}
|
||||||
|
|||||||
@@ -465,6 +465,7 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
<TankCardWrapper>
|
<TankCardWrapper>
|
||||||
{tanks.map((tank, index) => {
|
{tanks.map((tank, index) => {
|
||||||
const hasAd = (index + 16) % 32 === 0;
|
const hasAd = (index + 16) % 32 === 0;
|
||||||
|
const adId = Math.floor(index / 32);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment key={tank.id}>
|
<Fragment key={tank.id}>
|
||||||
@@ -477,7 +478,7 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
<Flex gridColumn="1 / -1">
|
<Flex gridColumn="1 / -1">
|
||||||
<Ad
|
<Ad
|
||||||
commonHeight={250}
|
commonHeight={250}
|
||||||
id={`tankopedia-search-${Math.floor(index / 32)}`}
|
id={`tankopedia-search-${adId}`}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in new issue
Block a user