mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: filters
This commit is contained in:
1 parent
d851a05f53
commit
f1c31c6d79
6 files changed
+38
-7
No files matched your search
@@ -6,7 +6,6 @@ import { BlitzKitTheme } from './BlitzKitTheme';
|
|||||||
|
|
||||||
type PageWrapperProps = FlexProps & {
|
type PageWrapperProps = FlexProps & {
|
||||||
color?: ComponentProps<typeof Theme>['accentColor'];
|
color?: ComponentProps<typeof Theme>['accentColor'];
|
||||||
size?: number | string;
|
|
||||||
noMaxWidth?: boolean;
|
noMaxWidth?: boolean;
|
||||||
containerProps?: ComponentProps<typeof Theme>;
|
containerProps?: ComponentProps<typeof Theme>;
|
||||||
noFlex1?: boolean;
|
noFlex1?: boolean;
|
||||||
@@ -17,7 +16,6 @@ type PageWrapperProps = FlexProps & {
|
|||||||
export function PageWrapper({
|
export function PageWrapper({
|
||||||
style,
|
style,
|
||||||
color,
|
color,
|
||||||
size = 800,
|
|
||||||
children,
|
children,
|
||||||
noMaxWidth = false,
|
noMaxWidth = false,
|
||||||
noFlex1 = false,
|
noFlex1 = false,
|
||||||
@@ -44,7 +42,6 @@ export function PageWrapper({
|
|||||||
p={padding}
|
p={padding}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
maxWidth: noMaxWidth ? undefined : size,
|
|
||||||
margin: 'auto',
|
margin: 'auto',
|
||||||
boxSizing: 'border-box',
|
boxSizing: 'border-box',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { ReloadIcon } from '@radix-ui/react-icons';
|
||||||
|
import { Button, Flex } from '@radix-ui/themes';
|
||||||
|
import { TierList } from '../../stores/tierList';
|
||||||
|
import { tierListRows } from './Table/constants';
|
||||||
|
|
||||||
|
export function TierListControls() {
|
||||||
|
const mutateTierList = TierList.useMutation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex justify="center">
|
||||||
|
<Button
|
||||||
|
color="red"
|
||||||
|
onClick={() => {
|
||||||
|
mutateTierList((draft) => {
|
||||||
|
draft.tanks = tierListRows.map(() => []);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ReloadIcon /> Reset
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { tierListRows } from './constants';
|
|||||||
|
|
||||||
export function TierListTable() {
|
export function TierListTable() {
|
||||||
return (
|
return (
|
||||||
<Table.Root variant="surface">
|
<Table.Root variant="surface" mb="6">
|
||||||
<Table.Body>
|
<Table.Body>
|
||||||
{tierListRows.map((_, index) => (
|
{tierListRows.map((_, index) => (
|
||||||
<TierListRow index={index} key={index} />
|
<TierListRow index={index} key={index} />
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { fetchTankDefinitions } from '@blitzkit/core';
|
import { fetchTankDefinitions } from '@blitzkit/core';
|
||||||
|
import { useStore } from '@nanostores/react';
|
||||||
|
import { filterTank } from '../../core/blitzkit/filterTank';
|
||||||
|
import { $tankFilters } from '../../stores/tankFilters';
|
||||||
import { TankCardWrapper } from '../TankSearch/components/TankCardWrapper';
|
import { TankCardWrapper } from '../TankSearch/components/TankCardWrapper';
|
||||||
import { TierListTile } from './Tile';
|
import { TierListTile } from './Tile';
|
||||||
|
|
||||||
@@ -6,9 +9,13 @@ const tankDefinitions = await fetchTankDefinitions();
|
|||||||
const tanks = Object.values(tankDefinitions.tanks);
|
const tanks = Object.values(tankDefinitions.tanks);
|
||||||
|
|
||||||
export function TierListTiles() {
|
export function TierListTiles() {
|
||||||
|
const filters = useStore($tankFilters);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TankCardWrapper>
|
<TankCardWrapper>
|
||||||
{tanks.map((tank) => (
|
{tanks
|
||||||
|
.filter((tank) => filterTank(filters, tank))
|
||||||
|
.map((tank) => (
|
||||||
<TierListTile key={tank.id} tank={tank} />
|
<TierListTile key={tank.id} tank={tank} />
|
||||||
))}
|
))}
|
||||||
</TankCardWrapper>
|
</TankCardWrapper>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function Page({ id, skeleton }: PageProps) {
|
|||||||
p="0"
|
p="0"
|
||||||
noMaxWidth
|
noMaxWidth
|
||||||
color="purple"
|
color="purple"
|
||||||
size={1600}
|
maxWidth="100rem"
|
||||||
gap="9"
|
gap="9"
|
||||||
pb="9"
|
pb="9"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { PageWrapper } from '../../../components/PageWrapper';
|
import { PageWrapper } from '../../../components/PageWrapper';
|
||||||
|
import { FilterControl } from '../../../components/TankSearch/components/FilterControl';
|
||||||
|
import { TierListControls } from '../../../components/TierList/Controls';
|
||||||
import { TierListTable } from '../../../components/TierList/Table';
|
import { TierListTable } from '../../../components/TierList/Table';
|
||||||
import { TierListTiles } from '../../../components/TierList/Tiles';
|
import { TierListTiles } from '../../../components/TierList/Tiles';
|
||||||
import { TankopediaPersistent } from '../../../stores/tankopediaPersistent';
|
import { TankopediaPersistent } from '../../../stores/tankopediaPersistent';
|
||||||
@@ -16,8 +18,10 @@ export function Page() {
|
|||||||
|
|
||||||
function Content() {
|
function Content() {
|
||||||
return (
|
return (
|
||||||
<PageWrapper color="orange">
|
<PageWrapper color="orange" maxWidth="100rem">
|
||||||
|
<TierListControls />
|
||||||
<TierListTable />
|
<TierListTable />
|
||||||
|
<FilterControl />
|
||||||
<TierListTiles />
|
<TierListTiles />
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user