Skip to content

feat(accordion): add direct actions #4020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: spectrum-two
Choose a base branch
from

Conversation

rise-erpelding
Copy link
Collaborator

@rise-erpelding rise-erpelding commented Jul 9, 2025

Description

Gives the accordion component a minor update to include direct actions, which may consist of a quiet action button, switch, or both. Direct action items are vertically centered within the heading's first line of text for all sizes and densities, and maintain their own individual key focus states.

CSS-1204

How and where has this been tested?

Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.

Validation steps

Regression testing

Validate:

  1. The documentation pages for at least two other components are still loading, including:
  • The pages render correctly, are accessible, and are responsive.
  1. If components have been modified, VRTs have been run on this branch:
  • VRTs have been run and looked at.
  • Any VRT changes have been accepted (by reviewer and/or PR author), or there are no changes.

Screenshots

To-do list

  • I have read the contribution guidelines.
  • I have updated relevant storybook stories and templates.
  • I have tested these changes in Windows High Contrast mode.
  • If my change impacts other components, I have tested to make sure they don't break.
  • If my change impacts documentation, I have updated the documentation accordingly.
  • ✨ This pull request is ready to merge. ✨

@rise-erpelding rise-erpelding self-assigned this Jul 9, 2025
@rise-erpelding rise-erpelding added wip This is a work in progress, don't judge. S2 Spectrum 2 labels Jul 9, 2025
Copy link

changeset-bot bot commented Jul 9, 2025

🦋 Changeset detected

Latest commit: 4480c6d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@spectrum-css/accordion Minor
@spectrum-css/bundle Patch
@spectrum-css/preview Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jul 9, 2025

File metrics

Summary

Total size: 1.43 MB*

Package Size Minified Gzipped
accordion 21.38 KB 20.54 KB 2.62 KB

accordion

Filename Head Minified Gzipped Compared to base
index.css 21.38 KB 20.54 KB 2.62 KB 🔴 ⬆ 1.42 KB
metadata.json 11.40 KB - - 🔴 ⬆ 0.54 KB
* Size is the sum of all main files for packages in the library.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

Copy link
Contributor

github-actions bot commented Jul 9, 2025

📚 Branch preview

PR #4020 has been deployed to Azure Blob Storage: https://spectrumcss.z13.web.core.windows.net/pr-4020/index.html.

@rise-erpelding rise-erpelding force-pushed the rise-erpelding/accordion-followups branch from 1f8e5b3 to a2a2bc9 Compare July 9, 2025 21:10
- updates test cases in order to use shorter content that fits better
with the default width of accordion items
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/accordion-followups branch 2 times, most recently from dc3ac58 to 812af2b Compare July 11, 2025 15:21
- adds direct actions feature to storybook, template, and css
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/accordion-followups branch from 812af2b to ec8d50d Compare July 11, 2025 15:36
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/accordion-followups branch from ec8d50d to 4480c6d Compare July 11, 2025 15:46
Comment on lines +77 to +82
/* Calculated vertical spacing for action button and switch to center them within the accordion item */
--spectrum-accordion-item-direct-actions-vertical-spacing: calc(
(var(--mod-accordion-item-min-block-size, var(--spectrum-accordion-item-min-block-size)) -
var(--mod-accordion-item-direct-actions-height, var(--spectrum-accordion-item-direct-actions-height))) / 2
);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did I miss a better way to do vertical spacing for this situation? I was finding that this got pretty complex, pretty fast:

  • An align-items: center on the .spectrum-Accordion-itemDirectActions isn't ideal when the text wraps because the designs show that we want direct actions to align with the first line of text, instead of all of them.
  • Accordion items have a min-height of component-height-75/component-height-100/component-height-200/component-height-300, same with the direct actions, but we don't usually see that min-height in accordion (except for compact) because of the calculations for spacing and font-size * line-height making it larger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S2 Spectrum 2 wip This is a work in progress, don't judge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant