mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
feat: add an auto or fixed columns picker to card grids
This commit is contained in:
1 parent
7b7b17e31f
commit
5f332aa5c3
18 files changed
+231
-83
No files matched your search
@@ -11,6 +11,7 @@ import {
|
||||
PanelShell,
|
||||
Segmented,
|
||||
ViewToggle,
|
||||
gridSizeStyle,
|
||||
} from "@/components/panel-layout";
|
||||
|
||||
afterEach(cleanup);
|
||||
@@ -72,6 +73,34 @@ describe("ViewToggle", () => {
|
||||
fireEvent.click(screen.getByLabelText("panel.compactRows"));
|
||||
expect(onDensity).toHaveBeenCalledWith("compact");
|
||||
});
|
||||
|
||||
it("shows the columns picker only in grid view", () => {
|
||||
const props = { onView: vi.fn(), columns: "auto" as const };
|
||||
const { rerender } = render(
|
||||
<ViewToggle view="grid" {...props} onColumns={vi.fn()} />,
|
||||
);
|
||||
expect(screen.getByLabelText("panel.columns.title")).toBeTruthy();
|
||||
|
||||
rerender(<ViewToggle view="list" {...props} onColumns={vi.fn()} />);
|
||||
expect(screen.queryByLabelText("panel.columns.title")).toBeNull();
|
||||
|
||||
rerender(<ViewToggle view="grid" {...props} />);
|
||||
expect(screen.queryByLabelText("panel.columns.title")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("gridSizeStyle", () => {
|
||||
it("fits auto cards to the pane", () => {
|
||||
expect(gridSizeStyle("auto", 280).gridTemplateColumns).toBe(
|
||||
"repeat(auto-fill, minmax(min(100%, 280px), 1fr))",
|
||||
);
|
||||
});
|
||||
|
||||
it("splits the width for a fixed count", () => {
|
||||
expect(gridSizeStyle("4").gridTemplateColumns).toContain(
|
||||
"(100% - 3 * 0.5rem) / 4",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Facts", () => {
|
||||
|
||||
Reference in new issue
Block a user