mirror of
https://github.com/revanced/revanced-website.git
synced 2025-05-30 21:30:13 +02:00
refactor: separate props
This commit is contained in:
parent
595a11b4d9
commit
4b740e780b
@ -31,7 +31,6 @@
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
type Props = ButtonProps | LinkProps;
|
type Props = ButtonProps | LinkProps;
|
||||||
|
|
||||||
let {
|
let {
|
||||||
type,
|
type,
|
||||||
// https://svelte.dev/docs/svelte/compiler-warnings#svelte_component_deprecated
|
// https://svelte.dev/docs/svelte/compiler-warnings#svelte_component_deprecated
|
||||||
|
@ -7,21 +7,28 @@
|
|||||||
|
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
import Button from '$components/atoms/Button.svelte';
|
import Button from '$components/atoms/Button.svelte';
|
||||||
|
import type { Prettify } from '$types';
|
||||||
|
|
||||||
type Props = {
|
type BaseProps = {
|
||||||
children: Snippet;
|
children: Snippet;
|
||||||
level: 'info' | 'warning' | 'caution';
|
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();
|
let { children, level = 'info', permanent = false, onDismiss }: Props = $props();
|
||||||
|
|
||||||
const icons = { info: Info, warning: Warning, caution: Caution };
|
const icons = { info: Info, warning: Warning, caution: Caution };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user