fix: images in /today expanding parent

This commit is contained in:
TresAbhi committed 2023-06-06 00:25:23 +00:00
1 parent 632881c6b0
commit 26e78c72b9
7 files changed
+13 -30

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ export const SKILLED_CLANS: Record<SkilledClan, string> = {
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: false, inPublic: false,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -40,7 +40,7 @@ const COMP_TANKS = [
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+3 -5
View File
@@ -7,7 +7,7 @@ import * as Breakdown from '../components/Breakdown/index.js';
import NoBattlesInPeriod from '../components/NoBattlesInPeriod.js'; import NoBattlesInPeriod from '../components/NoBattlesInPeriod.js';
import PoweredByBlitzStars from '../components/PoweredByBlitzStars.js'; import PoweredByBlitzStars from '../components/PoweredByBlitzStars.js';
import TitleBar from '../components/TitleBar.js'; import TitleBar from '../components/TitleBar.js';
import Wrapper, { WrapperSize } from '../components/Wrapper.js'; import Wrapper from '../components/Wrapper.js';
import { BLITZ_SERVERS } from '../constants/servers.js'; import { BLITZ_SERVERS } from '../constants/servers.js';
import usernameAutocomplete from '../core/autocomplete/username.js'; import usernameAutocomplete from '../core/autocomplete/username.js';
import getBlitzAccount from '../core/blitz/getBlitzAccount.js'; import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
@@ -32,7 +32,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: false, inDevelopment: true,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
@@ -160,7 +160,7 @@ export default {
}); });
const image = await render( const image = await render(
<Wrapper size={WrapperSize.Roomy}> <Wrapper>
<TitleBar <TitleBar
name={accountInfo[id].nickname} name={accountInfo[id].nickname}
nameDiscriminator={ nameDiscriminator={
@@ -181,7 +181,6 @@ export default {
<PoweredByBlitzStars /> <PoweredByBlitzStars />
</Wrapper>, </Wrapper>,
WrapperSize.Roomy,
); );
const actionRow = new ActionRowBuilder<ButtonBuilder>().addComponents( const actionRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
@@ -193,7 +192,6 @@ export default {
files: [image], files: [image],
components: [actionRow], components: [actionRow],
}); });
}, },
autocomplete: usernameAutocomplete, autocomplete: usernameAutocomplete,
@@ -34,6 +34,7 @@ export function Row({
return ( return (
<div style={{ display: 'flex', gap: 16 }}> <div style={{ display: 'flex', gap: 16 }}>
<RowDiscriminator name={name} icon={icon} /> <RowDiscriminator name={name} icon={icon} />
<RowStat <RowStat
name="Winrate" name="Winrate"
value={`${(winrate * 100).toFixed(2)}%`} value={`${(winrate * 100).toFixed(2)}%`}
@@ -22,9 +22,11 @@ export function RowDiscriminator({ name, icon }: RowDiscriminatorProps) {
{icon && ( {icon && (
<img <img
src={icon} src={icon}
style={{ width: '100%', flex: 1, objectFit: 'cover' }} height={0}
style={{ flex: 1, width: '100%', objectFit: 'contain' }}
/> />
)} )}
<span <span
style={{ style={{
color: theme.colors.textLowContrast, color: theme.colors.textLowContrast,
+2 -16
View File
@@ -1,25 +1,11 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { theme } from '../stitches.config.js'; import { theme } from '../stitches.config.js';
export enum WrapperSize {
Regular,
Roomy,
}
export interface WrapperProps { export interface WrapperProps {
children: ReactNode; children: ReactNode;
size?: WrapperSize;
} }
export const WRAPPER_SIZE_WIDTHS: Record<WrapperSize, number> = { export default function Wrapper({ children }: WrapperProps) {
[WrapperSize.Regular]: 640,
[WrapperSize.Roomy]: 800,
};
export default function Wrapper({
children,
size = WrapperSize.Regular,
}: WrapperProps) {
return ( return (
<div <div
style={{ style={{
@@ -27,7 +13,7 @@ export default function Wrapper({
flexDirection: 'column', flexDirection: 'column',
padding: 16, padding: 16,
gap: 32, gap: 32,
width: WRAPPER_SIZE_WIDTHS[size], width: 640,
background: 'url(https://i.imgur.com/PhS06NJ.png)', background: 'url(https://i.imgur.com/PhS06NJ.png)',
color: theme.colors.textHighContrast, color: theme.colors.textHighContrast,
}} }}
+2 -6
View File
@@ -2,7 +2,6 @@ import { Resvg } from '@resvg/resvg-js';
import { readFile } from 'fs'; import { readFile } from 'fs';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import satori from 'satori'; import satori from 'satori';
import { WRAPPER_SIZE_WIDTHS, WrapperSize } from '../../components/Wrapper.js';
const FONT_NAME = 'Roboto'; const FONT_NAME = 'Roboto';
const FONT_FILES = ['Roboto', 'Roboto-Bold', 'Roboto-Black']; const FONT_FILES = ['Roboto', 'Roboto-Bold', 'Roboto-Black'];
@@ -21,12 +20,9 @@ const [robotoFlex, robotoFlexBold, robotoFlexBlack] = await Promise.all(
); );
console.log('Fonts imported'); console.log('Fonts imported');
export default async function render( export default async function render(element: ReactNode) {
element: ReactNode,
size: WrapperSize = WrapperSize.Regular,
) {
const svg = await satori(element, { const svg = await satori(element, {
width: WRAPPER_SIZE_WIDTHS[size], width: 640,
fonts: [ fonts: [
{ data: robotoFlex, name: FONT_NAME, weight: 400 }, { data: robotoFlex, name: FONT_NAME, weight: 400 },
{ data: robotoFlexBold, name: FONT_NAME, weight: 700 }, { data: robotoFlexBold, name: FONT_NAME, weight: 700 },