mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: remove useWideFormat
This commit is contained in:
1 parent
332c1787f4
commit
697497b11e
4 files changed
+39
-62
No files matched your search
@@ -44,7 +44,6 @@ import searchPlayersAcrossRegions, {
|
|||||||
import { tankDefinitions } from '../../../core/blitzkit/tankDefinitions';
|
import { tankDefinitions } from '../../../core/blitzkit/tankDefinitions';
|
||||||
import { tankAverages } from '../../../core/blitzstars/tankAverages';
|
import { tankAverages } from '../../../core/blitzstars/tankAverages';
|
||||||
import { deltaTankStats } from '../../../core/statistics/deltaTankStats';
|
import { deltaTankStats } from '../../../core/statistics/deltaTankStats';
|
||||||
import { useWideFormat } from '../../../hooks/useWideFormat';
|
|
||||||
import * as Session from '../../../stores/session';
|
import * as Session from '../../../stores/session';
|
||||||
import { IndividualTankStats } from '../../../types/tanksStats';
|
import { IndividualTankStats } from '../../../types/tanksStats';
|
||||||
|
|
||||||
@@ -54,7 +53,6 @@ export default function Page({
|
|||||||
searchParams: { id?: string };
|
searchParams: { id?: string };
|
||||||
}) {
|
}) {
|
||||||
const [loaded, setLoaded] = useState(false);
|
const [loaded, setLoaded] = useState(false);
|
||||||
const wideFormat = useWideFormat(640);
|
|
||||||
const awaitedTankDefinitions = use(tankDefinitions);
|
const awaitedTankDefinitions = use(tankDefinitions);
|
||||||
const awaitedTankAvearges = use(tankAverages);
|
const awaitedTankAvearges = use(tankAverages);
|
||||||
const [showSearch, setShowSearch] = useState(false);
|
const [showSearch, setShowSearch] = useState(false);
|
||||||
@@ -318,7 +316,7 @@ export default function Page({
|
|||||||
<Flex
|
<Flex
|
||||||
mt="2"
|
mt="2"
|
||||||
mb="2"
|
mb="2"
|
||||||
direction={wideFormat ? 'row' : 'column'}
|
direction={{ initial: 'column', sm: 'row' }}
|
||||||
align="center"
|
align="center"
|
||||||
justify="between"
|
justify="between"
|
||||||
gap="2"
|
gap="2"
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { ChevronLeftIcon, MixIcon } from '@radix-ui/react-icons';
|
import { ChevronLeftIcon, MixIcon } from '@radix-ui/react-icons';
|
||||||
import { Button, Flex, Heading, Text } from '@radix-ui/themes';
|
import { Box, Button, Flex, Heading, Text } from '@radix-ui/themes';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { classIcons } from '../../../../../../components/ClassIcon';
|
import { classIcons } from '../../../../../../components/ClassIcon';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
||||||
import { useFullScreen } from '../../../../../../hooks/useFullScreen';
|
import { useFullScreen } from '../../../../../../hooks/useFullScreen';
|
||||||
import { useWideFormat } from '../../../../../../hooks/useWideFormat';
|
|
||||||
import strings from '../../../../../../lang/en-US.json';
|
import strings from '../../../../../../lang/en-US.json';
|
||||||
import { theme } from '../../../../../../stitches.config';
|
|
||||||
import * as Duel from '../../../../../../stores/duel';
|
import * as Duel from '../../../../../../stores/duel';
|
||||||
import { TankSandbox } from './TankSandbox';
|
import { TankSandbox } from './TankSandbox';
|
||||||
import { Options } from './components/Options';
|
import { Options } from './components/Options';
|
||||||
@@ -14,7 +12,6 @@ import { Options } from './components/Options';
|
|||||||
export function HeroSection() {
|
export function HeroSection() {
|
||||||
const protagonist = Duel.use((state) => state.protagonist!.tank);
|
const protagonist = Duel.use((state) => state.protagonist!.tank);
|
||||||
const antagonist = Duel.use((state) => state.antagonist!.tank);
|
const antagonist = Duel.use((state) => state.antagonist!.tank);
|
||||||
const wideFormat = useWideFormat(880);
|
|
||||||
const compareTanks =
|
const compareTanks =
|
||||||
protagonist.id === antagonist.id
|
protagonist.id === antagonist.id
|
||||||
? [protagonist.id]
|
? [protagonist.id]
|
||||||
@@ -25,41 +22,34 @@ export function HeroSection() {
|
|||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
justify="center"
|
justify="center"
|
||||||
pt={wideFormat ? '0' : '6'}
|
pt={{ initial: '6', md: '0' }}
|
||||||
style={{
|
style={{ background: 'var(--color-surface)', position: 'relative' }}
|
||||||
background: 'var(--color-surface)',
|
height={{ initial: 'calc(75vh - 64px)', md: undefined }}
|
||||||
position: 'relative',
|
|
||||||
height: wideFormat ? undefined : 'calc(75vh - 64px)',
|
|
||||||
}}
|
|
||||||
gap="4"
|
gap="4"
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
direction={wideFormat ? 'row' : 'column'}
|
direction={{ initial: 'column', md: 'row' }}
|
||||||
style={{
|
style={{ maxWidth: 1600, flex: 1 }}
|
||||||
maxWidth: 1600,
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
align="center"
|
align="center"
|
||||||
justify="center"
|
justify="center"
|
||||||
style={{
|
flexGrow={{ initial: undefined, md: '1' }}
|
||||||
flex: wideFormat ? 1 : undefined,
|
flexBasis="0"
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
gap={wideFormat ? '4' : '2'}
|
gap={{ initial: '2', md: '4' }}
|
||||||
direction="column"
|
direction="column"
|
||||||
ml={wideFormat ? '8' : undefined}
|
ml={{ initial: '0', md: '8' }}
|
||||||
align={wideFormat ? undefined : 'center'}
|
align={{ initial: 'center', md: undefined }}
|
||||||
justify="center"
|
justify="center"
|
||||||
style={{
|
style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Heading
|
<Heading
|
||||||
size={wideFormat ? '9' : '8'}
|
size={{ initial: '8', md: '9' }}
|
||||||
align={wideFormat ? undefined : 'center'}
|
align={{ initial: 'center', md: undefined }}
|
||||||
color={
|
color={
|
||||||
protagonist.treeType === 'collector'
|
protagonist.treeType === 'collector'
|
||||||
? 'blue'
|
? 'blue'
|
||||||
@@ -100,17 +90,18 @@ export function HeroSection() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<div
|
<Box
|
||||||
className="tank-sandbox-container"
|
className="tank-sandbox-container"
|
||||||
|
height={{ initial: undefined, md: '512px' }}
|
||||||
style={{
|
style={{
|
||||||
flex: 2,
|
flex: 2,
|
||||||
position: isFullScreen ? 'fixed' : 'relative',
|
position: isFullScreen ? 'fixed' : 'relative',
|
||||||
top: isFullScreen ? 0 : undefined,
|
top: isFullScreen ? 0 : undefined,
|
||||||
left: isFullScreen ? 0 : undefined,
|
left: isFullScreen ? 0 : undefined,
|
||||||
width: isFullScreen ? '100vw' : undefined,
|
width: isFullScreen ? '100vw' : undefined,
|
||||||
height: isFullScreen ? '100vh' : wideFormat ? 512 : undefined,
|
height: isFullScreen ? '100vh' : 'auto',
|
||||||
zIndex: isFullScreen ? 3 : undefined,
|
zIndex: isFullScreen ? 3 : undefined,
|
||||||
background: isFullScreen ? theme.colors.appBackground1 : undefined,
|
background: isFullScreen ? 'var(--color-background)' : undefined,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -131,7 +122,7 @@ export function HeroSection() {
|
|||||||
|
|
||||||
<Options />
|
<Options />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { ChevronRightIcon } from '@radix-ui/react-icons';
|
import { ChevronRightIcon } from '@radix-ui/react-icons';
|
||||||
import { ChevronDownIcon, Flex, Text } from '@radix-ui/themes';
|
import { Box, ChevronDownIcon, Flex, Heading, Text } from '@radix-ui/themes';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { ComponentProps, use } from 'react';
|
import { ComponentProps, use } from 'react';
|
||||||
import PageWrapper from '../../../../../../components/PageWrapper';
|
import PageWrapper from '../../../../../../components/PageWrapper';
|
||||||
import { asset } from '../../../../../../core/blitzkit/asset';
|
import { asset } from '../../../../../../core/blitzkit/asset';
|
||||||
import { tankDefinitions } from '../../../../../../core/blitzkit/tankDefinitions';
|
import { tankDefinitions } from '../../../../../../core/blitzkit/tankDefinitions';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
||||||
import { useWideFormat } from '../../../../../../hooks/useWideFormat';
|
|
||||||
import * as Duel from '../../../../../../stores/duel';
|
import * as Duel from '../../../../../../stores/duel';
|
||||||
|
|
||||||
export function TreeArrow({
|
export function TreeArrow({
|
||||||
@@ -51,7 +50,6 @@ export function TreeArrow({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function TechTreeSection() {
|
export function TechTreeSection() {
|
||||||
const wideFormat = useWideFormat(720);
|
|
||||||
const awaitedTankDefinitions = use(tankDefinitions);
|
const awaitedTankDefinitions = use(tankDefinitions);
|
||||||
const tank = Duel.use((state) => state.protagonist!.tank);
|
const tank = Duel.use((state) => state.protagonist!.tank);
|
||||||
|
|
||||||
@@ -139,21 +137,23 @@ export function TechTreeSection() {
|
|||||||
size={tank.ancestors && tank.successors ? 880 : 480}
|
size={tank.ancestors && tank.successors ? 880 : 480}
|
||||||
gap="0"
|
gap="0"
|
||||||
>
|
>
|
||||||
{/* <Flex justify="center">
|
<Flex justify="center" py="2" mb="4">
|
||||||
<Heading>Tech tree</Heading>
|
<Heading>Tech tree</Heading>
|
||||||
</Flex> */}
|
</Flex>
|
||||||
|
|
||||||
|
{/* BIG TODO: use number format to shorten currencies */}
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
align="center"
|
align="center"
|
||||||
gap="6"
|
gap="6"
|
||||||
style={{}}
|
style={{}}
|
||||||
direction={wideFormat ? 'row' : 'column'}
|
direction={{ initial: 'column', sm: 'row' }}
|
||||||
>
|
>
|
||||||
{tank.ancestors && (
|
{tank.ancestors && (
|
||||||
<>
|
<>
|
||||||
<Flex
|
<Flex
|
||||||
wrap="wrap"
|
wrap="wrap"
|
||||||
direction={wideFormat ? 'column' : 'row'}
|
direction={{ initial: 'column', sm: 'row' }}
|
||||||
align="center"
|
align="center"
|
||||||
justify="center"
|
justify="center"
|
||||||
style={{
|
style={{
|
||||||
@@ -166,7 +166,12 @@ export function TechTreeSection() {
|
|||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<TreeArrow down={!wideFormat} />
|
<Box display={{ initial: 'block', sm: 'none' }}>
|
||||||
|
<TreeArrow down />
|
||||||
|
</Box>
|
||||||
|
<Box display={{ initial: 'none', sm: 'block' }}>
|
||||||
|
<TreeArrow />
|
||||||
|
</Box>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -196,11 +201,16 @@ export function TechTreeSection() {
|
|||||||
|
|
||||||
{tank.successors && (
|
{tank.successors && (
|
||||||
<>
|
<>
|
||||||
<TreeArrow down={!wideFormat} />
|
<Box display={{ initial: 'block', sm: 'none' }}>
|
||||||
|
<TreeArrow down />
|
||||||
|
</Box>
|
||||||
|
<Box display={{ initial: 'none', sm: 'block' }}>
|
||||||
|
<TreeArrow />
|
||||||
|
</Box>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
wrap="wrap"
|
wrap="wrap"
|
||||||
direction={wideFormat ? 'column' : 'row'}
|
direction={{ initial: 'column', sm: 'row' }}
|
||||||
align="center"
|
align="center"
|
||||||
justify="center"
|
justify="center"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
import { useEffect, useState } from 'react';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated DO NOT USE; CAUSES NEXT JS HYDRATION ISSUES
|
|
||||||
*/
|
|
||||||
export function useWideFormat(size = 880) {
|
|
||||||
function hasWideFormat() {
|
|
||||||
return typeof window !== 'undefined' && window.innerWidth > size;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [wideFormat, setWideFormat] = useState(hasWideFormat());
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
function handleResize() {
|
|
||||||
setWideFormat(hasWideFormat());
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('resize', handleResize);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return wideFormat;
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user