mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix: centralize iOS safe area and refactor list components (#47)
* fix: add iOS safe-area-inset-top support for fullscreen overlays - Add pt-safe CSS utility class for safe-area-inset-top - Create FullscreenSheet component with built-in safe-area support - Add fullscreen prop to DialogContent for fullscreen dialogs - Update FileBrowserSheet to use FullscreenSheet - Update MobileFilePreviewModal to use FullscreenSheet - Add pt-safe to SettingsDialog mobile view Fixes status bar overlap on iOS devices with notch/Dynamic Island * fix: add pt-safe to main page headers - Header.tsx (main repos page) - SessionDetailHeader.tsx (session page) * docs: add TDD refactoring plan for iOS safe area * remove plan file from repo * refactor: centralize iOS safe area handling with PageHeader component - Add PageHeader component with pt-safe, sticky, z-10, border-b styling - Add TDD test infrastructure (vitest config, testing-library, jsdom) - Refactor Header, SessionDetailHeader, RepoDetailHeader, Workspace to use PageHeader - Fix missing pt-safe on RepoDetailHeader and Workspace pages - All header safe area styling now has single fix point * fix: add pt-safe to remaining fullscreen dialogs and sheets - GitChangesSheet, FilePreviewDialog: add fullscreen prop - ModelSelectDialog, RepoMcpDialog: add pt-safe class - EditSessionTitleDialog: add pt-safe on mobile * fix: use mobile-first positioning for large dialogs Dialogs need top-0 positioning on mobile for pt-safe to work. Centered dialogs don't benefit from safe area padding. * fix: add mobileFullscreen prop to DialogContent - Fullscreen on mobile with pt-safe, centered on desktop - Simplifies large dialog styling * fix: use inline styles for iOS safe area to fix CSS cascade issues - Convert pt-safe/pb-safe to @utility directives with iOS 11 fallback - Use inline styles on DialogContent for reliable safe-area padding - Position close button with calc(env(safe-area-inset-top) + 1rem) - Add 10 tests for DialogContent safe-area behavior * refactor: extract ListToolbar and Header components for reuse - Add ListToolbar component for search/select all/delete UI - Add Header compound component (Header.Root, Header.Title, etc.) - Update SessionList and RepoList to use ListToolbar - Mobile delete: deletes selected or all if none selected - Cancel delete now clears selection - Remove unused layout components --------- Co-authored-by: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com>
This commit is contained in:
1 parent
72bb20a4fa
commit
cd9a552bf8
34 files changed
+1627
-986
No files matched your search
@@ -0,0 +1,134 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "./dialog";
|
||||
|
||||
describe("DialogContent", () => {
|
||||
it("applies safe-area padding when fullscreen prop is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent fullscreen data-testid="dialog-content">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Test Dialog</DialogTitle>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveStyle({ paddingTop: "env(safe-area-inset-top, 0px)" });
|
||||
});
|
||||
|
||||
it("applies safe-area padding when mobileFullscreen prop is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent mobileFullscreen data-testid="dialog-content">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Test Dialog</DialogTitle>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveStyle({ paddingTop: "env(safe-area-inset-top, 0px)" });
|
||||
});
|
||||
|
||||
it("applies inset-0 for fullscreen dialogs", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent fullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveClass("inset-0");
|
||||
});
|
||||
|
||||
it("applies inset-0 for mobileFullscreen dialogs", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent mobileFullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveClass("inset-0");
|
||||
});
|
||||
|
||||
it("does not apply safe-area padding when neither fullscreen nor mobileFullscreen", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
const style = content.getAttribute("style") || "";
|
||||
expect(style).not.toContain("safe-area");
|
||||
expect(content).not.toHaveClass("inset-0");
|
||||
});
|
||||
|
||||
it("hides close button when fullscreen is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent fullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.queryByRole("button", { name: /close/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows close button when mobileFullscreen is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent mobileFullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.getByRole("button", { name: /close/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("hides close button when hideCloseButton is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent hideCloseButton data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.queryByRole("button", { name: /close/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("merges custom className with default classes", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent className="custom-class" data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveClass("custom-class");
|
||||
expect(content).toHaveClass("fixed");
|
||||
expect(content).toHaveClass("z-50");
|
||||
});
|
||||
|
||||
it("renders children correctly", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent>
|
||||
<span>Test Child Content</span>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.getByText("Test Child Content")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user