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(ui): Popover #1696

Merged
merged 6 commits into from
Aug 15, 2024
Merged

feat(ui): Popover #1696

merged 6 commits into from
Aug 15, 2024

Conversation

VanishMax
Copy link
Contributor

@VanishMax VanishMax commented Aug 14, 2024

Closes prax-wallet/prax#156

Implements Popover component but not the MenuItem that can be nested in the Popover – will do it in a separate PR.

Check it here: https://penumbra-ui-preview--pr1696-feat-prax-156-popov-940s7bhy.web.app/?path=/docs/ui-library-popover--docs

@VanishMax VanishMax requested review from jessepinho and a team August 14, 2024 14:44
@VanishMax VanishMax self-assigned this Aug 14, 2024
Copy link
Contributor

github-actions bot commented Aug 14, 2024

Visit the preview URL for this PR (updated for commit f8fa2c6):

https://penumbra-ui-preview--pr1696-feat-prax-156-popov-940s7bhy.web.app

(expires Thu, 22 Aug 2024 08:43:39 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 709d729610ef7a6369b23f1cb2b820a60cc685b1

@VanishMax VanishMax changed the title feat(ui): #prax-156: Popover feat(ui): Popover Aug 14, 2024
Copy link
Contributor

@jessepinho jessepinho 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 great! A few small notes, then feel free to merge after addressing.

packages/ui/src/Popover/index.stories.tsx Outdated Show resolved Hide resolved
packages/ui/src/Popover/index.tsx Outdated Show resolved Hide resolved
Comment on lines +139 to +140
side?: RadixPopoverContentProps['side'];
align?: RadixPopoverContentProps['align'];
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: This is prob fine, but for what it's worth, I'm a little wary of giving consumers too much control.

I feel like it's generally better to reduce the number of props we expose, and try to restrict usage to the designs Sam gives us. That said, I can see how users might need the side/alignment to be different for layout reasons, so this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, I couldn't figure out how to control the position on our side. Sam wrote in Figma that it should open "on the left side if above the trigger" and "on the right side if below the trigger". Radix doesn't allow to set it dynamically - we can choose only one option. So that's why I decided to give this level of control

const Content = ({ children, side, align }: PopoverContentProps) => {
return (
<RadixPopover.Portal>
<RadixPopover.Content sideOffset={4} side={side} align={align} asChild>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have the content grow out of its origin, like I'm doing with the tooltip here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, could we use theme spacing values, rather than hard-coding the 4? You can do that either of two ways:

  1. Call useTheme(), then pass theme.spacing(1) here, instead of 4.
  2. Use styled-components' .attrs() method to set sideOffset to props.theme.spacing(1), like I'm doing here.

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, updated to use useTheme. And agree that we should use the same animation in similar components. It would be beneficial if you move the scaleIn in a shared file to reuse it between Tooltip, Popover, and other components

@VanishMax VanishMax merged commit 7732f8d into main Aug 15, 2024
8 checks passed
@VanishMax VanishMax deleted the feat/#prax-156/popover branch August 15, 2024 08:48
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.

Implement <Popover /> component
2 participants