Skip to content

Commit

Permalink
chore: dimmed 백그라운드 컴포넌트 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
kingyong9169 committed Aug 3, 2024
1 parent bb63b88 commit fbfc2c4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
35 changes: 35 additions & 0 deletions apps/web/src/assets/svg/Ticket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 6 additions & 10 deletions apps/web/src/components/app-download-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from "~/libs/store/modal-status";
import { onAppDownloadClick } from "~/libs/utils";
import { cn } from "~/libs/utils";
import { getModalAnimationClassNames } from "~/styles/utils";
import DimmedBackground from "./ui/dimmed-background";

export const useAppDownloadModalStore =
create<ModalStatusStore>(getModalStatusStore);
Expand All @@ -37,19 +39,13 @@ export default function AppDownloadModal() {
<>
{createPortal(
<RemoveScroll removeScrollBar={false}>
{/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}
<div
className={cn(
status === "mounted" && "animate-fade-in",
status === "closed" && "animate-fade-out",
"z-[1000] fixed inset-0 bg-black bg-opacity-40",
)}
onClick={() => onClickClose(false)}
<DimmedBackground
classNames={getModalAnimationClassNames(status)}
onClose={() => onClickClose(false)}
/>
<div
className={cn(
status === "mounted" && "animate-fade-in",
status === "closed" && "animate-stage-out",
getModalAnimationClassNames(status),
"z-[1000] bg-white fixed -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2 w-[272px] overflow-hidden rounded-[8px] p-4 pt-[21px] text-[16px] leading-[22px]",
)}
onAnimationEnd={transferStatus}
Expand Down
22 changes: 22 additions & 0 deletions apps/web/src/components/ui/dimmed-background.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { cn } from "~/libs/utils";

interface Props extends React.DOMAttributes<HTMLDivElement> {
classNames?: Array<string>;
onClose?: () => void;
}

const DimmedBackground = ({ classNames, onClose, ...rest }: Props) => {
return (
<div
{...rest}
className={cn(
classNames,
"z-[1000] fixed inset-0 bg-black bg-opacity-40",
)}
onClick={onClose}
/>
);
};

export default DimmedBackground;
6 changes: 6 additions & 0 deletions apps/web/src/styles/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ModalStatus } from "~/types/modal-status";

export const getModalAnimationClassNames = (status: ModalStatus) => [
status === "mounted" ? "animate-fade-in" : "",
status === "closed" ? "animate-fade-out" : "",
];

0 comments on commit fbfc2c4

Please sign in to comment.