Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
Popover
component. This component will be used in the toolbar to display various menus. It's a fairly complex component.The bulk of the logic is handled by the Popper.js which is a tooltip/popover positioning library. The library also has a React hooks wrapper,
react-popper
which is how I interact with the API. I chose this library over one of the premade react component because we need flexibility in how the popover is styled on smaller screens. In the designs we've chosen to make the popovers full screen in our smallest breakpoint. This gives us plenty of real estate for the popover content and avoids a lot of the issues we may run into if trying to position the popover.The small breakpoint is detected using the
react-use-css-breakpoints
library. This small library gets the current breakpoint name by reading thecontent
property on thebody::before
pseudo element which is changed for each breakpoint. This allows us to define our CSS breakpoints in one place and dynamically react to the screen resizing.To avoid any issues with z-index, overflowing content, etc, the
Popover
component is rendered in a React portal. This is an element that is parented to thedocument.body
element, but can be managed in thePopover
component itself.Some other things to note:
react-popper
so I've aliasedreact-popper
toreact-popper-2
. This is done with this line in package.json"react-popper-2": "npm:react-popper@^2.2.3"
. We should be able to resolve this soon, I'm tracking this issueToolbarButton
component to accept theref
property by wrapping it inforwardRef
.content
property for the tooltip can either be an element or a component. This gives us a bit of flexibility and when you provide a component, the component will receive theclosePopover
prop. This is helpful if the content of the popover has logic that will force the popover to close.Controls
tab of Storybook.