chore: Adds inheritsMode support for visual contexts#188
Open
pan-kot wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #188 +/- ##
==========================================
+ Coverage 96.91% 97.22% +0.30%
==========================================
Files 54 55 +1
Lines 1362 1440 +78
Branches 245 264 +19
==========================================
+ Hits 1320 1400 +80
+ Misses 36 34 -2
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
127ee0e to
3e54630
Compare
3e54630 to
ed9e796
Compare
ed9e796 to
914477a
Compare
SpyZzey
reviewed
Jul 9, 2026
| @@ -0,0 +1,160 @@ | |||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |||
Member
There was a problem hiding this comment.
If we keep defaultMode as backwards-compatible property, should we add a test that guarantees it's previous output (not producing the same behavior as inheritedMode)?
Member
Author
There was a problem hiding this comment.
SpyZzey
approved these changes
Jul 9, 2026
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.
Changes overview
The PR introduces new
inheritsModeproperty for visual contexts definition.Currently, certain visual contexts: top-navigation, header, and compact-table inherit from the visual modes (dark for top-navigation and header, compact for compact-table). This is done by copying the corresponding mode tokens into the context definitions and using
defaultModeso that only dark or only compact values are taken from the token value pairs. This leads to a lot of duplication in the generated theme file, see: current.styles.scoped.css. The awsui-context-top-navigation there includes 271 token, the awsui-context-compact-table includes 36 tokens.With the changes applied (this PR merged and
inheritsModeused in components style dictionary), the tokens are no longer copied from mode to contexts. Instead, the inheritance is resolved by theming-core, mainly by appending the context selector to the corresponding mode selector, e.g.:In the updated stylesheet next.styles.scoped.css, the awsui-context-top-navigation only includes 10 tokens (is defines 2 tokens, but the list is expanded to handle token references correctly). The awsui-context-compact-table is no longer present (for classic variant), as it has no overrides compared to the compact mode. The changes decrease generated theme CSS size from 38.2KB to 35.9KB gzipped (~6% decrease).
Testing
I added new unit tests to validate the inherits-mode behaviour, including snapshot tests that showcase the output CSS. Additionally, I compared the current.styles.scoped.css and next.styles.scoped.css, generated by applying the inherits-mode to components for top-navigation, header, and compact-table contexts.
Additionally, I tested for regressions in the internal pipeline and made a dry-run to live.
Releasing
Merging this PR is expected to cause no regression in components, as the existing behaviours are kept the same. Once this is merged, I will create a follow-up PR for components, adopting the
inheritsMode. When that is complete - I will create another follow-up PR for theming-core to remove the deprecateddefaultModeAPI.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.