mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 12:24:55 +01:00
feat: better loading
This commit is contained in:
1 parent
76625dc7b2
commit
ee9dbdaf74
5 files changed
+65
-110
No files matched your search
+31
-13
@@ -1,4 +1,4 @@
|
||||
import { Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { Flex, Heading, Skeleton, Text } from '@radix-ui/themes';
|
||||
import { memo } from 'react';
|
||||
import { WargamingLoginButton } from '../../../../../../../../../components/Navbar/components/WargamingLoginButton';
|
||||
import { formatCompact } from '../../../../../../../../../core/math/formatCompact';
|
||||
@@ -19,9 +19,11 @@ export const Votes = memo(
|
||||
|
||||
return (
|
||||
<Flex direction="column" gap="3">
|
||||
<Flex justify="between" align="end">
|
||||
<Flex justify="between" align="center">
|
||||
<Heading size="4">
|
||||
{formatCompact(votes.votes)} {votes.votes === 1 ? 'vote' : 'votes'}
|
||||
{!votes && <Skeleton height="1em" width="4rem" />}
|
||||
{votes && formatCompact(votes.votes)}{' '}
|
||||
{votes && (votes.votes > 1 ? 'votes' : 'vote')}
|
||||
</Heading>
|
||||
|
||||
{!wargaming && (
|
||||
@@ -37,8 +39,14 @@ export const Votes = memo(
|
||||
gap={{ initial: '0', sm: '6' }}
|
||||
direction={{ initial: 'column', sm: 'row' }}
|
||||
>
|
||||
<StarRow stars={votes.categories.easiness} children="Easiness" />
|
||||
<StarRow stars={votes.categories.firepower} children="Firepower" />
|
||||
<StarRow
|
||||
stars={votes?.categories.easiness ?? null}
|
||||
children="Easiness"
|
||||
/>
|
||||
<StarRow
|
||||
stars={votes?.categories.firepower ?? null}
|
||||
children="Firepower"
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
<Flex
|
||||
@@ -46,24 +54,34 @@ export const Votes = memo(
|
||||
direction={{ initial: 'column', sm: 'row' }}
|
||||
>
|
||||
<StarRow
|
||||
stars={votes.categories.maneuverability}
|
||||
stars={votes?.categories.maneuverability ?? null}
|
||||
children="Maneuverability"
|
||||
/>
|
||||
<StarRow
|
||||
stars={votes.categories.survivability}
|
||||
stars={votes?.categories.survivability ?? null}
|
||||
children="Survivability"
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
{wargaming && (
|
||||
<Text align="center" size="2" color="gray" mt="2">
|
||||
<Flex justify="center">
|
||||
<Text size="2" color="gray" mt="2">
|
||||
<>
|
||||
{votes.last_updated
|
||||
? `You voted on ${new Date(votes.last_updated).toLocaleDateString()}`
|
||||
: `You haven't voted yet`}
|
||||
{votes ? (
|
||||
wargaming ? (
|
||||
votes.last_updated ? (
|
||||
`You voted on ${new Date(votes.last_updated).toLocaleDateString()}`
|
||||
) : (
|
||||
`You haven't voted yet`
|
||||
)
|
||||
) : (
|
||||
'Login to vote'
|
||||
)
|
||||
) : (
|
||||
<Skeleton height="1em" width="5rem" />
|
||||
)}
|
||||
</>
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
import { PaperPlaneIcon } from '@radix-ui/react-icons';
|
||||
import { Button, Flex, Heading, Skeleton, Text } from '@radix-ui/themes';
|
||||
import { WargamingLoginButton } from '../../../../../../../../components/Navbar/components/WargamingLoginButton';
|
||||
import * as App from '../../../../../../../../stores/app';
|
||||
|
||||
export function VotesSkeleton() {
|
||||
const wargaming = App.useDeferred(
|
||||
undefined,
|
||||
(state) => state.logins.wargaming,
|
||||
);
|
||||
|
||||
return (
|
||||
<Flex direction="column" gap="3">
|
||||
<Flex justify="between" align="end">
|
||||
<Heading size="4">
|
||||
<Skeleton height="1em" width="6rem" />
|
||||
</Heading>
|
||||
|
||||
{!wargaming && (
|
||||
<WargamingLoginButton variant="outline">
|
||||
Login to vote
|
||||
</WargamingLoginButton>
|
||||
)}
|
||||
{wargaming && (
|
||||
<Button variant="surface">
|
||||
<PaperPlaneIcon /> Vote
|
||||
</Button>
|
||||
)}
|
||||
</Flex>
|
||||
|
||||
<Flex gap="0" direction="column">
|
||||
<Flex gap="6">
|
||||
<Flex align="center" justify="between" width="15rem">
|
||||
<Text>Easiness</Text>
|
||||
<Skeleton height="1em" width="5rem" />
|
||||
</Flex>
|
||||
<Flex align="center" justify="between" width="15rem">
|
||||
<Text>Firepower</Text>
|
||||
<Skeleton height="1em" width="5rem" />
|
||||
</Flex>
|
||||
</Flex>
|
||||
<Flex gap="6">
|
||||
<Flex align="center" justify="between" width="15rem">
|
||||
<Text>Maneuverability</Text>
|
||||
<Skeleton height="1em" width="5rem" />
|
||||
</Flex>
|
||||
<Flex align="center" justify="between" width="15rem">
|
||||
<Text>Survivability</Text>
|
||||
<Skeleton height="1em" width="5rem" />
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ChevronLeftIcon, MixIcon } from '@radix-ui/react-icons';
|
||||
import { Button, Code, Flex } from '@radix-ui/themes';
|
||||
import { Suspense } from 'react';
|
||||
import { classIcons } from '../../../../../../../components/ClassIcon';
|
||||
import { Link } from '../../../../../../../components/Link';
|
||||
import { asset } from '../../../../../../../core/blitzkit/asset';
|
||||
@@ -9,7 +8,6 @@ import * as App from '../../../../../../../stores/app';
|
||||
import * as Duel from '../../../../../../../stores/duel';
|
||||
import { Listing } from './components/Listing';
|
||||
import { Votes } from './components/Votes';
|
||||
import { VotesSkeleton } from './components/VotesSkeleton';
|
||||
|
||||
export function MetaSection() {
|
||||
const developerMode = App.useDeferred(false, (state) => state.developerMode);
|
||||
@@ -40,7 +38,10 @@ export function MetaSection() {
|
||||
</Link>
|
||||
</Flex>
|
||||
|
||||
<Flex gap="6">
|
||||
<Flex
|
||||
gap={{ initial: '0', sm: '6' }}
|
||||
direction={{ initial: 'column', sm: 'row' }}
|
||||
>
|
||||
<Flex direction="column" width="100%">
|
||||
{protagonist.nameFull && (
|
||||
<Listing label="Full-name">{protagonist.nameFull}</Listing>
|
||||
@@ -139,9 +140,7 @@ export function MetaSection() {
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
<Suspense fallback={<VotesSkeleton />}>
|
||||
<Votes />
|
||||
</Suspense>
|
||||
<Votes />
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user