docs: write Storybook for Avatar
For some reason, the JSDoc annotation is not picked up yet. Need to investigate more. Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
parent
a350e43362
commit
8ed9837fea
2 changed files with 32 additions and 3 deletions
|
@ -1,10 +1,10 @@
|
||||||
import { join, dirname } from 'node:path';
|
import { dirname, join, resolve } from 'node:path';
|
||||||
|
|
||||||
import type { StorybookConfig } from '@storybook/sveltekit';
|
import type { StorybookConfig } from '@storybook/sveltekit';
|
||||||
import { mergeConfig } from 'vite';
|
import { mergeConfig } from 'vite';
|
||||||
|
|
||||||
const config: StorybookConfig = {
|
const config: StorybookConfig = {
|
||||||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.ts'],
|
||||||
addons: [
|
addons: [
|
||||||
'@storybook/addon-links',
|
'@storybook/addon-links',
|
||||||
'@storybook/addon-essentials',
|
'@storybook/addon-essentials',
|
||||||
|
@ -21,12 +21,19 @@ const config: StorybookConfig = {
|
||||||
autodocs: 'tag'
|
autodocs: 'tag'
|
||||||
},
|
},
|
||||||
async viteFinal(config) {
|
async viteFinal(config) {
|
||||||
|
const allowFiles = config.server?.fs?.allow || [];
|
||||||
|
const storyFiles = resolve('stories');
|
||||||
|
|
||||||
return mergeConfig(config, {
|
return mergeConfig(config, {
|
||||||
|
alias: {
|
||||||
|
...config.alias,
|
||||||
|
$lib: resolve('..', 'src', 'lib')
|
||||||
|
},
|
||||||
server: {
|
server: {
|
||||||
...config.server,
|
...config.server,
|
||||||
fs: {
|
fs: {
|
||||||
...config.server?.fs,
|
...config.server?.fs,
|
||||||
allow: [].concat(config.server?.fs?.allow || []).concat('stories')
|
allow: [...allowFiles, storyFiles]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
22
stories/atoms/Avatar.stories.ts
Normal file
22
stories/atoms/Avatar.stories.ts
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import type { Meta, StoryObj } from '@storybook/svelte';
|
||||||
|
|
||||||
|
import Avatar from '$lib/components/atoms/Avatar.svelte';
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
title: 'Atoms/Avatar',
|
||||||
|
component: Avatar,
|
||||||
|
tags: ['autodocs'],
|
||||||
|
argTypes: {
|
||||||
|
avatar: { control: 'text' },
|
||||||
|
displayName: { control: 'text' }
|
||||||
|
}
|
||||||
|
} satisfies Meta<Avatar>;
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof meta>;
|
||||||
|
|
||||||
|
export const Plain: Story = {
|
||||||
|
args: {
|
||||||
|
displayName: 'Jane Doe'
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue