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(Drawer): resizer, portal rendering, hide veil #270

Merged
merged 4 commits into from
Jul 22, 2024

Conversation

StepanKirichenko
Copy link
Contributor

Adds new functionality to Drawer.

Resizable drawer item

DrawerItem can be optionally made resizable, with the ability to save the width of the element.

New DrawerItem props:

  • resizable: (optional) Whether the item should be able to resize
  • width: (optional) The width of the resizable drawer item. If not provided, the current width will be stored internally in the component.
  • onResize: (optional) Callback that can be used to save the new item width
  • minResizeWidth: (optional) The minimum width the item can be resized to
  • maxResizeWidth: (optional) The maximum width the item can be resized to

Portal

Drawer renders itself in <Portal> by default. This can be disabled by passing disablePortal={true} prop.

Hide veil

The background veil element can be disabled by passing hideVeil={true} prop.

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@Lunory
Copy link
Collaborator

Lunory commented Jul 18, 2024

I get some points after testing Drawer in Storybook preview

  1. Drawer item doesn't close with hidden veil. That's OK?
    https://preview.gravity-ui.com/navigation/270/?path=/story/components-drawer--hide-veil

  2. I missed clicking on the resizable handle and panel was closing. May be we can make bigger handle or it's not necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

};

export type {DrawerDirection} from './utils';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move to the top or you can move to Drawer/index btw

@StepanKirichenko
Copy link
Contributor Author

I get some points after testing Drawer in Storybook preview

1. Drawer item doesn't close with hidden veil. That's OK?
   https://preview.gravity-ui.com/navigation/270/?path=/story/components-drawer--hide-veil

2. I missed clicking on the resizable handle and panel was closing. May be we can make bigger handle or it's not necessary?
  1. The veil does not emit pointer events when it is hidden. DrawerItem can still be made to close on outside click with things like useOutsideClick or useLayer.
  2. The resizer width can be made a part of CSS API

@StepanKirichenko StepanKirichenko requested a review from Lunory July 18, 2024 11:38
@@ -57,3 +87,16 @@ The Drawer module consists of two primary components: `Drawer` and `DrawerItem`.
| style | Optional inline styles to be applied to the drawer component. | `React.CSSProperties` | |
| onVeilClick | Optional callback function that is called when the veil (overlay) is clicked. | `(event: React.MouseEvent) => void` | |
| onEscape | Optional callback function that is called when the escape key is pressed, if the drawer is open. | `() => void` | |
| hideVeil | Optional flag to hide the background darkening | `boolean` | |
| disablePortal | Optional flag to hide the background darkening | `boolean` | |
Copy link
Collaborator

@DarkGenius DarkGenius Jul 18, 2024

Choose a reason for hiding this comment

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

Let's fix description for disablePortal

@StepanKirichenko StepanKirichenko merged commit 64da0f2 into main Jul 22, 2024
4 checks passed
@StepanKirichenko StepanKirichenko deleted the resizable-drawer branch July 22, 2024 10:42
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.

4 participants