컴포넌트 관련 사소한 리팩토링

This commit is contained in:
static
2025-01-27 20:17:20 +09:00
parent 7230810f3a
commit acb6e1ac6e
22 changed files with 70 additions and 50 deletions

View File

@@ -11,7 +11,7 @@
onclose?: () => void; onclose?: () => void;
} }
let { children, isOpen = $bindable(), onclose, ...props }: Props = $props(); let { children, class: className, isOpen = $bindable(), onclose }: Props = $props();
</script> </script>
{#if isOpen} {#if isOpen}
@@ -32,7 +32,7 @@
class="flex max-h-[70vh] min-h-[30vh] flex-col rounded-t-2xl bg-white" class="flex max-h-[70vh] min-h-[30vh] flex-col rounded-t-2xl bg-white"
transition:fly|global={{ y: 100, duration: 200 }} transition:fly|global={{ y: 100, duration: 200 }}
> >
<div class={["flex-grow overflow-y-auto", props.class]}> <div class={["flex-grow overflow-y-auto", className]}>
{@render children?.()} {@render children?.()}
</div> </div>
</div> </div>

View File

@@ -11,7 +11,7 @@
onclose?: () => void; onclose?: () => void;
} }
let { children, isOpen = $bindable(), onclose, ...props }: Props = $props(); let { children, class: className, isOpen = $bindable(), onclose }: Props = $props();
</script> </script>
{#if isOpen} {#if isOpen}
@@ -24,7 +24,7 @@
> >
<AdaptiveDiv class="h-full"> <AdaptiveDiv class="h-full">
<div class="flex h-full items-center justify-center px-4"> <div class="flex h-full items-center justify-center px-4">
<div onclick={(e) => e.stopPropagation()} class={["rounded-2xl bg-white p-4", props.class]}> <div onclick={(e) => e.stopPropagation()} class={["rounded-2xl bg-white p-4", className]}>
{@render children?.()} {@render children?.()}
</div> </div>
</div> </div>

View File

@@ -13,10 +13,11 @@
let { let {
actionButtonIcon: ActionButtonIcon, actionButtonIcon: ActionButtonIcon,
actionButtonClass: actionButtonClassName,
children, children,
class: className,
onActionButtonClick, onActionButtonClick,
onclick, onclick,
...props
}: Props = $props(); }: Props = $props();
</script> </script>
@@ -25,7 +26,7 @@
<div <div
id="container" id="container"
onclick={onclick && (() => setTimeout(onclick, 100))} onclick={onclick && (() => setTimeout(onclick, 100))}
class={["rounded-xl", props.class]} class={["rounded-xl", className]}
> >
<div id="children" class="flex h-full items-center justify-between gap-x-4 p-2 transition"> <div id="children" class="flex h-full items-center justify-between gap-x-4 p-2 transition">
<div class="flex-grow overflow-x-hidden"> <div class="flex-grow overflow-x-hidden">
@@ -40,10 +41,7 @@
setTimeout(onActionButtonClick, 100); setTimeout(onActionButtonClick, 100);
} }
}} }}
class={[ class={["flex-shrink-0 rounded-full p-1 text-lg active:bg-gray-100", actionButtonClassName]}
"flex-shrink-0 rounded-full p-1 text-lg active:bg-gray-100",
props.actionButtonClass,
]}
> >
<ActionButtonIcon /> <ActionButtonIcon />
</button> </button>

View File

@@ -9,7 +9,7 @@
onclick?: () => void; onclick?: () => void;
} }
let { children, color = "primary", onclick, ...props }: Props = $props(); let { children, class: className, color = "primary", onclick }: Props = $props();
let bgColor = $derived( let bgColor = $derived(
{ {
@@ -31,7 +31,7 @@
"h-12 min-w-fit rounded-xl p-3 font-medium transition active:scale-95", "h-12 min-w-fit rounded-xl p-3 font-medium transition active:scale-95",
bgColor, bgColor,
textColor, textColor,
props.class, className,
]} ]}
> >
{@render children?.()} {@render children?.()}

