-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: continue refactor hooks: useBodyScrollLock, useVirtualEleme…
…ntRef, usePortalContainer (#1038)
- Loading branch information
Showing
15 changed files
with
83 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export * from './useBodyScrollLock'; | ||
export * from './useOutsideClick'; | ||
export * from './usePortalContainer'; | ||
export * from './useVirtualElementRef'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!--GITHUB_BLOCK--> | ||
|
||
# useBodyScrollLock | ||
|
||
<!--/GITHUB_BLOCK--> | ||
|
||
```tsx | ||
import {useBodyScrollLock} from '@gravity-ui/uikit'; | ||
``` | ||
|
||
The `useBodyScrollLock` hook helps to blocks scrolling on the body element. | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :------ | :---------- | :-------: | :-----: | | ||
| enabled | Enable flag | `boolean` | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {useBodyScrollLock} from './useBodyScrollLock'; | ||
export type {BodyScrollLockProps, UseBodyScrollLockProps} from './useBodyScrollLock'; |
6 changes: 4 additions & 2 deletions
6
src/components/utils/useBodyScrollLock.ts → ...ks/useBodyScrollLock/useBodyScrollLock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!--GITHUB_BLOCK--> | ||
|
||
# usePortalContainer | ||
|
||
<!--/GITHUB_BLOCK--> | ||
|
||
```tsx | ||
import {usePortalContainer} from '@gravity-ui/uikit'; | ||
``` | ||
|
||
The `usePortalContainer` hook returns portal container element in the current scope | ||
|
||
## Result | ||
|
||
Container element for portal. `HTMLElement | null` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export {usePortalContainer} from './usePortalContainer'; | ||
export {PortalProvider} from './PortalProvider'; | ||
export type {UsePortalContainerResult} from './usePortalContainer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!--GITHUB_BLOCK--> | ||
|
||
# useVirtualElementRef | ||
|
||
<!--/GITHUB_BLOCK--> | ||
|
||
```tsx | ||
import {useVirtualElementRef} from '@gravity-ui/uikit'; | ||
``` | ||
|
||
The `useVirtualElementRef` hook helps to create virtual element for popup | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :------------- | :----------------------------------------------- | :----------------------------------------: | :-----: | | ||
| rect | Position of virtual element relative to viewport | `{top, bottom, left, right}: {[x]:number}` | | | ||
| contextElement | DOM-context of virtual element | `Element` | | | ||
|
||
## Result | ||
|
||
Virtual element ref link. `React.RefObject` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export {useVirtualElementRef} from './useVirtualElementRef'; | ||
export type { | ||
VirtualElementRect, | ||
UseVirtualElementRefProps, | ||
UseVirtualElementRefResult, | ||
} from './useVirtualElementRef'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters