feat: use bepaint

This commit is contained in:
TresAbhi committed 2023-05-29 18:29:02 +00:00
1 parent fcf7d99012
commit 2dbf754572
12 files changed
+94 -48

No files matched your search

+2
View File
@@ -10,7 +10,9 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@radix-ui/colors": "^0.1.8",
"@resvg/resvg-js": "^2.4.1", "@resvg/resvg-js": "^2.4.1",
"bepaint": "^0.1.0-beta.3",
"discord.js": "^14.9.0", "discord.js": "^14.9.0",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"fuzzysort": "^2.0.4", "fuzzysort": "^2.0.4",
+37 -34
View File
@@ -71,41 +71,44 @@ export default {
const accumulatedStats = sumStats(allStatsToAccumulate); const accumulatedStats = sumStats(allStatsToAccumulate);
const rows = Object.entries({ if (Object.keys(tankStatsOverTime).length > 0) {
0: accumulatedStats, tankStatsOverTime[0] = accumulatedStats;
...tankStatsOverTime, }
}).map(([tankId, tankStats]) => {
const career = careerStats[tankId as unknown as number];
return ( const rows = Object.entries(tankStatsOverTime).map(
<Breakdown.Row ([tankId, tankStats]) => {
key={tankId} const career = careerStats[tankId as unknown as number];
name={
tankId === '0' return (
? 'Today' <Breakdown.Row
: resolveTankName({ key={tankId}
tank_id: tankId as unknown as number, name={
name: tankopedia[tankId as unknown as number].name, tankId === '0'
}) ? 'Today'
} : resolveTankName({
winrate={tankStats.wins / tankStats.battles} tank_id: tankId as unknown as number,
careerWinrate={career.wins / career.battles} name: tankopedia[tankId as unknown as number].name,
WN8={-Infinity} })
careerWN8={-Infinity} }
damage={tankStats.damage_dealt / tankStats.battles} winrate={tankStats.wins / tankStats.battles}
careerDamage={career.damage_dealt / career.battles} careerWinrate={career.wins / career.battles}
survival={tankStats.survived_battles / tankStats.battles} WN8={-Infinity}
careerSurvival={career.survived_battles / career.battles} careerWN8={-Infinity}
battles={tankStats.battles} damage={tankStats.damage_dealt / tankStats.battles}
careerBattles={career.battles} careerDamage={career.damage_dealt / career.battles}
icon={ survival={tankStats.survived_battles / tankStats.battles}
tankId === '0' careerSurvival={career.survived_battles / career.battles}
? undefined battles={tankStats.battles}
: tankopedia[tankId as unknown as number].images.normal careerBattles={career.battles}
} icon={
/> tankId === '0'
); ? undefined
}); : tankopedia[tankId as unknown as number].images.normal
}
/>
);
},
);
const image = await render( const image = await render(
<Wrapper> <Wrapper>
@@ -1,3 +1,5 @@
import { theme } from '../../../stitches.config.js';
export interface RowDiscriminatorProps { export interface RowDiscriminatorProps {
name: string; name: string;
icon?: string; icon?: string;
@@ -25,7 +27,7 @@ export function RowDiscriminator({ name, icon }: RowDiscriminatorProps) {
)} )}
<span <span
style={{ style={{
color: '#A0A0A0', color: theme.colors.textLowContrast,
fontSize: 16, fontSize: 16,
textAlign: 'center', textAlign: 'center',
display: 'block', display: 'block',
@@ -1,3 +1,5 @@
import { theme } from '../../../stitches.config.js';
export interface RowStatProps { export interface RowStatProps {
name: string; name: string;
value: string; value: string;
@@ -17,7 +19,9 @@ export function RowStat({ name, value, career, delta }: RowStatProps) {
flex: 1, flex: 1,
}} }}
> >
<span style={{ color: '#A0A0A0', fontSize: 12 }}>{career}</span> <span style={{ color: theme.colors.textLowContrast, fontSize: 12 }}>
{career}
</span>
<div <div
style={{ style={{
@@ -38,12 +42,14 @@ export function RowStat({ name, value, career, delta }: RowStatProps) {
/> />
)} )}
<span style={{ color: 'white', fontSize: 16, fontWeight: 'bold' }}> <span style={{ color: theme.colors.textHighContrast, fontSize: 16, fontWeight: 'bold' }}>
{value} {value}
</span> </span>
</div> </div>
<span style={{ color: '#A0A0A0', fontSize: 12 }}>{name}</span> <span style={{ color: theme.colors.textLowContrast, fontSize: 12 }}>
{name}
</span>
</div> </div>
); );
} }
@@ -1,3 +1,4 @@
import { theme } from '../../../stitches.config.js';
import { Stat } from '../index.js'; import { Stat } from '../index.js';
export interface GenericStatsRowProps { export interface GenericStatsRowProps {
@@ -13,8 +14,10 @@ export default function GenericStatsRow({ stat }: GenericStatsRowProps) {
alignItems: 'center', alignItems: 'center',
}} }}
> >
<span style={{ color: '#A0A0A0', fontSize: 16 }}>{stat[0]}</span> <span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
<span style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}> {stat[0]}
</span>
<span style={{ color: theme.colors.textHighContrast, fontWeight: 'bold', fontSize: 16 }}>
{stat[1]} {stat[1]}
</span> </span>
</div> </div>
+3 -1
View File
@@ -1,3 +1,5 @@
import { theme } from '../stitches.config.js';
export default function NoBattlesInPeriod() { export default function NoBattlesInPeriod() {
return ( return (
<div <div
@@ -7,7 +9,7 @@ export default function NoBattlesInPeriod() {
justifyContent: 'center', justifyContent: 'center',
}} }}
> >
<span style={{ fontSize: 16, color: '#A0A0A0' }}> <span style={{ fontSize: 16, color: theme.colors.textLowContrast }}>
No battles played in this period No battles played in this period
</span> </span>
</div> </div>
+3 -1
View File
@@ -1,3 +1,5 @@
import { theme } from '../stitches.config.js';
export default function PoweredByBlitzStars() { export default function PoweredByBlitzStars() {
return ( return (
<div style={{ display: 'flex', gap: 4, justifyContent: 'flex-end' }}> <div style={{ display: 'flex', gap: 4, justifyContent: 'flex-end' }}>
@@ -5,7 +7,7 @@ export default function PoweredByBlitzStars() {
src="https://www.blitzstars.com/assets/images/4b4cb591.TankyMcPewpew.png" src="https://www.blitzstars.com/assets/images/4b4cb591.TankyMcPewpew.png"
style={{ height: 16, width: 16 }} style={{ height: 16, width: 16 }}
/> />
<span style={{ color: '#A0A0A0', fontSize: 16 }}> <span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
Powered by BlitzStars Powered by BlitzStars
</span> </span>
</div> </div>
+9 -3
View File
@@ -1,3 +1,5 @@
import { theme } from '../stitches.config.js';
export interface TitleBarProps { export interface TitleBarProps {
name: string; name: string;
nameDiscriminator?: string; nameDiscriminator?: string;
@@ -26,18 +28,22 @@ export default function TitleBar({
<span <span
style={{ style={{
fontSize: 32, fontSize: 32,
color: 'white', color: theme.colors.textHighContrast,
fontWeight: 900, fontWeight: 900,
gap: 4, gap: 4,
}} }}
> >
{name} {name}
{nameDiscriminator && ( {nameDiscriminator && (
<span style={{ color: '#A0A0A0' }}>{nameDiscriminator}</span> <span style={{ color: theme.colors.textLowContrast }}>
{nameDiscriminator}
</span>
)} )}
</span> </span>
<span style={{ color: '#A0A0A0', fontSize: 16 }}>{description}</span> <span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
{description}
</span>
</div> </div>
</div> </div>
+3 -2
View File
@@ -1,4 +1,5 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { theme } from '../stitches.config.js';
export interface WrapperProps { export interface WrapperProps {
children: ReactNode; children: ReactNode;
@@ -13,8 +14,8 @@ export default function Wrapper({ children }: WrapperProps) {
padding: 16, padding: 16,
gap: 32, gap: 32,
width: 640, width: 640,
background: 'black', backgroundColor: theme.colors.appBackground1,
color: 'white', color: theme.colors.textHighContrast,
}} }}
> >
{children} {children}
+3 -1
View File
@@ -1,3 +1,5 @@
export const ACCENT_COLOR = '#ffffff'; import { theme } from '../stitches.config.js';
export const ACCENT_COLOR = theme.colors.textHighContrast;
export const POSITIVE_COLOR = '#82ff29'; export const POSITIVE_COLOR = '#82ff29';
export const NEGATIVE_COLOR = '#ff4747'; export const NEGATIVE_COLOR = '#ff4747';
+7
View File
@@ -0,0 +1,7 @@
import { slateDark } from '@radix-ui/colors';
import { createColors } from 'bepaint';
// this isn't really a stitches config, but the object is compliant
export const theme = {
colors: createColors(slateDark),
};
+10
View File
@@ -156,6 +156,11 @@
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061"
integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==
"@radix-ui/colors@^0.1.8":
version "0.1.8"
resolved "https://registry.yarnpkg.com/@radix-ui/colors/-/colors-0.1.8.tgz#b08c62536fc462a87632165fb28e9b18f9bd047e"
integrity sha512-jwRMXYwC0hUo0mv6wGpuw254Pd9p/R6Td5xsRpOmaWkUHlooNWqVcadgyzlRumMq3xfOTXwJReU0Jv+EIy4Jbw==
"@resvg/[email protected]": "@resvg/[email protected]":
version "2.4.1" version "2.4.1"
resolved "https://registry.yarnpkg.com/@resvg/resvg-js-android-arm-eabi/-/resvg-js-android-arm-eabi-2.4.1.tgz#49dc9722f95096f8aff70186deae8e148d60dce5" resolved "https://registry.yarnpkg.com/@resvg/resvg-js-android-arm-eabi/-/resvg-js-android-arm-eabi-2.4.1.tgz#49dc9722f95096f8aff70186deae8e148d60dce5"
@@ -338,6 +343,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978"
integrity sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw== integrity sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw==
bepaint@^0.1.0-beta.3:
version "0.1.0-beta.3"
resolved "https://registry.yarnpkg.com/bepaint/-/bepaint-0.1.0-beta.3.tgz#fe8f0d20e35da075a6ed69f42d61156d985da584"
integrity sha512-rybuEo674bEal5QUm/qO9jok3TptyRH2bdHDheFO25fw+HCBic5Oiy+ZWnOFnROCGZQy2Zcw7po4KrKSxz02Pg==
busboy@^1.6.0: busboy@^1.6.0:
version "1.6.0" version "1.6.0"
resolved "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz" resolved "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz"