Skip to content

Commit

Permalink
feat: change isModal to nonModal
Browse files Browse the repository at this point in the history
  • Loading branch information
HyejinYang committed Apr 22, 2024
1 parent 627303d commit 1650eb8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions packages/design-system/src/components/Dialog/Dialog.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface DialogElementStyle {
[key: string]: CSSObject;
}

export type DialogStyle = Pick<DialogTypeBase, "isSmall" | "type" | "isModal">;
export type DialogStyle = Pick<DialogTypeBase, "isSmall" | "type" | "nonModal">;

const DIALOG_WRAPPER_STYLE: DialogElementStyle = {
small: {
Expand Down Expand Up @@ -88,7 +88,7 @@ export const StyledBackdrop = styled("div")({
});

export const StyledDialog = styled("div")<DialogStyle>(
({ theme, isSmall, isModal, type }) => ({
({ theme, isSmall, nonModal, type }) => ({
zIndex: 1001,
maxHeight: "80vh",
display: "flex",
Expand All @@ -99,7 +99,7 @@ export const StyledDialog = styled("div")<DialogStyle>(
color: theme.palette.lunit_token.core.text_normal,

...DIALOG_WRAPPER_STYLE[isSmall ? "small" : "medium"],
...DIALOG_WRAPPER_STYLE[isModal ? "modal" : "nonModal"],
...DIALOG_WRAPPER_STYLE[nonModal ? "nonModal" : "modal"],

"& #dialog-title": {
...DIALOG_TITLE_STYLE[isSmall ? "small" : "medium"],
Expand Down
24 changes: 12 additions & 12 deletions packages/design-system/src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface DialogBase {
titleIcon?: React.ReactNode;
titleVariant?: TypographyProps["variant"];
children: React.ReactNode;
isModal?: boolean; // default true
nonModal?: boolean; // default false
isSmall?: boolean; // default true
sx?: SxProps;
style?: React.CSSProperties;
Expand All @@ -49,30 +49,30 @@ export interface ActionDialogType extends DialogTypeBase {
}

export interface PassiveModalProps extends PassiveDialogType {
isModal?: true;
NonModal?: false;
}
export interface ActionModalProps extends ActionDialogType {
isModal?: true;
NonModal?: false;
}
export type ModalProps = PassiveModalProps | ActionModalProps;

export interface PassiveNonModalProps extends PassiveDialogType {
isModal?: false;
NonModal?: true;
}
export interface ActionNonModalProps extends ActionDialogType {
isModal?: false;
NonModal?: true;
enableBackdropClose?: false;
}
export type NonModalProps = PassiveNonModalProps | ActionNonModalProps;

export type DialogProps = ModalProps | NonModalProps;

function Dialog(props: DialogProps) {
const { isOpen, type, isModal = true, onClose } = props;
const { isOpen, type, nonModal = false, onClose } = props;

const isActionModal = type === "action" && isModal;
const isPassiveModal = type === "passive" && isModal;
const isActionNonModal = type === "action" && !isModal;
const isActionModal = type === "action" && !nonModal;
const isPassiveModal = type === "passive" && !nonModal;
const isActionNonModal = type === "action" && nonModal;

function handleBackdropClose(e: React.MouseEvent<HTMLDivElement>) {
const isClosable =
Expand Down Expand Up @@ -111,7 +111,7 @@ function Dialog(props: DialogProps) {

if (!isOpen) return null;
return createPortal(
!isModal ? (
nonModal ? (
<DialogBase dialogProps={{ ...props }} />
) : (
<StyledBackdrop
Expand All @@ -128,7 +128,7 @@ function Dialog(props: DialogProps) {

function DialogBase({ dialogProps }: { dialogProps: DialogTypeBase }) {
const {
isModal = true,
nonModal = false,
onClose,
title,
titleIcon,
Expand All @@ -147,7 +147,7 @@ function DialogBase({ dialogProps }: { dialogProps: DialogTypeBase }) {
role="dialog"
aria-labelledby="dialog-title"
isSmall={isSmall}
isModal={isModal}
nonModal={nonModal}
type={type}
sx={{
...sx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const NonModal: Story = {
<Dialog
className={classNameFromGlobal}
isOpen={isOpen}
isModal={false}
nonModal
type="action"
isSmall
onClose={close}
Expand Down

0 comments on commit 1650eb8

Please sign in to comment.