Skip to content

chore: Adds inheritsMode support for visual contexts#188

Open
pan-kot wants to merge 1 commit into
mainfrom
chore-internal-inherits-mode
Open

chore: Adds inheritsMode support for visual contexts#188
pan-kot wants to merge 1 commit into
mainfrom
chore-internal-inherits-mode

Conversation

@pan-kot

@pan-kot pan-kot commented Jun 24, 2026

Copy link
Copy Markdown
Member

Changes overview

The PR introduces new inheritsMode property 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 defaultMode so 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 inheritsMode used 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.:

.awsui-dark-mode,.awsui-context-top-navigation {
  // shared declaration
}
.awsui-context-top-navigation {
  // top-navigation specific overrides
}

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 deprecated defaultMode API.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.29577% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.22%. Comparing base (1fcdb55) to head (914477a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/shared/declaration/abstract.ts 96.42% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pan-kot pan-kot force-pushed the chore-internal-inherits-mode branch 2 times, most recently from 127ee0e to 3e54630 Compare June 26, 2026 09:11
@pan-kot pan-kot force-pushed the chore-internal-inherits-mode branch from 3e54630 to ed9e796 Compare July 6, 2026 14:58
@pan-kot pan-kot force-pushed the chore-internal-inherits-mode branch from ed9e796 to 914477a Compare July 6, 2026 15:11
@pan-kot pan-kot marked this pull request as ready for review July 7, 2026 13:37
@pan-kot pan-kot requested a review from a team as a code owner July 7, 2026 13:37
@pan-kot pan-kot requested review from SpyZzey and removed request for a team July 7, 2026 13:37
@@ -0,0 +1,160 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pan-kot pan-kot requested a review from SpyZzey July 9, 2026 12:24
@pan-kot pan-kot added this pull request to the merge queue Jul 9, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 9, 2026
@pan-kot pan-kot added this pull request to the merge queue Jul 9, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants