Loading component
This commit is contained in:
parent
51049b2b26
commit
c59c82d614
3 changed files with 72 additions and 0 deletions
40
src/lib/components/Feedback/Loading.stories.svelte
Normal file
40
src/lib/components/Feedback/Loading.stories.svelte
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<script module lang="ts">
|
||||||
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||||
|
import type { ComponentProps } from 'svelte';
|
||||||
|
import Loading from './Loading.svelte';
|
||||||
|
|
||||||
|
const { Story } = defineMeta({
|
||||||
|
title: 'Feedback/Loading',
|
||||||
|
component: Loading,
|
||||||
|
argTypes: {
|
||||||
|
color: {
|
||||||
|
control: 'select',
|
||||||
|
options: [
|
||||||
|
'neutral',
|
||||||
|
'primary',
|
||||||
|
'secondary',
|
||||||
|
'accent',
|
||||||
|
'info',
|
||||||
|
'success',
|
||||||
|
'warning',
|
||||||
|
'error',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
size: { control: 'select', options: ['xs', 'sm', 'md', 'lg'] },
|
||||||
|
variant: {
|
||||||
|
control: 'select',
|
||||||
|
options: ['spinner', 'dots', 'ring', 'ball', 'bars', 'infinity'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#snippet template(props: ComponentProps<typeof Loading>)}
|
||||||
|
<Loading {...props} />
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
<Story
|
||||||
|
name="Default"
|
||||||
|
args={{ color: 'neutral', size: 'md', variant: 'spinner' }}
|
||||||
|
children={template}
|
||||||
|
/>
|
||||||
31
src/lib/components/Feedback/Loading.svelte
Normal file
31
src/lib/components/Feedback/Loading.svelte
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import type { DaisyColor, DaisySize } from '$lib/types';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
color?: Exclude<DaisyColor, 'ghost'>;
|
||||||
|
size?: DaisySize | 'md';
|
||||||
|
variant?: 'spinner' | 'dots' | 'ring' | 'ball' | 'bars' | 'infinity';
|
||||||
|
};
|
||||||
|
let { color, size = 'md', variant = 'spinner' }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<span
|
||||||
|
class="loading"
|
||||||
|
class:text-primary={color === 'primary'}
|
||||||
|
class:text-secondary={color === 'secondary'}
|
||||||
|
class:text-accent={color === 'accent'}
|
||||||
|
class:text-info={color === 'info'}
|
||||||
|
class:text-success={color === 'success'}
|
||||||
|
class:text-warning={color === 'warning'}
|
||||||
|
class:text-error={color === 'error'}
|
||||||
|
class:loading-xs={size === 'xs'}
|
||||||
|
class:loading-sm={size === 'sm'}
|
||||||
|
class:loading-md={size === 'md'}
|
||||||
|
class:loading-lg={size === 'lg'}
|
||||||
|
class:loading-spinner={variant === 'spinner'}
|
||||||
|
class:loading-dots={variant === 'dots'}
|
||||||
|
class:loading-ring={variant === 'ring'}
|
||||||
|
class:loading-ball={variant === 'ball'}
|
||||||
|
class:loading-bars={variant === 'bars'}
|
||||||
|
class:loading-infinity={variant === 'infinity'}
|
||||||
|
></span>
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
export { default as Alert } from './Alert.svelte';
|
export { default as Alert } from './Alert.svelte';
|
||||||
export { default as Loader } from './Loader.svelte';
|
export { default as Loader } from './Loader.svelte';
|
||||||
|
export { default as Loading } from './Loading.svelte';
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue