fix(webui): align settings sidebar footer rows
This commit is contained in:
1 parent
6057ce59e5
commit
bc690f0394
3 files changed
+15
-12
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useContext, useEffect, useState, type ComponentProps } from "react";
|
||||
|
||||
import { useClient } from "@/providers/ClientProvider";
|
||||
import type { ConnectionStatus } from "@/lib/types";
|
||||
@@ -8,10 +8,10 @@ import { HostSwitcherView } from "./HostSwitcherView";
|
||||
export { HostNavigationContext, type HostPicker } from "./host-navigation";
|
||||
export { RemoteHostMenu } from "./HostSwitcherView";
|
||||
|
||||
export function HostSwitcher({ collapsed = false, portalContainer }: { collapsed?: boolean; portalContainer?: HTMLElement | null }) {
|
||||
export function HostSwitcher(props: Omit<ComponentProps<typeof HostSwitcherView>, "picker" | "status">) {
|
||||
const picker = useContext(HostNavigationContext);
|
||||
const { client } = useClient();
|
||||
const [status, setStatus] = useState<ConnectionStatus>(client.status);
|
||||
useEffect(() => client.onStatus(setStatus), [client]);
|
||||
return <HostSwitcherView picker={picker} status={status} collapsed={collapsed} portalContainer={portalContainer} />;
|
||||
return <HostSwitcherView {...props} picker={picker} status={status} />;
|
||||
}
|
||||
@@ -101,11 +101,12 @@ function HostMenuItems({ picker }: { picker: HostPicker }) {
|
||||
}
|
||||
|
||||
/** Shared sidebar control. Remote frames can only open the trusted shell's menu. */
|
||||
export function HostSwitcherView({ picker, status, collapsed = false, portalContainer }: {
|
||||
export function HostSwitcherView({ picker, status, collapsed = false, portalContainer, className }: {
|
||||
picker: HostPicker | EmbeddedPicker | null;
|
||||
status: ConnectionStatus;
|
||||
collapsed?: boolean;
|
||||
portalContainer?: HTMLElement | null;
|
||||
className?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
@@ -128,7 +129,7 @@ export function HostSwitcherView({ picker, status, collapsed = false, portalCont
|
||||
const detail = pendingName ? `${current}. ${t("remote.preparing", { name: pendingName })}` : current;
|
||||
const button = <Button ref={buttonRef} variant="ghost" size="sm" aria-label={t("remote.switchHost")}
|
||||
data-host-switcher data-theme-surface data-theme-ink className={cn("host-no-drag touch-target h-8 min-w-0 gap-2 rounded-xl px-2 text-xs font-normal text-sidebar-content/75 hover:text-sidebar-content",
|
||||
collapsed ? "w-8 justify-center px-0" : "max-w-full flex-1 justify-start")}
|
||||
collapsed ? "w-8 justify-center px-0" : "max-w-full flex-1 justify-start", className)}
|
||||
onClick={picker.kind === "embedded" ? () => {
|
||||
const rect = buttonRef.current?.getBoundingClientRect();
|
||||
if (rect) picker.open({ left: rect.left, top: rect.top, width: rect.width, height: rect.height });
|
||||
|
||||
@@ -29,6 +29,8 @@ import {
|
||||
import { useMediaQuery } from "@/hooks/useMediaQuery";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const SIDEBAR_ROW = "touch-target flex h-9 w-full items-center justify-start gap-2 rounded-xl px-2.5 text-left text-ui font-normal";
|
||||
|
||||
const SETTINGS_NAV_ITEMS: Array<{ key: SettingsSectionKey; icon: LucideIcon; fallback: string }> = [
|
||||
{ key: "overview", icon: OverviewIcon, fallback: "Overview" },
|
||||
{ key: "appearance", icon: AppearanceIcon, fallback: "Appearance" },
|
||||
@@ -130,7 +132,7 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
|
||||
aria-current={active ? "page" : undefined}
|
||||
onClick={() => onSelectSection(key)}
|
||||
className={cn(
|
||||
"touch-target flex h-9 w-full items-center gap-2 rounded-xl px-2.5 text-left text-ui",
|
||||
SIDEBAR_ROW,
|
||||
SIDEBAR_SELECTION_ITEM_CLASS,
|
||||
active
|
||||
? "text-sidebar-accent-foreground"
|
||||
@@ -147,9 +149,9 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
|
||||
</SidebarSelectionHighlight>
|
||||
</nav>
|
||||
|
||||
<div className="pt-2 lg:mt-auto lg:pt-4">
|
||||
<div className="mt-auto grid gap-1 pt-4">
|
||||
{onRestart ? (
|
||||
<div>
|
||||
<>
|
||||
{restartPending ? (
|
||||
<p id="settings-restart-status" role="status" className="sr-only">
|
||||
{t("settings.status.savedRestartApply")}
|
||||
@@ -161,7 +163,7 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
|
||||
onClick={onRestart}
|
||||
disabled={isRestarting}
|
||||
aria-describedby={restartPending ? "settings-restart-status" : undefined}
|
||||
className={cn("h-9 w-full justify-start gap-2 rounded-control px-2.5 text-ui settings-hover",
|
||||
className={cn(SIDEBAR_ROW, "settings-hover",
|
||||
restartPending && !isRestarting
|
||||
? "settings-restart-pending text-orange-600 hover:text-orange-700 dark:text-orange-400 dark:hover:text-orange-300"
|
||||
: "text-sidebar-content hover:text-foreground")}
|
||||
@@ -170,20 +172,20 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
|
||||
: <RestartIcon className="h-4 w-4" aria-hidden />}
|
||||
<span>{restartLabel}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
{onLogout && !hostChromeInset ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
onClick={onLogout}
|
||||
className="hidden h-9 w-full justify-start gap-2 rounded-control px-2.5 text-ui text-sidebar-content hover:bg-destructive/8 hover:text-destructive lg:flex"
|
||||
className={cn(SIDEBAR_ROW, "text-sidebar-content hover:bg-destructive/8 hover:text-destructive")}
|
||||
>
|
||||
<LogOut className="h-4 w-4" aria-hidden />
|
||||
<span>{t("app.account.logout")}</span>
|
||||
</Button>
|
||||
) : null}
|
||||
{hostNavigation && <div className="mt-2 flex min-w-0"><HostSwitcher /></div>}
|
||||
{hostNavigation && <HostSwitcher className={SIDEBAR_ROW} />}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user