Skip to content

feat: Update token component styles for one-theme#4633

Merged
at-susie merged 11 commits into
mainfrom
onetheme/token-dismiss-icon
Jun 16, 2026
Merged

feat: Update token component styles for one-theme#4633
at-susie merged 11 commits into
mainfrom
onetheme/token-dismiss-icon

Conversation

@at-susie

@at-susie at-susie commented Jun 15, 2026

Copy link
Copy Markdown
Member

Description

This PR:

  • Updated the icon size in the Token component for the dismiss button and inline variant
  • Introduce border radius token for the Token component's inline variant which replaces the hardcoded approach

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

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

@at-susie at-susie changed the title feat: Update icon styles of token component for one-theme feat: Update token component styles for one-theme Jun 15, 2026
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.51%. Comparing base (7be64a9) to head (249d781).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4633   +/-   ##
=======================================
  Coverage   97.51%   97.51%           
=======================================
  Files         948      948           
  Lines       30353    30360    +7     
  Branches    11072    11074    +2     
=======================================
+ Hits        29600    29607    +7     
  Misses        746      746           
  Partials        7        7           

☔ 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.

Comment thread src/token/__tests__/token.test.tsx Outdated
expect(inlineIcon).toHaveClass(styles['icon-inline']);
});

test('overrides icon size to x-small for inline variant in OneTheme', () => {

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.

suggestion: let's create a section "One theme" under describe and set document.body.classList.add('awsui-one-theme') before each and document.body.classList.remove('awsui-one-theme') after each test.

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.

Great suggestion. I moved the OneTheme test out of Icons describe block into its own describe('One theme', ...) with beforeEach/afterEach for class management.

Comment thread src/token/interfaces.ts Outdated
*
* When `variant="inline"`, icon size should be `small`.
*
* For the OneTheme with `variant="inline"`, the icon size will automatically be overridden to `x-small`.

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.

This strings will end up on the external website as well. Is that intentional?

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.

Removed the OneTheme-specific sentence from the icon prop.

Comment thread src/token/internal.tsx Outdated
});

const sizedIcon = (iconNode: React.ReactNode) => {
if (isInline && isOneTheme && React.isValidElement(iconNode)) {

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.

You also need to check if the iconNode is an instance of the Icon component, not just any react component

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.

Added iconNode.type === InternalIcon so sizedIcon only resizes actual InternalIcon elements

Comment thread src/token/internal.tsx Outdated

const sizedIcon = (iconNode: React.ReactNode) => {
if (isInline && isOneTheme && React.isValidElement(iconNode)) {
return React.cloneElement(iconNode as React.ReactElement<{ size?: string }>, { size: 'x-small' });

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.

Why do you need to cast the data here?

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.

Good call. Removed the as React.ReactElement<{ size?: string }> cast. Once the type guard iconNode.type === InternalIcon is in place, TypeScript can infer enough to make React.cloneElement work cleanly.

@at-susie at-susie removed the request for review from mxschll June 16, 2026 08:44
Comment thread src/token/dismiss-button.tsx Outdated
testUtilStyles['dismiss-button'],
inline && styles['dismiss-button-inline']
inline && styles['dismiss-button-inline'],
isOneTheme && styles['one-theme']

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.

Does it make sense to declare this variable in every component that needs one-theme styles?

let's create a new one-theme mixin here (similar to what we do for dark mode) and use it for css only, as it's less verbose and more scalable

https://github.com/cloudscape-design/components/blob/main/src/internal/styles/utils/theming.scss#L5

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.

That makes sense. I added the one-theme-only mixin in the src/internal/styles/utils/theming.scss.
This way I don't have to have isOneTheme && styles['one-theme'].

@at-susie at-susie added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit 41e179e Jun 16, 2026
99 checks passed
@at-susie at-susie deleted the onetheme/token-dismiss-icon branch June 16, 2026 13:59
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