feat(ui): scaffold packages/ui with theme foundations#1030
Open
EhabY wants to merge 4 commits into
Open
Conversation
Source all VS Code themes (light, dark, hc-dark, hc-light) from @vscode-elements/webview-playground instead of maintaining local copies, and add per-theme Chromatic snapshot modes. Also drops the sideEffects field that broke CSS tree-shaking, and fixes the Foundations story's token value column inheriting an unrelated --vscode-textPreformat-background instead of the row's own background, which made values unreadable in both high-contrast themes.
086eaf9 to
b9d3bea
Compare
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 and consumed as source likewebview-shared, but shaped for a future standalone NPM split:exportsmap (.,./tokens.css,./codicon.css),reactas the only peer dependency,@vscode/codicons(asset-only) as the only runtime dependency, noworkspace:*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. Every token always resolves: variables VS Code may omit (hover/selection fills in high contrast themes, contrast borders outside them) declare fallbacks that match native behavior.useVscodeTheme: returns the active theme kind from thedata-vscode-theme-kindbody attribute VS Code maintains in webviews, synced viaMutationObserver+useSyncExternalStore.data-vscode-theme-kindon the body. Theme data is no longer vendored: all four themes import from@vscode-elements/webview-playground, deleting the two ~700-line copied theme files. Net, the PR removes ~1,500 lines.UI/Foundationsstory: enumerates every--ui-*token from the loaded stylesheets (cannot drift fromtokens.css) and renders each as a swatch with its resolved value. Chromatic modes snapshot it in all four themes, scoped to this story to keep snapshot counts down.Testing
test/webview/ui/useVscodeTheme.test.ts: theme-kind mapping, missing-attribute default, re-render on theme change.pnpm typecheck,lint,format:check,test,build, andstorybook:ciall pass.Implementation decisions
webview-shared(no vite build), but self-contained so a real build step can be added at the actual NPM split../codicon.cssadded now since follow-up issues will use it.--vscode-*per component, as vscode-elements does): the deprecated@vscode/webview-ui-toolkitvalidated the token-layer pattern 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.sideEffectsfield: with it, this Vite/rolldown pipeline tree-shook thestorybook.preview.tstotokens.csschain out of the production Storybook build (even with**/*.css). Dev mode masked it. Dropped as speculative; revisit at the actual split.@vscode-elements/webview-playgroundpublishes the exact theme modules the repo had copied by hand. Importing them (typed via a small wildcard.d.ts) deletes the vendored data and makes theme refreshes apnpm update.webview-sharedre-export ofuseVscodeTheme: no consumers exist yet and it would add a workspace dep.