Skip to content

fix: Reduce size of icon hover-motion CSS - #5156

Open
TrevorBurnham wants to merge 1 commit into
cloudscape-design:mainfrom
TrevorBurnham:icon-hover-motion-css-size
Open

TrevorBurnham wants to merge 1 commit into
cloudscape-design:mainfrom
TrevorBurnham:icon-hover-motion-css-size

Conversation

@TrevorBurnham

@TrevorBurnham TrevorBurnham commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Icon hover-motion CSS, emitted when the One theme is included, is ~300 KB raw per copy of the library. Most of that is selector text: every hover rule repeats a long prefix (theme gate, trigger, disabled guard, target) once per trigger state, and there are four states since #5161.

This PR makes two output-only changes to src/icon/hover-motion.scss:

  1. All trigger states share one selector: :is([data-awsui-motion-trigger~=hover]:is(:hover, :focus-visible), [data-awsui-motion-trigger~=focus]:focus-visible, [data-awsui-motion-trigger~=delegated-focus]:focus-within:where(...)):not(:disabled):not([aria-disabled=true]). Each arm has the same specificity as the separate selectors it replaces, so the cascade is unchanged. No :has() is reintroduced.
  2. Specs that emit the same declarations on the same part share a rule via .icon:is(.name-a, .name-b). An icon has a single name class, so merging across icons cannot change the cascade.

lib/components/icon/styles.scoped.css with INCLUDE_ONE_THEME=true:

main this PR
Raw 312.6 KB 136.9 KB
Minified 298.4 KB 125.9 KB
Minified + gzip 9.7 KB 7.2 KB
Minified + brotli 7.7 KB 5.5 KB

Builds without the One theme are unaffected (no motion CSS is emitted).

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

How has this been tested?

  • New unit tests check that icons with identical motion share a rule and that no two rules differ only in the icon name. Existing selector-shape tests were updated for the merged selector.
  • Compared a One-theme build of this branch against main: every other CSS file under lib/components is byte-identical.
  • Expanding the merged selectors back into separate ones yields the same 1,008 selectors with the same declarations as main.
  • Compared computed styles in Chrome for all 80 animated icons, old CSS vs new, across hover, focus and delegated-focus triggers, disabled and motion-off controls, and both prefers-reduced-motion settings. All 693,120 property comparisons matched.
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.

@TrevorBurnham
TrevorBurnham marked this pull request as ready for review October 18, 2026 20:32
@TrevorBurnham
TrevorBurnham requested a review from a team as a code owner October 18, 2026 20:32
@TrevorBurnham
TrevorBurnham requested review from ernst-dev and removed request for a team October 18, 2026 20:32
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.88%. Comparing base (fdb6ffa) to head (3df62ae).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5156      +/-   ##
==========================================
- Coverage   97.72%   93.88%   -3.85%     
==========================================
  Files         995      994       -1     
  Lines       32129    27830    -4299     
  Branches    11851     9576    -2275     
==========================================
- Hits        31399    26127    -5272     
- Misses        684      784     +100     
- Partials       46      919     +873     

☔ 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.
@github-actions
github-actions Bot temporarily deployed to fork-dev-pages-react18 October 19, 2026 09:45 Inactive
@github-actions
github-actions Bot temporarily deployed to fork-dev-pages-react16 October 19, 2026 09:46 Inactive
@TrevorBurnham
TrevorBurnham force-pushed the icon-hover-motion-css-size branch from 3df62ae to 8fb64ab Compare October 27, 2026 20:47

This branch was previously deployed

2 inactive (outdated) deployments
fork-dev-pages-react16 — 3df62aea Deployed Oct 19, 2026 by github-actions[bot]
fork-dev-pages-react18 — 3df62aea Deployed Oct 19, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant