refactor: separate props

This commit is contained in:
madkarmaa 2025-05-10 22:11:37 +02:00
parent 595a11b4d9
commit 4b740e780b
No known key found for this signature in database
GPG Key ID: BF5E2EF8F188606D
2 changed files with 18 additions and 12 deletions

View File

@ -31,7 +31,6 @@
>;
type Props = ButtonProps | LinkProps;
let {
type,
// https://svelte.dev/docs/svelte/compiler-warnings#svelte_component_deprecated

View File

@ -7,21 +7,28 @@
import type { Snippet } from 'svelte';
import Button from '$components/atoms/Button.svelte';
import type { Prettify } from '$types';
type Props = {
type BaseProps = {
children: Snippet;
level: 'info' | 'warning' | 'caution';
} & (
| {
permanent?: false;
onDismiss?: () => void;
}
| {
permanent: true;
onDismiss?: never; // permanent banner doesn't have a dismiss button
}
);
};
type NonPermanentProps = Prettify<
BaseProps & {
permanent?: false;
onDismiss?: () => void;
}
>;
type PermanentProps = Prettify<
BaseProps & {
permanent: true;
onDismiss?: never; // permanent banner doesn't have a dismiss button
}
>;
type Props = NonPermanentProps | PermanentProps;
let { children, level = 'info', permanent = false, onDismiss }: Props = $props();
const icons = { info: Info, warning: Warning, caution: Caution };