-
Notifications
You must be signed in to change notification settings - Fork 49
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
fix: z-index modal #1152
Merged
Merged
fix: z-index modal #1152
Conversation
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
Other than these issues, the code looks good. Code after corrections: /**
* @file Modal
* generic modal component for chat UI
* does not handle any business logic, acts only as a container
*/
import { useRef, useContext } from "react";
import styled from "styled-components";
import { ThemeContext } from "../theme/ThemeProvider";
import { useClickAway } from "../../../hooks";
import { IChatTheme } from "../theme";
import { Section, Span, Image, Image } from "../../reusables"; // Import Image component
import { BackIcon } from "../../../icons/Back";
import CloseIcon from "../../../icons/close.svg";
import { MODAL_BACKGROUND_TYPE, MODAL_POSITION_TYPE, ModalBackgroundType, ModalPositionType } from "../../../types";
import { device } from "../../../config";
interface IModalProps {
width?: string;
clickawayClose?: () => void;
children: any;
theme?: IChatTheme;
modalBackground?: ModalBackgroundType;
modalPositionType: ModalPositionType; // Change to required property
}
interface IModalHeader {
handlePrevious?: () => void;
handleClose?: () => void;
title: string;
}
const ClickawayCloseModal = ({ children, clickawayClose, width }: IModalProps) => {
const modalRef = useRef(null);
const theme = useContext(ThemeContext);
useClickAway(modalRef, () => {
if (clickawayClose) {
clickawayClose();
}
});
return (
<ModalParent ref={modalRef} width={width} theme={theme}>
{children}
</ModalParent>
);
};
export const Modal = ({ clickawayClose, children, width, modalBackground = MODAL_BACKGROUND_TYPE.OVERLAY, modalPositionType = MODAL_POSITION_TYPE.GLOBAL }: IModalProps) => {
const theme = useContext(ThemeContext);
return (
<ModalOverlay theme={theme} modalBackground={modalBackground} modalPositionType={modalPositionType}>
{clickawayClose ? (
<ClickawayCloseModal clickawayClose={clickawayClose} width={width}>
{children}
</ClickawayCloseModal>
) : (
<ModalParent width={width} theme={theme}>
{children}
</ModalParent>
)}
</ModalOverlay>
);
};
export const ModalHeader = ({ handlePrevious, handleClose, title }: IModalHeader) => {
const theme = useContext(ThemeContext);
return (
<Section justifyContent="center" alignItems="center" width="100%">
{handlePrevious && (
<Span onClick={() => handlePrevious()} cursor="pointer">
<BackIcon />
</Span>
)}
<Span fontWeight="500" fontSize="24px" color={theme.textColor?.modalHeadingText} flex="1">
{title}
</Span>
{handleClose && (
<Image
src={CloseIcon}
height="24px"
maxHeight="24px"
width={"auto"}
onClick={() => handleClose()}
cursor="pointer"
/>
)}
</Section>
);
};
/* styling */
const ModalOverlay = styled.div<IModalProps>`
position: ${(props) => (props.modalPositionType === MODAL_POSITION_TYPE.GLOBAL ? "fixed" : "absolute")};
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
backdrop-filter: ${(props) => (props.modalBackground === MODAL_BACKGROUND_TYPE.BLUR ? "blur(3px)" : "none")}; /* Updated with a semicolon */
background-color: ${(props) => (props.modalBackground === MODAL_BACKGROUND_TYPE.OVERLAY ? "rgba(0, 0, 0, 0.5)" : "transparent")}; /* Black with 40% opacity */
display: flex;
color: ${(props) => props.theme.textColor?.modalHeadingText ?? "#000"};
justify-content: center;
align-items: center;
z-index: 999999;
max-height: 100vh;
overflow-y: auto;
margin: auto !important;
`;
const ModalParent = styled.div<IModalProps>`
display: flex;
flex-direction: column;
align-items: center;
padding: 24px 20px;
max-height: 75vh;
// @media ${device.mobileL} {
// max-height: 70vh;
// }
background: ${(props) => props.theme.backgroundColor?.modalBackground};
border-radius: ${(props) => props.theme.borderRadius?.modal};
width: ${(props) => (props.width ? props.width : "auto")};
margin: auto !important;
@media (max-width: 425px) {
min-width: 300px;
// max-width: 306px;
}
}; All looks good. |
mishramonalisha76
added a commit
that referenced
this pull request
Mar 6, 2024
This reverts commit 4e40221.
mishramonalisha76
added a commit
that referenced
this pull request
Mar 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes Issue
Changes proposed
Check List (Check all the applicable boxes)
Screenshots
Note to reviewers