feat: align CodeEditor theme with Cloudscape design tokens [WIP]#4824
Draft
ernst-dev wants to merge 1 commit into
Draft
feat: align CodeEditor theme with Cloudscape design tokens [WIP]#4824ernst-dev wants to merge 1 commit into
ernst-dev wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4824 +/- ##
=======================================
Coverage 97.61% 97.61%
=======================================
Files 952 953 +1
Lines 30816 30838 +22
Branches 11318 11321 +3
=======================================
+ Hits 30081 30103 +22
Misses 688 688
Partials 47 47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
[WIP / v0 — first cut of a multi-week epic. Not ready for merge.]
Adds an opt-in, token-driven Cloudscape theme to
CodeEditor(Ace) so the editor's colors align with Cloudscape design tokens and adapt automatically to the active light/dark visual mode.Today, consumers must choose from Ace's built-in themes (or the
cloud_editor/cloud_editor_darkthemes), whose colors are hard-coded and don't track Cloudscape design tokens or visual modes. This change introduces a single'cloudscape'theme whose colors come entirely from Cloudscape design tokens, so the same theme works in both light and dark mode.Approach
cloudscape-theme.tsregisters an Ace theme (ace/theme/cloudscape) with an emptycssTextand acssClassoface-cloudscape. Registration is idempotent per Ace instance and a no-op if the providedaceobject has nodefine.cloudscape-ace-theme.scsssupplies the actual colors, keyed off.ace-cloudscape, using Cloudscape design tokens (editor bg/fg, gutter, cursor, selection, active-line, and a first-cut syntax mapping using the charts palette for perceptually distinct, visual-mode-aware hues). Because the tokens resolve to CSS custom properties that change with the visual mode, no separate dark theme is needed.useSyncEditorThemeonly when'cloudscape'is selected, so existing behavior and defaults are unchanged.Public API (additive, backward-compatible)
CodeEditorProps.Themenow also accepts'cloudscape'(addedBuiltInThemeandCloudscapeThemetype aliases). Documenter snapshot regenerated.Done in this v0
preferences={{ theme: 'cloudscape' }}(andthemesfor the preferences modal).pages/code-editor/cloudscape-theme.page.tsx.Remaining / follow-ups (tracked for the epic)
'cloudscape'should be surfaced by default inDEFAULT_AVAILABLE_THEMES/ the preferences modal (single adaptive theme vs. the current light/dark split UX).isDarkflag from the active visual mode so Ace's ownace_dark-based rules stay consistent.defineCloudscapeAceTheme) if consumers need to register the theme independently.Related links, issue #, if available: SIM AWSUI-57002 (see note below).
How has this been tested?
eslint+stylelinton all changed files — clean.gulp quick-build— pass.gulp build(production) — pass (only pre-existing asset-size warnings).src/code-editor+documenter.test.ts— 203 tests / 97 snapshots pass (includes newcloudscape-theme.test.tsand an integration test assertingsetTheme('ace/theme/cloudscape')).'cloudscape'to the theme enum).code-editor/cloudscape-themedev page and toggle dark mode to see the theme adapt.Manual accessibility/contrast validation of the syntax color mapping is still outstanding (see follow-ups).
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.