Skip to content

chore: Introduce visualAccent prop to box#4679

Merged
at-susie merged 31 commits into
mainfrom
onetheme/box-accent
Jul 10, 2026
Merged

chore: Introduce visualAccent prop to box#4679
at-susie merged 31 commits into
mainfrom
onetheme/box-accent

Conversation

@at-susie

@at-susie at-susie commented Jul 1, 2026

Copy link
Copy Markdown
Member

Description

This PR introduces a new property visualAccent prop to the box component. The new prop allows builders to visually emphasize specific elements through a curated set of background and content color combinations.

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 chore: Introduce accentColor prop chore: Introduce visualAccent prop to box Jul 3, 2026
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.59%. Comparing base (c2472a9) to head (440d570).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4679   +/-   ##
=======================================
  Coverage   97.59%   97.59%           
=======================================
  Files         950      950           
  Lines       30655    30660    +5     
  Branches    11234    11240    +6     
=======================================
+ Hits        29919    29924    +5     
+ Misses        729      689   -40     
- Partials        7       47   +40     

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

colorBackgroundCodeView: { light: '#f8f8f8', dark: '#282c34' },

// ── Visual accent ───────────────────────────────────
colorBackgroundAccentRed: { light: '{colorError100}', dark: 'rgba(255, 61, 61, 0.2)' },

@mxschll mxschll Jul 10, 2026

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 we need these tokens in visual refresh? This is a 1T feature.

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.

Moving these to 1T style-dictionary

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.

I looked into moving the values into one-theme, but it turned out that they need to stay rooted in visual-refresh as the default package is built with classic as the primary theme (which inherits from visual-refresh), while one-theme is only ever a secondary theme.

Comment thread style-dictionary/visual-refresh/metadata/colors.ts Outdated
Comment thread src/box/internal.tsx Outdated
Comment thread src/box/internal.tsx Outdated
return tagOverride;
}

if (hasVisualAccent) {

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 can merge this: if (hasVisualAccent || variant === 'awsui-value-large')

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 does it have to be a span if hasVisualAccent === true?

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.

This was a leftover from an old experiment. Updated not to make it span by default when hasVisualAccent === true. Now it just follows the box variant

Comment thread src/box/visual-accent.scss Outdated
Comment thread style-dictionary/visual-refresh/color-palette.ts Outdated
Comment thread src/box/internal.tsx Outdated
Comment thread src/box/interfaces.ts
Comment thread pages/box/visual-accent.page.tsx Outdated

export default function StyleBoxPage() {
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>

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.

Can we use SimplePage and have a screenshot area inside, so we can take screenshot tests?

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.

Adding screenshot area

Comment thread src/box/internal.tsx Outdated

const accentAspectRatio = visualAccent?.aspectRatio ?? 'auto';
const accentBorderRadius = visualAccent?.borderRadius;
const isRadiusKeyword = accentBorderRadius !== undefined && RADIUS_KEYWORDS.includes(accentBorderRadius);

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.

Can we use types instead of having an array RADIUS_KEYWORDS? That is a bit awkward and I don't think we do that elsewhere?

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.

It's also hard to debug, if I pass an arbitrary string but nothing happens, I can't know why.

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. borderRadius is now a strict keyword union (xxxs…xxxl plus full), matching padding/margin. Dropped the runtime keyword array and check. Invalid values are caught by the type system now.

padding-inline: awsui.$space-xs;
// Force the element to be a square regardless of content dimensions.
// The width is constrained to match the height (content + padding).
aspect-ratio: 1 / 1;

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.

With long text, the element grows very large. How should this feature behave with text, or is not not supposed to be used with text?

Image

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.

Such extreme things can happen in buttons today as well. We will provide guidances

Comment thread src/box/internal.tsx Outdated
// the stylesheet through a custom property, which the base `.visual-accent` rule reads and
// applies to all four corners. When unset, no custom property is set and the base rule falls
// back to a `0` border radius.
const accentStyle =

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.

Nit: you could remove this const and move this directly to the style prop since it's not used anywhere else. Also, related to the comment above: it's weird to have this isRadiusKeyword check, instead of using types.

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.

Resolved by the same change. There is no more accentStyle const or isRadiusKeyword branch. The keyword maps directly to a .visual-accent-radius-* class.

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