Skip to content

Commit

Permalink
feat: alert sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 committed Jan 3, 2025
1 parent 8bb9e47 commit 8374589
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
16 changes: 13 additions & 3 deletions src/lib/components/Alert/Alert.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Icon from '$lib/components/Icon/Icon.svelte';
import Text from '$lib/components/Text/Text.svelte';
import CloseButton from '$lib/components/CloseButton/CloseButton.svelte';
import type { Color } from '$lib/types.js';
import type { Color, Size } from '$lib/types.js';
import { cleanClass } from '$lib/utils.js';
import {
mdiAlertOutline,
Expand All @@ -16,6 +16,7 @@
type Props = {
color?: Color;
size?: Size;
icon?: string | false;
title?: string;
class?: string;
Expand All @@ -29,6 +30,7 @@
const {
color = 'primary',
icon: iconOverride,
size = 'large',
title,
class: className,
duration,
Expand All @@ -40,6 +42,14 @@
let open = $state(true);
const iconSizes: Record<Size, string> = {
tiny: '1em',
small: '1.25em',
medium: '1.5em',
large: '1.75em',
giant: '1.85em',
};
const handleClose = () => {
if (!open) {
return;
Expand Down Expand Up @@ -74,13 +84,13 @@
<div class={cleanClass('flex gap-2')}>
{#if icon}
<div>
<Icon {icon} size="1.5em" class="h-7" />
<Icon {icon} size={iconSizes[size]} />
</div>
{/if}

<div class="flex flex-col gap-2">
{#if title}
<Text size="large" fontWeight={children ? 'bold' : undefined}>{title}</Text>
<Text {size} fontWeight={children ? 'bold' : undefined}>{title}</Text>
{/if}
{#if children}
{@render children()}
Expand Down
10 changes: 5 additions & 5 deletions src/routes/components/alert/BasicExample.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<Stack>
<Alert color="primary" title="This is an alert" />
<Alert color="secondary" title="This is an alert" />
<Alert color="success" title="This is an alert" />
<Alert color="info" title="This is an alert" />
<Alert color="warning" title="This is an alert" />
<Alert color="danger" title="This is an alert" />
<Alert color="secondary" title="This is an alert" size="tiny" />
<Alert color="success" title="This is an alert" size="small" />
<Alert color="info" title="This is an alert" size="medium" />
<Alert color="warning" title="This is an alert" size="large" />
<Alert color="danger" title="This is an alert" size="giant" />
</Stack>

0 comments on commit 8374589

Please sign in to comment.