View File

@@ -10,12 +10,12 @@
onclick?: () => void; onclick?: () => void;
} }
let { children, onclick, ...props }: Props = $props(); let { children, class: className, onclick }: Props = $props();
</script> </script>
<button <button
onclick={onclick && (() => setTimeout(onclick, 100))} onclick={onclick && (() => setTimeout(onclick, 100))}
class={["rounded-xl active:bg-gray-100", props.class]} class={["rounded-xl active:bg-gray-100", className]}
> >
<div class="flex h-full gap-x-4 p-2 transition active:scale-95"> <div class="flex h-full gap-x-4 p-2 transition active:scale-95">
<div class="h-full flex-grow"> <div class="h-full flex-grow">

View File

@@ -7,9 +7,9 @@
class?: ClassValue; class?: ClassValue;
} }
let { children, ...props }: Props = $props(); let { children, class: className }: Props = $props();
</script> </script>
<div class={["mx-auto max-w-screen-md", props.class]}> <div class={["mx-auto max-w-screen-md", className]}>
{@render children?.()} {@render children?.()}
</div> </div>

View File

@@ -7,9 +7,9 @@
class?: ClassValue; class?: ClassValue;
} }
let { children, ...props }: Props = $props(); let { children, class: className }: Props = $props();
</script> </script>
<div class={["sticky bottom-0 bg-white pb-4", props.class]}> <div class={["sticky bottom-0 bg-white pb-4", className]}>
{@render children?.()} {@render children?.()}
</div> </div>

View File

@@ -8,10 +8,10 @@
value?: string; value?: string;
} }
let { placeholder, type = "text", value = $bindable(""), ...props }: Props = $props(); let { class: className, placeholder, type = "text", value = $bindable("") }: Props = $props();
</script> </script>
<div class={props.class}> <div class={className}>
<div class="relative mt-5"> <div class="relative mt-5">
<input <input
bind:value bind:value

View File

@@ -13,11 +13,18 @@
textClass?: ClassValue; textClass?: ClassValue;
} }
let { children, icon, onclick, ...props }: Props = $props(); let {
children,
class: className,
icon,
iconClass: iconClassName,
onclick,
textClass: textClassName,
}: Props = $props();
</script> </script>
<EntryButton {onclick} class={props.class}> <EntryButton {onclick} class={className}>
<IconLabel {icon} class="h-full" iconClass={props.iconClass} textClass={props.textClass}> <IconLabel {icon} class="h-full" iconClass={iconClassName} textClass={textClassName}>
{@render children?.()} {@render children?.()}
</IconLabel> </IconLabel>
</EntryButton> </EntryButton>

View File

