-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Popover: rewrite Storybook examples using controls #42903
Conversation
import { Provider as SlotFillProvider } from '../../slot-fill'; | ||
import Popover from '../'; | ||
|
||
// Format: "[yAxis] [xAxis]" |
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.
It actually looks like the position
prop accepted also a third value, called corner
— although I couldn't find any reference in the old popover documentation and I didn't have enough time to investigate deeper
left: 1px; | ||
height: 2px; | ||
width: 100%; | ||
right: 1px; |
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.
Happy to move this adjustment to a separate PR if necessary
Size Change: +10 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
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.
A much needed improvement for the intense Popover work going on. Thanks!
parameters: { | ||
knobs: { disable: false }, | ||
docs: { source: { state: 'open' } }, |
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.
I think we can keep the code snippets collapsed for these stories, since they're not really useful in the current state. (Maybe with the exception of the iframe one?)
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.
I removed the whole parameters
key for now in 0381cd8. I'm sure we'll iterate over this file soon enough, especially when we'll convert this component to TypeScript
0381cd8
to
a72c13e
Compare
a72c13e
to
3612384
Compare
What?
In the context of #42770, the Storybook examples are being of little help when working on the
Popover
component in isolation.This PR refactors the Storybook examples to use controls (instead of the deprecated knobs add-on), and also rewrites some of the stories in a way that hopefully showcases the usages of the component in a better way compared to how it was before.
Why?
Better Storybook examples = better dev experience (both as a component author, and as a component consumer).
How?
Popover
propsdefault
example has been changed to mirror the example snippet in the component's README (see notes below). I feel like the previous default example was not really useful anyway.positions
example has been replaced with a new story that showcases all possible values forplacement
(ie. the new prop that is supposed to replaceposition
)Testing Instructions
Known issues
Working on this refactor highlighted a couple of issues:
The
Popover
is not anchoring itself correctly to its parent (which is the default behaviour when an explicit anchor it not passed):Kapture.2022-08-02.at.19.31.16.mp4
This behavior can be also spotted on
trunk
by visiting the positioning storybook example, and noting that thePopover
is not positioning itself correctly with respect to its parent (the pink bordered box). This is likely another regression introduced by #40740, and if folks confirm it, I will create a new issue and add it to #42770The positioning of the
Popover
is a bit off in theiframe
exampleKapture.2022-08-02.at.19.53.01.mp4
I haven't had time to debug this example in depth yet, but it looks like the offset applied to the
Popover
to compensate theiFrame
positioning is not correct. It's interesting (and worrying) that thePopover
doesn't work as expected with a simpleiframe
example. We should understand if something is wrong in the way I set up the Storybook example, or if this is another bug that we need to add to #42770 and fix.