Skip to content
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

feat(popover): migrate s2 popover #3365

Open
wants to merge 25 commits into
base: spectrum-two
Choose a base branch
from

Conversation

marissahuysentruyt
Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt commented Nov 4, 2024

Description

Welcome to the new and improved S2 popover! 🥳

This PR updates tokens used in the popover component. Additionally, it brings over all of the relevant stories, tests, and documentation from main (in the hopes of reducing the conflicts the merge may introduce). The copy/pastes from main are marked with [from main] in the commit messages.

- In .storybook/base.css: This update is from main and helps to stop cutting off the nested popover content.

Most of the work in popover.stories.js and template.js is just copied over from main.
- In template.js:

  1. I removed popoverAlignment["inset-inline-start"] = "0"; from 2 position cases (and left a comment explaining that decision).
  2. I replaced the renderContent() from main with the content.map() that works on spectrum-two.
  3. When spectrum-two merges, most of the comments in template.js can be uncommented and refactored to use the approaches we use in main.

- In popover.stories.js`

  1. When spectrum-two merges, most of the comments in popover.stories.js can be uncommented and refactored to use the approaches we use in main. There's a few TODO comments left to hopefully remind us about certain things during that merge.
  2. We'll need to remove the decorator, remove "Component/" from the title, and turn on the metadata/packageJson.

There are several components that have popover as a subcomponent. Those were updated with just enough additional code to make them work. Coachmark did have some additional CSS needs, particularly relating to the new popover corner rounding and the image/media.

Popover Mods

Some mods have been renamed to match their new token names, or better reflect their purposes:

Old mod name New mod name
--mod-popover-content-area-spacing-vertical --mod-popover-content-area-spacing
--mod-popover-shadow-blur --mod-popover-drop-shadow-blur
--mod-popover-shadow-color --mod-popover-drop-shadow-color
--mod-popover-shadow-horizontal --mod-popover-drop-shadow-x
--mod-popover-shadow-vertical --mod-popover-drop-shadow-y

Designs

S2 Popover Token specs
S2 / Desktop Popover

Jira

CSS-615

Pending Questions

  1. How should we be handling the "container padding" as seen in Figma? I'm currently implementing it here: feat(popover): migrate s2 popover #3365 (comment)
Screenshot 2024-11-06 at 3 52 29 PM
  1. Should popover handle the nested menu overlap margin? My guess is no...
Screenshot 2024-11-06 at 3 52 49 PM
  1. Do I need to address search within at all? It's deprecated component that calls for popover. It's very broken looking, but maybe that's to be expected.

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

  • Popover design review and approval
  • Pull down the branch
  • Visit the popover storybook. Verify all stories from main appear on the docs page. No immediate changes have been made to popover positions or tip placements.
  • The default popover matches the [s2 popover specs].(https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=27417-7447)
  • Verify the action button trigger and popover menu items are accessible via keyboard.
  • Create various combinations of the popover to verify combos are considered in the CSS:
    • mobile vs desktop
    • light vs dark mode (the border color/transparency should change in dark mode)
    • popover positioning and tip placement
  • Verify new tokens are used:
    • popover-border-color (see the comment in index.css)
    • popover-border-opacity
    • drop-shadow-elevated-color
    • drop-shadow-elevated-x
    • drop-shadow-elevated-y
    • drop-shadow-elevated-blur
  • Verify updated tokens are used:
    • corner-radius-large-default
    • popover-edge-to-content-area (popover-top-to-content-area was removed from tokens)
    • border-width-100
    • background-layer-2-color (it may not be pointing to gray-25 as intended, but should once we make the full change to S2 tokens)
  • Chromatic coverage (using popover.test.js file) continues to maintains test templates, and does not have additional variations/test scenarios.
  • Action bar, action menu, coach mark, combobox, contextual help, date picker and picker (which all call for a popover component) look acceptable. There may be slight style issues to handle with those components' migrations, as opposed to this PR.

Before:
Screenshot 2024-11-06 at 5 16 11 PM

After:
Screenshot 2024-11-06 at 5 16 28 PM

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

Copy link

changeset-bot bot commented Nov 4, 2024

🦋 Changeset detected

Latest commit: 3ee1873

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

This PR includes changesets to release 10 packages
Name Type
@spectrum-css/popover Major
@spectrum-css/coachmark Major
@spectrum-css/actionbar Major
@spectrum-css/actionmenu Major
@spectrum-css/combobox Major
@spectrum-css/contextualhelp Major
@spectrum-css/datepicker Major
@spectrum-css/picker Major
@spectrum-css/pickerbutton Major
@spectrum-css/tabs Major

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 Nov 4, 2024

File metrics

Summary

Total size: 4.30 MB*
Total change (Δ): ⬆ 3.64 KB (0.08%)

Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.

Package Size Δ
coachmark 8.20 KB ⬆ 0.40 KB
colorarea 3.46 KB ⬇ 0.20 KB
picker 29.19 KB ⬆ 0.40 KB
popover 32.54 KB ⬆ 0.46 KB

Details

coachmark

File Head Base Δ
index-base.css 8.20 KB 7.82 KB ⬆ 0.40 KB (4.93%)
index-vars.css 8.20 KB 7.82 KB ⬆ 0.40 KB (4.93%)
index.css 8.20 KB 7.82 KB ⬆ 0.40 KB (4.93%)
metadata.json 4.70 KB 4.33 KB ⬆ 0.38 KB (8.59%)

colorarea

File Head Base Δ
index-base.css 3.46 KB 3.66 KB ⬇ 0.20 KB (-5.42%)
index-vars.css 3.46 KB 3.66 KB ⬇ 0.20 KB (-5.42%)
index.css 3.46 KB 3.66 KB ⬇ 0.20 KB (-5.42%)
metadata.json 1.57 KB 1.69 KB ⬇ 0.12 KB (-7.01%)

picker

File Head Base Δ
index-base.css 29.19 KB 28.80 KB ⬆ 0.40 KB (1.35%)
index-vars.css 29.19 KB 28.80 KB ⬆ 0.40 KB (1.35%)
index.css 29.19 KB 28.80 KB ⬆ 0.40 KB (1.35%)
metadata.json 14.42 KB 14.31 KB ⬆ 0.11 KB (0.78%)

popover

File Head Base Δ
index-base.css 32.37 KB 31.93 KB ⬆ 0.45 KB (1.38%)
index-theme.css 0.76 KB 0.75 KB ⬆ 0.01 KB (1.06%)
index-vars.css 32.54 KB 32.09 KB ⬆ 0.46 KB (1.40%)
index.css 32.54 KB 32.09 KB ⬆ 0.46 KB (1.40%)
metadata.json 26.83 KB 26.63 KB ⬆ 0.20 KB (0.74%)
themes/express.css 0.67 KB 0.66 KB ⬆ < 0.01 KB (0.60%)
themes/spectrum.css 0.69 KB 0.68 KB ⬆ < 0.01 KB (0.58%)
* Size determined by adding together the size of the main file for all packages in the library.
* Results are not gzipped or minified.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

@marissahuysentruyt marissahuysentruyt self-assigned this Nov 5, 2024
@marissahuysentruyt marissahuysentruyt added wip This is a work in progress, don't judge. do not merge A flag for a branch indicating it should not be merged. skip_vrt Add to a PR to skip running VRT (but still pass the action) S2 Spectrum 2 labels Nov 5, 2024
Copy link
Contributor

github-actions bot commented Nov 5, 2024

🚀 Deployed on https://pr-3365--spectrum-css.netlify.app

@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-615-s2-popover branch from c982e9c to d9214ec Compare November 6, 2024 21:09
switch (position) {
case "top":
popoverWrapperStyles["inline-size"] = "var(--spectrum-popover-width)";
popoverAlignment["inset-block-end"] = "100%";
Copy link
Collaborator Author

@marissahuysentruyt marissahuysentruyt Nov 6, 2024

Choose a reason for hiding this comment

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

I removed 2 lines from these test cases about "inset-inline-start" being set to "0". Something about those 2 lines was uncentering the top and bottom positioning of the popover. I was wondering if maybe it had to do with the additional horizontal padding popover has now?

popoverAlignment["inset-inline-start"] = "0";

popoverAlignment["inset-inline-start"] = "0";

In the browser on production, toggling that property on and off doesn't affect the position of the popover, but in this branch it did. Am I missing something in the CSS which would allow me to keep these 2 lines?

Screen.Recording.2024-11-06.at.4.54.36.PM.mov

@marissahuysentruyt marissahuysentruyt marked this pull request as ready for review November 6, 2024 22:14
@marissahuysentruyt marissahuysentruyt added ready-for-review and removed wip This is a work in progress, don't judge. do not merge A flag for a branch indicating it should not be merged. labels Nov 6, 2024
@marissahuysentruyt marissahuysentruyt marked this pull request as draft November 6, 2024 22:18
@marissahuysentruyt marissahuysentruyt added wip This is a work in progress, don't judge. and removed ready-for-review labels Nov 6, 2024
@@ -68,7 +68,7 @@ export default {
parameters: {
actions: {
handles: [
...Popover.parameters.actions.handles,
...(Popover?.parameters?.actions?.handles ?? []),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is pulled over from main. I tried to pull the least amount of code changes in order to get them all to render.

@@ -68,6 +68,8 @@ export const Template = ({
],
}),
],
popoverHeight: 42,
Copy link
Collaborator Author

@marissahuysentruyt marissahuysentruyt Nov 7, 2024

Choose a reason for hiding this comment

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

Same here: this is pulled over from main. Most of the component template/story changes (that aren't popover) are just enough to get them to render properly(ish). I did mark the popover commits with [from main] before I started any new work for S2.

Comment on lines +124 to +126
& .spectrum-Popover {
--mod-popover-filter: drop-shadow(var(--mod-popover-drop-shadow-x, var(--spectrum-popover-drop-shadow-x)) var(--mod-popover-drop-shadow-y, var(--spectrum-popover-drop-shadow-y)) var(--mod-popover-drop-shadow-blur, var(--spectrum-popover-drop-shadow-blur)) var(--mod-popover-drop-shadow-color, var(--spectrum-popover-drop-shadow-color)));
}
Copy link
Collaborator Author

@marissahuysentruyt marissahuysentruyt Nov 7, 2024

Choose a reason for hiding this comment

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

Currently, none of these variables are defined. I just copied them verbatim from the popover CSS, BUT it's doing what I'd like to do, which is undefining the --mod-popover-filter.

I was trying to add the drop shadow back onto this popover, since it's lying on top of the rest of the coach mark's popover. I assume that's what is supposed to happen given this note in Figma: "Containers that appear on top of content, such as menus and tooltips, have drop shadows to show elevation," but then also the CSS comment to "prevent nested popovers from affecting each others drop shadow filters" (found here)

I would love to pair on this to get some help. Right now, the drop shadow on the right side of the action menu popover is "doubled up", with the drop shadow that's on the coach mark popover. I think it still needs the drop shadow when it's placed on top of other content, particularly in light mode.

Screen.Recording.2024-11-08.at.11.25.14.AM.mov

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doing this is also introducing extra mods to coach mark and I'm not sure we need to do that.

@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-615-s2-popover branch 3 times, most recently from 9eacd5d to b2e341b Compare November 8, 2024 18:06
isOpen: true,
customStyles: {
"margin-inline-start": "136px",
"margin-block-start": "32px"
"margin": "var(--spectrum-popover-nested-container-spacing)",
Copy link
Collaborator Author

@marissahuysentruyt marissahuysentruyt Nov 8, 2024

Choose a reason for hiding this comment

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

This was my attempt at adding the "container padding" that is outlined in Figma. It felt weird to put those styles on the popover itself, i.e.:

& > .spectrum-Popover {
  margin: var(--spectrum-popover-nested-container-spacing);
}

...since it certainly feels like they belong on the containing element. So that's what this is doing- putting that container padding on the popover wrapper.

<div style=${styleMap({

And then users can add those styles to the wrapper if they need. Any thoughts on where these styles are supposed to go?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great question! I don't really have an answer, but I did look into it and will share what I've found so far:

Strangely enough, you asked about this exact thing when we did S2 for Tooltip, which has the same container padding token in its spec, and there I think we decided that it was sort of out of our hands to ensure that that token was used in the implementation.

It's also worth mentioning that, if I dig through the wiki for the S1 specs, I can find the Popover S1 token specs in the XD file from the Sharepoint, and the container padding doesn't change from S1 to S2, and it doesn't seem like it was implemented anywhere in S1 (it's the same case for tooltip, if you're curious).

I think it's fine if we want to add some margin to ensure that there's spacing here, but I have a couple of follow-up questions about that:

  1. Is this --spectrum-popover-nested-container-spacing custom prop meant to be used for all container spacing, or is there a reason it's only used for the nested container/only named for nested container spacing?
  2. Was the intention to put this margin on the wrapper? It looks like this margin is ending up on the popover (on the same element as .spectrum-Popover), not the wrapper, but applying them to popoverWrapperStyles instead puts the margin on the action button, which isn't what we want either. It seems like we'd probably want some space here anyway (maybe?) but I'm not sure we need to use the token (but if I'm missing something let me know!).
    image
    image
  3. As far as I can tell, the --spectrum-popover-nested-container-spacing is defined in index.css then not used in index.css, is that going to cause some linting issues in main? (I would have thought there would be some in this branch too, but I didn't see any.)

Does any of that help here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am totally fine with not implementing the container padding, but I suppose the question is the same for this specific, nested popover story.

Is this --spectrum-popover-nested-container-spacing custom prop meant to be used for all container spacing, or is there a reason it's only used for the nested container/only named for nested container spacing?

I don't believe this should be used for all container spacing. I'm using it only for the nested popover because those 2 popovers "touch" now. The spacing between the trigger and the popover itself is dictated by the animation-distance. That animation distance if from the trigger, which in this case is 8px from the action buttons. But now with the new, additional padding popover has (which is also 8px), the .spectrum-Popover divs "touch."

I suppose instead of spacing-100, I could use the animation-distance token?

without --spectrum-popover-nested-container-spacing:
Screenshot 2024-11-18 at 1 39 27 PM

with --spectrum-popover-nested-container-spacing:
Screenshot 2024-11-18 at 1 40 31 PM

As far as I can tell, the --spectrum-popover-nested-container-spacing is defined in index.css then not used in index.css, is that going to cause some linting issues in main? (I would have thought there would be some in this branch too, but I didn't see any.)

Correct, I didn't actually use it in the CSS. I only used it in the stories file, so I moved it and just defined it in the stories file too. Good call.

Let me know if this solution also addresses your second question about not needing to use that token! 3ee1873

Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

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

This is looking great! I gave this a (relatively) quick once-over and all the tokens look like they're being used. I called out one issue I noticed in the CSS with border-width and noted in Picker that the spacing is looking a little weird.

I'll plan on circling back to this and looking more closely at your questions on the next round!


/* border-color: var(--spectrum-popover-border-color-default); */

border-width: var(--mod-popover-border-width, var(--spectrum-popover-border-thickness));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This mod --mod-popover-border-width is used in a few places, do we want to change the name of it to match its --spectrum-prefixed custom property?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure! Good catch 😄

--spectrum-popover-background-color: var(--spectrum-background-layer-2-color);
--spectrum-popover-border-color: var(--spectrum-gray-400);
--spectrum-popover-background-color: var(--spectrum-background-layer-2-color);
--spectrum-popover-border-thickness: var(--spectrum-border-width-100);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like there are still several references to --spectrum-popover-border-width which is defined in the themes/spectrum.css, this custom prop either needs to be updated to the same name or the references to the old one maybe should be removed and replaced... 🤔 I'm honestly not sure what the best move is here, it might be worth looking over the Foundations PR to get a feel for how we anticipate the different themes will work together in main.

border-radius: var(--mod-popover-corner-radius, var(--spectrum-popover-corner-radius));
border-color: var(--highcontrast-popover-border-color, var(--mod-popover-border-color, var(--spectrum-popover-border-color-with-transparency)));

/* border-color: var(--spectrum-popover-border-color-default); */
Copy link
Collaborator

Choose a reason for hiding this comment

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

A comment here about why this is commented out would be nice, but feel free not to add one if you disagree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was an extraneous comment from earlier edits, trying to popover-border-color-default, which is one of those rgba() tokens.

@@ -147,11 +149,14 @@ export const Template = ({
const popoverMarkup = content.length !== 0 ? Popover({
isOpen: isOpen && !isDisabled && !isLoading,
withTip: false,
position: "bottom",
position: "bottom-start",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something is looking a little funny with this position in Picker, although changing it back to bottom wouldn't fix it here:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I have that worked out now.

b76e4ac
5e12534

Would this be considered "fragile?" Picker on main has some significant updates that this picker doesn't, so the new CSS in these commits won't really apply with the new picker markup. Maybe I should leave some comments? Very happy for feedback on the fixes either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also, the side label shouldn't be broken now!

@rise-erpelding
Copy link
Collaborator

  1. Should popover handle the nested menu overlap margin? My guess is no...

Does this apply in this situation? It feels like it's slightly different than that example because this one has an action button? This one for submenu in popover applies the custom styles to Popover to move it, although I'm sure there are probably other ways we could handle it.

this should make the inline, popover stories show without getting cut
off.
- includes code and comments from template.js on main branch
- includes code and comments from popover.stories.js on main branch
- utilizes new s2 tokens
- add nested popover container margin
- adjust tip offset based on new corner radius
- adds the container padding for nested popovers as customStyles
- remove inset-inline-start from top/bottom positions
this property was causing the popover to be off-centered (likely due to
the new corner rounding)
- removes references to spectrum-popover-border-width
- `--bottom-start` was added to the popover within the picker markup
- sets --mod-popover-animation-distance to the picker spacing token
- adds the popover wrapper div to the CSS selector for the picker's
popover
- removes the transform: unset and utilizes a display: block instead for
the popover wrapper to override the animation distance properly
@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-615-s2-popover branch from b2e341b to 5e12534 Compare November 18, 2024 17:47
@marissahuysentruyt
Copy link
Collaborator Author

  1. Should popover handle the nested menu overlap margin? My guess is no...

Does this apply in this situation? It feels like it's slightly different than that example because this one has an action button? This one for submenu in popover applies the custom styles to Popover to move it, although I'm sure there are probably other ways we could handle it.

@rise-erpelding I think you're right, and using the customStyles for popover, within Menu, was what I was thinking. I just wanted to be sure I shouldn't have been touching that.

- removes `--spectrum-popover-nested-container-spacing` from CSS because
it was defined but never used. also removes its reference in the stories
file
- corrects the margin on the NestedPopover story to use the animation-
distance token as margin instead of spacing-100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review S2 Spectrum 2 skip_vrt Add to a PR to skip running VRT (but still pass the action)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants