feat: better titlebar

This commit is contained in:
TrèsAbhi committed 2024-03-06 09:52:09 -06:00
1 parent 19e81ff78a
commit f605801555
10 files changed
+63 -90

No files matched your search

+7 -7
View File
@@ -1,8 +1,8 @@
import { chunk } from 'lodash'; import { chunk } from 'lodash';
import * as Breakdown from '../components/Breakdown'; import * as Breakdown from '../components/Breakdown';
import CommandWrapper from '../components/CommandWrapper';
import NoData, { NoDataType } from '../components/NoData'; import NoData, { NoDataType } from '../components/NoData';
import TitleBar from '../components/TitleBar'; import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import { AllStats, getAccountInfo } from '../core/blitz/getAccountInfo'; import { AllStats, getAccountInfo } from '../core/blitz/getAccountInfo';
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
import getTankStats from '../core/blitz/getTankStats'; import getTankStats from '../core/blitz/getTankStats';
@@ -254,10 +254,10 @@ export async function renderBreakdown(
if (filteredOrder.length > 0) { if (filteredOrder.length > 0) {
return pages return pages
.map((page, index) => ( .map((page, index) => (
<Wrapper> <CommandWrapper>
{index === 0 && ( {index === 0 && (
<TitleBar <TitleBar
name={accountInfo.nickname} title={accountInfo.nickname}
image={ image={
clanData?.clan clanData?.clan
? `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${clanData?.clan?.emblem_set_id}.png` ? `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${clanData?.clan?.emblem_set_id}.png`
@@ -268,14 +268,14 @@ export async function renderBreakdown(
)} )}
<Breakdown.Root>{page}</Breakdown.Root> <Breakdown.Root>{page}</Breakdown.Root>
</Wrapper> </CommandWrapper>
)) ))
.reverse(); .reverse();
} else { } else {
return [ return [
<Wrapper> <CommandWrapper>
<TitleBar <TitleBar
name={accountInfo.nickname} title={accountInfo.nickname}
image={ image={
clanData?.clan clanData?.clan
? `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${clanData?.clan?.emblem_set_id}.png` ? `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${clanData?.clan?.emblem_set_id}.png`
@@ -285,7 +285,7 @@ export async function renderBreakdown(
/> />
<NoData type={NoDataType.BattlesInPeriod} /> <NoData type={NoDataType.BattlesInPeriod} />
</Wrapper>, </CommandWrapper>,
]; ];
} }
} }
+4 -4
View File
@@ -2,10 +2,10 @@ import {
SlashCommandBuilder, SlashCommandBuilder,
SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandGroupBuilder,
} from 'discord.js'; } from 'discord.js';
import CommandWrapper from '../components/CommandWrapper';
import * as Graph from '../components/Graph'; import * as Graph from '../components/Graph';
import NoData, { NoDataType } from '../components/NoData'; import NoData, { NoDataType } from '../components/NoData';
import TitleBar from '../components/TitleBar'; import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getAccountInfo } from '../core/blitz/getAccountInfo';
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
import resolveTankId from '../core/blitz/resolveTankId'; import resolveTankId from '../core/blitz/resolveTankId';
@@ -74,8 +74,8 @@ async function render(
const minX = Math.min(...xs); const minX = Math.min(...xs);
return ( return (
<Wrapper> <CommandWrapper>
<TitleBar name={accountInfo.nickname} image={logo} description={name} /> <TitleBar title={accountInfo.nickname} image={logo} description={name} />
{plot.length > 0 && ( {plot.length > 0 && (
<Graph.Root <Graph.Root
@@ -103,7 +103,7 @@ async function render(
)} )}
{plot.length === 0 && <NoData type={NoDataType.BattlesInPeriod} />} {plot.length === 0 && <NoData type={NoDataType.BattlesInPeriod} />}
</Wrapper> </CommandWrapper>
); );
} }
+4 -4
View File
@@ -1,9 +1,9 @@
import { SlashCommandBuilder } from 'discord.js'; import { SlashCommandBuilder } from 'discord.js';
import CommandWrapper from '../components/CommandWrapper';
import GenericAllStats from '../components/GenericAllStats'; import GenericAllStats from '../components/GenericAllStats';
import NoData, { NoDataType } from '../components/NoData'; import NoData, { NoDataType } from '../components/NoData';
import TierWeights from '../components/TierWeights'; import TierWeights from '../components/TierWeights';
import TitleBar from '../components/TitleBar'; import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getAccountInfo } from '../core/blitz/getAccountInfo';
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL'; import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
@@ -48,9 +48,9 @@ async function render(
const tierWeights = await getTierWeights(diffedTankStats.diff, filteredOrder); const tierWeights = await getTierWeights(diffedTankStats.diff, filteredOrder);
return ( return (
<Wrapper> <CommandWrapper>
<TitleBar <TitleBar
name={nickname} title={nickname}
image={clanImage} image={clanImage}
description={`${name} • ${filterDescriptions}`} description={`${name} • ${filterDescriptions}`}
/> />
@@ -60,7 +60,7 @@ async function render(
{stats.battles > 0 && ( {stats.battles > 0 && (
<GenericAllStats stats={stats} supplementaryStats={supplementary} /> <GenericAllStats stats={stats} supplementaryStats={supplementary} />
)} )}
</Wrapper> </CommandWrapper>
); );
} }
+4 -4
View File
@@ -1,8 +1,8 @@
import { SlashCommandBuilder } from 'discord.js'; import { SlashCommandBuilder } from 'discord.js';
import CommandWrapper from '../components/CommandWrapper';
import GenericStats from '../components/GenericStats'; import GenericStats from '../components/GenericStats';
import NoData, { NoDataType } from '../components/NoData'; import NoData, { NoDataType } from '../components/NoData';
import TitleBar from '../components/TitleBar'; import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getAccountInfo } from '../core/blitz/getAccountInfo';
import { getClanInfo } from '../core/blitz/getClanInfo'; import { getClanInfo } from '../core/blitz/getClanInfo';
import addClanChoices from '../core/discord/addClanChoices'; import addClanChoices from '../core/discord/addClanChoices';
@@ -52,16 +52,16 @@ export const inactiveCommand: CommandRegistry = {
const hasInactiveMembers = inactive.length > 0; const hasInactiveMembers = inactive.length > 0;
return ( return (
<Wrapper> <CommandWrapper>
<TitleBar <TitleBar
name={clanInfo.name} title={clanInfo.name}
image={`https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${clanInfo.emblem_set_id}.png`} image={`https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${clanInfo.emblem_set_id}.png`}
description={`Inactive for ${threshold}+ Days • ${new Date().toDateString()}`} description={`Inactive for ${threshold}+ Days • ${new Date().toDateString()}`}
/> />
{!hasInactiveMembers && <NoData type={NoDataType.PlayersInPeriod} />} {!hasInactiveMembers && <NoData type={NoDataType.PlayersInPeriod} />}
{hasInactiveMembers && <GenericStats stats={inactive} />} {hasInactiveMembers && <GenericStats stats={inactive} />}
</Wrapper> </CommandWrapper>
); );
}, },
+3 -3
View File
@@ -3,7 +3,7 @@ import { GuildMemberRoleManager, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape'; import markdownEscape from 'markdown-escape';
import discord from '../../discord.json' assert { type: 'json' }; import discord from '../../discord.json' assert { type: 'json' };
import { Glow } from '../components/AllStatsOverview/components/WN8Display/components/Glow'; import { Glow } from '../components/AllStatsOverview/components/WN8Display/components/Glow';
import Wrapper from '../components/Wrapper'; import CommandWrapper from '../components/CommandWrapper';
import { REGION_NAMES } from '../constants/regions'; import { REGION_NAMES } from '../constants/regions';
import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getAccountInfo } from '../core/blitz/getAccountInfo';
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
@@ -50,7 +50,7 @@ export const verifyCommand: CommandRegistry = {
} }
return [ return [
<Wrapper fat> <CommandWrapper fat>
<div <div
style={{ style={{
display: 'flex', display: 'flex',
@@ -196,7 +196,7 @@ export const verifyCommand: CommandRegistry = {
<Glow color={teal.teal9} rotation={-90} /> <Glow color={teal.teal9} rotation={-90} />
</div> </div>
</Wrapper>, </CommandWrapper>,
embedInfo( embedInfo(
'Incorrect account?', 'Incorrect account?',
+4 -4
View File
@@ -1,8 +1,8 @@
import { SlashCommandBuilder } from 'discord.js'; import { SlashCommandBuilder } from 'discord.js';
import CommandWrapper from '../components/CommandWrapper';
import NoData, { NoDataType } from '../components/NoData'; import NoData, { NoDataType } from '../components/NoData';
import * as Tanks from '../components/Tanks'; import * as Tanks from '../components/Tanks';
import TitleBar from '../components/TitleBar'; import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import { encyclopediaInfo } from '../core/blitz/encyclopediaInfo'; import { encyclopediaInfo } from '../core/blitz/encyclopediaInfo';
import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getAccountInfo } from '../core/blitz/getAccountInfo';
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
@@ -61,9 +61,9 @@ export const ownedTanksCommand: CommandRegistry = {
nations.sort(); nations.sort();
return ( return (
<Wrapper> <CommandWrapper>
<TitleBar <TitleBar
name={accountInfo.nickname} title={accountInfo.nickname}
image={ image={
clanAccountInfo?.clan clanAccountInfo?.clan
? emblemIdToURL(clanAccountInfo.clan.emblem_set_id) ? emblemIdToURL(clanAccountInfo.clan.emblem_set_id)
@@ -120,7 +120,7 @@ export const ownedTanksCommand: CommandRegistry = {
); );
}), }),
))} ))}
</Wrapper> </CommandWrapper>
); );
}, },
+4 -4
View File
@@ -6,9 +6,9 @@ import {
import { range } from 'lodash'; import { range } from 'lodash';
import markdownEscape from 'markdown-escape'; import markdownEscape from 'markdown-escape';
import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard'; import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard';
import CommandWrapper from '../components/CommandWrapper';
import * as Leaderboard from '../components/Leaderboard'; import * as Leaderboard from '../components/Leaderboard';
import TitleBar from '../components/TitleBar'; import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import { LEAGUES } from '../constants/leagues'; import { LEAGUES } from '../constants/leagues';
import { FIRST_ARCHIVED_RATINGS_SEASON } from '../constants/ratings'; import { FIRST_ARCHIVED_RATINGS_SEASON } from '../constants/ratings';
import { REGION_NAMES_SHORT, Region } from '../constants/regions'; import { REGION_NAMES_SHORT, Region } from '../constants/regions';
@@ -423,9 +423,9 @@ export const ratingsCommand = new Promise<CommandRegistryPromisable>(
}); });
return ( return (
<Wrapper> <CommandWrapper>
<TitleBar <TitleBar
name={titleName} title={titleName}
image={titleImage} image={titleImage}
description={titleDescription} description={titleDescription}
/> />
@@ -445,7 +445,7 @@ export const ratingsCommand = new Promise<CommandRegistryPromisable>(
)} )}
</Leaderboard.Root> </Leaderboard.Root>
)} )}
</Wrapper> </CommandWrapper>
); );
}, },
+4 -4
View File
@@ -1,8 +1,8 @@
import { SlashCommandBuilder } from 'discord.js'; import { SlashCommandBuilder } from 'discord.js';
import AllStatsOverview from '../components/AllStatsOverview'; import AllStatsOverview from '../components/AllStatsOverview';
import CommandWrapper from '../components/CommandWrapper';
import NoData, { NoDataType } from '../components/NoData'; import NoData, { NoDataType } from '../components/NoData';
import TitleBar from '../components/TitleBar'; import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getAccountInfo } from '../core/blitz/getAccountInfo';
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL'; import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
@@ -42,9 +42,9 @@ async function render(
const filterDescriptions = await filtersToDescription(filters); const filterDescriptions = await filtersToDescription(filters);
return ( return (
<Wrapper> <CommandWrapper>
<TitleBar <TitleBar
name={nickname} title={nickname}
image={clanImage} image={clanImage}
description={`${name} • ${filterDescriptions}`} description={`${name} • ${filterDescriptions}`}
/> />
@@ -53,7 +53,7 @@ async function render(
{stats.battles > 0 && ( {stats.battles > 0 && (
<AllStatsOverview stats={stats} supplementaryStats={supplementary} /> <AllStatsOverview stats={stats} supplementaryStats={supplementary} />
)} )}
</Wrapper> </CommandWrapper>
); );
} }
@@ -1,26 +1,22 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { theme } from '../stitches.config'; import { theme } from '../stitches.config';
export interface WrapperProps { interface CommandWrapperProps {
children: ReactNode; children: ReactNode;
naked?: boolean;
fat?: boolean; fat?: boolean;
} }
export default function Wrapper({ children, naked, fat }: WrapperProps) { export default function CommandWrapper({ children, fat }: CommandWrapperProps) {
return ( return (
<div <div
style={{ style={{
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
padding: `16px ${fat ? 0 : 16}px`, padding: `16px ${fat ? 0 : 16}px`,
gap: 32, gap: 16,
width: 480, width: 480,
color: theme.colors.textHighContrast, color: theme.colors.textHighContrast,
background: 'url(https://i.imgur.com/PhS06NJ.png)',
...(!naked && {
background: 'url(https://i.imgur.com/PhS06NJ.png)',
}),
}} }}
> >
{children} {children}
+25 -48
View File
@@ -1,75 +1,52 @@
import { theme } from '../stitches.config'; import { theme } from '../stitches.config';
export interface TitleBarProps { export interface TitleBarProps {
name: string; title: string;
image?: string; image?: string;
description?: string; description?: string;
} }
export default function TitleBar({ name, image, description }: TitleBarProps) { export default function TitleBar({ title, image, description }: TitleBarProps) {
return ( return (
<div <div
style={{ style={{
gap: 4,
display: 'flex', display: 'flex',
alignItems: 'center', flexDirection: 'column',
justifyContent: 'center', justifyContent: 'center',
overflow: 'hidden', alignItems: 'center',
}} }}
> >
<div style={{ display: 'flex', gap: 8 }}> <div
style={{
gap: 4,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
{image && ( {image && (
<img <img
style={{ width: 64, height: 64, objectFit: 'contain' }} style={{ width: 32, height: 32, objectFit: 'contain' }}
src={image} src={image}
/> />
)} )}
<div <span
style={{ style={{
display: 'flex', fontSize: 32,
flexDirection: 'column', fontWeight: 900,
justifyContent: 'center', background: `linear-gradient(180deg, ${theme.colors.textHighContrast} 0%, ${theme.colors.textLowContrast} 100%)`,
gap: 4, backgroundClip: 'text',
}} }}
> >
<div {title}
style={{ </span>
display: 'flex',
gap: 4,
alignItems: 'center',
justifyContent: 'center',
}}
>
<span
style={{
fontSize: 32,
color: theme.colors.textHighContrast,
fontWeight: 900,
whiteSpace: 'nowrap',
overflow: 'hidden',
}}
>
{name}
</span>
</div>
<div
style={{
display: 'flex',
justifyContent: image ? 'flex-start' : 'center',
}}
>
<span
style={{
color: theme.colors.textLowContrast,
fontSize: 16,
}}
>
{description}
</span>
</div>
</div>
</div> </div>
<span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
{description}
</span>
</div> </div>
); );
} }