Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/web-ui/src/app/components/SceneTopBar/SceneTopBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
container-type: inline-size;
user-select: none;

&:has(.window-controls--windows) {
// Extend through the scene surface's right gutter so Close reaches the edge.
width: calc(100% + var(--openbitfun-space-4));
padding-block: 0;
padding-inline-end: 0;

> [data-openbitfun-part='trailing'] {
align-self: stretch;
}
}

&[data-bordered='true'] {
&::before,
&::after {
Expand Down
32 changes: 32 additions & 0 deletions src/web-ui/src/app/components/WindowControls/WindowControls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,38 @@
}
}

// Windows caption buttons keep their full hit area even in a narrow window.
.window-controls--windows {
align-items: stretch;
gap: 0;
height: 100%;

.window-controls__btn {
flex: 0 0 46px;
width: 46px;
height: 100%;
border: 0;
border-radius: 0;
color: var(--openbitfun-color-content-primary);
cursor: default;

svg {
width: 12px;
height: 12px;
transition: none;
}

&:focus-visible {
outline-offset: -2px;
}

&--close:hover:not(:disabled) {
background: var(--openbitfun-color-status-danger-content);
color: var(--openbitfun-color-content-on-dark);
}
}
}

@media (prefers-reduced-motion: reduce) {
.window-controls__btn {
transition: none;
Expand Down
20 changes: 16 additions & 4 deletions src/web-ui/src/app/components/WindowControls/WindowControls.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Tooltip } from '@openbitfun/ui';
import { useTranslation } from 'react-i18next';
import { isWindowsDesktopRuntime } from '@/infrastructure/runtime';
import './WindowControls.scss';

export interface WindowControlsProps
Expand Down Expand Up @@ -38,6 +39,12 @@ const CloseGlyph = () => (
</svg>
);

const WindowsGlyph = ({ d }: { d: string }) => (
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
<path d={d} stroke="currentColor" strokeWidth="1" />
</svg>
);

/** Desktop-shell window commands. This is product chrome, not a public UI primitive. */
export const WindowControls: React.FC<WindowControlsProps> = ({
onMinimize,
Expand All @@ -49,6 +56,7 @@ export const WindowControls: React.FC<WindowControlsProps> = ({
...props
}) => {
const { t } = useTranslation('common');
const isWindows = isWindowsDesktopRuntime();
const maximizeLabel = maximized ? t('window.restore') : t('window.maximize');

const run = (event: React.MouseEvent<HTMLButtonElement>, command: () => void) => {
Expand All @@ -60,7 +68,7 @@ export const WindowControls: React.FC<WindowControlsProps> = ({
return (
<div
{...props}
className={['window-controls', className].filter(Boolean).join(' ')}
className={['window-controls', isWindows && 'window-controls--windows', className].filter(Boolean).join(' ')}
data-openbitfun-component="window-controls"
data-openbitfun-part="root"
data-openbitfun-state={[disabled && 'disabled', maximized && 'maximized'].filter(Boolean).join(' ') || undefined}
Expand All @@ -73,7 +81,7 @@ export const WindowControls: React.FC<WindowControlsProps> = ({
disabled={disabled}
aria-label={t('window.minimize')}
>
<MinimizeGlyph />
{isWindows ? <WindowsGlyph d="M1 6.5h10" /> : <MinimizeGlyph />}
</button>
</Tooltip>

Expand All @@ -85,7 +93,11 @@ export const WindowControls: React.FC<WindowControlsProps> = ({
disabled={disabled}
aria-label={maximizeLabel}
>
{maximized ? <RestoreGlyph /> : <MaximizeGlyph />}
{isWindows ? (
<WindowsGlyph d={maximized
? 'M3.5 3.5v-2h7v7h-2 M1.5 3.5h7v7h-7z'
: 'M1.5 1.5h9v9h-9z'} />
) : maximized ? <RestoreGlyph /> : <MaximizeGlyph />}
</button>
</Tooltip>

Expand All @@ -97,7 +109,7 @@ export const WindowControls: React.FC<WindowControlsProps> = ({
disabled={disabled}
aria-label={t('window.close')}
>
<CloseGlyph />
{isWindows ? <WindowsGlyph d="m1.5 1.5 9 9 m0-9-9 9" /> : <CloseGlyph />}
</button>
</Tooltip>
</div>
Expand Down
Loading