feat: search page

This commit is contained in:
TrèsAbhi committed 2024-09-21 12:16:51 -05:00
1 parent 187230439b
commit 408b561b75
8 files changed
+37 -15

No files matched your search

+2
View File
@@ -23,6 +23,8 @@ type AdProps = BoxProps & {
}; };
export function Ad({ type, style, ...props }: AdProps) { export function Ad({ type, style, ...props }: AdProps) {
return null;
const id = useRef(uniqueId()); const id = useRef(uniqueId());
const dimensions = AD_DIMENSIONS[type]; const dimensions = AD_DIMENSIONS[type];
@@ -2,6 +2,8 @@ import { Flex, type FlexProps } from '@radix-ui/themes';
import { Ad, AdType } from './Ad'; import { Ad, AdType } from './Ad';
export function AdMidSectionResponsive(props: FlexProps) { export function AdMidSectionResponsive(props: FlexProps) {
return null;
return ( return (
<Flex justify="center" py="4" gap="4" {...props}> <Flex justify="center" py="4" gap="4" {...props}>
<Ad <Ad
@@ -1,11 +1,11 @@
import { Theme } from '@radix-ui/themes'; import { Theme, type ThemeProps } from '@radix-ui/themes';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
interface BlitzKitThemeProps { interface BlitzKitThemeProps extends ThemeProps {
children: ReactNode; children: ReactNode;
} }
export function BlitzKitTheme({ children }: BlitzKitThemeProps) { export function BlitzKitTheme({ children, ...props }: BlitzKitThemeProps) {
return ( return (
<Theme <Theme
style={{ minHeight: 'unset' }} style={{ minHeight: 'unset' }}
@@ -15,6 +15,7 @@ export function BlitzKitTheme({ children }: BlitzKitThemeProps) {
accentColor="amber" accentColor="amber"
suppressHydrationWarning suppressHydrationWarning
suppressContentEditableWarning suppressContentEditableWarning
{...props}
> >
{children} {children}
</Theme> </Theme>
@@ -1,6 +1,7 @@
import { Flex, type FlexProps, Theme } from '@radix-ui/themes'; import { Flex, type FlexProps, Theme } from '@radix-ui/themes';
import type { ComponentProps } from 'react'; import type { ComponentProps } from 'react';
import type { RadixSize } from '../stores/embedState'; import type { RadixSize } from '../stores/embedState';
import { BlitzKitTheme } from './BlitzKitTheme';
type PageWrapperProps = FlexProps & { type PageWrapperProps = FlexProps & {
color?: ComponentProps<typeof Theme>['accentColor']; color?: ComponentProps<typeof Theme>['accentColor'];
@@ -23,7 +24,7 @@ export function PageWrapper({
...props ...props
}: PageWrapperProps) { }: PageWrapperProps) {
return ( return (
<Theme <BlitzKitTheme
accentColor={color} accentColor={color}
style={{ style={{
flex: noFlex1 ? undefined : 1, flex: noFlex1 ? undefined : 1,
@@ -49,6 +50,6 @@ export function PageWrapper({
> >
{children} {children}
</Flex> </Flex>
</Theme> </BlitzKitTheme>
); );
} }
@@ -19,7 +19,6 @@ import { Fragment, memo, useEffect, useMemo, useState } from 'react';
import { filterTank } from '../../core/blitzkit/filterTank'; import { filterTank } from '../../core/blitzkit/filterTank';
import { resolveReload } from '../../core/blitzkit/resolveReload'; import { resolveReload } from '../../core/blitzkit/resolveReload';
import { useAdExempt } from '../../hooks/useAdExempt'; import { useAdExempt } from '../../hooks/useAdExempt';
import { useAwait } from '../../hooks/useAwait';
import { $tankFilters } from '../../stores/tankFilters'; import { $tankFilters } from '../../stores/tankFilters';
import { import {
SORT_NAMES, SORT_NAMES,
@@ -45,15 +44,20 @@ type TankSearchProps = Omit<FlexProps, 'onSelect'> & {
const PREVIEW_COUNT = 25; const PREVIEW_COUNT = 25;
const DEFAULT_LOADED_CARDS = 75; const DEFAULT_LOADED_CARDS = 75;
const awaitedGameDefinitions = await gameDefinitions;
const awaitedModelDefinitions = await modelDefinitions;
const awaitedTankDefinitions = await tankDefinitions;
const awaitedTanksDefinitionsArray = await tankDefinitionsArray;
const awaitedTankNames = await tankNames;
export const TankSearch = memo<TankSearchProps>( export const TankSearch = memo<TankSearchProps>(
({ compact, onSelect, onSelectAll, ...props }) => { ({ compact, onSelect, onSelectAll, ...props }) => {
const exempt = useAdExempt(); const exempt = useAdExempt();
const awaitedGameDefinitions = useAwait(gameDefinitions); // const awaitedGameDefinitions = useAwait(gameDefinitions);
console.log(awaitedGameDefinitions); // const awaitedModelDefinitions = useAwait(modelDefinitions);
const awaitedModelDefinitions = useAwait(modelDefinitions); // const awaitedTankDefinitions = useAwait(tankDefinitions);
const awaitedTankDefinitions = useAwait(tankDefinitions); // const awaitedTanksDefinitionsArray = useAwait(tankDefinitionsArray);
const awaitedTanksDefinitionsArray = useAwait(tankDefinitionsArray); // const awaitedTankNames = useAwait(tankNames);
const awaitedTankNames = useAwait(tankNames);
const tankFilters = useStore($tankFilters); const tankFilters = useStore($tankFilters);
const tankopediaSort = useStore($tankopediaSort); const tankopediaSort = useStore($tankopediaSort);
@@ -405,7 +409,8 @@ export const TankSearch = memo<TankSearchProps>(
<Flex mt="2" gap="1" align="center" justify="center" direction="column"> <Flex mt="2" gap="1" align="center" justify="center" direction="column">
<Flex gap="2"> <Flex gap="2">
<Text color="gray"> <Text color="gray">
{tanksFiltered.length} tank{tanksFiltered.length === 1 ? '' : 's'} {tanksFiltered.length} tank
{tanksFiltered.length === 1 ? '' : 's'}
</Text> </Text>
{onSelectAll && ( {onSelectAll && (
@@ -41,7 +41,7 @@ const tool = TOOLS.find((tool) => tool.id === toolId);
style={{ style={{
backgroundImage: `url(${imgur(tool!.image, { backgroundImage: `url(${imgur(tool!.image, {
format: 'jpeg', format: 'jpeg',
size: ImgurSize.HugeThumbnail, size: ImgurSize.SmallThumbnail,
})})`, })})`,
backgroundSize: 'cover', backgroundSize: 'cover',
}} }}
@@ -1,7 +1,8 @@
--- ---
import ToolLayout from '../../../layouts/ToolLayout.astro'; import ToolLayout from '../../../layouts/ToolLayout.astro';
import { Page } from './index';
--- ---
<ToolLayout> <ToolLayout>
<!-- <TankSearch client:only="react" /> --> <Page client:load />
</ToolLayout> </ToolLayout>
@@ -0,0 +1,10 @@
import { PageWrapper } from '../../../components/PageWrapper';
import { TankSearch } from '../../../components/TankSearch';
export function Page() {
return (
<PageWrapper color="purple" size={1028}>
<TankSearch />
</PageWrapper>
);
}