feat(WEB-154): my profile view
This commit is contained in:
1
components/Modal/Header/header.module.css
Normal file
1
components/Modal/Header/header.module.css
Normal file
@@ -0,0 +1 @@
|
||||
.header {}
|
||||
9
components/Modal/Header/index.tsx
Normal file
9
components/Modal/Header/index.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import styles from "./header.module.css"
|
||||
|
||||
export default function Header({ children }: React.PropsWithChildren) {
|
||||
return (
|
||||
<header className={styles.header}>
|
||||
{children}
|
||||
</header>
|
||||
)
|
||||
}
|
||||
22
components/Modal/Modal/index.tsx
Normal file
22
components/Modal/Modal/index.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { forwardRef } from "react"
|
||||
|
||||
import styles from "./modal.module.css"
|
||||
|
||||
const Modal = forwardRef<HTMLDivElement, React.PropsWithChildren>(
|
||||
function ({ children }, ref) {
|
||||
return (
|
||||
<div
|
||||
className={styles.modal}
|
||||
ref={ref}
|
||||
role="dialog"
|
||||
tabIndex={-1}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
Modal.displayName = "Modal"
|
||||
|
||||
export default Modal
|
||||
11
components/Modal/Modal/modal.module.css
Normal file
11
components/Modal/Modal/modal.module.css
Normal file
@@ -0,0 +1,11 @@
|
||||
.modal {
|
||||
background-color: var(--some-white-color, #F2F2F2);
|
||||
border-radius: 0.4rem;
|
||||
left: 50%;
|
||||
outline: none;
|
||||
overflow: auto;
|
||||
padding: 3.5rem 7rem;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
44
components/Modal/Overlay/index.tsx
Normal file
44
components/Modal/Overlay/index.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
"use client"
|
||||
import { useCallback, useLayoutEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useHandleKeyPress } from "@/hooks/useHandleKeyPress";
|
||||
|
||||
import styles from "./overlay.module.css"
|
||||
|
||||
export default function Overlay({ children }: React.PropsWithChildren) {
|
||||
const router = useRouter()
|
||||
|
||||
const handleOnClose = useCallback(() => {
|
||||
return router.back()
|
||||
}, [router])
|
||||
|
||||
const handleOnEscape = useCallback((evt: KeyboardEvent) => {
|
||||
if (evt.code === "Escape") {
|
||||
handleOnClose()
|
||||
}
|
||||
}, [handleOnClose])
|
||||
|
||||
useHandleKeyPress(handleOnEscape)
|
||||
|
||||
useLayoutEffect(() => {
|
||||
// Get original body overflow
|
||||
const originalStyle = window.getComputedStyle(document.body).overflow;
|
||||
// Prevent scrolling on mount
|
||||
document.body.style.overflow = 'hidden';
|
||||
// Re-enable scrolling when component unmounts
|
||||
return () => {
|
||||
document.body.style.overflow = originalStyle;
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={styles.overlay}
|
||||
onClick={handleOnClose}
|
||||
role="button"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
9
components/Modal/Overlay/overlay.module.css
Normal file
9
components/Modal/Overlay/overlay.module.css
Normal file
@@ -0,0 +1,9 @@
|
||||
.overlay {
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: 9999;
|
||||
}
|
||||
9
components/Modal/Portal.tsx
Normal file
9
components/Modal/Portal.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
"use client"
|
||||
import { createPortal } from 'react-dom';
|
||||
|
||||
export default function Portal({ children }: React.PropsWithChildren) {
|
||||
return createPortal(
|
||||
children,
|
||||
document.body
|
||||
);
|
||||
};
|
||||
9
components/Modal/Title/index.tsx
Normal file
9
components/Modal/Title/index.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import styles from "./title.module.css"
|
||||
|
||||
export default function Title({ children }: React.PropsWithChildren) {
|
||||
return (
|
||||
<h1 className={styles.heading}>
|
||||
{children}
|
||||
</h1>
|
||||
)
|
||||
}
|
||||
1
components/Modal/Title/title.module.css
Normal file
1
components/Modal/Title/title.module.css
Normal file
@@ -0,0 +1 @@
|
||||
.heading {}
|
||||
20
components/Modal/index.tsx
Normal file
20
components/Modal/index.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import Header from "./Header"
|
||||
import UiModal from "./Modal"
|
||||
import Overlay from "./Overlay"
|
||||
import Portal from "./Portal"
|
||||
import Title from "./Title"
|
||||
|
||||
export default function Modal({ children }: React.PropsWithChildren) {
|
||||
return (
|
||||
<Portal>
|
||||
<Overlay>
|
||||
<UiModal>
|
||||
{children}
|
||||
</UiModal>
|
||||
</Overlay>
|
||||
</Portal>
|
||||
)
|
||||
}
|
||||
|
||||
Modal.Header = Header
|
||||
Modal.Title = Title
|
||||
Reference in New Issue
Block a user