Build out components #45
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',
|
||||
],
|
||||
|
It did occur to me, there can be variation between components though, some will have ghost, others might have neutral, or not. So I just haven't made a decision for it yet. It did occur to me, there can be variation between components though, some will have ghost, others might have neutral, or not. So I just haven't made a decision for it yet.
|
||||
},
|
||||
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 Loader } from './Loader.svelte';
|
||||
export { default as Loading } from './Loading.svelte';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue
I see some of them also used in the alert and other place, maybe it could be worth it to put them in an array or enums as UI tokens
Same thing for the sizes tokens and anything you see used in common
Just noticed my comment is on the stories file but I meant it to be on the component itself