mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
Modal, AdaptiveDiv, BottomDiv 컴포넌트를 molecules 디렉터리로 이동 및 리팩토링
This commit is contained in:
48
src/lib/components/molecules/ActionModal.svelte
Normal file
48
src/lib/components/molecules/ActionModal.svelte
Normal file
@@ -0,0 +1,48 @@
|
||||
<script module lang="ts">
|
||||
export type ConfirmHandler = () => void | Promise<void> | boolean | Promise<boolean>;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
import { Button, Modal } from "$lib/components/atoms";
|
||||
|
||||
interface Props {
|
||||
cancelText?: string;
|
||||
children?: Snippet;
|
||||
confirmText: string;
|
||||
isOpen: boolean;
|
||||
onbeforeclose?: () => void;
|
||||
onconfirm: ConfirmHandler;
|
||||
title: string;
|
||||
}
|
||||
|
||||
let {
|
||||
cancelText = "닫기",
|
||||
children,
|
||||
confirmText,
|
||||
isOpen = $bindable(),
|
||||
onbeforeclose,
|
||||
onconfirm,
|
||||
title,
|
||||
}: Props = $props();
|
||||
|
||||
const closeModal = () => {
|
||||
onbeforeclose?.();
|
||||
isOpen = false;
|
||||
};
|
||||
|
||||
const confirmAction = async () => {
|
||||
if ((await onconfirm()) !== false) {
|
||||
closeModal();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:isOpen onclose={closeModal} class="flex flex-col gap-y-2">
|
||||
<p class="text-xl font-bold">{title}</p>
|
||||
{@render children?.()}
|
||||
<div class="flex gap-x-2">
|
||||
<Button color="gray" onclick={closeModal} class="flex-1">{cancelText}</Button>
|
||||
<Button onclick={confirmAction} class="flex-1">{confirmText}</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
2
src/lib/components/molecules/index.ts
Normal file
2
src/lib/components/molecules/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./ActionModal.svelte";
|
||||
export { default as ActionModal } from "./ActionModal.svelte";
|
||||
Reference in New Issue
Block a user