Skip to content
Open
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ jobs:
run: pnpm exec pixel-storybook
env:
PIXEL_KEY: ${{ secrets.PIXEL_KEY }}
# On pull_request, github.sha is a synthetic merge commit, not the PR head.
PIXEL_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
# Auto-approve on mainline to avoid blocking CI after squash merges.
PIXEL_AUTO_REVIEW: ${{ github.ref == 'refs/heads/main' }}

Expand Down
6 changes: 6 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="vite/client" />

import { isPixel } from "@coder/pixel-storybook/storyapi";
import codiconCssUrl from "@vscode/codicons/dist/codicon.css?url";
import { createElement } from "react";

Expand Down Expand Up @@ -29,6 +30,11 @@ if (typeof window !== "undefined") {
});
}

// Lets us skip motion animation during Pixel captures.
if (typeof document !== "undefined" && isPixel()) {
document.documentElement.setAttribute("data-pixel", "true");
}

// Inject codicon stylesheet immediately (before any components render)
// Must be a <link> element with id "vscode-codicon-stylesheet" for vscode-elements
if (
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/src/components/Icon/Icon.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
animation: none;
}
}

/* data-pixel is set in .storybook/preview.ts via isPixel(). */
:root[data-pixel] .ui-icon--spin {
animation: none;
}
8 changes: 8 additions & 0 deletions packages/ui/src/components/Menu/Menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@
}
}

/* data-pixel is set in .storybook/preview.ts via isPixel(). */
@media (prefers-reduced-motion: no-preference) {
:where(:root[data-pixel]) .ui-menu[data-state="open"],
:where(:root[data-pixel]) .ui-menu[data-state="closed"] {
animation: none;
}
}

@media (forced-colors: active) {
.ui-menu__item[data-highlighted],
.ui-menu__item[data-state="open"] {
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/src/components/ProgressBar/ProgressBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@
background: Highlight;
}
}

/* data-pixel is set in .storybook/preview.ts via isPixel(). */
:root[data-pixel] .ui-progress-bar--indeterminate .ui-progress-bar__indicator {
animation: none;
}
5 changes: 5 additions & 0 deletions packages/ui/src/components/Spinner/Spinner.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@
border-inline-end-color: Highlight;
}
}

/* data-pixel is set in .storybook/preview.ts via isPixel(). */
:root[data-pixel] .ui-spinner {
animation: none;
}
12 changes: 4 additions & 8 deletions packages/ui/src/vscode-parity.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ProgressBar } from "./components/ProgressBar/ProgressBar";
import { SearchInput } from "./components/SearchInput/SearchInput";
import { Spinner } from "./components/Spinner/Spinner";
import { StatusPill } from "./components/StatusPill/StatusPill";
import { openMenu, PIXEL_ALL_THEMES } from "./storybook";
import { PIXEL_ALL_THEMES } from "./storybook";

import type { Meta, StoryObj } from "@storybook/react-vite";

Expand Down Expand Up @@ -177,8 +177,7 @@ const Parity = (): React.JSX.Element => (
</div>
);

/* The reference menu renders inline; ours is a real portalled DropdownMenu,
so the play function opens it under its trigger. */
/* defaultOpen + an invisible trigger mirror the reference's `show`. */
const MenuParity = (): React.JSX.Element => (
<div
style={{
Expand All @@ -189,9 +188,9 @@ const MenuParity = (): React.JSX.Element => (
fontSize: "13px",
}}
>
<DropdownMenu>
<DropdownMenu defaultOpen>
<DropdownMenuTrigger asChild>
<Button variant="secondary">Menu</Button>
<span />
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>Start workspace</DropdownMenuItem>
Expand Down Expand Up @@ -228,7 +227,4 @@ export const SideBySide: Story = {};

export const Menu: Story = {
render: () => <MenuParity />,
play: async ({ canvasElement }) => {
await openMenu(canvasElement, "Menu");
},
};