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

Fix Popover--right-bottom caret positioning #465

Merged
merged 8 commits into from
May 1, 2018
Merged

Conversation

shawnbot
Copy link
Contributor

@shawnbot shawnbot commented Mar 26, 2018

This fixes #462 and fleshes out all (?) of the popover positioning examples so that we can make sure they look right. (We're missing examples for .Popover--right-bottom, .Popover--right-top, .Popover--left-bottom, and .Popover--left-top.) I've re-ordered the positioning examples (alphabetically) and linked to them from the modifier class listings earlier in the docs.

Do not merge yet! This branches off #464 because we need markdown stories support to see the results without deploying to the style guide.

@shawnbot shawnbot requested review from jonrohan and broccolini March 26, 2018 23:19
}

&::after {
bottom: 21px;
bottom: $spacer-3 + 1;

Choose a reason for hiding this comment

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

I'm trying to understand the changes here - is it true that margin-top usually takes care of the one-pixel-offset before before/after pseudo elements, but not in this case since these are positioned relative to the bottom, not top?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, it's true that margin-top doesn't affect absolutely positioned elements with bottom.

@@ -108,7 +108,7 @@
}

&::before {
margin-top: -9px;
margin-top: -($spacer-2 + 1);

Choose a reason for hiding this comment

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

I know it's not a result of this PR, but it seems like this margin-top makes it so that the distance from the caret to the corner of the card is smaller for --right and --left popovers as compared to --top and --bottom popovers. Is this intended? Or should we have consistent distances from the carets to the corners of the popovers?

Smaller distance to corner:
screen shot 2018-03-27 at 11 27 40 am
Larger distance to corner:
screen shot 2018-03-27 at 11 27 19 am

We have some JS that tries to position the popovers relative to the hover target in a generic way, and it would be convenient if the distance from the caret to the corner was always consistent 😄. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly I'm not sure (I just got back from paternity leave, and my @primer/ds-core peeps are primarily responsible for this component), but my sense is that, yes, the horizontal and vertical alignment are intentionally different. I'd be very interested to see how that JS works, and how we can better support it from our side!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For what it's worth, though, this value actually hasn't changed; I'm just calculating it as a nudge from a "known" value ($spacer-2: 8px) rather than hard-coding 9px.

Choose a reason for hiding this comment

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

For what it's worth, though, this value actually hasn't changed; I'm just calculating it as a nudge from a "known" value ($spacer-2: 8px) rather than hard-coding 9px.

Right on - was asking an unrelated question 😄

Bummer that the distances aren't consistent, but we can handle it.

Thanks for taking this on!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know it's kind of crazy and might seem brittle, but you could determine the positions of those carets from their computed style, e.g.

const computed = window.getComputedStyle(myPopoverContent, '::after')
const bottom = computed.getPropertyValue('bottom')

🙈

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure of the reasons for the distances being different. @brandonrosage worked on adding this component but likely followed the custom styles that existed in dotcom. @pifafu wondering if you have any opinion on this with regards to using on hovercards?

Copy link

Choose a reason for hiding this comment

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

wondering if you have any opinion on this with regards to using on hovercards?

I didn't see a need for the distances between the corner of the card and the caret being different when the caret is top/bottom versus right/left for the user hovercard project. If the caret distance-to-corner was made consistent, we would be good with it 👍

The only spacing that the hovercards project wanted to update on was the distance of the hovercard from the entity that triggers it, since the original styles on the popover were flush to the triggering element.

screen shot 2018-04-11 at 1 12 32 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @pifafu! Have you all done that in the implementation (e.g. with margin utility classes), or should we account for it in the component styles?

Choose a reason for hiding this comment

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

@shawnbot our JS code positions the hovercard so that it's 12 pixels from the target element

Copy link

Choose a reason for hiding this comment

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

Have you all done that in the implementation (e.g. with margin utility classes), or should we account for it in the component styles?

@shawnbot I started with pb-2 to give more space when we started with the popover component, but @iancanderson's recent changes now help handle this! @califa also has interest in larger spacing between the triggering element on the popover component (mt-3 is too large, mt-2 is not enough?). It would be nice to have this accounted for in component styles 😄

@shawnbot shawnbot changed the title [Do not merge] Fix Popover--right-bottom caret positioning Fix Popover--right-bottom caret positioning Mar 27, 2018
@shawnbot
Copy link
Contributor Author

Okay, this is ready for a review now that #464 is merged.

Copy link
Member

@broccolini broccolini left a comment

Choose a reason for hiding this comment

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

Asking design folks to weigh in re positioning but otherwise happy for this to ship as is.

@@ -108,7 +108,7 @@
}

&::before {
margin-top: -9px;
margin-top: -($spacer-2 + 1);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure of the reasons for the distances being different. @brandonrosage worked on adding this component but likely followed the custom styles that existed in dotcom. @pifafu wondering if you have any opinion on this with regards to using on hovercards?

@shawnbot
Copy link
Contributor Author

Ping @brandonrosage @pifafu 😊

@shawnbot
Copy link
Contributor Author

shawnbot commented May 1, 2018

Follow-on notes are in #476. Merging for 10.5!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants