mirror of
https://github.com/revanced/revanced-website.git
synced 2025-05-28 12:20:13 +02:00
refactor: separate props
This commit is contained in:
parent
595a11b4d9
commit
4b740e780b
@ -31,7 +31,6 @@
|
||||
>;
|
||||
|
||||
type Props = ButtonProps | LinkProps;
|
||||
|
||||
let {
|
||||
type,
|
||||
// https://svelte.dev/docs/svelte/compiler-warnings#svelte_component_deprecated
|
||||
|
@ -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 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user