feat: icon buttons for page turner

This commit is contained in:
TrèsAbhi committed 2024-05-22 13:20:56 -05:00
1 parent fda4f76be3
commit 30a3e10bec
3 files changed
+10 -15

No files matched your search

-5
View File
@@ -20,7 +20,6 @@ import { debounce } from 'lodash';
import { useRef, useState } from 'react'; import { useRef, useState } from 'react';
import { Link } from '../components/Link'; import { Link } from '../components/Link';
import { NAVBAR_HEIGHT } from '../components/Navbar'; import { NAVBAR_HEIGHT } from '../components/Navbar';
import PageWrapper from '../components/PageWrapper';
import { UNLOCALIZED_REGION_NAMES_SHORT } from '../constants/regions'; import { UNLOCALIZED_REGION_NAMES_SHORT } from '../constants/regions';
import searchPlayersAcrossRegions, { import searchPlayersAcrossRegions, {
AccountListWithServer, AccountListWithServer,
@@ -346,10 +345,6 @@ export default function Page() {
</Flex> </Flex>
</Flex> </Flex>
<PageWrapper noFlex1>
{/* hello there! ignore my existence pretty please :&#41; */}
</PageWrapper>
<div style={{ flex: 1 }} /> <div style={{ flex: 1 }} />
</> </>
); );
@@ -3,7 +3,7 @@ import {
CaretRightIcon, CaretRightIcon,
SymbolIcon, SymbolIcon,
} from '@radix-ui/react-icons'; } from '@radix-ui/react-icons';
import { Button, Flex, TextField } from '@radix-ui/themes'; import { Flex, IconButton, TextField } from '@radix-ui/themes';
import { range } from 'lodash'; import { range } from 'lodash';
import { useEffect, useRef } from 'react'; import { useEffect, useRef } from 'react';
import { infiniteSpin } from './index.css'; import { infiniteSpin } from './index.css';
@@ -42,7 +42,7 @@ export function PageTurner({
return ( return (
<Flex justify="center" wrap="wrap" gap="2"> <Flex justify="center" wrap="wrap" gap="2">
<Flex gap="2"> <Flex gap="2">
<Button <IconButton
variant="soft" variant="soft"
onClick={() => onPageChange(Math.max(page - 1, 0), true)} onClick={() => onPageChange(Math.max(page - 1, 0), true)}
disabled={page === 0 || leftLoading} disabled={page === 0 || leftLoading}
@@ -52,7 +52,7 @@ export function PageTurner({
) : ( ) : (
<CaretLeftIcon /> <CaretLeftIcon />
)} )}
</Button> </IconButton>
<TextField.Root <TextField.Root
type="number" type="number"
@@ -75,7 +75,7 @@ export function PageTurner({
<TextField.Slot>Page</TextField.Slot> <TextField.Slot>Page</TextField.Slot>
<TextField.Slot>out of {pages}</TextField.Slot> <TextField.Slot>out of {pages}</TextField.Slot>
</TextField.Root> </TextField.Root>
<Button <IconButton
variant="soft" variant="soft"
onClick={() => { onClick={() => {
onPageChange(Math.min(page + 1, pages - 1), true); onPageChange(Math.min(page + 1, pages - 1), true);
@@ -87,7 +87,7 @@ export function PageTurner({
) : ( ) : (
<CaretRightIcon /> <CaretRightIcon />
)} )}
</Button> </IconButton>
</Flex> </Flex>
</Flex> </Flex>
); );
@@ -1,5 +1,5 @@
import { CaretLeftIcon, CaretRightIcon } from '@radix-ui/react-icons'; import { CaretLeftIcon, CaretRightIcon } from '@radix-ui/react-icons';
import { Button, Flex, TextField } from '@radix-ui/themes'; import { Flex, IconButton, TextField } from '@radix-ui/themes';
import { useEffect, useRef } from 'react'; import { useEffect, useRef } from 'react';
import { TankDefinition } from '../../../../core/blitzkit/tankDefinitions'; import { TankDefinition } from '../../../../core/blitzkit/tankDefinitions';
import mutateTankopediaPersistent, { import mutateTankopediaPersistent, {
@@ -21,7 +21,7 @@ export function PageTurner({ searchedList, tanksPerPage }: PageTurnerProps) {
return ( return (
<Flex align="center" justify="center" gap="2"> <Flex align="center" justify="center" gap="2">
<Button <IconButton
variant="soft" variant="soft"
disabled={page === 0} disabled={page === 0}
onClick={() => { onClick={() => {
@@ -31,7 +31,7 @@ export function PageTurner({ searchedList, tanksPerPage }: PageTurnerProps) {
}} }}
> >
<CaretLeftIcon /> <CaretLeftIcon />
</Button> </IconButton>
<TextField.Root <TextField.Root
defaultValue={1} defaultValue={1}
type="number" type="number"
@@ -61,7 +61,7 @@ export function PageTurner({ searchedList, tanksPerPage }: PageTurnerProps) {
out of {Math.floor(searchedList.length / tanksPerPage) + 1} out of {Math.floor(searchedList.length / tanksPerPage) + 1}
</TextField.Slot> </TextField.Slot>
</TextField.Root> </TextField.Root>
<Button <IconButton
variant="soft" variant="soft"
disabled={Math.floor(searchedList.length / tanksPerPage) === page} disabled={Math.floor(searchedList.length / tanksPerPage) === page}
onClick={() => { onClick={() => {
@@ -74,7 +74,7 @@ export function PageTurner({ searchedList, tanksPerPage }: PageTurnerProps) {
}} }}
> >
<CaretRightIcon /> <CaretRightIcon />
</Button> </IconButton>
</Flex> </Flex>
); );
} }