ActionModal 레이아웃 및 Props 이름 관련 리팩토링

This commit is contained in:
static
2025-01-24 21:58:51 +09:00
parent fea9cd729c
commit 38a1c8d7e0
6 changed files with 18 additions and 16 deletions

View File

@@ -12,7 +12,7 @@
confirmText: string; confirmText: string;
isOpen: boolean; isOpen: boolean;
onbeforeclose?: () => void; onbeforeclose?: () => void;
onconfirm: ConfirmHandler; onConfirmClick: ConfirmHandler;
title: string; title: string;
} }
@@ -22,7 +22,7 @@
confirmText, confirmText,
isOpen = $bindable(), isOpen = $bindable(),
onbeforeclose, onbeforeclose,
onconfirm, onConfirmClick,
title, title,
}: Props = $props(); }: Props = $props();
@@ -32,15 +32,17 @@
}; };
const confirmAction = async () => { const confirmAction = async () => {
if ((await onconfirm()) !== false) { if ((await onConfirmClick()) !== false) {
closeModal(); closeModal();
} }
}; };
</script> </script>
<Modal bind:isOpen onclose={closeModal} class="flex flex-col gap-y-2"> <Modal bind:isOpen onclose={closeModal} class="space-y-4">
<p class="text-xl font-bold">{title}</p> <div class="flex flex-col gap-y-2 break-keep">
{@render children?.()} <p class="text-xl font-bold">{title}</p>
{@render children?.()}
</div>
<div class="flex gap-x-2"> <div class="flex gap-x-2">
<Button color="gray" onclick={closeModal} class="flex-1">{cancelText}</Button> <Button color="gray" onclick={closeModal} class="flex-1">{cancelText}</Button>
<Button onclick={confirmAction} class="flex-1">{confirmText}</Button> <Button onclick={confirmAction} class="flex-1">{confirmText}</Button>

View File

@@ -14,5 +14,5 @@
title="새 카테고리" title="새 카테고리"
placeholder="카테고리 이름" placeholder="카테고리 이름"
submitText="만들기" submitText="만들기"
onsubmit={oncreate} onSubmitClick={oncreate}
/> />

View File

@@ -4,11 +4,11 @@
interface Props { interface Props {
isOpen: boolean; isOpen: boolean;
onbeforeclose?: () => void; onbeforeclose?: () => void;
onrename: (newName: string) => Promise<boolean>; onRenameClick: (newName: string) => Promise<boolean>;
originalName: string | undefined; originalName: string | undefined;
} }
let { isOpen = $bindable(), onbeforeclose, onrename, originalName }: Props = $props(); let { isOpen = $bindable(), onbeforeclose, onRenameClick, originalName }: Props = $props();
</script> </script>
<TextInputModal <TextInputModal
@@ -18,5 +18,5 @@
placeholder="이름" placeholder="이름"
defaultValue={originalName} defaultValue={originalName}
submitText="바꾸기" submitText="바꾸기"
onsubmit={onrename} onSubmitClick={onRenameClick}
/> />

View File

@@ -6,7 +6,7 @@
defaultValue?: string; defaultValue?: string;
isOpen: boolean; isOpen: boolean;
onbeforeclose?: () => void; onbeforeclose?: () => void;
onsubmit: (value: string) => ReturnType<ConfirmHandler>; onSubmitClick: (value: string) => ReturnType<ConfirmHandler>;
placeholder: string; placeholder: string;
submitText: string; submitText: string;
title: string; title: string;
@@ -16,7 +16,7 @@
defaultValue = "", defaultValue = "",
isOpen = $bindable(), isOpen = $bindable(),
onbeforeclose, onbeforeclose,
onsubmit, onSubmitClick,
placeholder, placeholder,
submitText, submitText,
title, title,
@@ -36,7 +36,7 @@
{onbeforeclose} {onbeforeclose}
{title} {title}
confirmText={submitText} confirmText={submitText}
onconfirm={() => onsubmit(value)} onConfirmClick={() => onSubmitClick(value)}
> >
<TextInput bind:value {placeholder} class="mb-5" /> <TextInput bind:value {placeholder} class="mb-3" />
</ActionModal> </ActionModal>

View File

@@ -89,7 +89,7 @@
bind:isOpen={isCategoryRenameModalOpen} bind:isOpen={isCategoryRenameModalOpen}
onbeforeclose={() => (selectedSubCategory = undefined)} onbeforeclose={() => (selectedSubCategory = undefined)}
originalName={selectedSubCategory?.name} originalName={selectedSubCategory?.name}
onrename={async (newName: string) => { onRenameClick={async (newName: string) => {
if (await requestCategoryRename(selectedSubCategory!, newName)) { if (await requestCategoryRename(selectedSubCategory!, newName)) {
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
return true; return true;

View File

@@ -170,7 +170,7 @@
bind:isOpen={isDirectoryEntryRenameModalOpen} bind:isOpen={isDirectoryEntryRenameModalOpen}
onbeforeclose={() => (selectedEntry = undefined)} onbeforeclose={() => (selectedEntry = undefined)}
originalName={selectedEntry?.name} originalName={selectedEntry?.name}
onrename={async (newName: string) => { onRenameClick={async (newName: string) => {
if (await requestDirectoryEntryRename(selectedEntry!, newName)) { if (await requestDirectoryEntryRename(selectedEntry!, newName)) {
info = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME info = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
return true; return true;