mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
made tags panel
This commit is contained in:
parent
f2289f4530
commit
c4f60f3d81
31 changed files with 552 additions and 75 deletions
|
@ -2,21 +2,27 @@ import React, { FC, useEffect, useRef } from 'react';
|
|||
import styles from './styles.module.scss';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
|
||||
import { useCloseOnEscape } from '~/utils/hooks';
|
||||
|
||||
interface IProps {}
|
||||
interface IProps {
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
const SidebarWrapper: FC<IProps> = ({ children }) => {
|
||||
const SidebarWrapper: FC<IProps> = ({ children, onClose }) => {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
useCloseOnEscape(onClose);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current) return;
|
||||
disableBodyScroll(ref.current);
|
||||
disableBodyScroll(ref.current, { reserveScrollBarGap: true });
|
||||
|
||||
return () => enableBodyScroll(ref.current);
|
||||
}, [ref.current]);
|
||||
|
||||
return createPortal(
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.clicker} onClick={onClose} />
|
||||
<div className={styles.content} ref={ref}>
|
||||
{children}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue