mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 04:14:12 +01:00
migrated embed
This commit is contained in:
98 files changed
+1979
-1376
No files matched your search
@@ -25,6 +25,83 @@
|
||||
"clear": "Clear"
|
||||
},
|
||||
|
||||
"embed": {
|
||||
"coming_soon": "More embeds coming soon.",
|
||||
"suggest": "Suggest ideas.",
|
||||
"preview": {
|
||||
"title": "Example preview",
|
||||
"upload": "Upload test background"
|
||||
},
|
||||
"configuration": {
|
||||
"import": {
|
||||
"title": "Import",
|
||||
"description": "Paste your current URL if you have one already to import your settings",
|
||||
"hint": "Paste URL...",
|
||||
"apply": "Apply",
|
||||
"applied": "Applied!",
|
||||
"idiot_title": "Invalid URL",
|
||||
"idiot_description": "Try pasting the URL that BlitzKit previously generated, you silly goose!",
|
||||
"idiot_button": "Okay, my bad"
|
||||
},
|
||||
"export": {
|
||||
"title": "Export",
|
||||
"description": "Copy all properties for you streaming software",
|
||||
"generate": {
|
||||
"button": "Generate URL",
|
||||
"title": "Generate URL",
|
||||
"subtitle": "Search an account to track",
|
||||
"cancel": "Cancel",
|
||||
"success": {
|
||||
"title": "Copy URL",
|
||||
"info": "Generated the URL for {name}. The embed will start tracking as soon as the URL is pasted. Reset at any time by right-clicking on PC or long-pressing on mobile and then selecting \"Reset\".",
|
||||
"back": "Back",
|
||||
"copy": "Copy URL"
|
||||
}
|
||||
},
|
||||
"css": "Copy CSS",
|
||||
"width": "Copy Width",
|
||||
"height": "Copy Height",
|
||||
"framerate": "Copy Framerate"
|
||||
},
|
||||
"customize": {
|
||||
"title": "Customize",
|
||||
"reset": "Reset",
|
||||
"description": "Bells and whistles of your embed"
|
||||
}
|
||||
},
|
||||
"types": {
|
||||
"breakdown": {
|
||||
"name": "Breakdown",
|
||||
"reset": "Reset",
|
||||
"options": {
|
||||
"width": "Width",
|
||||
"height": "Height",
|
||||
"show_total": "Show total",
|
||||
"list_gap": "List gap",
|
||||
"list_max_tanks": "Max tanks",
|
||||
"card_radius": "Card radius",
|
||||
"card_header_background_color": "Card header background color",
|
||||
"card_header_padding": "Card header padding",
|
||||
"card_title": "Card title",
|
||||
"card_title_type_color": "Card title type color",
|
||||
"card_title_class_icon": "Card title class icon",
|
||||
"card_body_background_color": "Card body background color",
|
||||
"card_body_padding": "Card body padding",
|
||||
"column_gap": "Column gap",
|
||||
"column_value": "Column value",
|
||||
"column_label": "Column label",
|
||||
"column_1": "Column 1",
|
||||
"column_2": "Column 2",
|
||||
"column_3": "Column 3",
|
||||
"column_4": "Column 4",
|
||||
"column_1_custom_label": "Column 1 label",
|
||||
"column_2_custom_label": "Column 2 label",
|
||||
"column_3_custom_label": "Column 3 label"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"compare": {
|
||||
"no_tanks": {
|
||||
"title": "No tanks to compare",
|
||||
|
||||
@@ -16,7 +16,7 @@ export default defineConfig({
|
||||
outDir: "../../dist/website",
|
||||
prefetch: { defaultStrategy: "hover", prefetchAll: true },
|
||||
|
||||
build: { concurrency: 4 },
|
||||
build: { concurrency: 4, inlineStylesheets: "never" },
|
||||
|
||||
integrations: [
|
||||
favicons({
|
||||
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
@@ -0,0 +1,50 @@
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
gap: var(--space-2);
|
||||
|
||||
box-sizing: border-box;
|
||||
border-radius: var(--radius-max);
|
||||
outline-offset: calc(-1 * var(--space-1));
|
||||
|
||||
font-weight: var(--weight-medium);
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
|
||||
&[data-size="minor"] {
|
||||
padding: var(--space-2) var(--space-3);
|
||||
font-size: var(--font-size-minor);
|
||||
}
|
||||
|
||||
&[data-size="regular"] {
|
||||
padding: var(--space-3) var(--space-4);
|
||||
font-size: var(--font-size-regular);
|
||||
}
|
||||
|
||||
&[data-variant="solid"] {
|
||||
background-color: var(--accent-8);
|
||||
color: var(--white-a12);
|
||||
}
|
||||
|
||||
&[data-variant="soft"] {
|
||||
background-color: var(--accent-a3);
|
||||
color: var(--accent-a11);
|
||||
}
|
||||
|
||||
&[data-variant="surface"] {
|
||||
background-color: var(--accent-a2);
|
||||
outline: var(--space-1) solid var(--accent-5);
|
||||
color: var(--accent-a11);
|
||||
}
|
||||
|
||||
&[data-variant="outline"] {
|
||||
outline: var(--space-1) solid var(--accent-5);
|
||||
color: var(--accent-a11);
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { ComponentProps } from "react";
|
||||
import { classNames } from "../../ui/classNames";
|
||||
import type { Color } from "../../ui/color";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export interface BadgeProps extends ComponentProps<"span"> {
|
||||
color?: Color;
|
||||
variant?: "solid" | "soft" | "surface" | "outline";
|
||||
size?: "minor" | "regular";
|
||||
}
|
||||
|
||||
export function Badge({
|
||||
className,
|
||||
color,
|
||||
variant = "soft",
|
||||
size = "minor",
|
||||
...props
|
||||
}: BadgeProps) {
|
||||
return (
|
||||
<span
|
||||
className={classNames(styles.badge, className)}
|
||||
data-accent={color}
|
||||
data-variant={variant}
|
||||
data-size={size}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +1,27 @@
|
||||
---
|
||||
import "@fontsource-variable/jetbrains-mono";
|
||||
import "@fontsource-variable/roboto-flex";
|
||||
import { spaces, weights } from "../config/styles";
|
||||
|
||||
let styles = "";
|
||||
|
||||
styles += ":root{";
|
||||
|
||||
spaces.forEach((space, index) => {
|
||||
styles += `--space-${index}:${space}rem;`;
|
||||
});
|
||||
|
||||
for (const weight in weights) {
|
||||
styles += `--weight-${weight}:${weights[weight as keyof typeof weights]};`;
|
||||
}
|
||||
|
||||
styles += "}";
|
||||
---
|
||||
|
||||
<style set:html={styles}></style>
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--space-0: 0.0625rem;
|
||||
--space-1: 0.125rem;
|
||||
--space-2: 0.25rem;
|
||||
--space-3: 0.5rem;
|
||||
--space-4: 1rem;
|
||||
--space-5: 2rem;
|
||||
--space-6: 4rem;
|
||||
--space-7: 8rem;
|
||||
--space-8: 16rem;
|
||||
--space-9: 32rem;
|
||||
|
||||
--page-width: 64rem;
|
||||
|
||||
--max-size: max(100vw, 100vh);
|
||||
@@ -38,21 +44,9 @@ import "@fontsource-variable/roboto-flex";
|
||||
--color-regular: var(--gray-12);
|
||||
--color-low-contrast: var(--gray-11);
|
||||
|
||||
--weight-light: 300;
|
||||
--weight-regular: 400;
|
||||
--weight-medium: 500;
|
||||
--weight-bold: 700;
|
||||
--weight-black: 900;
|
||||
|
||||
--outline-interactive: var(--space-1) solid var(--gray-4);
|
||||
--outline-focus: var(--space-1) solid var(--accent-6);
|
||||
|
||||
/* --shadow-cavity:
|
||||
inset calc(var(--space-1) * sin(45deg)) calc(var(--space-1) * sin(45deg))
|
||||
var(--space-1) var(--black-a3),
|
||||
inset calc(var(--space-1) * sin(45deg) * -1)
|
||||
calc(var(--space-1) * sin(45deg) * -1) var(--space-1) var(--white-a1); */
|
||||
|
||||
--shadow-bump:
|
||||
inset calc(var(--space-1) * sin(45deg)) calc(var(--space-1) * sin(45deg))
|
||||
var(--space-1) var(--white-a3),
|
||||
@@ -62,17 +56,6 @@ import "@fontsource-variable/roboto-flex";
|
||||
--shadow-outline-width: 1.5px;
|
||||
--shadow-outline-width-negative: calc(var(--shadow-outline-width) * -1);
|
||||
|
||||
/* --shadow-interactive-background: 0 0 0 var(--shadow-outline-width)
|
||||
var(--gray-6);
|
||||
--shadow-interactive-shine: var(--shadow-outline-width-negative)
|
||||
var(--shadow-outline-width-negative) var(--shadow-outline-width)
|
||||
var(--white-a1);
|
||||
--shadow-interactive-shadow: var(--shadow-outline-width)
|
||||
var(--shadow-outline-width) var(--shadow-outline-width) var(--black-a4);
|
||||
--shadow-interactive:
|
||||
var(--shadow-interactive-shine), var(--shadow-interactive-shadow),
|
||||
var(--shadow-interactive-background); */
|
||||
|
||||
--shadow-aggressive: var(--space-1) var(--space-1) var(--space-4)
|
||||
var(--black-a11);
|
||||
--shadow-subtle: 0 var(--space-1) var(--space-3) var(--black-a5);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--space-3);
|
||||
|
||||
cursor: pointer;
|
||||
@@ -116,6 +117,7 @@
|
||||
&[data-variant="surface"],
|
||||
&[data-variant="outline"] {
|
||||
outline: var(--space-1) solid var(--accent-5);
|
||||
outline-offset: calc(-1 * var(--space-1));
|
||||
|
||||
&[data-high-contrast="true"] {
|
||||
outline: var(--space-1) solid var(--accent-11);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
@import "../DropdownMenu/index.module.css";
|
||||
|
||||
.Content,
|
||||
.SubContent {
|
||||
max-height: calc(
|
||||
var(--radix-context-menu-content-available-height) - var(--space-6)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ContextMenu as _ } from "radix-ui";
|
||||
import { composeRadixComponents } from "../../ui/compose";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export const ContextMenu = composeRadixComponents(_, styles);
|
||||
@@ -1,19 +1,23 @@
|
||||
import { Button, type ButtonProps, Tooltip } from '@radix-ui/themes';
|
||||
import { useState } from 'react';
|
||||
import { useLocale } from '../hooks/useLocale';
|
||||
import { useState } from "react";
|
||||
import { useStrings } from "../hooks/useStrings";
|
||||
import { Button, type ButtonProps } from "./Button";
|
||||
import { Tooltip } from "./Tooltip";
|
||||
|
||||
const COPIED_TOOLTIP_DURATION = 2000;
|
||||
|
||||
interface CopyButtonProps extends ButtonProps {
|
||||
copy: () => string | undefined;
|
||||
}
|
||||
|
||||
export function CopyButton({ copy, ...props }: CopyButtonProps) {
|
||||
export function CopyButton({ copy, style, ...props }: CopyButtonProps) {
|
||||
const [tooltipOpen, setTooltipOpen] = useState(false);
|
||||
const { strings } = useLocale();
|
||||
const strings = useStrings();
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
open={tooltipOpen}
|
||||
content={strings.website.common.copy_button.copied}
|
||||
tooltip={strings.website.common.copy_button.copied}
|
||||
style={style}
|
||||
>
|
||||
<Button
|
||||
{...props}
|
||||
@@ -24,7 +28,7 @@ export function CopyButton({ copy, ...props }: CopyButtonProps) {
|
||||
|
||||
navigator.clipboard.writeText(content);
|
||||
setTooltipOpen(true);
|
||||
setTimeout(() => setTooltipOpen(false), 2000);
|
||||
setTimeout(() => setTooltipOpen(false), COPIED_TOOLTIP_DURATION);
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
|
||||
box-sizing: border-box;
|
||||
width: calc(100dvw - 2 * var(--space-4));
|
||||
max-width: 40rem;
|
||||
max-height: calc(100dvh - 2 * var(--space-4));
|
||||
padding: var(--space-4);
|
||||
overflow: hidden;
|
||||
|
||||
background-color: var(--gray-2);
|
||||
@@ -45,17 +47,10 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
|
||||
padding: var(--space-4);
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.body {
|
||||
--scroller-curtain-color: var(--gray-2);
|
||||
|
||||
flex: 1;
|
||||
|
||||
.content {
|
||||
padding: var(--space-4);
|
||||
}
|
||||
}
|
||||
@@ -11,19 +11,13 @@ function Header({ className, ...props }: ComponentProps<"div">) {
|
||||
}
|
||||
|
||||
// Scrolls the content that follows the header
|
||||
function Body({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: ComponentProps<typeof Scroller>) {
|
||||
function Body({ className, ...props }: ComponentProps<typeof Scroller>) {
|
||||
return (
|
||||
<Scroller
|
||||
orientation={ScrollerOrientation.Vertical}
|
||||
className={classNames(styles.body, className)}
|
||||
{...props}
|
||||
>
|
||||
<div className={styles.content}>{children}</div>
|
||||
</Scroller>
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { assertSecret } from '@blitzkit/core';
|
||||
import { CaretRightIcon } from '@radix-ui/react-icons';
|
||||
import { Box, Button, Flex, Link, Text } from '@radix-ui/themes';
|
||||
import { times } from 'lodash-es';
|
||||
import { discordLink } from '../../config/socials';
|
||||
import { getStrings } from '../../core/i18n/getStrings';
|
||||
import { Var } from '../../core/radix/var';
|
||||
import type { LocaleAcceptorProps } from '../../hooks/useLocale';
|
||||
@@ -161,7 +162,7 @@ export function DiscordPlug({
|
||||
<Flex justify="center" flexGrow="1" flexShrink="0">
|
||||
<Link
|
||||
style={{ display: 'contents' }}
|
||||
href="https://discord.gg/nDt7AjGJQH"
|
||||
href={discordLink}
|
||||
target="_blank"
|
||||
>
|
||||
<Flex
|
||||
|
||||
@@ -76,6 +76,10 @@
|
||||
border-bottom: var(--space-1) solid var(--gray-2);
|
||||
}
|
||||
|
||||
&[data-accent] {
|
||||
color: var(--accent-11);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is actually .ItemText, but its class name isn't being passed to the
|
||||
* html, so I am selecting the span instead.
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Switch } from "@radix-ui/themes";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
import { Switch } from "../Switch";
|
||||
|
||||
export function Boolean({ configKey }: EmbedPreviewControllerProps) {
|
||||
return (
|
||||
<Switch
|
||||
variant="classic"
|
||||
checked={EmbedState.use((state) => state[configKey] as boolean)}
|
||||
onCheckedChange={() => {
|
||||
EmbedState.mutate((draft) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Slider } from '@radix-ui/themes';
|
||||
import { RangeSlider } from "./RangeSlider";
|
||||
|
||||
interface ColorControllerRawProps {
|
||||
value: string;
|
||||
@@ -20,17 +20,16 @@ export function ColorControllerRaw({
|
||||
value={value.slice(0, 7)}
|
||||
onChange={(event) => {
|
||||
let alpha = value.slice(7, 9);
|
||||
if (alpha.length === 0) alpha = 'ff';
|
||||
if (alpha.length === 0) alpha = "ff";
|
||||
onValueChange(`${event.target.value}${alpha}`);
|
||||
}}
|
||||
/>
|
||||
<Slider
|
||||
variant="classic"
|
||||
<RangeSlider
|
||||
min={0}
|
||||
max={255}
|
||||
value={[alpha]}
|
||||
onValueChange={([value]) => {
|
||||
onValueChange(`${tintString}${value.toString(16)}`);
|
||||
value={alpha}
|
||||
onValueChange={(value) => {
|
||||
onValueChange(`${tintString}${value.toString(16).padStart(2, "0")}`);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Select } from "@radix-ui/themes";
|
||||
import { CaretDownIcon, DotFilledIcon } from "@radix-ui/react-icons";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
EmbedConfigItemType,
|
||||
EmbedItemType,
|
||||
} from "../../stores/embedState/constants";
|
||||
import { Select } from "../Select";
|
||||
|
||||
export function Enum({
|
||||
configKey,
|
||||
@@ -13,26 +14,45 @@ export function Enum({
|
||||
}: EmbedPreviewControllerProps & {
|
||||
config: EmbedConfigItemType<EmbedItemType.Enum>;
|
||||
}) {
|
||||
const { locale } = useLocale();
|
||||
const locale = useLocale();
|
||||
const value = EmbedState.use((state) => state[configKey] as string);
|
||||
|
||||
// Passed as children so the label renders before hydration
|
||||
const label = config.options.find((option) => option.value === value)!
|
||||
.locales[locale];
|
||||
|
||||
return (
|
||||
<Select.Root
|
||||
value={EmbedState.use((state) => state[configKey] as string)}
|
||||
value={value}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
draft[configKey] = value;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Select.Trigger variant="classic" />
|
||||
<Select.Trigger>
|
||||
<Select.Value>{label}</Select.Value>
|
||||
|
||||
<Select.Content>
|
||||
{config.options.map((option) => (
|
||||
<Select.Item key={option.value} value={option.value}>
|
||||
{option.locales[locale]}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Content>
|
||||
<Select.Icon>
|
||||
<CaretDownIcon />
|
||||
</Select.Icon>
|
||||
</Select.Trigger>
|
||||
|
||||
<Select.Portal>
|
||||
<Select.Content>
|
||||
<Select.Viewport>
|
||||
{config.options.map((option) => (
|
||||
<Select.Item key={option.value} value={option.value}>
|
||||
<Select.ItemIndicator>
|
||||
<DotFilledIcon />
|
||||
</Select.ItemIndicator>
|
||||
|
||||
<Select.ItemText>{option.locales[locale]}</Select.ItemText>
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Viewport>
|
||||
</Select.Content>
|
||||
</Select.Portal>
|
||||
</Select.Root>
|
||||
);
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
import {
|
||||
searchPlayersAcrossRegions,
|
||||
type AccountListItem,
|
||||
type AccountListWithServer,
|
||||
} from "@blitzkit/core";
|
||||
import { literals } from "@blitzkit/i18n/src/literals";
|
||||
import { CaretLeftIcon, Link2Icon, PersonIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
Flex,
|
||||
Heading,
|
||||
Spinner,
|
||||
Text,
|
||||
TextField,
|
||||
} from "@radix-ui/themes";
|
||||
import { debounce } from "lodash-es";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { stringify } from "urlon";
|
||||
import type { embedConfigurations } from "../../constants/embeds";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import { EmbedState, type EmbedStateStore } from "../../stores/embedState";
|
||||
import { CopyButton } from "../CopyButton";
|
||||
import { SearchResults } from "../SearchResults";
|
||||
|
||||
interface GenerateURLProps {
|
||||
embed: keyof typeof embedConfigurations;
|
||||
}
|
||||
|
||||
export function GenerateURL({ embed }: GenerateURLProps) {
|
||||
const [searchDialogOpen, setSearchDialogOpen] = useState(false);
|
||||
const [copyDialogOpen, setCopyDialogOpen] = useState(false);
|
||||
const [copyUser, setCopyUser] = useState<AccountListItem | null>(null);
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [results, setResults] = useState<AccountListWithServer>([]);
|
||||
const { strings } = useLocale();
|
||||
const performSearch = useCallback(
|
||||
debounce(async () => {
|
||||
if (!input.current) return;
|
||||
|
||||
const sanitized = input.current.value.trim();
|
||||
|
||||
if (sanitized.length === 0) {
|
||||
setSearching(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const results = await searchPlayersAcrossRegions(sanitized, 12);
|
||||
|
||||
setSearching(false);
|
||||
setResults(results);
|
||||
}, 500),
|
||||
[]
|
||||
);
|
||||
const handleChange = useCallback(() => {
|
||||
if (!input.current) return;
|
||||
|
||||
const sanitized = input.current.value.trim();
|
||||
|
||||
if (sanitized.length === 0) {
|
||||
setSearching(false);
|
||||
setResults([]);
|
||||
} else {
|
||||
setSearching(true);
|
||||
performSearch();
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog.Root open={searchDialogOpen} onOpenChange={setSearchDialogOpen}>
|
||||
<Dialog.Trigger>
|
||||
<Button>
|
||||
<Link2Icon />
|
||||
{strings.website.tools.embed.configuration.export.generate.button}
|
||||
</Button>
|
||||
</Dialog.Trigger>
|
||||
|
||||
<Dialog.Content width="fit-content">
|
||||
<Flex direction="column" gap="1">
|
||||
<Heading size="5">
|
||||
{strings.website.tools.embed.configuration.export.generate.title}
|
||||
</Heading>
|
||||
<Text color="gray">
|
||||
{
|
||||
strings.website.tools.embed.configuration.export.generate
|
||||
.subtitle
|
||||
}
|
||||
</Text>
|
||||
</Flex>
|
||||
|
||||
<TextField.Root
|
||||
variant="classic"
|
||||
mt="4"
|
||||
style={{ width: "20rem" }}
|
||||
placeholder={strings.website.common.player_search.hint}
|
||||
ref={input}
|
||||
onChange={handleChange}
|
||||
>
|
||||
<TextField.Slot>
|
||||
<PersonIcon />
|
||||
</TextField.Slot>
|
||||
</TextField.Root>
|
||||
|
||||
<Flex justify="center" my="6">
|
||||
{searching && (
|
||||
<Text color="gray">
|
||||
<Flex align="center" gap="2">
|
||||
<Spinner /> {strings.website.common.player_search.searching}
|
||||
</Flex>
|
||||
</Text>
|
||||
)}
|
||||
{!searching && results.length === 0 && (
|
||||
<Text color="gray">
|
||||
{strings.website.common.player_search.no_results}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{!searching && results.length > 0 && (
|
||||
<SearchResults.Root>
|
||||
{results.map((result) => (
|
||||
<SearchResults.Item
|
||||
text={result.nickname}
|
||||
discriminator={strings.common.regions.short[result.region]}
|
||||
onClick={() => {
|
||||
setCopyUser(result);
|
||||
setCopyDialogOpen(true);
|
||||
setSearchDialogOpen(false);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</SearchResults.Root>
|
||||
)}
|
||||
</Flex>
|
||||
|
||||
<Dialog.Close>
|
||||
<Button color="red" variant="outline" style={{ width: "100%" }}>
|
||||
{strings.website.tools.embed.configuration.export.generate.cancel}
|
||||
</Button>
|
||||
</Dialog.Close>
|
||||
</Dialog.Content>
|
||||
</Dialog.Root>
|
||||
|
||||
<Dialog.Root open={copyDialogOpen} onOpenChange={setCopyDialogOpen}>
|
||||
<Dialog.Content style={{ width: "fit-content" }}>
|
||||
<Flex direction="column" gap="1">
|
||||
<Heading size="5">
|
||||
{
|
||||
strings.website.tools.embed.configuration.export.generate
|
||||
.success.title
|
||||
}
|
||||
</Heading>
|
||||
<Text color="gray">
|
||||
{literals(
|
||||
strings.website.tools.embed.configuration.export.generate
|
||||
.success.info,
|
||||
{ name: copyUser?.nickname }
|
||||
)}
|
||||
</Text>
|
||||
</Flex>
|
||||
|
||||
<Flex gap="2" mt="4">
|
||||
<Button
|
||||
style={{ flex: 1 }}
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setCopyDialogOpen(false);
|
||||
setSearchDialogOpen(true);
|
||||
}}
|
||||
>
|
||||
<CaretLeftIcon />{" "}
|
||||
{
|
||||
strings.website.tools.embed.configuration.export.generate
|
||||
.success.back
|
||||
}
|
||||
</Button>
|
||||
<CopyButton
|
||||
style={{ flex: 1 }}
|
||||
copy={() => {
|
||||
if (!copyUser) return;
|
||||
|
||||
const shallowState: EmbedStateStore = {};
|
||||
|
||||
Object.entries(EmbedState.state).forEach(([key, value]) => {
|
||||
if (value !== EmbedState.initial[key]) {
|
||||
shallowState[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
const searchParams = new URLSearchParams({
|
||||
id: `${copyUser.account_id}`,
|
||||
state: stringify(shallowState),
|
||||
});
|
||||
|
||||
setSearchDialogOpen(false);
|
||||
setCopyDialogOpen(false);
|
||||
|
||||
return `${location.origin}/embed/${embed}/host?${searchParams.toString()}`;
|
||||
}}
|
||||
>
|
||||
<Link2Icon />{" "}
|
||||
{
|
||||
strings.website.tools.embed.configuration.export.generate
|
||||
.success.copy
|
||||
}
|
||||
</CopyButton>
|
||||
</Flex>
|
||||
</Dialog.Content>
|
||||
</Dialog.Root>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
.content {
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.search {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.results {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.searching {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
import {
|
||||
searchPlayersAcrossRegions,
|
||||
type AccountListItem,
|
||||
type AccountListWithServer,
|
||||
} from "@blitzkit/core";
|
||||
import { literals } from "@blitzkit/i18n";
|
||||
import { CaretLeftIcon, Link2Icon, PersonIcon } from "@radix-ui/react-icons";
|
||||
import { debounce } from "lodash-es";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { stringify } from "urlon";
|
||||
import type { embedConfigurations } from "../../../constants/embeds";
|
||||
import { useStrings } from "../../../hooks/useStrings";
|
||||
import { EmbedState, type EmbedStateStore } from "../../../stores/embedState";
|
||||
import { AlertDialog } from "../../AlertDialog";
|
||||
import { Button } from "../../Button";
|
||||
import { CopyButton } from "../../CopyButton";
|
||||
import { Dialog } from "../../Dialog";
|
||||
import { SearchResults } from "../../SearchResults";
|
||||
import { Spinner } from "../../Spinner";
|
||||
import { Text } from "../../Text";
|
||||
import { TextField } from "../../TextField";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
interface GenerateURLProps {
|
||||
embed: keyof typeof embedConfigurations;
|
||||
}
|
||||
|
||||
export function GenerateURL({ embed }: GenerateURLProps) {
|
||||
const [searchDialogOpen, setSearchDialogOpen] = useState(false);
|
||||
const [copyDialogOpen, setCopyDialogOpen] = useState(false);
|
||||
const [copyUser, setCopyUser] = useState<AccountListItem | null>(null);
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [results, setResults] = useState<AccountListWithServer>([]);
|
||||
const strings = useStrings();
|
||||
const generateStrings = strings.embed.configuration.export.generate;
|
||||
|
||||
const performSearch = useCallback(
|
||||
debounce(async () => {
|
||||
if (!input.current) return;
|
||||
|
||||
const sanitized = input.current.value.trim();
|
||||
|
||||
if (sanitized.length === 0) {
|
||||
setSearching(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const results = await searchPlayersAcrossRegions(sanitized, 12);
|
||||
|
||||
setSearching(false);
|
||||
setResults(results);
|
||||
}, 500),
|
||||
[]
|
||||
);
|
||||
|
||||
const handleChange = useCallback(() => {
|
||||
if (!input.current) return;
|
||||
|
||||
const sanitized = input.current.value.trim();
|
||||
|
||||
if (sanitized.length === 0) {
|
||||
setSearching(false);
|
||||
setResults([]);
|
||||
} else {
|
||||
setSearching(true);
|
||||
performSearch();
|
||||
}
|
||||
}, [performSearch]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog.Root open={searchDialogOpen} onOpenChange={setSearchDialogOpen}>
|
||||
<Dialog.Trigger asChild>
|
||||
<Button>
|
||||
<Link2Icon />
|
||||
{generateStrings.button}
|
||||
</Button>
|
||||
</Dialog.Trigger>
|
||||
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay />
|
||||
<Dialog.Content className={styles.content}>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{generateStrings.title}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
{generateStrings.subtitle}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
|
||||
<Dialog.Body>
|
||||
<div className={styles.search}>
|
||||
<TextField
|
||||
placeholder={strings.common.search.hint_players}
|
||||
ref={input}
|
||||
onChange={handleChange}
|
||||
>
|
||||
<PersonIcon />
|
||||
</TextField>
|
||||
|
||||
<div className={styles.results}>
|
||||
{searching && (
|
||||
<Text lowContrast className={styles.searching}>
|
||||
<Spinner />
|
||||
{strings.common.search.searching}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{!searching && results.length === 0 && (
|
||||
<Text lowContrast>{strings.common.search.no_results}</Text>
|
||||
)}
|
||||
|
||||
{!searching && results.length > 0 && (
|
||||
<SearchResults.Root>
|
||||
{results.map((result) => (
|
||||
<SearchResults.Item
|
||||
key={`${result.region}-${result.account_id}`}
|
||||
text={result.nickname}
|
||||
discriminator={
|
||||
strings.common.regions.short[result.region]
|
||||
}
|
||||
onClick={() => {
|
||||
setCopyUser(result);
|
||||
setCopyDialogOpen(true);
|
||||
setSearchDialogOpen(false);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</SearchResults.Root>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Body>
|
||||
|
||||
<AlertDialog.Actions>
|
||||
<Dialog.Close asChild>
|
||||
<Button color="red" variant="outline">
|
||||
{generateStrings.cancel}
|
||||
</Button>
|
||||
</Dialog.Close>
|
||||
</AlertDialog.Actions>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
|
||||
<Dialog.Root open={copyDialogOpen} onOpenChange={setCopyDialogOpen}>
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay />
|
||||
<Dialog.Content className={styles.content}>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{generateStrings.success.title}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
{literals(generateStrings.success.info, {
|
||||
name: copyUser?.nickname,
|
||||
})}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
|
||||
<AlertDialog.Actions>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setCopyDialogOpen(false);
|
||||
setSearchDialogOpen(true);
|
||||
}}
|
||||
>
|
||||
<CaretLeftIcon />
|
||||
{generateStrings.success.back}
|
||||
</Button>
|
||||
<CopyButton
|
||||
copy={() => {
|
||||
if (!copyUser) return;
|
||||
|
||||
const shallowState: EmbedStateStore = {};
|
||||
|
||||
Object.entries(EmbedState.state).forEach(([key, value]) => {
|
||||
if (value !== EmbedState.initial[key]) {
|
||||
shallowState[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
const searchParams = new URLSearchParams({
|
||||
id: `${copyUser.account_id}`,
|
||||
state: stringify(shallowState),
|
||||
});
|
||||
|
||||
setSearchDialogOpen(false);
|
||||
setCopyDialogOpen(false);
|
||||
|
||||
return `${
|
||||
location.origin
|
||||
}/embed/${embed}/host?${searchParams.toString()}`;
|
||||
}}
|
||||
>
|
||||
<Link2Icon />
|
||||
{generateStrings.success.copy}
|
||||
</CopyButton>
|
||||
</AlertDialog.Actions>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
import {
|
||||
AlertDialog,
|
||||
Button,
|
||||
Flex,
|
||||
Heading,
|
||||
Text,
|
||||
TextField,
|
||||
Tooltip,
|
||||
} from "@radix-ui/themes";
|
||||
import { useRef, useState } from "react";
|
||||
import { parse } from "urlon";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
|
||||
export function Import() {
|
||||
const importInput = useRef<HTMLInputElement>(null);
|
||||
const [showInvalidURLPrompt, setShowInvalidURLPrompt] = useState(false);
|
||||
const [showConfirmation, setConfirmation] = useState(false);
|
||||
const { strings } = useLocale();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Heading>
|
||||
{strings.website.tools.embed.configuration.import.title}
|
||||
</Heading>
|
||||
<Text size="2" color="gray" mb="2">
|
||||
{strings.website.tools.embed.configuration.import.description}
|
||||
</Text>
|
||||
|
||||
<AlertDialog.Root
|
||||
open={showInvalidURLPrompt}
|
||||
onOpenChange={setShowInvalidURLPrompt}
|
||||
>
|
||||
<AlertDialog.Content>
|
||||
<AlertDialog.Title>
|
||||
{strings.website.tools.embed.configuration.import.idiot_title}
|
||||
</AlertDialog.Title>
|
||||
<AlertDialog.Description>
|
||||
{strings.website.tools.embed.configuration.import.idiot_description}
|
||||
</AlertDialog.Description>
|
||||
|
||||
<Flex gap="3" mt="4" justify="end">
|
||||
<AlertDialog.Cancel>
|
||||
<Button>
|
||||
{strings.website.tools.embed.configuration.import.idiot_button}
|
||||
</Button>
|
||||
</AlertDialog.Cancel>
|
||||
</Flex>
|
||||
</AlertDialog.Content>
|
||||
</AlertDialog.Root>
|
||||
|
||||
<Flex gap="2" mb="6">
|
||||
<TextField.Root
|
||||
variant="classic"
|
||||
ref={importInput}
|
||||
placeholder={strings.website.tools.embed.configuration.import.hint}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
<Tooltip content="Applied!" open={showConfirmation}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (!importInput.current) return;
|
||||
|
||||
try {
|
||||
const url = new URL(importInput.current.value);
|
||||
const state = url.searchParams.get("state");
|
||||
if (state === null) throw undefined;
|
||||
const json = parse(state);
|
||||
|
||||
EmbedState.mutate((draft) => {
|
||||
Object.assign(draft, json);
|
||||
});
|
||||
|
||||
importInput.current.value = "";
|
||||
setConfirmation(true);
|
||||
setTimeout(() => setConfirmation(false), 2000);
|
||||
} catch {
|
||||
setShowInvalidURLPrompt(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{strings.website.tools.embed.configuration.import.apply}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Flex>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
.description {
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.field {
|
||||
flex: 1;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { parse } from "urlon";
|
||||
import { useStrings } from "../../../hooks/useStrings";
|
||||
import { EmbedState } from "../../../stores/embedState";
|
||||
import { AlertDialog } from "../../AlertDialog";
|
||||
import { Button } from "../../Button";
|
||||
import { Heading } from "../../Heading";
|
||||
import { Text } from "../../Text";
|
||||
import { TextField } from "../../TextField";
|
||||
import { Tooltip } from "../../Tooltip";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export function Import() {
|
||||
const importInput = useRef<HTMLInputElement>(null);
|
||||
const [showInvalidURLPrompt, setShowInvalidURLPrompt] = useState(false);
|
||||
const [showConfirmation, setConfirmation] = useState(false);
|
||||
const strings = useStrings();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Heading size="3" weight="bold">
|
||||
{strings.embed.configuration.import.title}
|
||||
</Heading>
|
||||
<Text size="minor" lowContrast className={styles.description}>
|
||||
{strings.embed.configuration.import.description}
|
||||
</Text>
|
||||
|
||||
<AlertDialog.Root
|
||||
open={showInvalidURLPrompt}
|
||||
onOpenChange={setShowInvalidURLPrompt}
|
||||
>
|
||||
<AlertDialog.Portal>
|
||||
<AlertDialog.Overlay />
|
||||
<AlertDialog.Content>
|
||||
<AlertDialog.Title>
|
||||
{strings.embed.configuration.import.idiot_title}
|
||||
</AlertDialog.Title>
|
||||
<AlertDialog.Description>
|
||||
{strings.embed.configuration.import.idiot_description}
|
||||
</AlertDialog.Description>
|
||||
|
||||
<AlertDialog.Actions>
|
||||
<AlertDialog.Cancel asChild>
|
||||
<Button>
|
||||
{strings.embed.configuration.import.idiot_button}
|
||||
</Button>
|
||||
</AlertDialog.Cancel>
|
||||
</AlertDialog.Actions>
|
||||
</AlertDialog.Content>
|
||||
</AlertDialog.Portal>
|
||||
</AlertDialog.Root>
|
||||
|
||||
<div className={styles.row}>
|
||||
<TextField
|
||||
ref={importInput}
|
||||
placeholder={strings.embed.configuration.import.hint}
|
||||
className={styles.field}
|
||||
/>
|
||||
<Tooltip
|
||||
tooltip={strings.embed.configuration.import.applied}
|
||||
open={showConfirmation}
|
||||
>
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (!importInput.current) return;
|
||||
|
||||
try {
|
||||
const url = new URL(importInput.current.value);
|
||||
const state = url.searchParams.get("state");
|
||||
if (state === null) throw undefined;
|
||||
const json = parse(state);
|
||||
|
||||
EmbedState.mutate((draft) => {
|
||||
Object.assign(draft, json);
|
||||
});
|
||||
|
||||
importInput.current.value = "";
|
||||
setConfirmation(true);
|
||||
setTimeout(() => setConfirmation(false), 2000);
|
||||
} catch {
|
||||
setShowInvalidURLPrompt(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{strings.embed.configuration.import.apply}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import { Box } from "@radix-ui/themes";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { embedPreviews } from "../../constants/embeds";
|
||||
import { useEmbedStateCurry } from "../../stores/embedState/utilities";
|
||||
|
||||
interface PreviewWrapperProps {
|
||||
name: keyof typeof embedPreviews;
|
||||
naked?: boolean;
|
||||
}
|
||||
|
||||
export function PreviewWrapper({ name, naked }: PreviewWrapperProps) {
|
||||
const { useEmbedState } = useEmbedStateCurry();
|
||||
|
||||
const width = useEmbedState("width");
|
||||
const height = useEmbedState("height");
|
||||
|
||||
const Preview = embedPreviews[name];
|
||||
|
||||
const wrapper = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!wrapper.current) return;
|
||||
|
||||
wrapper.current.classList.remove("preview-container-animated");
|
||||
void wrapper.current.offsetWidth;
|
||||
wrapper.current.classList.add("preview-container-animated");
|
||||
}, [width, height]);
|
||||
|
||||
if (naked) {
|
||||
return (
|
||||
<Box
|
||||
position="absolute"
|
||||
top="0"
|
||||
left="50%"
|
||||
style={{ transform: "translate(-50%, 0) scale(0.75)" }}
|
||||
width={`${width}px`}
|
||||
height={`${height}px`}
|
||||
>
|
||||
<Preview />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box
|
||||
position="absolute"
|
||||
top="50%"
|
||||
left="50%"
|
||||
overflow="hidden"
|
||||
style={{ transform: naked ? "scale(0.25)" : "translate(-50%, -50%)" }}
|
||||
ref={wrapper}
|
||||
className="preview-container-animated"
|
||||
width={`${width}px`}
|
||||
height={`${height}px`}
|
||||
>
|
||||
<Preview />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
@keyframes fade-out-border {
|
||||
from {
|
||||
outline: var(--space-4) solid #ff0000ff;
|
||||
}
|
||||
to {
|
||||
outline: var(--space-3) solid #ff000000;
|
||||
}
|
||||
}
|
||||
|
||||
.naked {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0) scale(0.75);
|
||||
}
|
||||
|
||||
.preview {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.animated {
|
||||
animation: fade-out-border var(--duration-brief) linear;
|
||||
|
||||
&:hover {
|
||||
outline: 1rem solid #ff000080;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { embedPreviews } from "../../../constants/embeds";
|
||||
import { classNames } from "../../../ui/classNames";
|
||||
import { useEmbedStateCurry } from "../../../stores/embedState/utilities";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
interface PreviewWrapperProps {
|
||||
name: keyof typeof embedPreviews;
|
||||
naked?: boolean;
|
||||
}
|
||||
|
||||
export function PreviewWrapper({ name, naked }: PreviewWrapperProps) {
|
||||
const { useEmbedState } = useEmbedStateCurry();
|
||||
|
||||
const width = useEmbedState("width");
|
||||
const height = useEmbedState("height");
|
||||
|
||||
const Preview = embedPreviews[name];
|
||||
|
||||
const wrapper = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!wrapper.current) return;
|
||||
|
||||
wrapper.current.classList.remove(styles.animated);
|
||||
void wrapper.current.offsetWidth;
|
||||
wrapper.current.classList.add(styles.animated);
|
||||
}, [width, height]);
|
||||
|
||||
if (naked) {
|
||||
return (
|
||||
<div
|
||||
className={styles.naked}
|
||||
style={{ width: `${width}px`, height: `${height}px` }}
|
||||
>
|
||||
<Preview />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={wrapper}
|
||||
className={classNames(styles.preview, styles.animated)}
|
||||
style={{ width: `${width}px`, height: `${height}px` }}
|
||||
>
|
||||
<Preview />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,22 +1,20 @@
|
||||
import { Slider } from "@radix-ui/themes";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState, type RadixRadius } from "../../stores/embedState";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
import type { Radius } from "../../types/styles";
|
||||
import { RangeSlider } from "./RangeSlider";
|
||||
|
||||
export function Radius({ configKey }: EmbedPreviewControllerProps) {
|
||||
return (
|
||||
<Slider
|
||||
variant="classic"
|
||||
<RangeSlider
|
||||
min={0}
|
||||
max={5}
|
||||
value={[
|
||||
EmbedState.use((state) => {
|
||||
const radius = state[configKey] as RadixRadius;
|
||||
return radius === "full" ? 5 : parseInt(radius);
|
||||
}),
|
||||
]}
|
||||
onValueChange={([value]) => {
|
||||
max={10}
|
||||
value={EmbedState.use((state) => {
|
||||
const radius = state[configKey] as Radius;
|
||||
return radius === "full" ? 10 : parseInt(radius);
|
||||
})}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
draft[configKey] = value === 5 ? "full" : `${value}`;
|
||||
draft[configKey] = value === 10 ? "full" : `${value}`;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.root {
|
||||
flex: 1;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Slider } from "../../Slider";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
interface RangeSliderProps {
|
||||
min: number;
|
||||
max: number;
|
||||
value: number;
|
||||
onValueChange(value: number): void;
|
||||
}
|
||||
|
||||
export function RangeSlider({
|
||||
min,
|
||||
max,
|
||||
value,
|
||||
onValueChange,
|
||||
}: RangeSliderProps) {
|
||||
return (
|
||||
<Slider.Root
|
||||
className={styles.root}
|
||||
min={min}
|
||||
max={max}
|
||||
value={[value]}
|
||||
onValueChange={([value]) => onValueChange(value)}
|
||||
>
|
||||
<Slider.Track>
|
||||
<Slider.Range />
|
||||
</Slider.Track>
|
||||
<Slider.Thumb />
|
||||
</Slider.Root>
|
||||
);
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
import { FontBoldIcon, FontSizeIcon } from "@radix-ui/react-icons";
|
||||
import { Flex, Slider, Text } from "@radix-ui/themes";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState, type RadixSizeWithout0 } from "../../stores/embedState";
|
||||
import {
|
||||
radixTextWeights,
|
||||
type EmbedConfigItemType,
|
||||
type EmbedItemType,
|
||||
} from "../../stores/embedState/constants";
|
||||
import { ColorControllerRaw } from "./ColorControllerRaw";
|
||||
|
||||
export function RichText({ configKey }: EmbedPreviewControllerProps) {
|
||||
const state = EmbedState.use(
|
||||
(state) =>
|
||||
state[
|
||||
configKey
|
||||
] as EmbedConfigItemType<EmbedItemType.RichText>["default"],
|
||||
);
|
||||
|
||||
return (
|
||||
<Flex direction="column" flexGrow="1" gap="2">
|
||||
<Flex gap="2" align="center">
|
||||
<ColorControllerRaw
|
||||
value={state.color}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
(
|
||||
draft[
|
||||
configKey
|
||||
] as EmbedConfigItemType<EmbedItemType.RichText>["default"]
|
||||
).color = value;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
<Flex align="center" gap="2" py="2">
|
||||
<Text size="4" trim="both">
|
||||
<FontSizeIcon width="1em" height="1em" />
|
||||
</Text>
|
||||
<Slider
|
||||
variant="classic"
|
||||
min={1}
|
||||
max={9}
|
||||
value={[Number(state.size)]}
|
||||
onValueChange={([value]) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
(
|
||||
draft[
|
||||
configKey
|
||||
] as EmbedConfigItemType<EmbedItemType.RichText>["default"]
|
||||
).size = `${value}` as RadixSizeWithout0;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
<Flex align="center" gap="2" py="2">
|
||||
<Text size="4" trim="both">
|
||||
<FontBoldIcon width="1em" height="1em" />
|
||||
</Text>
|
||||
<Slider
|
||||
variant="classic"
|
||||
min={0}
|
||||
max={radixTextWeights.length - 1}
|
||||
value={[radixTextWeights.indexOf(state.weight)]}
|
||||
onValueChange={([value]) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
(
|
||||
draft[
|
||||
configKey
|
||||
] as EmbedConfigItemType<EmbedItemType.RichText>["default"]
|
||||
).weight = radixTextWeights[value];
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
.rich-text {
|
||||
flex: 1;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
|
||||
&[data-padded] {
|
||||
padding: var(--space-3) 0;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
flex-shrink: 0;
|
||||
width: var(--font-size-major);
|
||||
height: var(--font-size-major);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { FontBoldIcon, FontSizeIcon } from "@radix-ui/react-icons";
|
||||
import type { EmbedPreviewControllerProps } from "../../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { weights } from "../../../config/styles";
|
||||
import { EmbedState } from "../../../stores/embedState";
|
||||
import type {
|
||||
EmbedConfigItemType,
|
||||
EmbedItemType,
|
||||
} from "../../../stores/embedState/constants";
|
||||
import type { SpaceWithout0, Weight } from "../../../types/styles";
|
||||
import { ColorControllerRaw } from "../ColorControllerRaw";
|
||||
import { RangeSlider } from "../RangeSlider";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
const weightNames = Object.keys(weights) as Weight[];
|
||||
|
||||
type RichTextState = EmbedConfigItemType<EmbedItemType.RichText>["default"];
|
||||
|
||||
export function RichText({ configKey }: EmbedPreviewControllerProps) {
|
||||
const state = EmbedState.use((state) => state[configKey] as RichTextState);
|
||||
|
||||
return (
|
||||
<div className={styles["rich-text"]}>
|
||||
<div className={styles.row}>
|
||||
<ColorControllerRaw
|
||||
value={state.color}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
(draft[configKey] as RichTextState).color = value;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.row} data-padded>
|
||||
<FontSizeIcon className={styles.icon} />
|
||||
<RangeSlider
|
||||
min={1}
|
||||
max={9}
|
||||
value={Number(state.size)}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
(draft[configKey] as RichTextState).size =
|
||||
`${value}` as SpaceWithout0;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.row} data-padded>
|
||||
<FontBoldIcon className={styles.icon} />
|
||||
<RangeSlider
|
||||
min={0}
|
||||
max={weightNames.length - 1}
|
||||
value={weightNames.indexOf(state.weight)}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
(draft[configKey] as RichTextState).weight =
|
||||
weightNames[value];
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
import { Slider } from "@radix-ui/themes";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState, type RadixSize } from "../../stores/embedState";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
import type { Space } from "../../types/styles";
|
||||
import { RangeSlider } from "./RangeSlider";
|
||||
|
||||
export function Size({ configKey }: EmbedPreviewControllerProps) {
|
||||
return (
|
||||
<Slider
|
||||
variant="classic"
|
||||
<RangeSlider
|
||||
min={0}
|
||||
max={9}
|
||||
value={[
|
||||
EmbedState.use((state) => parseInt(state[configKey] as RadixSize)),
|
||||
]}
|
||||
onValueChange={([value]) => {
|
||||
value={EmbedState.use((state) => parseInt(state[configKey] as Space))}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
draft[configKey] = `${value}`;
|
||||
});
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
import { Slider } from "@radix-ui/themes";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState, type RadixSizeWithout0 } from "../../stores/embedState";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
import type { SpaceWithout0 } from "../../types/styles";
|
||||
import { RangeSlider } from "./RangeSlider";
|
||||
|
||||
export function SizeWithout0({ configKey }: EmbedPreviewControllerProps) {
|
||||
return (
|
||||
<Slider
|
||||
variant="classic"
|
||||
<RangeSlider
|
||||
min={1}
|
||||
max={9}
|
||||
value={[
|
||||
EmbedState.use((state) =>
|
||||
parseInt(state[configKey] as RadixSizeWithout0),
|
||||
),
|
||||
]}
|
||||
onValueChange={([value]) => {
|
||||
value={EmbedState.use((state) =>
|
||||
parseInt(state[configKey] as SpaceWithout0),
|
||||
)}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
draft[configKey] = `${value}`;
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Slider as RadixSlider } from "@radix-ui/themes";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState, type RadixSize } from "../../stores/embedState";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
import type {
|
||||
EmbedConfigItemType,
|
||||
EmbedItemType,
|
||||
} from "../../stores/embedState/constants";
|
||||
import { RangeSlider } from "./RangeSlider";
|
||||
|
||||
export function Slider({
|
||||
configKey,
|
||||
@@ -13,14 +13,11 @@ export function Slider({
|
||||
config: EmbedConfigItemType<EmbedItemType.Slider>;
|
||||
}) {
|
||||
return (
|
||||
<RadixSlider
|
||||
variant="classic"
|
||||
<RangeSlider
|
||||
min={config.min}
|
||||
max={config.max}
|
||||
value={[
|
||||
EmbedState.use((state) => parseInt(state[configKey] as RadixSize)),
|
||||
]}
|
||||
onValueChange={([value]) => {
|
||||
value={EmbedState.use((state) => Number(state[configKey]))}
|
||||
onValueChange={(value) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
draft[configKey] = value;
|
||||
});
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { TextField } from "@radix-ui/themes";
|
||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState } from "../../stores/embedState";
|
||||
|
||||
export function TextController({ configKey }: EmbedPreviewControllerProps) {
|
||||
return (
|
||||
<TextField.Root
|
||||
variant="classic"
|
||||
placeholder="Empty"
|
||||
value={EmbedState.use((state) => state[configKey] as string)}
|
||||
onChange={(event) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
draft[configKey] = event.target.value;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.field {
|
||||
flex: 1;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { EmbedPreviewControllerProps } from "../../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||
import { EmbedState } from "../../../stores/embedState";
|
||||
import { TextField } from "../../TextField";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export function TextController({ configKey }: EmbedPreviewControllerProps) {
|
||||
return (
|
||||
<TextField
|
||||
className={styles.field}
|
||||
placeholder="Empty"
|
||||
value={EmbedState.use((state) => state[configKey] as string)}
|
||||
onChange={(event) => {
|
||||
EmbedState.mutate((draft) => {
|
||||
draft[configKey] = (event.target as HTMLInputElement).value;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -8,20 +8,28 @@ import {
|
||||
sumCompositeStats,
|
||||
type IndividualTankStats,
|
||||
} from "@blitzkit/core";
|
||||
import { STRINGS } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { ReloadIcon } from "@radix-ui/react-icons";
|
||||
import { ContextMenu } from "@radix-ui/themes";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { api } from "../../api/dynamic";
|
||||
import { breakdownConfig } from "../../constants/embeds";
|
||||
import { awaitableAverageDefinitions } from "../../core/awaitables/averageDefinitions";
|
||||
import { useStrings } from "../../hooks/useStrings";
|
||||
import { EmbedBreakdown } from "../../stores/embedBreakdown";
|
||||
import { useEmbedStateCurry } from "../../stores/embedState/utilities";
|
||||
import { ContextMenu } from "../ContextMenu";
|
||||
import { BreakdownEmbedCard, BreakdownEmbedWrapper } from "../TanksEmbed";
|
||||
|
||||
const allStrings = await Promise.all(
|
||||
locales.supported.map(async ({ locale }) => ({
|
||||
locale,
|
||||
strings: await api.strings(locale),
|
||||
}))
|
||||
);
|
||||
|
||||
export const compositeStatsKeysOptions = compositeStatsKeys.map((value) => ({
|
||||
value,
|
||||
locales: Object.entries(STRINGS).reduce((accumulator, [locale, strings]) => {
|
||||
locales: allStrings.reduce((accumulator, { locale, strings }) => {
|
||||
return {
|
||||
...accumulator,
|
||||
[locale]: strings.common.composite_stats[value],
|
||||
@@ -56,7 +64,7 @@ export const fakeCompositeStats = compositeStats(
|
||||
wins: 30,
|
||||
xp: 1230 * 50,
|
||||
},
|
||||
averageDefinitions.averages[7297].mu!,
|
||||
averageDefinitions.averages[7297].mu!
|
||||
);
|
||||
|
||||
export function BreakdownPreview() {
|
||||
@@ -65,11 +73,11 @@ export function BreakdownPreview() {
|
||||
|
||||
return (
|
||||
<BreakdownEmbedWrapper>
|
||||
{useEmbedState("showTotal") && (
|
||||
{useEmbedState("show_total") && (
|
||||
<BreakdownEmbedCard composite={fakeCompositeStats} tank={null} />
|
||||
)}
|
||||
|
||||
{tanks.slice(0, useEmbedState("listMaxTanks")).map((tank) => (
|
||||
{tanks.slice(0, useEmbedState("list_max_tanks")).map((tank) => (
|
||||
<BreakdownEmbedCard
|
||||
composite={fakeCompositeStats}
|
||||
key={tank.id}
|
||||
@@ -81,6 +89,7 @@ export function BreakdownPreview() {
|
||||
}
|
||||
|
||||
export function BreakdownRenderer() {
|
||||
const strings = useStrings();
|
||||
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const id = Number(params.get("id"));
|
||||
@@ -89,9 +98,9 @@ export function BreakdownRenderer() {
|
||||
const diff = useMemo(
|
||||
() =>
|
||||
deltaTankStats(tankStatsA, tankStatsB).sort(
|
||||
(a, b) => b.last_battle_time - a.last_battle_time,
|
||||
(a, b) => b.last_battle_time - a.last_battle_time
|
||||
),
|
||||
[tankStatsB],
|
||||
[tankStatsB]
|
||||
);
|
||||
const compositeStats = diff
|
||||
.map((diff) => {
|
||||
@@ -101,14 +110,14 @@ export function BreakdownRenderer() {
|
||||
|
||||
const compositeStats = calculateCompositeStats(
|
||||
{ battle_life_time: diff.battle_life_time, ...diff.all },
|
||||
average.mu!,
|
||||
average.mu!
|
||||
);
|
||||
|
||||
return { id: diff.tank_id, compositeStats };
|
||||
})
|
||||
.filter((stats) => stats !== null);
|
||||
const sum = sumCompositeStats(
|
||||
compositeStats.map(({ compositeStats }) => compositeStats),
|
||||
compositeStats.map(({ compositeStats }) => compositeStats)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -125,14 +134,14 @@ export function BreakdownRenderer() {
|
||||
|
||||
return (
|
||||
<ContextMenu.Root>
|
||||
<ContextMenu.Trigger>
|
||||
<ContextMenu.Trigger asChild>
|
||||
<BreakdownEmbedWrapper>
|
||||
{useEmbedState("showTotal") && (
|
||||
{useEmbedState("show_total") && (
|
||||
<BreakdownEmbedCard composite={sum} tank={null} />
|
||||
)}
|
||||
|
||||
{compositeStats
|
||||
.slice(0, useEmbedState("listMaxTanks"))
|
||||
.slice(0, useEmbedState("list_max_tanks"))
|
||||
.map(({ id, compositeStats }) => {
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
|
||||
@@ -147,22 +156,25 @@ export function BreakdownRenderer() {
|
||||
</BreakdownEmbedWrapper>
|
||||
</ContextMenu.Trigger>
|
||||
|
||||
<ContextMenu.Content>
|
||||
<ContextMenu.Item
|
||||
color="red"
|
||||
onClick={async () => {
|
||||
const newA = await getTankStats(idToRegion(id), id);
|
||||
<ContextMenu.Portal>
|
||||
<ContextMenu.Content>
|
||||
<ContextMenu.Item
|
||||
data-accent="red"
|
||||
onSelect={async () => {
|
||||
const newA = await getTankStats(idToRegion(id), id);
|
||||
|
||||
if (newA === null) return;
|
||||
if (newA === null) return;
|
||||
|
||||
EmbedBreakdown.mutate((draft) => {
|
||||
draft[id] = newA;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ReloadIcon /> Reset
|
||||
</ContextMenu.Item>
|
||||
</ContextMenu.Content>
|
||||
EmbedBreakdown.mutate((draft) => {
|
||||
draft[id] = newA;
|
||||
});
|
||||
}}
|
||||
>
|
||||
{strings.embed.types.breakdown.reset}
|
||||
<ReloadIcon />
|
||||
</ContextMenu.Item>
|
||||
</ContextMenu.Content>
|
||||
</ContextMenu.Portal>
|
||||
</ContextMenu.Root>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { assertSecret } from "@blitzkit/core";
|
||||
import { Box, Code, Flex, Heading, Link, Text } from "@radix-ui/themes";
|
||||
import packageJson from "../../../../package.json";
|
||||
import { api } from "../api/dynamic";
|
||||
import { discordLink } from "../config/socials";
|
||||
import { LinkI18n } from "./LinkI18n";
|
||||
import { LocaleSwitcherThemeWrapper } from "./LocaleSwitcher";
|
||||
|
||||
@@ -84,7 +85,7 @@ const strings = await api.strings(locale);
|
||||
}}
|
||||
>
|
||||
<Link
|
||||
href="https://discord.gg/nDt7AjGJQH"
|
||||
href={discordLink}
|
||||
target="_blank"
|
||||
color="gray"
|
||||
>
|
||||
|
||||
@@ -21,58 +21,6 @@
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
|
||||
width: 100%;
|
||||
padding: var(--space-2);
|
||||
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: var(--space-3);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
color: var(--gray-12);
|
||||
text-align: left;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background-color: var(--gray-4);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.flag {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
.name {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.discriminator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--space-2);
|
||||
|
||||
min-width: 38px;
|
||||
padding: 0 var(--space-3);
|
||||
|
||||
border-radius: var(--max-size);
|
||||
background-color: var(--gray-4);
|
||||
font-size: var(--font-size-minor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.controls {
|
||||
|
||||
@@ -27,6 +27,7 @@ import { ClassIcon } from "../ClassIcon";
|
||||
import { DropdownMenu } from "../DropdownMenu";
|
||||
import { IconButton } from "../IconButton";
|
||||
import { TRANSITION_ANIMATION_TIME, transitionEvent } from "../Lighting";
|
||||
import { SearchResults } from "../SearchResults";
|
||||
import { Text } from "../Text";
|
||||
import { TextField } from "../TextField";
|
||||
import styles from "./index.module.css";
|
||||
@@ -96,7 +97,7 @@ export function Guesser() {
|
||||
});
|
||||
|
||||
setResults(
|
||||
searchResults.map((result) => tankDefinitions.tanks[result.obj.id]),
|
||||
searchResults.map((result) => tankDefinitions.tanks[result.obj.id])
|
||||
);
|
||||
}, []);
|
||||
|
||||
@@ -115,37 +116,36 @@ export function Guesser() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={styles.list}>
|
||||
{results.map((result) => {
|
||||
return (
|
||||
<button
|
||||
key={result.id}
|
||||
className={styles.item}
|
||||
onClick={() => {
|
||||
if (!input.current) return;
|
||||
|
||||
input.current.value = unwrap(result.name!);
|
||||
setSelected(result);
|
||||
setResults(null);
|
||||
}}
|
||||
>
|
||||
<SearchResults.Root>
|
||||
{results.map((result) => (
|
||||
<SearchResults.Item
|
||||
key={result.id}
|
||||
text={unwrap(result.name!)}
|
||||
prefix={
|
||||
<img
|
||||
className={styles.flag}
|
||||
src={alias("api", `/flags/circle/${result.nation}.webp`)}
|
||||
/>
|
||||
<Text className={styles.name}>{unwrap(result.name!)}</Text>
|
||||
<span className={styles.discriminator}>
|
||||
}
|
||||
discriminator={
|
||||
<>
|
||||
<ClassIcon
|
||||
class={result.class}
|
||||
width="1em"
|
||||
height="1em"
|
||||
/>
|
||||
{romanize(result.tier)}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
onClick={() => {
|
||||
if (!input.current) return;
|
||||
|
||||
input.current.value = unwrap(result.name!);
|
||||
setSelected(result);
|
||||
setResults(null);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</SearchResults.Root>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
@@ -314,7 +314,7 @@ export function Guesser() {
|
||||
return tiers.includes(tank.tier);
|
||||
});
|
||||
const id = Number(
|
||||
filteredIds[Math.floor(Math.random() * filteredIds.length)],
|
||||
filteredIds[Math.floor(Math.random() * filteredIds.length)]
|
||||
);
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
|
||||
|
||||
@@ -22,11 +22,12 @@ const strings = await api.strings(locale);
|
||||
<ToolCardLayoutRoot>
|
||||
<ToolCardLayoutColumn>
|
||||
<ToolCard {locale} minor tool={tools.session} />
|
||||
<ToolCard {locale} minor tool={tools.playlist} />
|
||||
<ToolCard {locale} minor tool={tools.embed} />
|
||||
</ToolCardLayoutColumn>
|
||||
|
||||
<ToolCardLayoutColumn major>
|
||||
<ToolCard {locale} tool={tools.players} />
|
||||
<ToolCard {locale} minor tool={tools.playlist} />
|
||||
<!-- <ToolCard {locale} tool={tools.players} /> -->
|
||||
</ToolCardLayoutColumn>
|
||||
</ToolCardLayoutRoot>
|
||||
</HomeSection>
|
||||
@@ -107,7 +107,8 @@ export function PlaylistGenerator({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
}}
|
||||
size="3"
|
||||
>
|
||||
{strings.website.tools.playlist.generate} <ChevronRightIcon />
|
||||
{strings.website.tools.playlist.generate}
|
||||
<ChevronRightIcon />
|
||||
</Button>
|
||||
</Flex>
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
.thumb {
|
||||
position: absolute;
|
||||
|
||||
border-radius: var(--max-size);
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--gray-a8);
|
||||
touch-action: none;
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Flex,
|
||||
Text,
|
||||
type ButtonProps,
|
||||
type FlexProps,
|
||||
} from "@radix-ui/themes";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
function Root(props: FlexProps) {
|
||||
return <Flex direction="column" gap="2" width="100%" {...props} />;
|
||||
}
|
||||
|
||||
interface ItemProps extends Omit<ButtonProps, "prefix"> {
|
||||
prefix?: React.ReactNode;
|
||||
text: string;
|
||||
discriminator?: ReactNode;
|
||||
}
|
||||
|
||||
function Item({ text, discriminator, prefix, ...props }: ItemProps) {
|
||||
return (
|
||||
<Button variant="ghost" {...props} highContrast>
|
||||
<Flex width="100%" gap="2" align="center">
|
||||
{prefix}
|
||||
<Text style={{ flex: 1 }} align={prefix ? "left" : "center"}>
|
||||
{text}
|
||||
</Text>
|
||||
{discriminator !== undefined && <Badge>{discriminator}</Badge>}
|
||||
</Flex>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export const SearchResults = { Root, Item };
|
||||
@@ -0,0 +1,11 @@
|
||||
.root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.item {
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { ComponentProps, ReactNode } from "react";
|
||||
import { classNames } from "../../ui/classNames";
|
||||
import { Badge } from "../Badge";
|
||||
import { Button, type ButtonProps } from "../Button";
|
||||
import { Text } from "../Text";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
function Root({ className, ...props }: ComponentProps<"div">) {
|
||||
return <div className={classNames(styles.root, className)} {...props} />;
|
||||
}
|
||||
|
||||
interface ItemProps extends Omit<ButtonProps, "prefix"> {
|
||||
prefix?: ReactNode;
|
||||
text: string;
|
||||
discriminator?: ReactNode;
|
||||
}
|
||||
|
||||
function Item({ text, discriminator, prefix, className, ...props }: ItemProps) {
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
{...props}
|
||||
highContrast
|
||||
className={classNames(styles.item, className)}
|
||||
>
|
||||
{prefix}
|
||||
<Text>{text}</Text>
|
||||
{discriminator !== undefined && (
|
||||
<>
|
||||
<div className={styles.spacer} />
|
||||
<Badge>{discriminator}</Badge>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export const SearchResults = { Root, Item };
|
||||
@@ -4,6 +4,7 @@ import styles from "./index.module.css";
|
||||
|
||||
export interface SectionProps extends ComponentProps<"div"> {}
|
||||
|
||||
// TODO: reevaluate the usefulness of this as it seems to do very little
|
||||
export function Section({ className, children, ...props }: SectionProps) {
|
||||
return (
|
||||
<div className={classNames(styles.section, className)} {...props}>
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
@import "../DropdownMenu/index.module.css";
|
||||
|
||||
.Content,
|
||||
.SubContent {
|
||||
max-height: calc(
|
||||
var(--radix-select-content-available-height) - var(--space-6)
|
||||
);
|
||||
}
|
||||
|
||||
.Trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -8,10 +15,11 @@
|
||||
|
||||
padding: var(--space-3) var(--space-4);
|
||||
border: none;
|
||||
border-radius: var(--max-size);
|
||||
border-radius: var(--radius-max);
|
||||
|
||||
background-color: var(--gray-1);
|
||||
outline: var(--outline-interactive);
|
||||
outline-offset: calc(-1 * var(--space-1));
|
||||
color: var(--gray-12);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Select as _ } from "radix-ui";
|
||||
import { composeRadixComponents } from "../../ui/compose";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
// TODO: for select, context menu, and dropdown menus, use scroller curtains
|
||||
export const Select = composeRadixComponents(_, styles, {
|
||||
Content: { position: "popper", align: "center" },
|
||||
});
|
||||
@@ -1,12 +1,13 @@
|
||||
---
|
||||
import { Heading, Link, Text } from '@radix-ui/themes';
|
||||
import { discordLink } from '../config/socials';
|
||||
import { PageWrapper } from './PageWrapper';
|
||||
---
|
||||
|
||||
<PageWrapper align="center" justify="center" gap="0">
|
||||
<Heading>BlitzKit down for servicing</Heading>
|
||||
<Text color="gray">
|
||||
<Link color="blue" href="https://discord.gg/nDt7AjGJQH">
|
||||
<Link color="blue" href={discordLink}>
|
||||
Join the official Discord server
|
||||
</Link>
|
||||
for updates.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
flex: 1;
|
||||
height: var(--space-2);
|
||||
|
||||
border-radius: var(--max-size);
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--gray-5);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
|
||||
border-radius: var(--max-size);
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--accent-8);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
width: var(--space-4);
|
||||
height: var(--space-4);
|
||||
|
||||
border-radius: var(--max-size);
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--gray-12);
|
||||
box-shadow: var(--shadow-subtle);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
.spinner {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
width: var(--space-5);
|
||||
height: var(--space-5);
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
|
||||
border: var(--space-2) solid var(--gray-5);
|
||||
border: calc(1em / 4) solid var(--gray-5);
|
||||
border-top-color: var(--gray-12);
|
||||
border-radius: 50%;
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
.Root {
|
||||
--switch-thumb-size: var(--space-4);
|
||||
--switch-inset: var(--space-2);
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
box-sizing: border-box;
|
||||
width: calc(var(--switch-thumb-size) * 2.25 + 2 * var(--switch-inset));
|
||||
margin: 0;
|
||||
padding: var(--switch-inset);
|
||||
|
||||
border: none;
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--gray-a5);
|
||||
|
||||
cursor: pointer;
|
||||
transition: var(--duration-brief);
|
||||
|
||||
&[data-state="checked"] {
|
||||
background-color: var(--accent-8);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 var(--space-1) var(--accent-6);
|
||||
}
|
||||
|
||||
&[data-disabled] {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.Thumb {
|
||||
display: block;
|
||||
|
||||
width: var(--switch-thumb-size);
|
||||
height: var(--switch-thumb-size);
|
||||
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--white-a12);
|
||||
box-shadow: var(--shadow-subtle);
|
||||
|
||||
transition: var(--duration-brief);
|
||||
|
||||
&[data-state="checked"] {
|
||||
transform: translateX(calc(var(--switch-thumb-size) * 1.25));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Switch as _Switch } from "radix-ui";
|
||||
import { composeRadixComponents } from "../../ui/compose";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
const _ = composeRadixComponents(_Switch, styles);
|
||||
|
||||
export interface SwitchProps {
|
||||
checked: boolean;
|
||||
onCheckedChange(checked: boolean): void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function Switch({ checked, onCheckedChange, disabled }: SwitchProps) {
|
||||
return (
|
||||
<_.Root
|
||||
checked={checked}
|
||||
onCheckedChange={onCheckedChange}
|
||||
disabled={disabled}
|
||||
>
|
||||
<_.Thumb />
|
||||
</_.Root>
|
||||
);
|
||||
}
|
||||
@@ -19,7 +19,8 @@ export function QuickLink({ topResult }: QuickLinkProps) {
|
||||
<TextField.Slot>
|
||||
<LinkI18n locale={locale} href={`/tanks/${topResult.slug}`}>
|
||||
<Button variant="ghost">
|
||||
{unwrap(topResult.name!)} <CaretRightIcon />
|
||||
{unwrap(topResult.name!)}
|
||||
<CaretRightIcon />
|
||||
</Button>
|
||||
</LinkI18n>
|
||||
</TextField.Slot>
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
import {
|
||||
formatCompositeStat,
|
||||
type CompositeStats,
|
||||
type CompositeStatsKey,
|
||||
} from "@blitzkit/core";
|
||||
import strings from "@blitzkit/i18n/strings/en.json";
|
||||
import {
|
||||
TankClass,
|
||||
TankDefinition,
|
||||
TankType,
|
||||
} from "@blitzkit/protos";
|
||||
import { amberDark, blueDark } from "@radix-ui/colors";
|
||||
import { Flex, Text, type FlexProps } from "@radix-ui/themes";
|
||||
import { times } from "lodash-es";
|
||||
import type { ReactNode } from "react";
|
||||
import { breakdownConfig } from "../constants/embeds";
|
||||
import { toRadiusVar } from "../core/radix/utils";
|
||||
import { useLocale } from "../hooks/useLocale";
|
||||
import { useEmbedStateCurry } from "../stores/embedState/utilities";
|
||||
import { ClassHeavy } from "./ClassIcon/components/ClassHeavy";
|
||||
import { ClassLight } from "./ClassIcon/components/ClassLight";
|
||||
import { ClassMedium } from "./ClassIcon/components/ClassMedium";
|
||||
import { ClassTankDestroyer } from "./ClassIcon/components/ClassTankDestroyer";
|
||||
|
||||
type BreakdownEmbedWrapperProps = FlexProps & {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export function BreakdownEmbedWrapper({
|
||||
children,
|
||||
...props
|
||||
}: BreakdownEmbedWrapperProps) {
|
||||
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||
|
||||
return (
|
||||
<Flex
|
||||
direction="column"
|
||||
gap={useEmbedState("listGap")}
|
||||
height="100%"
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
interface BreakdownEmbedCardProps {
|
||||
tank: TankDefinition | null | undefined;
|
||||
composite: CompositeStats;
|
||||
}
|
||||
|
||||
export function BreakdownEmbedCard({
|
||||
tank,
|
||||
composite,
|
||||
}: BreakdownEmbedCardProps) {
|
||||
const { useEmbedState, useRichText } =
|
||||
useEmbedStateCurry<typeof breakdownConfig>();
|
||||
const { unwrap } = useLocale();
|
||||
|
||||
return (
|
||||
<Flex
|
||||
flexShrink="0"
|
||||
direction="column"
|
||||
style={{
|
||||
borderRadius: toRadiusVar(useEmbedState("cardRadius")),
|
||||
overflow: "hidden",
|
||||
backgroundColor: useEmbedState("cardBodyBackgroundColor"),
|
||||
}}
|
||||
>
|
||||
<Flex
|
||||
justify="center"
|
||||
style={{
|
||||
backgroundColor: useEmbedState("cardHeaderBackgroundColor"),
|
||||
}}
|
||||
p={useEmbedState("cardHeaderPadding")}
|
||||
>
|
||||
<Text
|
||||
{...{
|
||||
...useRichText("cardTitle"),
|
||||
style:
|
||||
tank === null
|
||||
? undefined
|
||||
: tank === undefined ||
|
||||
tank.type === TankType.TANK_TYPE_RESEARCHABLE ||
|
||||
!useEmbedState("cardTitleTypeColor")
|
||||
? undefined
|
||||
: {
|
||||
color:
|
||||
tank.type === TankType.TANK_TYPE_PREMIUM
|
||||
? amberDark.amber11
|
||||
: blueDark.blue11,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Flex align="center" gap="1">
|
||||
{useEmbedState("cardTitleClassIcon") &&
|
||||
tank !== null &&
|
||||
tank !== undefined && (
|
||||
<>
|
||||
{tank.class === TankClass.TANK_CLASS_LIGHT && (
|
||||
<ClassLight width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === TankClass.TANK_CLASS_MEDIUM && (
|
||||
<ClassMedium width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === TankClass.TANK_CLASS_HEAVY && (
|
||||
<ClassHeavy width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === TankClass.TANK_CLASS_TANK_DESTROYER && (
|
||||
<ClassTankDestroyer width="1em" height="1em" />
|
||||
)}
|
||||
</>
|
||||
)}{" "}
|
||||
{tank === null
|
||||
? "Total"
|
||||
: tank === undefined
|
||||
? `Unknown tank`
|
||||
: unwrap(tank.name!)}
|
||||
</Flex>
|
||||
</Text>
|
||||
</Flex>
|
||||
|
||||
<Flex p={useEmbedState("cardBodyPadding")}>
|
||||
{times(4, (index) => {
|
||||
const column = (index + 1) as 1 | 2 | 3 | 4;
|
||||
const statKey = useEmbedState(`column${column}`) as CompositeStatsKey;
|
||||
const customLabel = useEmbedState(`column${column}CustomLabel`);
|
||||
|
||||
return (
|
||||
<Flex
|
||||
key={column}
|
||||
direction="column"
|
||||
align="center"
|
||||
gap={useEmbedState("columnGap")}
|
||||
flexGrow="1"
|
||||
>
|
||||
<Text {...useRichText("columnValue")}>
|
||||
{formatCompositeStat(composite[statKey], statKey, composite)}
|
||||
</Text>
|
||||
<Text {...useRichText("columnLabel")}>
|
||||
{customLabel.length === 0
|
||||
? strings.common.composite_stats[statKey]
|
||||
: customLabel}
|
||||
</Text>
|
||||
</Flex>
|
||||
);
|
||||
})}
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
.wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.text {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.column {
|
||||
flex-grow: 1;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
import {
|
||||
formatCompositeStat,
|
||||
type CompositeStats,
|
||||
type CompositeStatsKey,
|
||||
} from "@blitzkit/core";
|
||||
import strings from "@blitzkit/i18n/strings/en.json";
|
||||
import { TankClass, TankDefinition, TankType } from "@blitzkit/protos";
|
||||
import { amberDark, blueDark } from "@radix-ui/colors";
|
||||
import { times } from "lodash-es";
|
||||
import type { ComponentProps } from "react";
|
||||
import { breakdownConfig } from "../../constants/embeds";
|
||||
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
||||
import { embedRadius, embedSpace } from "../../stores/embedState/tokens";
|
||||
import { useEmbedStateCurry } from "../../stores/embedState/utilities";
|
||||
import { classNames } from "../../ui/classNames";
|
||||
import { ClassHeavy } from "../ClassIcon/components/ClassHeavy";
|
||||
import { ClassLight } from "../ClassIcon/components/ClassLight";
|
||||
import { ClassMedium } from "../ClassIcon/components/ClassMedium";
|
||||
import { ClassTankDestroyer } from "../ClassIcon/components/ClassTankDestroyer";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export function BreakdownEmbedWrapper({
|
||||
className,
|
||||
style,
|
||||
...props
|
||||
}: ComponentProps<"div">) {
|
||||
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(styles.wrapper, className)}
|
||||
style={{ gap: embedSpace(useEmbedState("list_gap")), ...style }}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
interface BreakdownEmbedCardProps {
|
||||
tank: TankDefinition | null | undefined;
|
||||
composite: CompositeStats;
|
||||
}
|
||||
|
||||
export function BreakdownEmbedCard({
|
||||
tank,
|
||||
composite,
|
||||
}: BreakdownEmbedCardProps) {
|
||||
const { useEmbedState, useRichText } =
|
||||
useEmbedStateCurry<typeof breakdownConfig>();
|
||||
const unwrap = useUnwrapper();
|
||||
const titleText = useRichText("card_title");
|
||||
const cardTitleTypeColor = useEmbedState("card_title_type_color");
|
||||
const typeColored =
|
||||
tank !== null &&
|
||||
tank !== undefined &&
|
||||
tank.type !== TankType.TANK_TYPE_RESEARCHABLE &&
|
||||
cardTitleTypeColor;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={styles.card}
|
||||
style={{
|
||||
borderRadius: embedRadius(useEmbedState("card_radius")),
|
||||
backgroundColor: useEmbedState("card_body_background_color"),
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={styles.header}
|
||||
style={{
|
||||
backgroundColor: useEmbedState("card_header_background_color"),
|
||||
padding: embedSpace(useEmbedState("card_header_padding")),
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className={styles.text}
|
||||
style={{
|
||||
...titleText,
|
||||
...(typeColored && {
|
||||
color:
|
||||
tank.type === TankType.TANK_TYPE_PREMIUM
|
||||
? amberDark.amber11
|
||||
: blueDark.blue11,
|
||||
}),
|
||||
}}
|
||||
>
|
||||
<span className={styles.title}>
|
||||
{useEmbedState("card_title_class_icon") &&
|
||||
tank !== null &&
|
||||
tank !== undefined && (
|
||||
<>
|
||||
{tank.class === TankClass.TANK_CLASS_LIGHT && (
|
||||
<ClassLight width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === TankClass.TANK_CLASS_MEDIUM && (
|
||||
<ClassMedium width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === TankClass.TANK_CLASS_HEAVY && (
|
||||
<ClassHeavy width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === TankClass.TANK_CLASS_TANK_DESTROYER && (
|
||||
<ClassTankDestroyer width="1em" height="1em" />
|
||||
)}
|
||||
</>
|
||||
)}{" "}
|
||||
{tank === null
|
||||
? "Total"
|
||||
: tank === undefined
|
||||
? `Unknown tank`
|
||||
: unwrap(tank.name!)}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={styles.body}
|
||||
style={{ padding: embedSpace(useEmbedState("card_body_padding")) }}
|
||||
>
|
||||
{times(4, (index) => {
|
||||
const column = (index + 1) as 1 | 2 | 3 | 4;
|
||||
const statKey = useEmbedState(
|
||||
`column_${column}`
|
||||
) as CompositeStatsKey;
|
||||
const customLabel = useEmbedState(`column_${column}_custom_label`);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={column}
|
||||
className={styles.column}
|
||||
style={{ gap: embedSpace(useEmbedState("column_gap")) }}
|
||||
>
|
||||
<span className={styles.text} style={useRichText("column_value")}>
|
||||
{formatCompositeStat(composite[statKey], statKey, composite)}
|
||||
</span>
|
||||
<span className={styles.text} style={useRichText("column_label")}>
|
||||
{customLabel.length === 0
|
||||
? strings.common.composite_stats[statKey]
|
||||
: customLabel}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
gap: var(--space-3);
|
||||
|
||||
cursor: text;
|
||||
outline-offset: calc(-1 * var(--space-1));
|
||||
|
||||
font: inherit;
|
||||
color: var(--gray-11);
|
||||
@@ -13,7 +14,7 @@
|
||||
font-size: var(--font-size-regular);
|
||||
|
||||
&[data-variant="bubble"] {
|
||||
border-radius: var(--max-size);
|
||||
border-radius: var(--radius-max);
|
||||
|
||||
background-color: var(--gray-1);
|
||||
outline: var(--outline-interactive);
|
||||
|
||||
@@ -15,7 +15,8 @@ export function Share() {
|
||||
`${location.origin}/tier-list?${generateTierListParams(rows)}`
|
||||
}
|
||||
>
|
||||
<Share2Icon /> {strings.website.tools.tier_list.buttons.share}
|
||||
<Share2Icon />
|
||||
{strings.website.tools.tier_list.buttons.share}
|
||||
</CopyButton>
|
||||
);
|
||||
}
|
||||
@@ -17,7 +17,8 @@ export function TierListControls() {
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ReloadIcon /> {strings.website.tools.tier_list.buttons.reset}
|
||||
<ReloadIcon />
|
||||
{strings.website.tools.tier_list.buttons.reset}
|
||||
</Button>
|
||||
|
||||
<Share />
|
||||
|
||||
@@ -88,7 +88,8 @@ export function Header({ index }: HeaderProps) {
|
||||
}}
|
||||
>
|
||||
<Button variant="outline" color="red" style={{ flex: 1 }}>
|
||||
<Cross1Icon /> Cancel
|
||||
<Cross1Icon />
|
||||
Cancel
|
||||
</Button>
|
||||
</Popover.Close>
|
||||
|
||||
@@ -100,7 +101,8 @@ export function Header({ index }: HeaderProps) {
|
||||
input.current.blur();
|
||||
}}
|
||||
>
|
||||
<CheckIcon /> Apply
|
||||
<CheckIcon />
|
||||
Apply
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -32,9 +32,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.text {
|
||||
display: block;
|
||||
}
|
||||
&[data-controlled="false"]:hover .text,
|
||||
.text[data-open="true"] {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,26 @@ interface Props extends ComponentProps<"div"> {
|
||||
children: ReactNode;
|
||||
tooltip: string;
|
||||
side?: "top" | "left";
|
||||
|
||||
// Controls visibility instead of hover when defined
|
||||
open?: boolean;
|
||||
}
|
||||
|
||||
export function Tooltip({
|
||||
children,
|
||||
tooltip,
|
||||
side = "top",
|
||||
open,
|
||||
className,
|
||||
...props
|
||||
}: Props) {
|
||||
return (
|
||||
<div className={classNames(styles.tooltip, className)} {...props}>
|
||||
<div className={styles.text} data-side={side}>
|
||||
<div
|
||||
className={classNames(styles.tooltip, className)}
|
||||
data-controlled={open !== undefined}
|
||||
{...props}
|
||||
>
|
||||
<div className={styles.text} data-side={side} data-open={open}>
|
||||
{tooltip}
|
||||
</div>
|
||||
{children}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// in rem
|
||||
export const spaces = [
|
||||
2 ** -4,
|
||||
2 ** -3,
|
||||
2 ** -2,
|
||||
2 ** -1,
|
||||
2 ** 0,
|
||||
2 ** 1,
|
||||
2 ** 2,
|
||||
2 ** 3,
|
||||
2 ** 4,
|
||||
2 ** 5,
|
||||
] as const;
|
||||
|
||||
export const weights = {
|
||||
light: 300,
|
||||
regular: 400,
|
||||
medium: 500,
|
||||
bold: 700,
|
||||
black: 900,
|
||||
} as const;
|
||||
@@ -16,10 +16,10 @@ 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 },
|
||||
show_total: { type: EmbedItemType.Boolean, default: true, pad: true },
|
||||
|
||||
listGap: { type: EmbedItemType.Size, default: "2" },
|
||||
listMaxTanks: {
|
||||
list_gap: { type: EmbedItemType.Size, default: "3" },
|
||||
list_max_tanks: {
|
||||
type: EmbedItemType.Slider,
|
||||
default: 4,
|
||||
min: 0,
|
||||
@@ -27,63 +27,63 @@ export const breakdownConfig = {
|
||||
pad: true,
|
||||
},
|
||||
|
||||
cardRadius: { type: EmbedItemType.Radius, default: "2" },
|
||||
cardHeaderBackgroundColor: {
|
||||
card_radius: { type: EmbedItemType.Radius, default: "2" },
|
||||
card_header_background_color: {
|
||||
type: EmbedItemType.Color,
|
||||
default: grayDarkA.grayA3,
|
||||
},
|
||||
cardHeaderPadding: { type: EmbedItemType.Size, default: "1" },
|
||||
cardTitle: {
|
||||
card_header_padding: { type: EmbedItemType.Size, default: "2" },
|
||||
card_title: {
|
||||
type: EmbedItemType.RichText,
|
||||
default: { color: grayDark.gray12, weight: "bold", size: "3" },
|
||||
default: { color: grayDark.gray12, weight: "bold", size: "4" },
|
||||
},
|
||||
cardTitleTypeColor: { type: EmbedItemType.Boolean, default: true },
|
||||
cardTitleClassIcon: { type: EmbedItemType.Boolean, default: true },
|
||||
cardBodyBackgroundColor: {
|
||||
card_title_type_color: { type: EmbedItemType.Boolean, default: true },
|
||||
card_title_class_icon: { type: EmbedItemType.Boolean, default: true },
|
||||
card_body_background_color: {
|
||||
type: EmbedItemType.Color,
|
||||
default: grayA.grayA11,
|
||||
},
|
||||
cardBodyPadding: {
|
||||
card_body_padding: {
|
||||
type: EmbedItemType.Size,
|
||||
default: "2",
|
||||
default: "3",
|
||||
pad: true,
|
||||
},
|
||||
|
||||
columnGap: { type: EmbedItemType.Size, default: "0" },
|
||||
columnValue: {
|
||||
column_gap: { type: EmbedItemType.Size, default: "1" },
|
||||
column_value: {
|
||||
type: EmbedItemType.RichText,
|
||||
default: { color: grayDark.gray12, size: "3", weight: "regular" },
|
||||
default: { color: grayDark.gray12, size: "4", weight: "regular" },
|
||||
},
|
||||
columnLabel: {
|
||||
column_label: {
|
||||
type: EmbedItemType.RichText,
|
||||
default: { color: grayDark.gray11, size: "2", weight: "regular" },
|
||||
default: { color: grayDark.gray11, size: "4", weight: "regular" },
|
||||
pad: true,
|
||||
},
|
||||
|
||||
column1: {
|
||||
column_1: {
|
||||
type: EmbedItemType.Enum,
|
||||
default: "cumulative_battles" satisfies CompositeStatsKey,
|
||||
options: compositeStatsKeysOptions,
|
||||
},
|
||||
column2: {
|
||||
column_2: {
|
||||
type: EmbedItemType.Enum,
|
||||
default: "normalized_wins" satisfies CompositeStatsKey,
|
||||
options: compositeStatsKeysOptions,
|
||||
},
|
||||
column3: {
|
||||
column_3: {
|
||||
type: EmbedItemType.Enum,
|
||||
default: "cumulative_wn8" satisfies CompositeStatsKey,
|
||||
options: compositeStatsKeysOptions,
|
||||
},
|
||||
column4: {
|
||||
column_4: {
|
||||
type: EmbedItemType.Enum,
|
||||
default: "normalized_damage_dealt" satisfies CompositeStatsKey,
|
||||
options: compositeStatsKeysOptions,
|
||||
},
|
||||
column1CustomLabel: { type: EmbedItemType.String, default: "" },
|
||||
column2CustomLabel: { type: EmbedItemType.String, default: "" },
|
||||
column3CustomLabel: { type: EmbedItemType.String, default: "" },
|
||||
column4CustomLabel: { type: EmbedItemType.String, default: "" },
|
||||
column_1_custom_label: { type: EmbedItemType.String, default: "" },
|
||||
column_2_custom_label: { type: EmbedItemType.String, default: "" },
|
||||
column_3_custom_label: { type: EmbedItemType.String, default: "" },
|
||||
column_4_custom_label: { type: EmbedItemType.String, default: "" },
|
||||
} satisfies EmbedConfig;
|
||||
|
||||
export const embedConfigurations = {
|
||||
@@ -95,10 +95,10 @@ export const embedPreviews = {
|
||||
} satisfies Record<string, () => ReactNode>;
|
||||
|
||||
export function extractEmbedConfigDefaults<Config extends EmbedConfig>(
|
||||
config: Config,
|
||||
config: Config
|
||||
) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(config).map(([key, value]) => [key, value.default]),
|
||||
Object.entries(config).map(([key, value]) => [key, value.default])
|
||||
) as ExtractEmbedConfigTypes<Config>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { discordLink } from "../config/socials";
|
||||
|
||||
export interface Tool {
|
||||
id: string;
|
||||
|
||||
@@ -70,11 +72,11 @@ export const tools: Record<string, Tool> = {
|
||||
},
|
||||
embed: {
|
||||
id: "embed",
|
||||
banner_background_position: "bottom",
|
||||
banner_background_position: "top",
|
||||
},
|
||||
more: {
|
||||
id: "more",
|
||||
href: "https://discord.gg/nDt7AjGJQH",
|
||||
href: discordLink,
|
||||
banner_background_position: "bottom",
|
||||
},
|
||||
api: {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import type { RadixColorCompound, RadixRadius } from '../../stores/embedState';
|
||||
|
||||
export function toWidthVar(state: number) {
|
||||
return `${state}px`;
|
||||
}
|
||||
export function toRadiusVar(state: RadixRadius) {
|
||||
return `var(--radius-${state})`;
|
||||
}
|
||||
export function toColorVar(state: RadixColorCompound) {
|
||||
return `var(--${state.base}-${state.variant})`;
|
||||
}
|
||||
@@ -1,10 +1,44 @@
|
||||
---
|
||||
import './base.css';
|
||||
import BaseMeta from "../components/BaseMeta.astro";
|
||||
import BaseStyles from "../components/BaseStyles.astro";
|
||||
import ColorAlias from "../components/ColorAlias.astro";
|
||||
import ColorScale from "../components/ColorScale.astro";
|
||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||
|
||||
type Props = LocaleAcceptorProps;
|
||||
|
||||
const { locale } = Astro.props;
|
||||
---
|
||||
|
||||
<html>
|
||||
<html lang={locale} class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<BaseMeta />
|
||||
|
||||
<ColorScale color="mauve" />
|
||||
<ColorScale color="mauve" alpha />
|
||||
<ColorAlias color="mauve" alias="gray" />
|
||||
<ColorAlias color="mauve" alpha alias="gray" />
|
||||
|
||||
<ColorScale color="black" alpha />
|
||||
<ColorScale color="white" alpha />
|
||||
|
||||
<ColorScale color="indigo" />
|
||||
<ColorScale color="indigo" alpha />
|
||||
<ColorAlias color="indigo" alias="accent" />
|
||||
<ColorAlias color="indigo" alpha alias="accent" />
|
||||
|
||||
<BaseStyles />
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
|
||||
background-color: transparent;
|
||||
color: var(--gray-12);
|
||||
font-family: var(--font-family-regular);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
---
|
||||
import { CheckIcon, StarFilledIcon } from "@radix-ui/react-icons";
|
||||
import { Badge } from "../../../components/Badge";
|
||||
import ColorScale from "../../../components/ColorScale.astro";
|
||||
import BaseLayout from "../../../layouts/BaseLayout.astro";
|
||||
import type { Color } from "../../../ui/color";
|
||||
|
||||
export { getStaticPaths } from "./index.astro";
|
||||
|
||||
const { locale } = Astro.props;
|
||||
|
||||
const variants = ["solid", "soft", "surface", "outline"] as const;
|
||||
const sizes = ["minor", "regular"] as const;
|
||||
const colors = [undefined, "gray", "red", "amber", "green"] as const;
|
||||
const iconLayouts = ["leading", "trailing", "both", "icon only"] as const;
|
||||
const extraColors = ["red", "amber", "green"] satisfies Color[];
|
||||
---
|
||||
|
||||
<BaseLayout accent="blue" {locale}>
|
||||
{
|
||||
extraColors.map((color) => (
|
||||
<>
|
||||
<ColorScale {color} />
|
||||
<ColorScale {color} alpha />
|
||||
</>
|
||||
))
|
||||
}
|
||||
|
||||
<div class="page">
|
||||
<h1>Badge</h1>
|
||||
|
||||
{
|
||||
sizes.map((size) => (
|
||||
<section>
|
||||
<h2>size="{size}"</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
{variants.map((variant) => (
|
||||
<th>{variant}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{colors.map((color) => (
|
||||
<tr>
|
||||
<th>{color ?? "accent"}</th>
|
||||
{variants.map((variant) => (
|
||||
<td>
|
||||
<Badge {color} {variant} {size}>
|
||||
Badge
|
||||
</Badge>
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
|
||||
{
|
||||
sizes.map((size) => (
|
||||
<section>
|
||||
<h2>size="{size}" with icons</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
{iconLayouts.map((layout) => (
|
||||
<th>{layout}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{variants.map((variant) => (
|
||||
<tr>
|
||||
<th>{variant}</th>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
Badge
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
Badge
|
||||
<CheckIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
Badge
|
||||
<CheckIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
padding: var(--space-7);
|
||||
}
|
||||
|
||||
table {
|
||||
border-spacing: var(--space-5) var(--space-4);
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
color: var(--gray-11);
|
||||
}
|
||||
</style>
|
||||
-16
@@ -1,5 +1,4 @@
|
||||
---
|
||||
import { AstroSeo } from "@astrolib/seo";
|
||||
import { readFile } from "fs/promises";
|
||||
import { mixStaticPaths } from "../../../../../../core/blitzkit/mixStaticPaths";
|
||||
import BaseLayout from "../../../../../../layouts/BaseLayout.astro";
|
||||
@@ -29,23 +28,8 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
});
|
||||
|
||||
const { content, locale } = Astro.props;
|
||||
|
||||
const title = content.split("\n")[0].replace("# ", "");
|
||||
---
|
||||
|
||||
<AstroSeo
|
||||
title={title}
|
||||
description={title}
|
||||
canonical={Astro.url.href}
|
||||
openGraph={{
|
||||
url: Astro.url.href,
|
||||
title,
|
||||
description: title,
|
||||
site_name: "BlitzKit",
|
||||
}}
|
||||
twitter={{ cardType: "summary_large_image" }}
|
||||
/>
|
||||
|
||||
<BaseLayout {locale}>
|
||||
<Page content={content} />
|
||||
</BaseLayout>
|
||||
@@ -1,10 +1,8 @@
|
||||
---
|
||||
import { AstroSeo } from "@astrolib/seo";
|
||||
import { MagicWandIcon, StarFilledIcon } from "@radix-ui/react-icons";
|
||||
import { Flex, Heading, Link } from "@radix-ui/themes";
|
||||
import { compareVersions } from "compare-versions";
|
||||
import { PageWrapper } from "../../../../../components/PageWrapper";
|
||||
import { getStrings } from "../../../../../core/i18n/getStrings";
|
||||
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
|
||||
|
||||
export { getStaticPaths } from "../../index.astro";
|
||||
@@ -13,7 +11,6 @@ export { getStaticPaths } from "../../index.astro";
|
||||
const ROOT = "../../../../../../../../docs/changelogs/";
|
||||
|
||||
const { locale } = Astro.props;
|
||||
const strings = getStrings(locale);
|
||||
const versions = Object.keys(
|
||||
import.meta.glob("../../../../../../../../docs/changelogs/*.md", {
|
||||
eager: true,
|
||||
@@ -24,19 +21,6 @@ const versions = Object.keys(
|
||||
.reverse();
|
||||
---
|
||||
|
||||
<AstroSeo
|
||||
title={strings.website.docs.patches.name}
|
||||
description={strings.website.docs.patches.seo_description}
|
||||
canonical={Astro.url.href}
|
||||
openGraph={{
|
||||
url: Astro.url.href,
|
||||
title: strings.website.docs.patches.name,
|
||||
description: strings.website.docs.patches.seo_description,
|
||||
site_name: "BlitzKit",
|
||||
}}
|
||||
twitter={{ cardType: "summary_large_image" }}
|
||||
/>
|
||||
|
||||
<BaseLayout {locale}>
|
||||
<PageWrapper align="center">
|
||||
<Heading mt="6" mb="4">BlitzKit patches</Heading>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
---
|
||||
import { AstroSeo } from "@astrolib/seo";
|
||||
import { capitalize } from "lodash-es";
|
||||
import { embedConfigurations } from "../../../../../constants/embeds";
|
||||
import { mixStaticPaths } from "../../../../../core/blitzkit/mixStaticPaths";
|
||||
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
|
||||
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
return Object.keys(embedConfigurations).map((embed) => ({
|
||||
params: { embed: embed as keyof typeof embedConfigurations },
|
||||
}));
|
||||
});
|
||||
|
||||
const name = capitalize(Astro.params.embed);
|
||||
const title = `BlitzKit - ${name} embed`;
|
||||
const description = `BlitzKit ${name} embeds for streaming World of Tanks Blitz with extreme customization`;
|
||||
const { locale } = Astro.props;
|
||||
---
|
||||
|
||||
<AstroSeo
|
||||
title={title}
|
||||
description={description}
|
||||
canonical={Astro.url.href}
|
||||
openGraph={{
|
||||
url: Astro.url.href,
|
||||
title,
|
||||
description,
|
||||
site_name: "BlitzKit",
|
||||
}}
|
||||
twitter={{ cardType: "summary_large_image" }}
|
||||
/>
|
||||
|
||||
<style is:global>
|
||||
@keyframes fade-out-border {
|
||||
from {
|
||||
outline: 1rem solid #ff0000ff;
|
||||
}
|
||||
to {
|
||||
outline: 0.75rem solid #ff000000;
|
||||
}
|
||||
}
|
||||
|
||||
.preview-container-animated {
|
||||
animation: fade-out-border 0.5s linear;
|
||||
}
|
||||
|
||||
.preview-container-animated:hover {
|
||||
outline: 1rem solid #ff000080;
|
||||
}
|
||||
</style>
|
||||
|
||||
<BaseLayout {locale}>
|
||||
<Page {locale} client:load embed={Astro.params.embed} />
|
||||
</BaseLayout>
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
.page {
|
||||
display: flex;
|
||||
gap: var(--space-4);
|
||||
|
||||
box-sizing: border-box;
|
||||
padding: var(--space-4);
|
||||
padding-left: 0;
|
||||
|
||||
@media screen and (max-width: 80rem) {
|
||||
padding-left: var(--space-4);
|
||||
}
|
||||
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
height: 100%;
|
||||
max-width: 20rem;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.description {
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
.exports {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.customize {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
|
||||
.control {
|
||||
flex: 1;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
&[data-one-liner="true"] {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
|
||||
.control {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
&[data-pad="true"] {
|
||||
padding-bottom: var(--space-4);
|
||||
}
|
||||
}
|
||||
|
||||
.stage {
|
||||
flex: 1;
|
||||
|
||||
position: sticky;
|
||||
top: var(--space-4);
|
||||
|
||||
height: calc(100dvh - 2 * var(--space-4));
|
||||
}
|
||||
|
||||
.window {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
border-radius: var(--space-3);
|
||||
box-shadow: var(--shadow-subtle);
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
padding: var(--space-3);
|
||||
padding-left: var(--space-4);
|
||||
|
||||
background-color: var(--gray-2);
|
||||
}
|
||||
|
||||
.preview {
|
||||
flex: 1;
|
||||
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
+177
-205
@@ -6,8 +6,8 @@ import {
|
||||
TimerIcon,
|
||||
WidthIcon,
|
||||
} from "@radix-ui/react-icons";
|
||||
import { Box, Button, Flex, Heading, ScrollArea, Text } from "@radix-ui/themes";
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { Button } from "../../../../../components/Button";
|
||||
import { CopyButton } from "../../../../../components/CopyButton";
|
||||
import { Boolean } from "../../../../../components/Embeds/Boolean";
|
||||
import { Color } from "../../../../../components/Embeds/Color";
|
||||
@@ -21,19 +21,25 @@ import { Size } from "../../../../../components/Embeds/Size";
|
||||
import { SizeWithout0 } from "../../../../../components/Embeds/SizeWithout0";
|
||||
import { Slider } from "../../../../../components/Embeds/Slider";
|
||||
import { TextController } from "../../../../../components/Embeds/TextController";
|
||||
import { PageWrapper } from "../../../../../components/PageWrapper";
|
||||
import { Heading } from "../../../../../components/Heading";
|
||||
import { IconButton } from "../../../../../components/IconButton";
|
||||
import {
|
||||
Scroller,
|
||||
ScrollerOrientation,
|
||||
} from "../../../../../components/Scroller";
|
||||
import { Text } from "../../../../../components/Text";
|
||||
import {
|
||||
embedConfigurations,
|
||||
extractEmbedConfigDefaults,
|
||||
} from "../../../../../constants/embeds";
|
||||
import { NAVBAR_HEIGHT } from "../../../../../constants/navbar";
|
||||
import {
|
||||
LocaleProvider,
|
||||
useLocale,
|
||||
type LocaleAcceptorProps,
|
||||
} from "../../../../../hooks/useLocale";
|
||||
import { useStrings } from "../../../../../hooks/useStrings";
|
||||
import { EmbedState, type EmbedConfig } from "../../../../../stores/embedState";
|
||||
import { EmbedItemType } from "../../../../../stores/embedState/constants";
|
||||
import styles from "./_index.module.css";
|
||||
|
||||
export interface EmbedPreviewControllerProps {
|
||||
configKey: string;
|
||||
@@ -58,10 +64,10 @@ export function Page({ embed, locale }: PageProps & LocaleAcceptorProps) {
|
||||
function Content({ embed }: PageProps) {
|
||||
const config = embedConfigurations[embed] as EmbedConfig;
|
||||
const [backgroundImage, setBackgroundImage] = useState(
|
||||
"/assets/images/backgrounds/embed-default.webp",
|
||||
"/media/embed-default.webp",
|
||||
);
|
||||
const fileInput = useRef<HTMLInputElement>(null!);
|
||||
const { strings } = useLocale();
|
||||
const strings = useStrings();
|
||||
|
||||
useEffect(() => {
|
||||
fileInput.current = document.createElement("input");
|
||||
@@ -76,213 +82,179 @@ function Content({ embed }: PageProps) {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PageWrapper padding="0" maxWidth="104rem" color="red">
|
||||
<Flex>
|
||||
<ScrollArea
|
||||
scrollbars="vertical"
|
||||
style={{ height: "100%", maxWidth: 320 }}
|
||||
>
|
||||
<Flex direction="column" gap="2" p="4">
|
||||
<Import />
|
||||
<div className={styles.page}>
|
||||
<div className={styles.stage}>
|
||||
<div className={styles.window}>
|
||||
<div className={styles.toolbar}>
|
||||
<Text lowContrast>{strings.embed.preview.title}</Text>
|
||||
|
||||
<Heading>
|
||||
{strings.website.tools.embed.configuration.export.title}
|
||||
</Heading>
|
||||
<Text size="2" color="gray" mb="2">
|
||||
{strings.website.tools.embed.configuration.export.description}
|
||||
</Text>
|
||||
<Button
|
||||
variant="outline"
|
||||
color="gray"
|
||||
onClick={() => fileInput.current?.click()}
|
||||
>
|
||||
<ImageIcon />
|
||||
{strings.embed.preview.upload}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Flex mb="6" gap="2" wrap="wrap">
|
||||
<GenerateURL embed={embed} />
|
||||
|
||||
<CopyButton
|
||||
variant="outline"
|
||||
copy={() =>
|
||||
"body { margin: 0; background-color: transparent; overflow: hidden; }"
|
||||
}
|
||||
>
|
||||
<CodeIcon />
|
||||
{strings.website.tools.embed.configuration.export.css}
|
||||
</CopyButton>
|
||||
<CopyButton
|
||||
variant="outline"
|
||||
copy={() => `${EmbedState.state.width}`}
|
||||
>
|
||||
<WidthIcon />
|
||||
{strings.website.tools.embed.configuration.export.width}
|
||||
</CopyButton>
|
||||
<CopyButton
|
||||
variant="outline"
|
||||
copy={() => `${EmbedState.state.height}`}
|
||||
>
|
||||
<HeightIcon />
|
||||
{strings.website.tools.embed.configuration.export.height}
|
||||
</CopyButton>
|
||||
<CopyButton variant="outline" copy={() => "1"}>
|
||||
<TimerIcon />
|
||||
{strings.website.tools.embed.configuration.export.framerate}
|
||||
</CopyButton>
|
||||
</Flex>
|
||||
|
||||
<Flex justify="between" align="center">
|
||||
<Heading>
|
||||
{strings.website.tools.embed.configuration.customize.title}
|
||||
</Heading>
|
||||
<Button
|
||||
color="red"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
EmbedState.set(EmbedState.initial);
|
||||
}}
|
||||
>
|
||||
<ResetIcon />{" "}
|
||||
{strings.website.tools.embed.configuration.customize.reset}
|
||||
</Button>
|
||||
</Flex>
|
||||
<Text size="2" color="gray" mb="2">
|
||||
{strings.website.tools.embed.configuration.customize.description}
|
||||
</Text>
|
||||
|
||||
{Object.keys(config).map((configKey) => {
|
||||
const item = config[configKey];
|
||||
let control: ReactNode;
|
||||
let oneLiner = false;
|
||||
|
||||
switch (item.type) {
|
||||
case EmbedItemType.Boolean: {
|
||||
control = <Boolean configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Color: {
|
||||
control = <Color configKey={configKey} />;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Radius: {
|
||||
control = <Radius configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Size: {
|
||||
control = <Size configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.SizeWithout0: {
|
||||
control = <SizeWithout0 configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Slider: {
|
||||
control = <Slider configKey={configKey} config={item} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.String: {
|
||||
control = <TextController configKey={configKey} />;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.RichText: {
|
||||
control = <RichText configKey={configKey} />;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Enum: {
|
||||
control = <Enum configKey={configKey} config={item} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Flex
|
||||
key={configKey}
|
||||
direction={oneLiner ? undefined : "column"}
|
||||
gap={oneLiner ? "2" : "1"}
|
||||
justify={oneLiner ? "between" : undefined}
|
||||
mb={oneLiner ? "2" : "4"}
|
||||
pb={item.pad ? "6" : undefined}
|
||||
>
|
||||
<Text>
|
||||
{
|
||||
(
|
||||
strings.website.tools.embed.types[embed]
|
||||
.options as Record<string, string>
|
||||
)[configKey]
|
||||
}
|
||||
</Text>
|
||||
<Flex
|
||||
gap="2"
|
||||
align="center"
|
||||
flexGrow="1"
|
||||
justify={oneLiner ? "end" : undefined}
|
||||
>
|
||||
{control}
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
})}
|
||||
</Flex>
|
||||
</ScrollArea>
|
||||
|
||||
<Box
|
||||
p="4"
|
||||
flexGrow="1"
|
||||
position="sticky"
|
||||
top={`${NAVBAR_HEIGHT}px`}
|
||||
height={`calc(100vh - ${NAVBAR_HEIGHT}px)`}
|
||||
>
|
||||
<Flex
|
||||
direction="column"
|
||||
height="100%"
|
||||
<div
|
||||
className={styles.preview}
|
||||
style={{
|
||||
borderRadius: "var(--radius-3)",
|
||||
overflow: "hidden",
|
||||
boxShadow: "var(--shadow-3)",
|
||||
background: `url(${backgroundImage}) center / cover no-repeat`,
|
||||
}}
|
||||
>
|
||||
<Flex
|
||||
justify="between"
|
||||
align="center"
|
||||
p="2"
|
||||
pl="3"
|
||||
style={{
|
||||
backgroundColor: "var(--color-panel-solid)",
|
||||
<PreviewWrapper name={embed} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Scroller
|
||||
orientation={ScrollerOrientation.Vertical}
|
||||
className={styles.sidebar}
|
||||
>
|
||||
<div className={styles.controls}>
|
||||
<Import />
|
||||
|
||||
<Heading size="3" weight="bold">
|
||||
{strings.embed.configuration.export.title}
|
||||
</Heading>
|
||||
<Text size="minor" lowContrast className={styles.description}>
|
||||
{strings.embed.configuration.export.description}
|
||||
</Text>
|
||||
|
||||
<div className={styles.exports}>
|
||||
<GenerateURL embed={embed} />
|
||||
|
||||
<CopyButton
|
||||
variant="outline"
|
||||
copy={() =>
|
||||
"body { margin: 0; background-color: transparent; overflow: hidden; }"
|
||||
}
|
||||
>
|
||||
<CodeIcon />
|
||||
{strings.embed.configuration.export.css}
|
||||
</CopyButton>
|
||||
<CopyButton
|
||||
variant="outline"
|
||||
copy={() => `${EmbedState.state.width}`}
|
||||
>
|
||||
<WidthIcon />
|
||||
{strings.embed.configuration.export.width}
|
||||
</CopyButton>
|
||||
<CopyButton
|
||||
variant="outline"
|
||||
copy={() => `${EmbedState.state.height}`}
|
||||
>
|
||||
<HeightIcon />
|
||||
{strings.embed.configuration.export.height}
|
||||
</CopyButton>
|
||||
<CopyButton variant="outline" copy={() => "1"}>
|
||||
<TimerIcon />
|
||||
{strings.embed.configuration.export.framerate}
|
||||
</CopyButton>
|
||||
</div>
|
||||
|
||||
<div className={styles.customize}>
|
||||
<Heading size="3" weight="bold">
|
||||
{strings.embed.configuration.customize.title}
|
||||
</Heading>
|
||||
<IconButton
|
||||
color="red"
|
||||
variant="ghost"
|
||||
size="minor"
|
||||
onClick={() => {
|
||||
EmbedState.set(EmbedState.initial);
|
||||
}}
|
||||
>
|
||||
<Text color="gray">
|
||||
{strings.website.tools.embed.preview.title}
|
||||
</Text>
|
||||
<ResetIcon />
|
||||
</IconButton>
|
||||
</div>
|
||||
<Text size="minor" lowContrast className={styles.description}>
|
||||
{strings.embed.configuration.customize.description}
|
||||
</Text>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
color="gray"
|
||||
onClick={() => fileInput.current?.click()}
|
||||
{Object.keys(config).map((configKey) => {
|
||||
const item = config[configKey];
|
||||
let control: ReactNode;
|
||||
let oneLiner = false;
|
||||
|
||||
switch (item.type) {
|
||||
case EmbedItemType.Boolean: {
|
||||
control = <Boolean configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Color: {
|
||||
control = <Color configKey={configKey} />;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Radius: {
|
||||
control = <Radius configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Size: {
|
||||
control = <Size configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.SizeWithout0: {
|
||||
control = <SizeWithout0 configKey={configKey} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Slider: {
|
||||
control = <Slider configKey={configKey} config={item} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.String: {
|
||||
control = <TextController configKey={configKey} />;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.RichText: {
|
||||
control = <RichText configKey={configKey} />;
|
||||
break;
|
||||
}
|
||||
|
||||
case EmbedItemType.Enum: {
|
||||
control = <Enum configKey={configKey} config={item} />;
|
||||
oneLiner = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
key={configKey}
|
||||
className={styles.option}
|
||||
data-one-liner={oneLiner}
|
||||
data-pad={item.pad}
|
||||
>
|
||||
<ImageIcon /> {strings.website.tools.embed.preview.upload}
|
||||
</Button>
|
||||
</Flex>
|
||||
|
||||
<Box
|
||||
flexGrow="1"
|
||||
style={{
|
||||
background: `url(${backgroundImage}) center / cover no-repeat`,
|
||||
}}
|
||||
position="relative"
|
||||
overflow="hidden"
|
||||
>
|
||||
<PreviewWrapper name={embed} />
|
||||
</Box>
|
||||
</Flex>
|
||||
</Box>
|
||||
</Flex>
|
||||
</PageWrapper>
|
||||
<Text>
|
||||
{
|
||||
(
|
||||
strings.embed.types[embed].options as Record<
|
||||
string,
|
||||
string
|
||||
>
|
||||
)[configKey]
|
||||
}
|
||||
</Text>
|
||||
<div className={styles.control}>{control}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Scroller>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
---
|
||||
import EmbedLayout from "../../../../../../layouts/EmbedLayout.astro";
|
||||
import type { getStaticPaths } from "../index.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
|
||||
const { locale } = Astro.props;
|
||||
---
|
||||
|
||||
<EmbedLayout>
|
||||
<Page {locale} client:only="react" embed={Astro.params.embed} />
|
||||
</EmbedLayout>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.embed {
|
||||
overflow: hidden;
|
||||
}
|
||||
+7
-7
@@ -1,7 +1,5 @@
|
||||
import { Box } from "@radix-ui/themes";
|
||||
import { useMemo } from "react";
|
||||
import { parse } from "urlon";
|
||||
import { BlitzKitTheme } from "../../../../../../components/BlitzKitTheme";
|
||||
import {
|
||||
embedConfigurations,
|
||||
embedRenderers,
|
||||
@@ -17,6 +15,7 @@ import {
|
||||
type ExtractEmbedConfigTypes,
|
||||
} from "../../../../../../stores/embedState";
|
||||
import { useEmbedStateCurry } from "../../../../../../stores/embedState/utilities";
|
||||
import styles from "./_index.module.css";
|
||||
|
||||
interface PageProps {
|
||||
embed: keyof typeof embedConfigurations;
|
||||
@@ -51,10 +50,11 @@ function Content({ embed }: PageProps) {
|
||||
const height = useEmbedState("height");
|
||||
|
||||
return (
|
||||
<BlitzKitTheme style={{ background: "transparent" }}>
|
||||
<Box width={`${width}px`} height={`${height}px`} overflow="hidden">
|
||||
<Renderer />
|
||||
</Box>
|
||||
</BlitzKitTheme>
|
||||
<div
|
||||
className={styles.embed}
|
||||
style={{ width: `${width}px`, height: `${height}px` }}
|
||||
>
|
||||
<Renderer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
---
|
||||
import ColorScale from "../../../../../../components/ColorScale.astro";
|
||||
import EmbedLayout from "../../../../../../layouts/EmbedLayout.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
|
||||
const { locale, embed } = Astro.props;
|
||||
---
|
||||
|
||||
<EmbedLayout {locale}>
|
||||
<ColorScale color="red" />
|
||||
|
||||
<Page {locale} client:only="react" {embed} />
|
||||
</EmbedLayout>
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
import { mixStaticPaths } from "../../../../../astro/mixStaticPaths";
|
||||
import { embedConfigurations } from "../../../../../constants/embeds";
|
||||
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
|
||||
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
return (
|
||||
Object.keys(embedConfigurations) as (keyof typeof embedConfigurations)[]
|
||||
).map((embed) => ({
|
||||
params: { embed },
|
||||
props: { embed },
|
||||
}));
|
||||
});
|
||||
|
||||
const { locale, embed } = Astro.props;
|
||||
---
|
||||
|
||||
<BaseLayout {locale} accent="red">
|
||||
<Page {locale} client:load {embed} />
|
||||
</BaseLayout>
|
||||
@@ -1,13 +0,0 @@
|
||||
---
|
||||
import { tools } from "../../../../constants/tools";
|
||||
import ToolLayout from "../../../../layouts/ToolLayout.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
|
||||
const { locale } = Astro.props;
|
||||
---
|
||||
|
||||
<ToolLayout {locale} tool={tools.embed}>
|
||||
<Page {locale} />
|
||||
</ToolLayout>
|
||||
@@ -0,0 +1,49 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-6);
|
||||
}
|
||||
|
||||
.intro {
|
||||
margin-top: var(--space-3);
|
||||
}
|
||||
|
||||
.embeds {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.embed {
|
||||
display: block;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
.card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
||||
border-radius: var(--space-4);
|
||||
background-color: var(--gray-2);
|
||||
box-shadow: var(--shadow-subtle);
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: var(--space-3);
|
||||
}
|
||||
|
||||
.preview {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
width: 20rem;
|
||||
height: 20rem;
|
||||
|
||||
background-image: url(/media/embed-default.webp);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
import { Box, Flex, Link, Text } from "@radix-ui/themes";
|
||||
import { PreviewWrapper } from "../../../../components/Embeds/PreviewWrapper";
|
||||
import { Link } from "../../../../components/Link";
|
||||
import { LinkI18n } from "../../../../components/LinkI18n";
|
||||
import { PageWrapper } from "../../../../components/PageWrapper";
|
||||
import { Text } from "../../../../components/Text";
|
||||
import { discordLink } from "../../../../config/socials";
|
||||
import { embedConfigurations } from "../../../../constants/embeds";
|
||||
import { Var } from "../../../../core/radix/var";
|
||||
import {
|
||||
type LocaleAcceptorProps,
|
||||
LocaleProvider,
|
||||
useLocale,
|
||||
} from "../../../../hooks/useLocale";
|
||||
import { useStrings } from "../../../../hooks/useStrings";
|
||||
import styles from "./_index.module.css";
|
||||
|
||||
export function Page({ locale }: LocaleAcceptorProps) {
|
||||
return (
|
||||
@@ -19,74 +21,50 @@ export function Page({ locale }: LocaleAcceptorProps) {
|
||||
}
|
||||
|
||||
function Content() {
|
||||
const { locale, strings } = useLocale();
|
||||
const locale = useLocale();
|
||||
const strings = useStrings();
|
||||
|
||||
return (
|
||||
<PageWrapper color="red">
|
||||
<Text align="center" mt="3">
|
||||
{strings.website.tools.embed.coming_soon}{" "}
|
||||
<Link
|
||||
underline="always"
|
||||
href="https://discord.gg/nDt7AjGJQH"
|
||||
target="_blank"
|
||||
>
|
||||
{strings.website.tools.embed.suggest}
|
||||
<div className={styles.content}>
|
||||
<Text align="center" className={styles.intro}>
|
||||
{strings.embed.coming_soon}{" "}
|
||||
<Link href={discordLink} target="_blank">
|
||||
{strings.embed.suggest}
|
||||
</Link>
|
||||
</Text>
|
||||
|
||||
<Flex justify="center">
|
||||
<div className={styles.embeds}>
|
||||
{Object.keys(embedConfigurations).map((embed) => (
|
||||
<LinkI18n
|
||||
key={embed}
|
||||
locale={locale}
|
||||
href={`/embed/${embed}`}
|
||||
color="gray"
|
||||
highContrast
|
||||
style={{
|
||||
width: "fit-content",
|
||||
height: "fit-content",
|
||||
}}
|
||||
underline="hover"
|
||||
className={styles.embed}
|
||||
>
|
||||
<Flex
|
||||
direction="column"
|
||||
overflow="hidden"
|
||||
style={{
|
||||
borderRadius: Var("radius-4"),
|
||||
backgroundColor: Var("color-panel-solid"),
|
||||
boxShadow: Var("shadow-3"),
|
||||
}}
|
||||
>
|
||||
<Flex justify="center" p="2">
|
||||
<div className={styles.card}>
|
||||
<div className={styles.title}>
|
||||
<Text>
|
||||
{
|
||||
strings.website.tools.embed.types[
|
||||
embed as keyof typeof strings.website.tools.embed.types
|
||||
strings.embed.types[
|
||||
embed as keyof typeof strings.embed.types
|
||||
].name
|
||||
}
|
||||
</Text>
|
||||
</Flex>
|
||||
</div>
|
||||
|
||||
<Box
|
||||
width="20rem"
|
||||
height="20rem"
|
||||
overflow="hidden"
|
||||
position="relative"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"url(/assets/images/backgrounds/embed-default.webp)",
|
||||
backgroundSize: "cover",
|
||||
backgroundPosition: "center",
|
||||
}}
|
||||
>
|
||||
<div className={styles.preview}>
|
||||
<PreviewWrapper
|
||||
naked
|
||||
name={embed as keyof typeof embedConfigurations}
|
||||
/>
|
||||
</Box>
|
||||
</Flex>
|
||||
</div>
|
||||
</div>
|
||||
</LinkI18n>
|
||||
))}
|
||||
</Flex>
|
||||
</PageWrapper>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
import ToolBanner from "../../../../components/ToolBanner.astro";
|
||||
import { tools } from "../../../../constants/tools";
|
||||
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
|
||||
const { locale } = Astro.props;
|
||||
---
|
||||
|
||||
<BaseLayout {locale} accent="red">
|
||||
<ToolBanner {locale} tool={tools.embed} />
|
||||
|
||||
<Page {locale} />
|
||||
</BaseLayout>
|
||||
@@ -1,4 +1,5 @@
|
||||
.content {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
height: 100dvh;
|
||||
background-color: black;
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import { Page } from "./_index";
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
|
||||
const { locale } = Astro.props;
|
||||
|
||||
// TODO: the tank search popup is complete unreviewed AI slop, write a proper system for it manually
|
||||
---
|
||||
|
||||
<BaseLayout accent="blue" {locale} solidNavbar>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
---
|
||||
import { AstroSeo } from "@astrolib/seo";
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { api } from "../../../api/dynamic";
|
||||
import { mixStaticPaths } from "../../../astro/mixStaticPaths";
|
||||
import { AesonPlug } from "../../../components/AesonPlug";
|
||||
import HelpTranslate from "../../../components/HelpTranslate.astro";
|
||||
@@ -20,7 +18,6 @@ const MAX_TOOLS_PER_ROW = 2;
|
||||
|
||||
const environment = assertSecret(import.meta.env.PUBLIC_ENVIRONMENT);
|
||||
const { locale } = Astro.props;
|
||||
const strings = await api.strings(locale);
|
||||
const rows: Tool[][] = [];
|
||||
|
||||
for (const id in tools) {
|
||||
@@ -49,19 +46,6 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => {
|
||||
});
|
||||
---
|
||||
|
||||
<AstroSeo
|
||||
title="BlitzKit"
|
||||
description={strings.website.home.seo_description}
|
||||
canonical={Astro.url.href}
|
||||
openGraph={{
|
||||
url: Astro.url.href,
|
||||
title: "BlitzKit",
|
||||
description: strings.website.home.seo_description,
|
||||
site_name: "BlitzKit",
|
||||
}}
|
||||
twitter={{ cardType: "summary_large_image" }}
|
||||
/>
|
||||
|
||||
<BaseLayout accent="blue" {locale}>
|
||||
<!-- <HomeHero {locale} /> -->
|
||||
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
---
|
||||
import { AstroSeo } from "@astrolib/seo";
|
||||
import { getStrings } from "../../../../core/i18n/getStrings";
|
||||
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
|
||||
const { locale } = Astro.props;
|
||||
|
||||
const strings = getStrings(locale);
|
||||
---
|
||||
|
||||
<AstroSeo
|
||||
title={strings.website.settings.title}
|
||||
description={strings.website.settings.description}
|
||||
/>
|
||||
|
||||
<BaseLayout {locale}>
|
||||
<Page {locale} client:load />
|
||||
</BaseLayout>
|
||||
@@ -3,6 +3,7 @@ import { DiscordLogoIcon, HomeIcon } from "@radix-ui/react-icons";
|
||||
import { Button, Flex, Heading, Link, Text } from "@radix-ui/themes";
|
||||
import { LinkI18n } from "../../components/LinkI18n";
|
||||
import { PageWrapper } from "../../components/PageWrapper";
|
||||
import { discordLink } from "../../config/socials";
|
||||
import BaseLayout from "../../layouts/BaseLayout.astro";
|
||||
|
||||
export { getStaticPaths } from "./_index";
|
||||
@@ -18,12 +19,14 @@ const { locale } = Astro.props;
|
||||
<Flex mt="4" gap="2">
|
||||
<LinkI18n {locale} href="/">
|
||||
<Button>
|
||||
<HomeIcon /> Home
|
||||
<HomeIcon />
|
||||
Home
|
||||
</Button>
|
||||
</LinkI18n>
|
||||
<Link href="https://discord.gg/nDt7AjGJQH">
|
||||
<Link href={discordLink}>
|
||||
<Button variant="outline">
|
||||
<DiscordLogoIcon /> Discord
|
||||
<DiscordLogoIcon />
|
||||
Discord
|
||||
</Button>
|
||||
</Link>
|
||||
</Flex>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { EmbedConfigItem } from '.';
|
||||
import type { EmbedConfigItem } from ".";
|
||||
|
||||
export enum EmbedItemType {
|
||||
Radius,
|
||||
@@ -12,16 +12,14 @@ export enum EmbedItemType {
|
||||
Enum,
|
||||
}
|
||||
|
||||
export const radixGrays = [
|
||||
'gray',
|
||||
'mauve',
|
||||
'slate',
|
||||
'sage',
|
||||
'olive',
|
||||
'sand',
|
||||
export const grays = [
|
||||
"gray",
|
||||
"mauve",
|
||||
"slate",
|
||||
"sage",
|
||||
"olive",
|
||||
"sand",
|
||||
] as const;
|
||||
|
||||
export const radixTextWeights = ['light', 'regular', 'medium', 'bold'] as const;
|
||||
|
||||
export type EmbedConfigItemType<Type extends EmbedItemType> =
|
||||
EmbedConfigItem & { type: Type };
|
||||
@@ -1,25 +1,26 @@
|
||||
import * as radixColors from "@radix-ui/colors";
|
||||
import { Soapstone } from "soapstone";
|
||||
import type { Color } from "../../ui/color";
|
||||
import type {
|
||||
Radius,
|
||||
Space,
|
||||
SpaceWithout0,
|
||||
Weight,
|
||||
} from "../../types/styles";
|
||||
import {
|
||||
type EmbedConfigItemType,
|
||||
EmbedItemType,
|
||||
radixGrays,
|
||||
radixTextWeights,
|
||||
grays,
|
||||
} from "./constants";
|
||||
|
||||
export type RadixSize = `${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
|
||||
export type RadixSizeWithout0 = Exclude<RadixSize, "0">;
|
||||
export type RadixRadius = `${1 | 2 | 3 | 4}` | "full";
|
||||
export type RadixTextWeight = (typeof radixTextWeights)[number];
|
||||
export type RadixColorCompound = {
|
||||
base: RadixColor;
|
||||
variant: RadixColorVariant;
|
||||
export type ColorCompound = {
|
||||
base: Color;
|
||||
variant: ColorVariant;
|
||||
};
|
||||
export type RadixTextColor =
|
||||
| Exclude<RadixColor, RadixColorGrays>
|
||||
export type TextColor =
|
||||
| Exclude<Color, Gray>
|
||||
| "gray"
|
||||
| undefined;
|
||||
export type RadixColorVariantRaw = `${
|
||||
export type ColorStep = `${
|
||||
| 1
|
||||
| 2
|
||||
| 3
|
||||
@@ -32,12 +33,8 @@ export type RadixColorVariantRaw = `${
|
||||
| 10
|
||||
| 11
|
||||
| 12}`;
|
||||
export type RadixColorVariant = `${"" | "a"}${RadixColorVariantRaw}`;
|
||||
export type RadixColor = Exclude<
|
||||
keyof typeof radixColors,
|
||||
`${string}${"A" | "P3" | "Dark"}`
|
||||
>;
|
||||
export type RadixColorGrays = (typeof radixGrays)[number];
|
||||
export type ColorVariant = `${"" | "a"}${ColorStep}`;
|
||||
export type Gray = (typeof grays)[number];
|
||||
|
||||
export type ExtractEmbedConfigTypes<Config extends EmbedConfig> = {
|
||||
[Key in keyof Config]: ({
|
||||
@@ -67,15 +64,15 @@ export type EmbedConfigItem = (
|
||||
}
|
||||
| {
|
||||
type: EmbedItemType.Radius;
|
||||
default: RadixRadius;
|
||||
default: Radius;
|
||||
}
|
||||
| {
|
||||
type: EmbedItemType.Size;
|
||||
default: RadixSize;
|
||||
default: Space;
|
||||
}
|
||||
| {
|
||||
type: EmbedItemType.SizeWithout0;
|
||||
default: RadixSizeWithout0;
|
||||
default: SpaceWithout0;
|
||||
}
|
||||
| {
|
||||
type: EmbedItemType.Color;
|
||||
@@ -85,8 +82,8 @@ export type EmbedConfigItem = (
|
||||
type: EmbedItemType.RichText;
|
||||
default: {
|
||||
color: string;
|
||||
size: RadixSizeWithout0;
|
||||
weight: RadixTextWeight;
|
||||
size: SpaceWithout0;
|
||||
weight: Weight;
|
||||
};
|
||||
}
|
||||
| {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { CSSProperties } from "react";
|
||||
import type { Radius, Space, SpaceWithout0, Weight } from "../../types/styles";
|
||||
|
||||
export interface EmbedRichText {
|
||||
color: string;
|
||||
size: SpaceWithout0;
|
||||
weight: Weight;
|
||||
}
|
||||
|
||||
export function embedSpace(size: Space) {
|
||||
return `var(--space-${size})`;
|
||||
}
|
||||
|
||||
export function embedRadius(radius: Radius) {
|
||||
if (radius === "full") return "var(--radius-max)";
|
||||
return embedSpace(radius);
|
||||
}
|
||||
|
||||
export function embedText({ color, size, weight }: EmbedRichText) {
|
||||
return {
|
||||
color,
|
||||
fontSize: embedSpace(size),
|
||||
fontWeight: `var(--weight-${weight})`,
|
||||
} satisfies CSSProperties;
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { TextProps } from "@radix-ui/themes";
|
||||
import { EmbedState, type EmbedConfig, type ExtractEmbedConfigTypes } from ".";
|
||||
import {
|
||||
breakdownConfig,
|
||||
extractEmbedConfigDefaults,
|
||||
} from "../../constants/embeds";
|
||||
import type { EmbedConfigItemType, EmbedItemType } from "./constants";
|
||||
import { embedText } from "./tokens";
|
||||
|
||||
export function useEmbedStateCurry<Config extends EmbedConfig>() {
|
||||
// TODO: find a way to initialize with the correct state preset
|
||||
@@ -23,14 +23,11 @@ export function useEmbedStateCurry<Config extends EmbedConfig>() {
|
||||
: never;
|
||||
}[keyof Config],
|
||||
>(key: Key) {
|
||||
const { color, ...state } = useEmbedState(
|
||||
const state = useEmbedState(
|
||||
key,
|
||||
) as EmbedConfigItemType<EmbedItemType.RichText>["default"];
|
||||
|
||||
return {
|
||||
style: { color },
|
||||
...state,
|
||||
} satisfies TextProps;
|
||||
return embedText(state);
|
||||
}
|
||||
|
||||
return { useEmbedState, useRichText };
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export type Space = `${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { weights } from "../config/styles";
|
||||
|
||||
export type Space = `${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
|
||||
export type SpaceWithout0 = Exclude<Space, "0">;
|
||||
|
||||
export type Radius = Space | "full";
|
||||
|
||||
export type Weight = keyof typeof weights;
|
||||
Reference in new issue
Block a user