@@ -19,13 +19,13 @@
} }
let { let {
class: className,
info, info,
onSubCategoryClick, onSubCategoryClick,
onSubCategoryCreateClick, onSubCategoryCreateClick,
onSubCategoryMenuClick, onSubCategoryMenuClick,
subCategoryCreatePosition = "bottom", subCategoryCreatePosition = "bottom",
subCategoryMenuIcon, subCategoryMenuIcon,
...props
}: Props = $props(); }: Props = $props();
let subCategories: Writable<CategoryInfo | null>[] = $state([]); let subCategories: Writable<CategoryInfo | null>[] = $state([]);
@@ -37,7 +37,7 @@
}); });
</script> </script>
<div class={["space-y-1", props.class]}> <div class={["space-y-1", className]}>
{#snippet subCategoryCreate()} {#snippet subCategoryCreate()}
<IconEntryButton <IconEntryButton
icon={IconAddCircle} icon={IconAddCircle}

View File

@@ -13,12 +13,20 @@
titleClass?: ClassValue; titleClass?: ClassValue;
} }
let { children, description, icon, title, ...props }: Props = $props(); let {
children,
childrenClass: childrenClassName,
class: className,
description,
icon,
title,
titleClass: titleClassName,
}: Props = $props();
</script> </script>
<div class={["space-y-4 py-4", props.class]}> <div class={["space-y-4 py-4", className]}>
<div class="space-y-2 break-keep"> <div class="space-y-2 break-keep">
<TitleLabel {icon} textClass={props.titleClass}> <TitleLabel {icon} textClass={titleClassName}>
{@render title?.()} {@render title?.()}
</TitleLabel> </TitleLabel>
{#if description} {#if description}
@@ -28,7 +36,7 @@
{/if} {/if}
</div> </div>
{#if children} {#if children}
<div class={props.childrenClass}> <div class={childrenClassName}>
{@render children()} {@render children()}
</div> </div>
{/if} {/if}

View File

@@ -11,13 +11,13 @@
title?: string; title?: string;
} }
let { children, onBackClick, title, ...props }: Props = $props(); let { children, class: className, onBackClick, title }: Props = $props();
</script> </script>
<div <div
class={[ class={[
"sticky top-0 z-10 flex items-center justify-between gap-x-2 px-2 py-3 backdrop-blur-2xl", "sticky top-0 z-10 flex items-center justify-between gap-x-2 px-2 py-3 backdrop-blur-2xl",
props.class, className,
]} ]}
> >
<button <button

View File

