Build out components #45

Merged
BenjaminPalko merged 14 commits from build-out-components into master 2025-01-04 22:14:19 -05:00
5 changed files with 59 additions and 0 deletions
Showing only changes of commit 51049b2b26 - Show all commits

View file

@ -0,0 +1,25 @@
<script module lang="ts">
import { defineMeta } from '@storybook/addon-svelte-csf';
import Alert from './Alert.svelte';
import type { ComponentProps } from 'svelte';
import { InfoIcon } from '../Icons';
const { Story } = defineMeta({
title: 'Feedback/Alert',
component: Alert,
argTypes: {
status: { control: 'select', options: ['info', 'success', 'warning', 'error'] },
},
});
</script>
{#snippet template(props: ComponentProps<typeof Alert>)}
<Alert {...props}>
{#snippet icon()}
<InfoIcon class="h-6 w-6 shrink-0 stroke-info" />
{/snippet}
<span>Hello world!</span>
</Alert>
{/snippet}
<Story name="Default" args={{}} children={template} />

View file

@ -0,0 +1,24 @@
<script lang="ts">
import type { DaisyColor } from '$lib/types';
import type { Snippet } from 'svelte';
type Props = {
children?: Snippet;
icon?: Snippet;
status?: Extract<DaisyColor, 'info' | 'success' | 'warning' | 'error'>;
};
let { children, icon, status: color }: Props = $props();
</script>
<div
role="alert"
class="alert"
class:alert-info={color === 'info'}
class:alert-success={color === 'success'}
class:alert-warning={color === 'warning'}
class:alert-error={color === 'error'}
>
{@render icon?.()}
{@render children?.()}
</div>

View file

@ -1 +1,2 @@
export { default as Alert } from './Alert.svelte';
export { default as Loader } from './Loader.svelte';

View file

@ -0,0 +1,8 @@
<script lang="ts">
import type { SvelteHTMLElements } from 'svelte/elements';
import { twMerge } from 'tailwind-merge';
let { class: className, ...props }: SvelteHTMLElements['i'] = $props();
</script>
<i {...props} class={twMerge(className, 'fi fi-sr-info')}></i>

View file

@ -0,0 +1 @@
export { default as InfoIcon } from './InfoIcon.svelte';