mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
Button 및 Input 컴포넌트를 atoms 디렉터리로 이동 및 리팩토링
This commit is contained in:
35
src/lib/components/atoms/buttons/Button.svelte
Normal file
35
src/lib/components/atoms/buttons/Button.svelte
Normal file
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
import type { ClassValue } from "svelte/elements";
|
||||
|
||||
interface Props {
|
||||
children?: Snippet;
|
||||
class?: ClassValue;
|
||||
color?: "primary" | "gray";
|
||||
onclick?: () => void;
|
||||
}
|
||||
|
||||
let { children, color = "primary", onclick, ...props }: Props = $props();
|
||||
|
||||
let bgColor = $derived(
|
||||
{
|
||||
primary: "bg-primary-600 active:bg-primary-500",
|
||||
gray: "bg-gray-300 active:bg-gray-400",
|
||||
}[color],
|
||||
);
|
||||
let textColor = $derived(
|
||||
{
|
||||
primary: "text-white",
|
||||
gray: "text-gray-800",
|
||||
}[color],
|
||||
);
|
||||
</script>
|
||||
|
||||
<button
|
||||
onclick={onclick && (() => setTimeout(onclick, 100))}
|
||||
class={["h-12 min-w-fit rounded-xl font-medium", bgColor, textColor, props.class]}
|
||||
>
|
||||
<div class="h-full p-3 transition active:scale-95">
|
||||
{@render children?.()}
|
||||
</div>
|
||||
</button>
|
||||
Reference in New Issue
Block a user