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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
*/

import type { APIClient } from "@/browser/contexts/API";
import { expandProjects, selectWorkspace } from "@/browser/stories/helpers/uiState";
import {
expandLeftSidebar,
expandProjects,
selectWorkspace,
} from "@/browser/stories/helpers/uiState";
import { createMockORPCClient } from "@/browser/stories/mocks/orpc";
import { createWorkspace, groupWorkspacesByProject } from "@/browser/stories/mocks/workspaces";
import type { AppStory } from "@/browser/stories/meta.js";
Expand All @@ -29,6 +33,9 @@ function setupProjectCreateStory(): APIClient {
const workspaces = [createWorkspace({ id: "ws-1", name: "main", projectName: "my-app" })];
selectWorkspace(workspaces[0]);
expandProjects(["/mock/my-app"]);
// The sidebar defaults to collapsed at phone widths; the play functions need
// its "Add project" button visible to open the modal.
expandLeftSidebar();
return createMockORPCClient({
projects: groupWorkspacesByProject(workspaces),
workspaces,
Expand Down
10 changes: 10 additions & 0 deletions src/browser/stories/helpers/uiState.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { updatePersistedState } from "@/browser/hooks/usePersistedState";
import type { FrontendWorkspaceMetadata } from "@/common/types/workspace";
import {
SELECTED_WORKSPACE_KEY,
Expand Down Expand Up @@ -53,3 +54,12 @@ export function collapseLeftSidebar(): void {
export function expandRightSidebar(): void {
localStorage.setItem(RIGHT_SIDEBAR_COLLAPSED_KEY, JSON.stringify(false));
}

/**
* Expand the left sidebar (project tree). The app defaults it to collapsed at
* mobile widths, so stories whose play functions click sidebar controls must
* force it open to pass under Pixel's phone viewport.
*/
export function expandLeftSidebar(): void {
updatePersistedState(LEFT_SIDEBAR_COLLAPSED_KEY, false);
}
Loading