@@ -11,7 +11,7 @@
textClass?: ClassValue; textClass?: ClassValue;
} }
let { name, subtext, ...props }: Props = $props(); let { class: className, name, subtext, textClass: textClassName }: Props = $props();
</script> </script>
{#snippet subtextSnippet()} {#snippet subtextSnippet()}
@@ -21,8 +21,8 @@
<IconLabel <IconLabel
icon={IconCategory} icon={IconCategory}
subtext={subtext ? subtextSnippet : undefined} subtext={subtext ? subtextSnippet : undefined}
class={props.class} class={className}
textClass={props.textClass} textClass={textClassName}
> >
{name} {name}
</IconLabel> </IconLabel>

View File

@@ -13,7 +13,7 @@
type: "directory" | "file"; type: "directory" | "file";
} }
let { name, subtext, type, ...props }: Props = $props(); let { class: className, name, subtext, textClass: textClassName, type }: Props = $props();
</script> </script>
{#snippet subtextSnippet()} {#snippet subtextSnippet()}
@@ -24,8 +24,8 @@
icon={type === "directory" ? IconFolder : IconDraft} icon={type === "directory" ? IconFolder : IconDraft}
iconClass={type === "file" ? "text-blue-400" : undefined} iconClass={type === "file" ? "text-blue-400" : undefined}
subtext={subtext ? subtextSnippet : undefined} subtext={subtext ? subtextSnippet : undefined}
class={props.class} class={className}
textClass={props.textClass} textClass={textClassName}
> >
{name} {name}
</IconLabel> </IconLabel>

View File

@@ -11,15 +11,22 @@
textClass?: ClassValue; textClass?: ClassValue;
} }
let { children, icon: Icon, subtext, ...props }: Props = $props(); let {
children,
class: className,
icon: Icon,
iconClass: iconClassName,
subtext,
textClass: textClassName,
}: Props = $props();
</script> </script>
<div class={["flex items-center gap-x-4", props.class]}> <div class={["flex items-center gap-x-4", className]}>
<div class={["flex-shrink-0 text-lg", props.iconClass]}> <div class={["flex-shrink-0 text-lg", iconClassName]}>
<Icon /> <Icon />
</div> </div>
<div class="flex flex-grow flex-col overflow-x-hidden text-left"> <div class="flex flex-grow flex-col overflow-x-hidden text-left">
<p class={["truncate font-medium", props.textClass]}> <p class={["truncate font-medium", textClassName]}>
{@render children?.()} {@render children?.()}
</p> </p>
{#if subtext} {#if subtext}

View File

@@ -9,16 +9,16 @@
textClass?: ClassValue; textClass?: ClassValue;
} }
let { children, icon: Icon, ...props }: Props = $props(); let { children, class: className, icon: Icon, textClass: textClassName }: Props = $props();
</script> </script>
<div class={props.class}> <div class={className}>
<div class="flex min-h-[10vh] items-center"> <div class="flex min-h-[10vh] items-center">
{#if Icon} {#if Icon}
<Icon class="text-5xl text-gray-600" /> <Icon class="text-5xl text-gray-600" />
{/if} {/if}
</div> </div>
<p class={["text-3xl font-bold", props.textClass]}> <p class={["text-3xl font-bold", textClassName]}>
{@render children?.()} {@render children?.()}
</p> </p>
</div> </div>

View File

@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { Button, BottomDiv, FullscreenDiv, TextInput } from "$lib/components/atoms"; import { BottomDiv, Button, FullscreenDiv, TextInput } from "$lib/components/atoms";
import { TitledDiv, TopBar } from "$lib/components/molecules"; import { TitledDiv, TopBar } from "$lib/components/molecules";
import { requestPasswordChange } from "./service"; import { requestPasswordChange } from "./service";

View File

@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { Button, TextButton, BottomDiv, FullscreenDiv, TextInput } from "$lib/components/atoms"; import { BottomDiv, Button, FullscreenDiv, TextButton, TextInput } from "$lib/components/atoms";
import { TitledDiv } from "$lib/components/molecules"; import { TitledDiv } from "$lib/components/molecules";
import { clientKeyStore, masterKeyStore } from "$lib/stores"; import { clientKeyStore, masterKeyStore } from "$lib/stores";
import { requestLogin, requestSessionUpgrade, requestMasterKeyDownload } from "./service"; import { requestLogin, requestSessionUpgrade, requestMasterKeyDownload } from "./service";

View File

@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { Writable } from "svelte/store"; import type { Writable } from "svelte/store";
import { BottomSheet, Button, BottomDiv, FullscreenDiv } from "$lib/components/atoms"; import { BottomDiv, BottomSheet, Button, FullscreenDiv } from "$lib/components/atoms";
import { SubCategories } from "$lib/components/molecules"; import { SubCategories } from "$lib/components/molecules";
import { CategoryCreateModal } from "$lib/components/organisms"; import { CategoryCreateModal } from "$lib/components/organisms";
import { getCategoryInfo, type CategoryInfo } from "$lib/modules/filesystem"; import { getCategoryInfo, type CategoryInfo } from "$lib/modules/filesystem";

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { Button, TextButton, BottomDiv, FullscreenDiv } from "$lib/components/atoms"; import { BottomDiv, Button, FullscreenDiv, TextButton } from "$lib/components/atoms";
import { TitledDiv } from "$lib/components/molecules"; import { TitledDiv } from "$lib/components/molecules";
import { clientKeyStore } from "$lib/stores"; import { clientKeyStore } from "$lib/stores";
import BeforeContinueBottomSheet from "./BeforeContinueBottomSheet.svelte"; import BeforeContinueBottomSheet from "./BeforeContinueBottomSheet.svelte";

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { BottomSheet, Button, BottomDiv, FullscreenDiv } from "$lib/components/atoms"; import { BottomDiv, BottomSheet, Button, FullscreenDiv } from "$lib/components/atoms";
interface Props { interface Props {
onRetryClick: () => void; onRetryClick: () => void;

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte"; import { onMount } from "svelte";
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { Button, TextButton, BottomDiv, FullscreenDiv } from "$lib/components/atoms"; import { BottomDiv, Button, FullscreenDiv, TextButton } from "$lib/components/atoms";
import { TitledDiv } from "$lib/components/molecules"; import { TitledDiv } from "$lib/components/molecules";
import { gotoStateful } from "$lib/hooks"; import { gotoStateful } from "$lib/hooks";
import { clientKeyStore } from "$lib/stores"; import { clientKeyStore } from "$lib/stores";