-
Notifications
You must be signed in to change notification settings - Fork 205
fix(accordion): clean up spacing issues #4139
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
fix(accordion): clean up spacing issues #4139
Conversation
📚 Branch previewPR #4139 has been deployed to Azure Blob Storage: https://spectrumcss.z13.web.core.windows.net/pr-4139/index.html. |
File metricsSummaryTotal size: 1.43 MB*
accordion
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
ec06316
to
c9ef6f4
Compare
🦋 Changeset detectedLatest commit: 113ecd9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
c9ef6f4
to
782a1aa
Compare
36de749
to
b349d2c
Compare
@@ -13,7 +13,7 @@ | |||
|
|||
.spectrum-Accordion { | |||
/* Layout and spacing */ | |||
--spectrum-accordion-item-minimum-height: var(--spectrum-component-height-100); | |||
--spectrum-accordion-item-minimum-height: var(--spectrum-component-height-200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are going to be one size up all the way through! It goes something like this, and if you check out the design, you'll see that these min heights align with what's seen there too:
Size | Compact | Regular | Spacious |
---|---|---|---|
S | 24px/component-height-75 |
32px/component-height-100 |
40px/component-height-200 |
M | 32px/component-height-100 |
40px/component-height-200 |
48px/component-height-300 |
L | 40px/component-height-200 |
48px/component-height-300 |
56px/component-height-400 |
XL | 48px/component-height-300 |
56px/component-height-400 |
64px/component-height-500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this table in the changelog?! It's awesome.
/* if we use min-height token, sometimes we'll have extra space so we'll need to center the text vertically */ | ||
display: flex; | ||
align-items: center; | ||
|
||
min-block-size: var(--mod-accordion-item-min-block-size, var(--spectrum-accordion-item-min-block-size)); | ||
box-sizing: border-box; /* respect min-block-size but include padding */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example to illustrate why we need these properties, if I take them out for compact XL for example, I get this:
Versus if I add them back in, here you can see that the chevron disclosure icon is much more aligned with the title text:
This is happening because when we adjusted the min-height tokens, we created more space in the accordion item. The vertical space that is taken up by the padding tokens, font-size & line height no longer fills the whole item. (This happens in the design too, I think the ticket for the issue has a screen shot of this.)
}), | ||
], | ||
}), | ||
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend est mollis ligula lobortis, tempus ultricies sapien lacinia. Nulla ut turpis velit. Sed finibus dapibus diam et sollicitudin. Phasellus in ipsum nec ante elementum congue eget in leo. Morbi eleifend justo non rutrum venenatis. Fusce cursus et lectus eu facilisis. Ut laoreet felis in magna dignissim feugiat.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When showing the Storybook preview to Kami, she noticed the discrepancies between the item content formatting that we had before, where some of the items use plain text styled according to the design spec, but some demonstrate use of the Typography component, which has different line spacing and a larger font size (even if we use the same t-shirt size). I see how that's confusing and inconsistent, so I've taken this out of the default story.
Since it is useful within the custom width story that has links within its content, the typography classes are still used there.
@@ -80,9 +61,10 @@ export const longerContent = new Map([ | |||
"Are Adobe products worth it?", | |||
{ | |||
content: Typography({ | |||
size: "s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typography font size doesn't line up with the spec'd font size for accordion item content, so we're using a smaller typography size here.
@@ -334,7 +334,7 @@ | |||
|
|||
&:has(+ .spectrum-Accordion-itemDirectActions) { | |||
/* set spacing between header and direct actions, whether or not noInlinePadding variant is used */ | |||
padding-inline-end: var(--mod-accordion-item-header-to-direct-actions-space, var(--spectrum-accordion-item-header-to-direct-actions-space)); | |||
margin-inline-end: var(--mod-accordion-item-header-to-direct-actions-space, var(--spectrum-accordion-item-header-to-direct-actions-space)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just makes the space look a little prettier when there's hover/key focus!
58ea3eb
to
5bf2d51
Compare
.changeset/pre.json
Outdated
@@ -142,6 +142,7 @@ | |||
"itchy-shrimps-help", | |||
"itchy-waves-work", | |||
"khaki-icons-hammer", | |||
"kind-cycles-check", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be included as part of the changes for this PR? ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like another rebase resolved these!
.storybook/CHANGELOG.md
Outdated
@@ -1,5 +1,14 @@ | |||
# Change Log | |||
|
|||
## 12.1.0-next.15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This as well — it looks like it pertains to one of @castastrophe's recent changes? ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like another rebase resolved these!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran through all the validation steps and everything looks great to me! ✨ 👏🏻
(Left a few comments about commit content, but nothing blocking.)
b349d2c
to
56aeea1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved! Thanks for the detailed notes inline. My only feedback is that I'd love to see that table you shared embedded in the changeset you wrote out. Thanks again!
@@ -13,7 +13,7 @@ | |||
|
|||
.spectrum-Accordion { | |||
/* Layout and spacing */ | |||
--spectrum-accordion-item-minimum-height: var(--spectrum-component-height-100); | |||
--spectrum-accordion-item-minimum-height: var(--spectrum-component-height-200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this table in the changelog?! It's awesome.
6e1d8b5
to
113ecd9
Compare
Description
Resolves the previous issue with accordion where, when the action button was added to an item's direct actions area, the action button was taller than the accordion item's height. (This was only an issue with compact XL.)

The updates made to accordion adjust the spacing tokens so that the action button always fits within the accordion item, although its focus outline may be outside of the accordion item (just as the accordion item's focus outline is outside of the item).

After confirming with design, the tokens used for minimum height have been updated to be more spacious, which better matches the designs. Note that these tokens aren't always used; there is a calculation that sets the min height to the maximum between the token or the sum of the space needed (top & bottom padding + font-size * line-height) to ensure that the accordion item always has enough space even with adjustments to padding, font-size, or line-height.
Since accordion items have more space, some adjustments were also made to center the accordion's itemTitle vertically.
Also addresses a small issue with the hover/key focus state where the itemTitle extends to the edge of the direct actions, this was more noticeable if there was a switch direct action, but not an action button:




Before:
After:
CSS-1260
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
Use the PR preview or check out the branch locally:
Regression testing
Validate:
or there are no changes.To-do list
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.