2026-02-01 20:55:39 +02:00
|
|
|
import React from 'react';
|
2026-04-19 15:52:54 +03:00
|
|
|
import { Dialog } from '@base-ui/react/dialog';
|
2026-02-01 20:55:39 +02:00
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
import { SettingsView } from './SettingsView';
|
|
|
|
|
|
|
|
|
|
interface SettingsWindowProps {
|
|
|
|
|
open: boolean;
|
|
|
|
|
onOpenChange: (open: boolean) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Settings rendered as a centered window with blurred backdrop.
|
|
|
|
|
* Used for desktop and web (non-mobile) environments.
|
|
|
|
|
*/
|
|
|
|
|
export const SettingsWindow: React.FC<SettingsWindowProps> = ({ open, onOpenChange }) => {
|
2026-02-04 01:13:23 -08:00
|
|
|
const descriptionId = React.useId();
|
2026-02-28 00:50:02 +02:00
|
|
|
|
|
|
|
|
const hasOpenFloatingMenu = React.useCallback(() => {
|
|
|
|
|
if (typeof document === 'undefined') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Boolean(
|
2026-04-19 15:52:54 +03:00
|
|
|
document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')
|
2026-02-28 00:50:02 +02:00
|
|
|
);
|
|
|
|
|
}, []);
|
|
|
|
|
|
2026-02-01 20:55:39 +02:00
|
|
|
return (
|
2026-04-19 15:52:54 +03:00
|
|
|
<Dialog.Root
|
|
|
|
|
open={open}
|
|
|
|
|
onOpenChange={(next) => {
|
|
|
|
|
if (!next && hasOpenFloatingMenu()) return;
|
|
|
|
|
onOpenChange(next);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Dialog.Portal>
|
|
|
|
|
<Dialog.Backdrop className="fixed inset-0 z-50 bg-black/50 dark:bg-black/75" />
|
|
|
|
|
<Dialog.Popup
|
2026-02-04 01:13:23 -08:00
|
|
|
aria-describedby={descriptionId}
|
2026-02-01 20:55:39 +02:00
|
|
|
className={cn(
|
|
|
|
|
'fixed z-50 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]',
|
2026-02-24 03:28:30 +02:00
|
|
|
'w-[90vw] max-w-[960px] h-[85vh] max-h-[900px]',
|
2026-02-25 14:32:23 +02:00
|
|
|
'rounded-xl border shadow-none overflow-hidden',
|
2026-02-01 20:55:39 +02:00
|
|
|
'bg-background'
|
|
|
|
|
)}
|
|
|
|
|
>
|
2026-04-19 15:52:54 +03:00
|
|
|
<Dialog.Description id={descriptionId} className="sr-only">
|
2026-02-04 01:13:23 -08:00
|
|
|
OpenChamber settings window.
|
2026-04-19 15:52:54 +03:00
|
|
|
</Dialog.Description>
|
2026-02-01 20:55:39 +02:00
|
|
|
<SettingsView onClose={() => onOpenChange(false)} isWindowed />
|
2026-04-19 15:52:54 +03:00
|
|
|
</Dialog.Popup>
|
|
|
|
|
</Dialog.Portal>
|
|
|
|
|
</Dialog.Root>
|
2026-02-01 20:55:39 +02:00
|
|
|
);
|
|
|
|
|
};
|