mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: sticky
This commit is contained in:
1 parent
a57734cdee
commit
c8e207b6a2
2 files changed
+18
-4
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { Flex, Grid, Heading, Separator } from '@radix-ui/themes';
|
import { Flex, Grid, Heading, Separator } from '@radix-ui/themes';
|
||||||
import { useEffect, useRef } from 'react';
|
import { memo, useEffect, useRef } from 'react';
|
||||||
import {
|
import {
|
||||||
TankDefinition,
|
TankDefinition,
|
||||||
Tier,
|
Tier,
|
||||||
@@ -14,14 +14,17 @@ interface TierCardProps {
|
|||||||
tanks: TankDefinition[];
|
tanks: TankDefinition[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TierCard({ tier, tanks }: TierCardProps) {
|
export const TierCard = memo(
|
||||||
|
({ tier, tanks }: TierCardProps) => {
|
||||||
const container = useRef<HTMLDivElement>(null);
|
const container = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribe = useTankopediaFilters.subscribe((filters) => {
|
const unsubscribe = useTankopediaFilters.subscribe((filters) => {
|
||||||
if (!container.current) return;
|
if (!container.current) return;
|
||||||
|
|
||||||
const visible = tanks.some((tank) => tankopediaFilterTank(filters, tank));
|
const visible = tanks.some((tank) =>
|
||||||
|
tankopediaFilterTank(filters, tank),
|
||||||
|
);
|
||||||
container.current.style.display = visible ? 'flex' : 'none';
|
container.current.style.display = visible ? 'flex' : 'none';
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,4 +55,6 @@ export function TierCard({ tier, tanks }: TierCardProps) {
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
(prev, next) => prev.tier === next.tier,
|
||||||
|
);
|
||||||
@@ -6,6 +6,7 @@ import { times } from 'lodash';
|
|||||||
import { use } from 'react';
|
import { use } from 'react';
|
||||||
import { classIcons } from '../../../components/ClassIcon';
|
import { classIcons } from '../../../components/ClassIcon';
|
||||||
import { ExperimentIcon } from '../../../components/ExperimentIcon';
|
import { ExperimentIcon } from '../../../components/ExperimentIcon';
|
||||||
|
import { NAVBAR_HEIGHT } from '../../../components/Navbar';
|
||||||
import PageWrapper from '../../../components/PageWrapper';
|
import PageWrapper from '../../../components/PageWrapper';
|
||||||
import { ResearchedIcon } from '../../../components/ResearchedIcon';
|
import { ResearchedIcon } from '../../../components/ResearchedIcon';
|
||||||
import { ScienceIcon } from '../../../components/ScienceIcon';
|
import { ScienceIcon } from '../../../components/ScienceIcon';
|
||||||
@@ -44,6 +45,7 @@ export default function Page() {
|
|||||||
initial: 'row',
|
initial: 'row',
|
||||||
sm: 'column',
|
sm: 'column',
|
||||||
}}
|
}}
|
||||||
|
height="fit-content"
|
||||||
gap="2"
|
gap="2"
|
||||||
align={{
|
align={{
|
||||||
initial: 'start',
|
initial: 'start',
|
||||||
@@ -53,6 +55,13 @@ export default function Page() {
|
|||||||
initial: 'center',
|
initial: 'center',
|
||||||
sm: 'start',
|
sm: 'start',
|
||||||
}}
|
}}
|
||||||
|
position={{
|
||||||
|
initial: 'static',
|
||||||
|
sm: 'sticky',
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
top: `calc(${NAVBAR_HEIGHT}px + var(--space-3))`,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
direction={{
|
direction={{
|
||||||
|
|||||||
Reference in new issue
Block a user