Build out components #45
3 changed files with 72 additions and 0 deletions
41
src/lib/components/Layout/Divider.stories.svelte
Normal file
41
src/lib/components/Layout/Divider.stories.svelte
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<script module lang="ts">
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import Divider from './Divider.svelte';
|
||||
import type { ComponentProps } from 'svelte';
|
||||
|
||||
const { Story } = defineMeta({
|
||||
title: 'Layout/Divider',
|
||||
component: Divider,
|
||||
argTypes: {
|
||||
color: {
|
||||
control: 'select',
|
||||
options: [
|
||||
'neutral',
|
||||
'primary',
|
||||
'secondary',
|
||||
'accent',
|
||||
'info',
|
||||
'success',
|
||||
'warning',
|
||||
'error',
|
||||
],
|
||||
},
|
||||
direction: { control: 'select', options: ['horizontal', 'vertical'] },
|
||||
variant: { control: 'select', options: ['start', 'end'] },
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
{#snippet template(props: ComponentProps<typeof Divider>)}
|
||||
<div
|
||||
class="flex"
|
||||
class:flex-row={props.direction === 'horizontal'}
|
||||
class:flex-col={props.direction === 'vertical'}
|
||||
>
|
||||
<span>Side A</span>
|
||||
<Divider {...props} />
|
||||
<span>Side B</span>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
<Story name="Default" args={{}} children={template} />
|
||||
31
src/lib/components/Layout/Divider.svelte
Normal file
31
src/lib/components/Layout/Divider.svelte
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<script lang="ts">
|
||||
import type { DaisyColor } from '$lib/types';
|
||||
import type { SvelteHTMLElements } from 'svelte/elements';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
type Props = {
|
||||
color?: Exclude<DaisyColor, 'ghost'>;
|
||||
direction?: 'horizontal' | 'vertical';
|
||||
variant?: 'start' | 'end';
|
||||
} & SvelteHTMLElements['div'];
|
||||
let { children, class: className, color, direction, variant, ...props }: Props = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
class={twMerge('divider', className)}
|
||||
class:divider-neutral={color === 'neutral'}
|
||||
class:divider-primary={color === 'primary'}
|
||||
class:divider-secondary={color === 'secondary'}
|
||||
class:divider-accent={color === 'accent'}
|
||||
class:divider-info={color === 'info'}
|
||||
class:divider-success={color === 'success'}
|
||||
class:divider-warning={color === 'warning'}
|
||||
class:divider-error={color === 'error'}
|
||||
class:divider-horizontal={direction === 'horizontal'}
|
||||
class:divider-vertical={direction === 'vertical'}
|
||||
class:divider-start={variant === 'start'}
|
||||
class:divider-end={variant === 'end'}
|
||||
{...props}
|
||||
>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
0
src/lib/components/Layout/index.ts
Normal file
0
src/lib/components/Layout/index.ts
Normal file
Loading…
Add table
Reference in a new issue