Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

3.0 KB
Raw Blame
"use client";

import { useState } from "react";
import { PanelLeft } from "lucide-react";
import { Button } from "@/components/ui/button";
import { AppSidebar, AppFrame, usePublishMobileNavigation, useShellDesign } from "@/features/appshell";
import type { SectionId } from "../lib/sections";
import { settingsBackTarget, settingsSection } from "../lib/sections";
import { SettingsSidebar, SettingsTabs } from "./nav";
import { IosSettings } from "./ios-settings";
import { SectionDetail } from "./sections";
import { AndroidSettingsIndex } from "./android-settings";

export function SettingsShell({ active, onSelect }: { active: SectionId | null; onSelect: (id: SectionId | null) => void }) {
  const design = useShellDesign();
  const [sidebarOpen, setSidebarOpen] = useState(false);
  const detail = active ? settingsSection(active) : null;
  const mobile = design.mobileNavigation !== "none";
  const backTo = active ? settingsBackTarget(active) : null;

  usePublishMobileNavigation(
    "os-settings",
    mobile && detail ? { title: detail.label, backLabel: backTo ? "Account" : "Settings", onBack: () => onSelect(backTo) } : null,
    [mobile, detail?.id, detail?.label, backTo, onSelect],
  );

  if (design.settingsNavigation === "ios-stack") {
    return (
      <AppFrame safeArea={false} bodyClassName="overflow-hidden">
        <IosSettings active={active} onSelect={(id) => onSelect(id)} />
      </AppFrame>
    );
  }

  if (design.settingsNavigation === "android-stack") {
    return (
      <AppFrame safeArea={false} bodyClassName="overflow-hidden bg-background">
        {active ? <SectionDetail id={active} showHeading={false} onOpen={(id) => onSelect(id)} /> : <AndroidSettingsIndex onSelect={(id) => onSelect(id)} />}
      </AppFrame>
    );
  }

  const desktopActive: SectionId = active ?? "appearance";
  if (design.settingsNavigation === "macos-sidebar" || design.settingsNavigation === "windows-sidebar") {
    return (
      <div className="flex h-full min-h-0 bg-muted/30">
        <AppSidebar open={sidebarOpen} onOpenChange={setSidebarOpen} title="Settings sections"
          railClassName={design.id === "windows" ? "border-r-0 bg-[var(--mica-win,var(--sidebar))]" : "bg-sidebar/70"}>
          <SettingsSidebar windows={design.id === "windows"} active={desktopActive} onSelect={(id) => { onSelect(id); setSidebarOpen(false); }} />
        </AppSidebar>
        <AppFrame className="min-w-0 flex-1" toolbar={<div className="hidden border-b border-border p-1 @max-[600px]:block">
          <Button variant="ghost" size="sm" onClick={() => setSidebarOpen(true)}><PanelLeft className="size-4" /> Settings sections</Button>
        </div>}>
          <SectionDetail id={desktopActive} onOpen={(id) => onSelect(id)} />
        </AppFrame>
      </div>
    );
  }

  return (
    <AppFrame toolbar={<div className="bg-sidebar/40"><SettingsTabs active={desktopActive} onSelect={(id) => onSelect(id)} /></div>}>
      <SectionDetail id={desktopActive} onOpen={(id) => onSelect(id)} />
    </AppFrame>
  );
}