Files
blitzkit/packages/website/src/constants/embeds.ts
T

107 lines
3.2 KiB
TypeScript
Raw Normal View History

2026-08-05 13:13:48 -05:00
import { type CompositeStatsKey } from "@blitzkit/core";
import { grayA, grayDark, grayDarkA } from "@radix-ui/colors";
import type { ReactNode } from "react";
2024-09-08 21:52:12 -05:00
import {
BreakdownPreview,
2024-10-27 22:29:28 -05:00
BreakdownRenderer,
2024-09-08 21:52:12 -05:00
compositeStatsKeysOptions,
2026-08-05 13:13:48 -05:00
} from "../components/Embeds/breakdown";
2024-10-05 15:57:34 -05:00
import type {
EmbedConfig,
ExtractEmbedConfigTypes,
2026-08-05 13:13:48 -05:00
} from "../stores/embedState";
import { EmbedItemType } from "../stores/embedState/constants";
2024-09-08 21:52:12 -05:00
export const breakdownConfig = {
width: { type: EmbedItemType.Slider, default: 320, min: 128, max: 640 },
height: { type: EmbedItemType.Slider, default: 492, min: 128, max: 1024 },
showTotal: { type: EmbedItemType.Boolean, default: true, pad: true },
2026-08-05 13:13:48 -05:00
listGap: { type: EmbedItemType.Size, default: "2" },
2024-09-08 21:52:12 -05:00
listMaxTanks: {
type: EmbedItemType.Slider,
default: 4,
min: 0,
max: 8,
pad: true,
},
2026-08-05 13:13:48 -05:00
cardRadius: { type: EmbedItemType.Radius, default: "2" },
2024-09-08 21:52:12 -05:00
cardHeaderBackgroundColor: {
type: EmbedItemType.Color,
default: grayDarkA.grayA3,
},
2026-08-05 13:13:48 -05:00
cardHeaderPadding: { type: EmbedItemType.Size, default: "1" },
2024-09-08 21:52:12 -05:00
cardTitle: {
type: EmbedItemType.RichText,
2026-08-05 13:13:48 -05:00
default: { color: grayDark.gray12, weight: "bold", size: "3" },
2024-09-08 21:52:12 -05:00
},
cardTitleTypeColor: { type: EmbedItemType.Boolean, default: true },
cardTitleClassIcon: { type: EmbedItemType.Boolean, default: true },
cardBodyBackgroundColor: {
type: EmbedItemType.Color,
default: grayA.grayA11,
},
cardBodyPadding: {
type: EmbedItemType.Size,
2026-08-05 13:13:48 -05:00
default: "2",
2024-09-08 21:52:12 -05:00
pad: true,
},
2026-08-05 13:13:48 -05:00
columnGap: { type: EmbedItemType.Size, default: "0" },
2024-09-08 21:52:12 -05:00
columnValue: {
type: EmbedItemType.RichText,
2026-08-05 13:13:48 -05:00
default: { color: grayDark.gray12, size: "3", weight: "regular" },
2024-09-08 21:52:12 -05:00
},
columnLabel: {
type: EmbedItemType.RichText,
2026-08-05 13:13:48 -05:00
default: { color: grayDark.gray11, size: "2", weight: "regular" },
2024-09-08 21:52:12 -05:00
pad: true,
},
column1: {
type: EmbedItemType.Enum,
2026-08-05 13:13:48 -05:00
default: "cumulative_battles" satisfies CompositeStatsKey,
2024-09-08 21:52:12 -05:00
options: compositeStatsKeysOptions,
},
column2: {
type: EmbedItemType.Enum,
2026-08-05 13:13:48 -05:00
default: "normalized_wins" satisfies CompositeStatsKey,
2024-09-08 21:52:12 -05:00
options: compositeStatsKeysOptions,
},
column3: {
type: EmbedItemType.Enum,
2026-08-05 13:13:48 -05:00
default: "cumulative_wn8" satisfies CompositeStatsKey,
2024-09-08 21:52:12 -05:00
options: compositeStatsKeysOptions,
},
column4: {
type: EmbedItemType.Enum,
2026-08-05 13:13:48 -05:00
default: "normalized_damage_dealt" satisfies CompositeStatsKey,
2024-09-08 21:52:12 -05:00
options: compositeStatsKeysOptions,
},
2026-08-05 13:13:48 -05:00
column1CustomLabel: { type: EmbedItemType.String, default: "" },
column2CustomLabel: { type: EmbedItemType.String, default: "" },
column3CustomLabel: { type: EmbedItemType.String, default: "" },
column4CustomLabel: { type: EmbedItemType.String, default: "" },
2024-09-08 21:52:12 -05:00
} satisfies EmbedConfig;
2024-10-26 19:46:35 -05:00
export const embedConfigurations = {
2024-09-08 21:52:12 -05:00
breakdown: breakdownConfig,
} satisfies Record<string, EmbedConfig>;
2024-10-26 19:46:35 -05:00
export const embedPreviews = {
2024-09-08 21:52:12 -05:00
breakdown: BreakdownPreview,
} satisfies Record<string, () => ReactNode>;
2026-08-05 13:13:48 -05:00
2024-09-08 21:54:05 -05:00
export function extractEmbedConfigDefaults<Config extends EmbedConfig>(
config: Config,
) {
return Object.fromEntries(
Object.entries(config).map(([key, value]) => [key, value.default]),
) as ExtractEmbedConfigTypes<Config>;
}
2024-10-27 22:29:28 -05:00
export const embedRenderers = {
breakdown: BreakdownRenderer,
} satisfies Record<string, () => ReactNode>;