Skip to content

Commit

Permalink
fix(ui): prop typing on various components
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Shatford <[email protected]>
  • Loading branch information
jordanshatford committed Sep 20, 2023
1 parent 18a5f79 commit bbea467
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
15 changes: 6 additions & 9 deletions packages/ui/src/lib/components/Alert.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,15 @@
</script>

<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { Icon } from '../icons';
import { toIcon } from '../utilities';
interface $$Props extends HTMLAttributes<HTMLDivElement>, AlertVariants {
title?: string;
description?: string;
}
let className: string = '';
export { className as class };
export let variant: $$Props['variant'] = 'default';
export let title: $$Props['title'] = undefined;
export let description: $$Props['title'] = undefined;
export let variant: AlertVariants['variant'] = 'default';
export let title: string | undefined = undefined;
export let description: string | undefined = undefined;
const icon = toIcon(variant);
Expand All @@ -67,7 +64,7 @@
});
</script>

<div {...$$restProps} role="alert" class={divClass({ class: $$props.class })}>
<div {...$$restProps} role="alert" class={divClass({ class: className })}>
<div class={iconDivClass()}>
{#if icon}
<Icon src={icon} theme="solid" class={iconClass()} />
Expand Down
17 changes: 7 additions & 10 deletions packages/ui/src/lib/components/Badge.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,13 @@
close: undefined;
}>();
interface $$Props extends HTMLAttributes<HTMLSpanElement>, BadgeVariants {
closable?: boolean;
icon?: boolean | IconSource;
loading?: boolean;
}
let className: string = '';
export { className as class };
export let variant: $$Props['variant'] = 'default';
export let closable: $$Props['closable'] = false;
export let icon: $$Props['icon'] = false;
export let loading: $$Props['loading'] = false;
export let variant: BadgeVariants['variant'] = 'default';
export let closable: boolean = false;
export let icon: boolean | IconSource = false;
export let loading: boolean = false;
const _icon = typeof icon === 'object' ? icon : toIcon(variant, { loading });
Expand All @@ -80,7 +77,7 @@
});
</script>

<span {...$$restProps} class={spanClass({ class: $$props.class })}>
<span {...$$restProps} class={spanClass({ class: className })}>
<span class={iconWrapperClass()}>
{#if _icon}
<Icon src={_icon} theme="solid" class={iconClass()} />
Expand Down
21 changes: 8 additions & 13 deletions packages/ui/src/lib/components/Confirm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,18 @@
</script>

<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { fly, fade } from 'svelte/transition';
import { Icon } from '../icons';
import { toIcon } from '../utilities';
interface $$Props extends HTMLAttributes<HTMLDivElement>, ConfirmVariants {
title: string;
description: string;
confirmText: string;
cancelText: string;
}
let className: string = '';
export { className as class };
export let variant: $$Props['variant'] = 'info';
export let title: $$Props['title'] = 'Confirm?';
export let description: $$Props['description'] = '';
export let confirmText: $$Props['confirmText'] = 'Confirm';
export let cancelText: $$Props['cancelText'] = 'Cancel';
export let variant: ConfirmVariants['variant'] = 'info';
export let title: string = 'Confirm?';
export let description: string = '';
export let confirmText: string = 'Confirm';
export let cancelText: string = 'Cancel';
const icon = toIcon(variant);
Expand Down Expand Up @@ -130,7 +125,7 @@
<span class={trickCenteringSpanClass()} aria-hidden="true">&#8203;</span>
<div
{...$$restProps}
class={contentDivClass({ class: $$props.class })}
class={contentDivClass({ class: className })}
in:fly={{ y: -10, delay: 200, duration: 200 }}
out:fly={{ y: -10, duration: 200 }}
>
Expand Down

1 comment on commit bbea467

@vercel
Copy link

@vercel vercel bot commented on bbea467 Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.