-
Notifications
You must be signed in to change notification settings - Fork 42
chore: implement storybook #932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jakehwll
wants to merge
82
commits into
main
Choose a base branch
from
jakehwll/implement-storybook
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
df33940
feat: implement storybook config
jakehwll d47927c
feat: implement basic stories + theme
jakehwll 77adc50
fix: use `fontFamily` over `font-family`
jakehwll 5a1abb8
fix: resolve codicons
jakehwll dc8dc2e
feat: add `Opened` variant of `<ActionMenu />` story
jakehwll 1d1fc50
feat: add queryclient helper
jakehwll e1d726c
fix: resolve rendering
jakehwll 0798669
fix: resolve max-width size
jakehwll 34dd889
feat: missing args in `<PromptInput />`
jakehwll 23ae3a2
fix: resolve background color
jakehwll ea85877
fix: resolve theme and imports
jakehwll b2779b9
fix: prepend `void `
jakehwll 7d3b120
fix: resolve story type
jakehwll 7ac9626
fix: add future expansion
jakehwll 90768d4
fix: document `getDefaultFontStack`
jakehwll a0324cb
fix: remove unnecessary themes
jakehwll ada1dcb
fix: resolve `acquireVsCodeApi`
jakehwll 162bc3a
chore: reusable entities
jakehwll 5587a8d
Merge branch 'main' into jakehwll/implement-storybook
jakehwll 9dd27f4
fix: resolve rendering of `TasksPanel`
jakehwll 76a6f3e
feat: move `testHelpers` to `mock`
jakehwll 12d7c2b
fix: move to existing mock helpers
jakehwll eed89ac
feat: implement theme switcher
jakehwll fba820c
fix: debroaden `tsconfig.json`
jakehwll 9def7ca
fix: improve imports
jakehwll 08d95ac
fix: remove unnecessary `satisfies`
jakehwll 8861bb5
fix: prefer use of `fn()`
jakehwll 468b87c
fix: use `fn()` not `() => fn()`
jakehwll d28e7ae
fix: move to using `fn()` (again)
jakehwll 5261c61
fix: use `import type`
jakehwll a501c75
chore: cleanup inputs
jakehwll cdae85b
fix: remove "useless ecapes"
jakehwll c85a0d5
fix: no children as props
jakehwll f21ab72
fix: no async `viteFinal`
jakehwll 1271eef
fix: cleanup `preview.ts` lint
jakehwll 01544dc
chore: document source of colorSchemes
jakehwll 901d0d6
fix: use `StoryObj<typeof Foo>`
jakehwll ca15391
chore: stale `tsconfig.json`
jakehwll 763cbea
fix: `rootDir` definition
jakehwll 6a825dc
chore: comment feedback
jakehwll 64b5fc6
chore: resolve pnpm lock
jakehwll 5227a74
feat: `<TasksPanel />` stories
jakehwll d08350c
fix: resolve stories
jakehwll a47f0f0
chore: lint fix
jakehwll af22f0d
fix: taskspanel ids
jakehwll 4672a84
fix: resolve test
jakehwll ca614fa
fix: `useRef` for `queryClient`
jakehwll 181a491
fix: `createElement` story to preserve side-effects
jakehwll 82385b8
fix: remove unused comment
jakehwll ea16883
fix: dynamically imported tasks css
jakehwll 6d225a5
fix: describe sidebar width
jakehwll 93a3e85
fix: rename story
jakehwll ecf7da1
fix: unique task IDs in TaskList story, clarify loading assertion in …
jakehwll ee1d2a6
fix: add missing assertions in ActionMenu and PromptInput stories
jakehwll 144ea5e
fix: backport `storybook:build`
jakehwll 7b5e825
fix: inline storybook dependencies
jakehwll cfedf94
fix: remove storybook artifacts from `.vscodeignore`
jakehwll 0d5d139
fix: storybook `.gitignore`
jakehwll e346f15
fix: remove `getDefaultFontStack()`
jakehwll 90c39bc
fix: resolve storybook to `tsconfig.packages.json`
jakehwll 9350f36
fix: remove unnecessary values from `preview.ts`
jakehwll 6ac98ab
fix: minify `WebviewApi`
jakehwll 3411417
fix: add `@repo/storybook-utils`
jakehwll d534058
feat: implement `@repo/mocks`
jakehwll 1d716b1
refactor: move tasks CSS to per-package withTasksStyles decorator
jakehwll 563c07c
refactor: move withTasksStyles to utils/storybook.ts
jakehwll 0983d78
refactor: use useState initializer for QueryClient in withQueryClient
jakehwll 1e6e091
refactor: remove manual workspace alias resolution from Storybook
jakehwll 5a94c21
fix: add missing deps to storybook-utils, fix lint errors
jakehwll 1440080
fix: add tsconfigs for new packages, fix lint errors
jakehwll 6b3aa21
fix: restore original coder dependency SHA in pnpm-lock.yaml
jakehwll 93243c2
fix: `.prettierignore` and `eslint.config.mjs` ignore
jakehwll eef9896
chore: prettier format
jakehwll 7f12290
fix: remove spurious workspaces/overrides from package.json
jakehwll c0321a6
revert: restore getDefaultFontStack in preview.ts
jakehwll f05a685
fix: reoslve `TasksPanel.stories.tsx` `CollapsibleToggle`
jakehwll 19f74de
fix: remove brittle play functions from TasksPanel stories
jakehwll 5eb5368
chore: restrict @repo/mocks and @repo/storybook-utils imports in runt…
jakehwll 7070606
chore: move storybook dependencies back to catalog
jakehwll b0ec3f2
fix: set font stack as CSS variable instead of inline fontFamily
jakehwll 7023245
refactor: replace withTasksStyles decorator with import.meta.glob CSS…
jakehwll 9ca1df6
chore: add sync-vscode-themes script to fetch upstream theme files
jakehwll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,6 @@ pnpm-debug.log | |
|
|
||
| # Workspace packages | ||
| packages/*/node_modules/ | ||
|
|
||
| # Storybook | ||
| storybook-static/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ | |
| flake.lock | ||
| pnpm-debug.log | ||
| pnpm-lock.yaml | ||
| /storybook-static/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| declare module "*.css"; | ||
| declare module "*.css?url" { | ||
| const url: string; | ||
| export default url; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| html { | ||
| background: var(--vscode-sideBar-background); | ||
| } | ||
|
|
||
| body { | ||
| margin: 0; | ||
| padding: 0; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| #storybook-preview-wrapper { | ||
| background-color: var(--vscode-sideBar-background); | ||
| } | ||
|
|
||
| #root { | ||
| overscroll-behavior-x: none; | ||
| background-color: var(--vscode-sideBar-background); | ||
| color: var(--vscode-editor-foreground); | ||
| font-family: var(--vscode-font-family); | ||
| font-weight: var(--vscode-font-weight); | ||
| font-size: var(--vscode-font-size); | ||
| margin: 0; | ||
| max-width: 100%; | ||
| /* arbitrary size choice for the rough VSCode sidebar size */ | ||
| width: 300px; | ||
| } | ||
|
|
||
| img, | ||
| video { | ||
| max-width: 100%; | ||
| max-height: 100%; | ||
| } | ||
|
|
||
| a, | ||
| a code { | ||
| color: var(--vscode-textLink-foreground); | ||
| } | ||
|
|
||
| p > a { | ||
| text-decoration: var(--text-link-decoration); | ||
| } | ||
|
|
||
| a:hover { | ||
| color: var(--vscode-textLink-activeForeground); | ||
| } | ||
|
|
||
| a:focus, | ||
| input:focus, | ||
| select:focus, | ||
| textarea:focus { | ||
| outline: 1px solid -webkit-focus-ring-color; | ||
| outline-offset: -1px; | ||
| } | ||
|
|
||
| code { | ||
| font-family: var(--monaco-monospace-font); | ||
| color: var(--vscode-textPreformat-foreground); | ||
| background-color: var(--vscode-textPreformat-background); | ||
| padding: 1px 3px; | ||
| border-radius: 4px; | ||
| } | ||
|
|
||
| pre code { | ||
| padding: 0; | ||
| } | ||
|
|
||
| blockquote { | ||
| background: var(--vscode-textBlockQuote-background); | ||
| border-color: var(--vscode-textBlockQuote-border); | ||
| } | ||
|
|
||
| kbd { | ||
| background-color: var(--vscode-keybindingLabel-background); | ||
| color: var(--vscode-keybindingLabel-foreground); | ||
| border-style: solid; | ||
| border-width: 1px; | ||
| border-radius: 3px; | ||
| border-color: var(--vscode-keybindingLabel-border); | ||
| border-bottom-color: var(--vscode-keybindingLabel-bottomBorder); | ||
| box-shadow: inset 0 -1px 0 var(--vscode-widget-shadow); | ||
| vertical-align: middle; | ||
| padding: 1px 3px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar { | ||
| width: 10px; | ||
| height: 10px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-corner { | ||
| background-color: var(--vscode-editor-background); | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-thumb { | ||
| background-color: var(--vscode-scrollbarSlider-background); | ||
| } | ||
| ::-webkit-scrollbar-thumb:hover { | ||
| background-color: var(--vscode-scrollbarSlider-hoverBackground); | ||
| } | ||
| ::-webkit-scrollbar-thumb:active { | ||
| background-color: var(--vscode-scrollbarSlider-activeBackground); | ||
| } | ||
| ::highlight(find-highlight) { | ||
| background-color: var(--vscode-editor-findMatchHighlightBackground); | ||
| } | ||
| ::highlight(current-find-highlight) { | ||
| background-color: var(--vscode-editor-findMatchBackground); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { mergeConfig } from "vite"; | ||
|
|
||
| import type { StorybookConfig } from "@storybook/react-vite"; | ||
|
|
||
| const config: StorybookConfig = { | ||
| stories: ["../packages/*/src/**/*.stories.@(ts|tsx)"], | ||
| addons: ["@storybook/addon-essentials", "@storybook/addon-a11y"], | ||
| framework: { | ||
| name: "@storybook/react-vite", | ||
| options: {}, | ||
| }, | ||
| viteFinal(baseConfig) { | ||
| return mergeConfig(baseConfig, { | ||
| assetsInclude: ["**/*.ttf", "**/*.woff", "**/*.woff2"], | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /// <reference types="vite/client" /> | ||
|
|
||
| import codiconCssUrl from "@vscode/codicons/dist/codicon.css?url"; | ||
| import { createElement, useEffect } from "react"; | ||
|
|
||
| import "./global.css"; | ||
|
|
||
| // Auto-import per-package Storybook CSS entry points | ||
| import.meta.glob("../packages/*/storybook.preview.ts", { eager: true }); | ||
|
|
||
| import { darkTheme } from "./themes/dark-v2"; | ||
| import { lightTheme } from "./themes/light-v2"; | ||
|
|
||
| import type { Preview } from "@storybook/react"; | ||
| import type { WebviewApi } from "vscode-webview"; | ||
|
|
||
| // Mock the acquireVsCodeApi function for Storybook, so that components | ||
| // that rely on it can function without errors. | ||
| if ( | ||
| typeof window !== "undefined" && | ||
| !(window as { acquireVsCodeApi?: () => WebviewApi<unknown> }).acquireVsCodeApi | ||
| ) { | ||
| (window as { acquireVsCodeApi: () => WebviewApi<unknown> }).acquireVsCodeApi = | ||
| () => ({ | ||
| postMessage: () => undefined, | ||
| getState: () => undefined, | ||
| setState: (state) => state, | ||
| }); | ||
|
jakehwll marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // Inject codicon stylesheet immediately (before any components render) | ||
| // Must be a <link> element with id "vscode-codicon-stylesheet" for vscode-elements | ||
| if ( | ||
| typeof document !== "undefined" && | ||
| !document.getElementById("vscode-codicon-stylesheet") | ||
| ) { | ||
| const link = document.createElement("link"); | ||
| link.id = "vscode-codicon-stylesheet"; | ||
| link.rel = "stylesheet"; | ||
| link.href = codiconCssUrl; | ||
| document.head.appendChild(link); | ||
| } | ||
|
|
||
| // This allows the system viewing the storybook to use the same font | ||
| // stack as vscode, which is important for accurate rendering of text. | ||
| const getDefaultFontStack = () => { | ||
| if (navigator.userAgent.includes("Linux")) { | ||
| return 'system-ui, "Ubuntu", "Droid Sans", sans-serif'; | ||
| } else if (navigator.userAgent.includes("Mac")) { | ||
| return "-apple-system, BlinkMacSystemFont, sans-serif"; | ||
| } else if (navigator.userAgent.includes("Windows")) { | ||
| return '"Segoe WPC", "Segoe UI", sans-serif'; | ||
| } else { | ||
| return "sans-serif"; | ||
| } | ||
| }; | ||
|
|
||
| const preview: Preview = { | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| globalTypes: { | ||
| theme: { | ||
| description: "Global theme for components", | ||
| defaultValue: "dark", | ||
| toolbar: { | ||
| title: "Theme", | ||
| icon: "circlehollow", | ||
| items: [ | ||
| { value: "light", icon: "circlehollow", title: "Light" }, | ||
| { value: "dark", icon: "circle", title: "Dark" }, | ||
| ], | ||
| dynamicTitle: true, | ||
| }, | ||
| }, | ||
| }, | ||
| decorators: [ | ||
| (Story, context) => { | ||
| const selectedTheme = | ||
| context.globals.theme === "light" ? lightTheme : darkTheme; | ||
|
|
||
| useEffect(() => { | ||
| const root = document.documentElement.style; | ||
|
|
||
| // Apply CSS custom properties to the document root | ||
| selectedTheme.forEach(([property, value]) => { | ||
| root.setProperty(property, value); | ||
| }); | ||
| root.setProperty("--vscode-font-family", getDefaultFontStack()); | ||
|
|
||
| // Cleanup function to remove properties when unmounting | ||
| return () => { | ||
| selectedTheme.forEach(([property]) => { | ||
| root.removeProperty(property); | ||
| }); | ||
| root.removeProperty("--vscode-font-family"); | ||
| }; | ||
| }, [selectedTheme]); | ||
|
|
||
| return createElement("div", { id: "root" }, createElement(Story)); | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export default preview; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.