feat(ui): scaffold packages/ui with theme foundations#1030
Open
EhabY wants to merge 3 commits into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes DEVEX-624.
Scaffolds the shared component library for the Workspaces webview work. Foundations only — no components yet (DEVEX-618/619/620 build on this).
packages/ui— React + TS package wired like existing packages (catalog deps, root Storybook/ESLint/typecheck globs pick it up automatically). Consumed as source likewebview-shared, but shaped for a future standalone NPM split: properexportsmap (.,./tokens.css,./codicon.css),reactas the only peer dependency,@vscode/codicons(asset-only) as the only runtime dependency, noworkspace:*runtime deps. A short README documents the theming model and the rules that keep the package splittable.tokens.css— semantic--ui-*tokens mapped to--vscode-*variables; the single place the library is theme-matched to VS Code. Same pattern as Microsoft's Webview UI Toolkit design-token layer, but pure CSS: components style against a small curated semantic set instead of scattering raw--vscode-*references (VS Code exposes 500+). High contrast needs no JS edge-case handling —--vscode-contrast*vars only exist in HC themes, so--ui-contrast-*tokens use transparent fallbacks and become no-ops elsewhere.useVscodeTheme— the issue asked to move it fromwebview-shared, but no such hook existed anywhere in the repo, so it is implemented here instead: returns the active theme kind from thedata-vscode-theme-kindbody attribute VS Code maintains in webviews, synced viaMutationObserver+useSyncExternalStore. No re-export fromwebview-sharedsince there are no consumers yet.UI/Foundationsstory rendering the token swatches and current theme kind. The theme decorator now also mirrorsdata-vscode-theme-kindon the body so theme-aware hooks behave in Storybook as they do in real webviews.Testing
test/webview/ui/useVscodeTheme.test.ts— theme-kind mapping, missing-attribute default, re-render on theme change.pnpm typecheck,pnpm lint,pnpm format:check,pnpm test,pnpm build,pnpm storybook:ciall pass.Implementation plan & decisions
Context
packages/{shared,webview-shared,tasks,workspaces,netcheck,speedtest,mocks,storybook-utils}with pnpmcatalog:deps (catalogMode: strict)..storybookglobspackages/*/src/**/*.stories.@(ts|tsx)— apackages/uistory is picked up with zero config.typecheck:packages/build:webviewsrunpnpm -r --filter ./packages/*— packages without abuildscript are skipped (e.g.webview-shared, consumed as source via itsexportsmap).Finding:
useVscodeThemedid not existThe issue says "move
useVscodeThemefrompackages/webview-shared", but no such hook exists on main or any branch. Decision: implement it fresh inpackages/ui(DOMdata-vscode-theme-kind+MutationObserverviauseSyncExternalStore).Decisions
webview-shared(no vite build), but kept easy to separate later — self-contained package, properexportsmap,reactpeer dep, noworkspace:*deps. A real build step only becomes necessary at the actual NPM split../codicon.cssre-exporting@vscode/codicons) since follow-up issues will use it.--vscode-*per component, as vscode-elements does): the deprecated@vscode/webview-ui-toolkitvalidated the token-layer pattern but implemented it with a JS design-token system; a pure-CSS layer gets the same single theming point without the machinery, and gives the future standalone package one place to define non-webview fallbacks.Deliverables
packages/ui/{package.json,tsconfig.json,storybook.preview.ts,README.md}+src/{index.ts,tokens.css,codicon.css,useVscodeTheme.ts,foundations.stories.tsx,css.d.ts}@repo/uialiases invitest.config.ts(webview project) andtest/tsconfig.jsondata-vscode-theme-kindtest/webview/ui/