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(component): added fw-popover component #231

Merged
merged 19 commits into from
Nov 3, 2021
Merged

Conversation

kishore-kumar-E3682
Copy link
Contributor

@kishore-kumar-E3682 kishore-kumar-E3682 commented Oct 8, 2021

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My commits have standard messages as mentioned in Contributing Guidelines

How Has This Been Tested?

The component fw-popover can be used whever an element need to be shown elevated like dropdown or
tooltip. It will automatically takes care of postion, clipping, etc.,
Copy link
Contributor

@parsuram-vijaysankar parsuram-vijaysankar left a comment

Choose a reason for hiding this comment

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

Please find my review comments inline!
Along with this how will the consuming component define the animation?

@@ -0,0 +1,97 @@
import { Component, Element, State, Method, Prop, h } from '@stencil/core';
import { createPopper, Instance } from '@popperjs/core';
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we use the lite import with specific modifiers!

import { createPopper } from '@popperjs/core/lib/popper-lite';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are consuming the modules flip and preventOverflow which are not available in the lite version. Lite + flip + preventOverflow modules is almost equals the popperjs core lib.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok then if that is the case... it should be fine!

@@ -0,0 +1,9 @@
.popper {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the :host directly as the class?

In the render template, you can directly use the <Host> tag instead of the div making the markup more cleaner!

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, for the suggestion. Will implement it via the :host selector.

.popper {
width: 100%;
display: none;
z-index: 99;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to specify z-index or will popper.js handle the clipping part?

@Method()
async show() {
if (!this.isOpen) {
this.popperInstance = createPopper(
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on this logic what is the purpose of this.isOpen?

Can you give an example of how the consuming component will wire this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of this.isOpen flag is to prevent the re-render of the component if it's already created. Since this.popperInstance is a state variable changing it will trigger the re-render.
The consuming component's like tooltip or select will use the the element reference and call the show or hide method - during focus-in and focus-out events in case of tooltip and click events in case of select.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a very cumbersome way to wire up the component... where the parent component will be doing most of the heavy lifting by making sure it needs to call the.

it may not just be the focus-in & focus-out states...Can you wire this up with the select component to see it in action!? I would like to see if a further abstraction can be moved in the popover component!

If popperInstance is a reference to the created popper object, why do we need it to be a State attribute?

Finally, let's not mix tooltips requirements into this component. Since we have named this component as popover... I feel it would make sense if we keep this only for Dropdown, Select, Calendar picker etc. which has a rounded radius, with shadow and background, with a display animation.

For tooltip, we can create a similar implementation if required or break it into a private class that can be extended for both.

@kishore-kumar-E3682 kishore-kumar-E3682 merged commit d046637 into monorepo Nov 3, 2021
@kishore-kumar-E3682 kishore-kumar-E3682 deleted the pepperjs branch November 3, 2021 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants