scroll dialog

This commit is contained in:
tresabhi committed 2026-12-03 21:53:14 -06:00
1 parent 7684867180
commit 4c57a5ffca
8 files changed
+278 -300

No files matched your search

@@ -1,41 +1,8 @@
.Overlay { @import "../Dialog/index.module.css";
position: fixed;
inset: 0;
z-index: 1;
background-color: var(--black-a9);
}
.Content { .Content {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
display: flex;
flex-direction: column;
gap: var(--space-3); gap: var(--space-3);
box-sizing: border-box; width: 100%;
width: calc(100dvw - 2 * var(--space-4));
max-width: var(--alert-max-width); max-width: var(--alert-max-width);
padding: var(--space-4);
background-color: var(--gray-2);
box-shadow: var(--shadow-subtle);
border-radius: var(--space-4);
outline: var(--outline-interactive) !important;
} }
.Title {
margin: 0;
font-size: var(--font-size-heading-4);
color: var(--gray-12);
}
.Description {
margin: 0;
color: var(--gray-11);
}
@@ -3,25 +3,26 @@
inset: 0; inset: 0;
z-index: 1; z-index: 1;
display: flex;
box-sizing: border-box;
padding: var(--space-4);
overflow-y: auto;
background-color: var(--black-a9); background-color: var(--black-a9);
} }
.Content { .Content {
position: fixed; margin: auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: var(--space-4); gap: var(--space-4);
box-sizing: border-box; box-sizing: border-box;
max-width: min(40rem, calc(100dvw - 2 * var(--space-4))); min-width: 0;
max-height: calc(100dvh - 2 * var(--space-4)); max-width: min(40rem, 100%);
padding: var(--space-4); padding: var(--space-4);
overflow: hidden;
background-color: var(--gray-2); background-color: var(--gray-2);
box-shadow: var(--shadow-subtle); box-shadow: var(--shadow-subtle);
@@ -78,122 +78,124 @@ export function GenerateURL({ embed }: GenerateURLProps) {
</Dialog.Trigger> </Dialog.Trigger>
<Dialog.Portal> <Dialog.Portal>
<Dialog.Overlay /> <Dialog.Overlay>
<Dialog.Content className={styles.content}> <Dialog.Content className={styles.content}>
<Dialog.Header> <Dialog.Header>
<Dialog.Title>{generateStrings.title}</Dialog.Title> <Dialog.Title>{generateStrings.title}</Dialog.Title>
<Dialog.Description> <Dialog.Description>
{generateStrings.subtitle} {generateStrings.subtitle}
</Dialog.Description> </Dialog.Description>
</Dialog.Header> </Dialog.Header>
<Dialog.Body> <Dialog.Body>
<TextField <TextField
placeholder={strings.common.search.hint_players} placeholder={strings.common.search.hint_players}
ref={input} ref={input}
onChange={handleChange} onChange={handleChange}
> >
<PersonIcon /> <PersonIcon />
</TextField> </TextField>
<div className={styles.results}> <div className={styles.results}>
{searching && ( {searching && (
<Text lowContrast className={styles.searching}> <Text lowContrast className={styles.searching}>
<Spinner /> <Spinner />
{strings.common.search.searching} {strings.common.search.searching}
</Text> </Text>
)} )}
{!searching && results.length === 0 && ( {!searching && results.length === 0 && (
<Text lowContrast>{strings.common.search.no_results}</Text> <Text lowContrast>{strings.common.search.no_results}</Text>
)} )}
{!searching && results.length > 0 && ( {!searching && results.length > 0 && (
<SearchResults.Root> <SearchResults.Root>
{results.map((result) => ( {results.map((result) => (
<SearchResults.Item <SearchResults.Item
key={`${result.region}-${result.account_id}`} key={`${result.region}-${result.account_id}`}
text={result.nickname} text={result.nickname}
discriminator={ discriminator={
strings.common.regions.short[result.region] strings.common.regions.short[result.region]
} }
onClick={() => { onClick={() => {
setCopyUser(result); setCopyUser(result);
setCopyDialogOpen(true); setCopyDialogOpen(true);
setSearchDialogOpen(false); setSearchDialogOpen(false);
}} }}
/> />
))} ))}
</SearchResults.Root> </SearchResults.Root>
)} )}
</div> </div>
</Dialog.Body> </Dialog.Body>
<Dialog.Actions> <Dialog.Actions>
<Dialog.Close asChild> <Dialog.Close asChild>
<Button color="red" variant="outline"> <Button color="red" variant="outline">
{generateStrings.cancel} {generateStrings.cancel}
</Button> </Button>
</Dialog.Close> </Dialog.Close>
</Dialog.Actions> </Dialog.Actions>
</Dialog.Content> </Dialog.Content>
</Dialog.Overlay>
</Dialog.Portal> </Dialog.Portal>
</Dialog.Root> </Dialog.Root>
<Dialog.Root open={copyDialogOpen} onOpenChange={setCopyDialogOpen}> <Dialog.Root open={copyDialogOpen} onOpenChange={setCopyDialogOpen}>
<Dialog.Portal> <Dialog.Portal>
<Dialog.Overlay /> <Dialog.Overlay>
<Dialog.Content className={styles.content}> <Dialog.Content className={styles.content}>
<Dialog.Header> <Dialog.Header>
<Dialog.Title>{generateStrings.success.title}</Dialog.Title> <Dialog.Title>{generateStrings.success.title}</Dialog.Title>
<Dialog.Description> <Dialog.Description>
{literals(generateStrings.success.info, { {literals(generateStrings.success.info, {
name: copyUser?.nickname, name: copyUser?.nickname,
})} })}
</Dialog.Description> </Dialog.Description>
</Dialog.Header> </Dialog.Header>
<Dialog.Actions> <Dialog.Actions>
<Button <Button
variant="outline" variant="outline"
onClick={() => { onClick={() => {
setCopyDialogOpen(false); setCopyDialogOpen(false);
setSearchDialogOpen(true); setSearchDialogOpen(true);
}} }}
> >
<CaretLeftIcon /> <CaretLeftIcon />
{generateStrings.success.back} {generateStrings.success.back}
</Button> </Button>
<CopyButton <CopyButton
copy={() => { copy={() => {
if (!copyUser) return; if (!copyUser) return;
const shallowState: EmbedStateStore = {}; const shallowState: EmbedStateStore = {};
Object.entries(EmbedState.state).forEach(([key, value]) => { Object.entries(EmbedState.state).forEach(([key, value]) => {
if (value !== EmbedState.initial[key]) { if (value !== EmbedState.initial[key]) {
shallowState[key] = value; shallowState[key] = value;
} }
}); });
const searchParams = new URLSearchParams({ const searchParams = new URLSearchParams({
id: `${copyUser.account_id}`, id: `${copyUser.account_id}`,
state: stringify(shallowState), state: stringify(shallowState),
}); });
setSearchDialogOpen(false); setSearchDialogOpen(false);
setCopyDialogOpen(false); setCopyDialogOpen(false);
return `${ return `${
location.origin location.origin
}/embed/${embed}/host?${searchParams.toString()}`; }/embed/${embed}/host?${searchParams.toString()}`;
}} }}
> >
<Link2Icon /> <Link2Icon />
{generateStrings.success.copy} {generateStrings.success.copy}
</CopyButton> </CopyButton>
</Dialog.Actions> </Dialog.Actions>
</Dialog.Content> </Dialog.Content>
</Dialog.Overlay>
</Dialog.Portal> </Dialog.Portal>
</Dialog.Root> </Dialog.Root>
</> </>
@@ -30,23 +30,24 @@ export function Import() {
onOpenChange={setShowInvalidURLPrompt} onOpenChange={setShowInvalidURLPrompt}
> >
<AlertDialog.Portal> <AlertDialog.Portal>
<AlertDialog.Overlay /> <AlertDialog.Overlay>
<AlertDialog.Content> <AlertDialog.Content>
<AlertDialog.Title> <AlertDialog.Title>
{strings.embed.configuration.import.idiot_title} {strings.embed.configuration.import.idiot_title}
</AlertDialog.Title> </AlertDialog.Title>
<AlertDialog.Description> <AlertDialog.Description>
{strings.embed.configuration.import.idiot_description} {strings.embed.configuration.import.idiot_description}
</AlertDialog.Description> </AlertDialog.Description>
<AlertDialog.Actions> <AlertDialog.Actions>
<AlertDialog.Cancel asChild> <AlertDialog.Cancel asChild>
<Button> <Button>
{strings.embed.configuration.import.idiot_button} {strings.embed.configuration.import.idiot_button}
</Button> </Button>
</AlertDialog.Cancel> </AlertDialog.Cancel>
</AlertDialog.Actions> </AlertDialog.Actions>
</AlertDialog.Content> </AlertDialog.Content>
</AlertDialog.Overlay>
</AlertDialog.Portal> </AlertDialog.Portal>
</AlertDialog.Root> </AlertDialog.Root>
@@ -98,7 +98,7 @@ export function Guesser() {
}); });
setResults( setResults(
searchResults.map((result) => tankDefinitions.tanks[result.obj.id]) searchResults.map((result) => tankDefinitions.tanks[result.obj.id]),
); );
}, []); }, []);
@@ -124,7 +124,10 @@ export function Guesser() {
text={unwrap(result.name!)} text={unwrap(result.name!)}
prefix={ prefix={
<LazyImage <LazyImage
src={alias("api", `nations/${result.nation}/flags/circle.webp`)} src={alias(
"api",
`nations/${result.nation}/flags/circle.webp`,
)}
/> />
} }
discriminator={ discriminator={
@@ -244,36 +247,37 @@ export function Guesser() {
</AlertDialog.Trigger> </AlertDialog.Trigger>
<AlertDialog.Portal> <AlertDialog.Portal>
<AlertDialog.Overlay /> <AlertDialog.Overlay>
<AlertDialog.Content> <AlertDialog.Content>
<AlertDialog.Title> <AlertDialog.Title>
{strings.guesser.help.title} {strings.guesser.help.title}
</AlertDialog.Title> </AlertDialog.Title>
<AlertDialog.Description> <AlertDialog.Description>
{strings.guesser.help.description} {strings.guesser.help.description}
</AlertDialog.Description> </AlertDialog.Description>
<AlertDialog.Actions> <AlertDialog.Actions>
<AlertDialog.Cancel asChild> <AlertDialog.Cancel asChild>
<Button variant="outline" color="gray"> <Button variant="outline" color="gray">
{strings.guesser.help.cancel} {strings.guesser.help.cancel}
</Button> </Button>
</AlertDialog.Cancel> </AlertDialog.Cancel>
<AlertDialog.Action asChild> <AlertDialog.Action asChild>
<Button <Button
color="red" color="red"
onClick={() => { onClick={() => {
Guess.mutate((draft) => { Guess.mutate((draft) => {
draft.helpingReveal = true; draft.helpingReveal = true;
}); });
}} }}
> >
{strings.guesser.help.reveal} {strings.guesser.help.reveal}
</Button> </Button>
</AlertDialog.Action> </AlertDialog.Action>
</AlertDialog.Actions> </AlertDialog.Actions>
</AlertDialog.Content> </AlertDialog.Content>
</AlertDialog.Overlay>
</AlertDialog.Portal> </AlertDialog.Portal>
</AlertDialog.Root> </AlertDialog.Root>
@@ -315,7 +319,7 @@ export function Guesser() {
return tiers.includes(tank.tier); return tiers.includes(tank.tier);
}); });
const id = Number( const id = Number(
filteredIds[Math.floor(Math.random() * filteredIds.length)] filteredIds[Math.floor(Math.random() * filteredIds.length)],
); );
const tank = tankDefinitions.tanks[id]; const tank = tankDefinitions.tanks[id];
@@ -61,62 +61,63 @@ export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
</Dialog.Trigger> </Dialog.Trigger>
<Dialog.Portal> <Dialog.Portal>
<Dialog.Overlay /> <Dialog.Overlay>
<Dialog.Content> <Dialog.Content>
<Dialog.Header> <Dialog.Header>
<Dialog.Title>{strings.common.screenshot.title}</Dialog.Title> <Dialog.Title>{strings.common.screenshot.title}</Dialog.Title>
<Dialog.Description> <Dialog.Description>
{strings.common.screenshot.description} {strings.common.screenshot.description}
</Dialog.Description> </Dialog.Description>
</Dialog.Header> </Dialog.Header>
<Dialog.Actions> <Dialog.Actions>
<Dialog.Close asChild> <Dialog.Close asChild>
<Button color="red" variant="outline"> <Button color="red" variant="outline">
{strings.common.screenshot.cancel} {strings.common.screenshot.cancel}
</Button> </Button>
</Dialog.Close> </Dialog.Close>
<Dialog.Close asChild> <Dialog.Close asChild>
<Button <Button
variant="outline" variant="outline"
onClick={async () => { onClick={async () => {
const image = await screenshot(); const image = await screenshot();
const buffer = await image.getBuffer("image/png"); const buffer = await image.getBuffer("image/png");
const blob = new Blob([buffer as unknown as ArrayBuffer], { const blob = new Blob([buffer as unknown as ArrayBuffer], {
type: "image/png", type: "image/png",
}); });
navigator.clipboard.write([ navigator.clipboard.write([
new ClipboardItem({ "image/png": blob }), new ClipboardItem({ "image/png": blob }),
]); ]);
}} }}
> >
<CopyIcon /> <CopyIcon />
{strings.common.screenshot.copy} {strings.common.screenshot.copy}
</Button> </Button>
</Dialog.Close> </Dialog.Close>
<Dialog.Close asChild> <Dialog.Close asChild>
<Button <Button
onClick={async () => { onClick={async () => {
const image = await screenshot(); const image = await screenshot();
const anchor = document.createElement("a"); const anchor = document.createElement("a");
anchor.setAttribute("download", `${name}.png`); anchor.setAttribute("download", `${name}.png`);
anchor.setAttribute( anchor.setAttribute(
"href", "href",
await image.getBase64("image/png"), await image.getBase64("image/png"),
); );
anchor.click(); anchor.click();
}} }}
> >
<DownloadIcon /> <DownloadIcon />
{strings.common.screenshot.download} {strings.common.screenshot.download}
</Button> </Button>
</Dialog.Close> </Dialog.Close>
</Dialog.Actions> </Dialog.Actions>
</Dialog.Content> </Dialog.Content>
</Dialog.Overlay>
</Dialog.Portal> </Dialog.Portal>
</Dialog.Root> </Dialog.Root>
); );
@@ -31,44 +31,44 @@ export const SettingsDialog = withLocale(
<Dialog.Trigger className={styles.trigger}>{children}</Dialog.Trigger> <Dialog.Trigger className={styles.trigger}>{children}</Dialog.Trigger>
<Dialog.Portal> <Dialog.Portal>
<Dialog.Overlay /> <Dialog.Overlay>
<Dialog.Content>
<Dialog.Header>
<Dialog.Title>{strings.navbar.settings}</Dialog.Title>
</Dialog.Header>
<Dialog.Content> <Dialog.Body>
<Dialog.Header> <div className={styles.row}>
<Dialog.Title>{strings.navbar.settings}</Dialog.Title> <Text>{strings.settings.language}</Text>
</Dialog.Header> <LocaleSelect options={localeOptions} />
</div>
<Dialog.Body> <div className={styles.row}>
<div className={styles.row}> <Text>{strings.settings.auto_load_models}</Text>
<Text>{strings.settings.language}</Text> <Switch
<LocaleSelect options={localeOptions} /> checked={autoLoadModels}
</div> onCheckedChange={(checked) => {
App.mutate((draft) => {
draft.autoLoadModels = checked;
});
}}
/>
</div>
<div className={styles.row}> <div className={styles.row}>
<Text>{strings.settings.auto_load_models}</Text> <Text>{strings.settings.developer_mode}</Text>
<Switch <Switch
checked={autoLoadModels} checked={developerMode}
onCheckedChange={(checked) => { onCheckedChange={(checked) => {
App.mutate((draft) => { App.mutate((draft) => {
draft.autoLoadModels = checked; draft.developerMode = checked;
}); });
}} }}
/> />
</div> </div>
</Dialog.Body>
<div className={styles.row}> </Dialog.Content>
<Text>{strings.settings.developer_mode}</Text> </Dialog.Overlay>
<Switch
checked={developerMode}
onCheckedChange={(checked) => {
App.mutate((draft) => {
draft.developerMode = checked;
});
}}
/>
</div>
</Dialog.Body>
</Dialog.Content>
</Dialog.Portal> </Dialog.Portal>
</Dialog.Root> </Dialog.Root>
); );
@@ -50,34 +50,36 @@ export function TankSearchDialog({
<Dialog.Trigger asChild>{children}</Dialog.Trigger> <Dialog.Trigger asChild>{children}</Dialog.Trigger>
<Dialog.Portal> <Dialog.Portal>
<Dialog.Overlay /> <Dialog.Overlay>
<Dialog.Content> <Dialog.Content>
<Dialog.Header> <Dialog.Header>
<Dialog.Title> <Dialog.Title>
{title ?? strings.website.common.tank_search.select_dialog_title} {title ??
</Dialog.Title> strings.website.common.tank_search.select_dialog_title}
</Dialog.Title>
{description && ( {description && (
<Dialog.Description>{description}</Dialog.Description> <Dialog.Description>{description}</Dialog.Description>
)} )}
</Dialog.Header> </Dialog.Header>
<Dialog.Body> <Dialog.Body>
<TankSearchBar locale={locale} onSelect={handleSelect} /> <TankSearchBar locale={locale} onSelect={handleSelect} />
<div className={styles.filters}> <div className={styles.filters}>
<ScrollerCurtains /> <ScrollerCurtains />
<TankSearchFilters locale={locale} /> <TankSearchFilters locale={locale} />
</div> </div>
<TankSearchResults <TankSearchResults
locale={locale} locale={locale}
compact compact
onSelect={handleSelect} onSelect={handleSelect}
onSelectAll={onSelectAll && handleSelectAll} onSelectAll={onSelectAll && handleSelectAll}
/> />
</Dialog.Body> </Dialog.Body>
</Dialog.Content> </Dialog.Content>
</Dialog.Overlay>
</Dialog.Portal> </Dialog.Portal>
</Dialog.Root> </Dialog.Root>
); );