From 1195f078c7b7defaec3e1bbedb51761a72f47610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:28:09 -0500 Subject: [PATCH] feat: banner --- src/app/components/Hero.tsx | 311 +----------------------------------- src/app/page.tsx | 3 + 2 files changed, 9 insertions(+), 305 deletions(-) diff --git a/src/app/components/Hero.tsx b/src/app/components/Hero.tsx index 328781568..b9cd45d11 100644 --- a/src/app/components/Hero.tsx +++ b/src/app/components/Hero.tsx @@ -1,82 +1,17 @@ -'use client'; - -import { - CaretRightIcon, - Cross2Icon, - MagnifyingGlassIcon, -} from '@radix-ui/react-icons'; -import { - Button, - Card, - Flex, - Heading, - IconButton, - Link, - Spinner, - Text, - TextField, -} from '@radix-ui/themes'; -import { go } from 'fuzzysort'; -import { debounce } from 'lodash'; -import { useRef, useState } from 'react'; -import { isMobile } from 'react-device-detect'; -import { NAVBAR_HEIGHT } from '../../components/Navbar'; -import { UNLOCALIZED_REGION_NAMES_SHORT } from '../../constants/regions'; -import searchPlayersAcrossRegions, { - AccountListWithServer, -} from '../../core/blitz/searchPlayersAcrossRegions'; -import { - TankDefinition, - tankDefinitions, - tankNames, -} from '../../core/blitzkit/tankDefinitions'; -import { TIER_ROMAN_NUMERALS } from '../../core/blitzkit/tankDefinitions/constants'; -import { useWideFormat } from '../../hooks/useWideFormat'; +import { Flex, Heading, Text } from '@radix-ui/themes'; +import { imgur } from '../../core/blitzkit/imgur'; import { theme } from '../../stitches.config'; -const DISCRIMINATOR_WIDTH = 32; - -// https://i.imgur.com/rUPie9G.jpeg - export function Hero() { - const wideFormat = useWideFormat(512); - const [showSearch, setShowSearch] = useState(false); - const [searching, setSearching] = useState(false); - const [searchResults, setSearchResults] = useState(); - const search = useRef(null); - - const performSearch = debounce(async () => { - if (!search.current) return; - - const sanitized = search.current.value.trim(); - const awaitedTankDefinitions = await tankDefinitions; - const awaitedTankNames = await tankNames; - const tanks = go(sanitized, awaitedTankNames, { - keys: ['combined'], - limit: 6, - }); - const players = await searchPlayersAcrossRegions(sanitized, 6); - - setSearchResults({ - tanks: tanks.map((tank) => awaitedTankDefinitions[tank.obj.id]), - players, - }); - setSearching(false); - }, 500); - return (
BlitzKit - + Everything World of Tanks Blitz - -
- { - if (!search.current) return; - - const sanitized = search.current.value.trim(); - - if (sanitized.length > 0) { - setShowSearch(true); - setSearching(true); - performSearch(); - } else { - setShowSearch(false); - } - }} - onFocus={() => { - if (!search.current || !isMobile) return; - - const sanitized = search.current.value.trim(); - setShowSearch(sanitized.length > 0); - - window.scrollTo({ - top: - search.current.getBoundingClientRect().top - - NAVBAR_HEIGHT - - 32, - behavior: 'smooth', - }); - }} - > - - - - - {showSearch && ( - - { - if (!search.current) return; - - search.current.value = ''; - setShowSearch(false); - }} - > - - - - )} - - - {showSearch && ( - - {searching && ( - - - - )} - - {!searching && searchResults && ( - <> - - - - - Tankopedia - - - - - - {searchResults.tanks.map((tank) => ( - - - - - - ))} - - {searchResults.tanks.length === 0 && ( - - No tanks found - - )} - - - - - Players - - - {searchResults.players.map((player) => ( - - - - - - ))} - - {searchResults.players.length === 0 && ( - - No players found - - )} - - - - - )} - - )} -
); diff --git a/src/app/page.tsx b/src/app/page.tsx index b4ca07548..9c047e61f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -4,10 +4,13 @@ import Link from 'next/link'; import PageWrapper from '../components/PageWrapper'; import { TOOLS } from '../constants/tools'; import { imgur } from '../core/blitzkit/imgur'; +import { Hero } from './components/Hero'; export default function Page() { return ( <> + +