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