Sharkey/packages/frontend/src/components/MkAnnouncementDialog.stories.impl.ts
zyoshoka 9c057e6854
fix(frontend): fix Storybook type errors (#13779)
* fix(frontend): fix Storybook type errors

* fix: `hasReduce` doesn't work in args
2024-05-01 16:39:16 +09:00

65 lines
1.4 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { action } from '@storybook/addon-actions';
import { StoryObj } from '@storybook/vue3';
import { HttpResponse, http } from 'msw';
import { commonHandlers } from '../../.storybook/mocks.js';
import MkAnnouncementDialog from './MkAnnouncementDialog.vue';
export const Default = {
render(args) {
return {
components: {
MkAnnouncementDialog,
},
setup() {
return {
args,
};
},
computed: {
props() {
return {
...this.args,
};
},
events() {
return {
closed: action('closed'),
};
},
},
template: '<MkAnnouncementDialog v-bind="props" v-on="events" />',
};
},
args: {
announcement: {
id: '1',
title: 'Title',
text: 'Text',
createdAt: new Date().toISOString(),
updatedAt: null,
icon: 'info',
imageUrl: null,
display: 'dialog',
needConfirmationToRead: false,
silence: false,
forYou: true,
},
},
parameters: {
layout: 'centered',
msw: {
handlers: [
...commonHandlers,
http.post('/api/i/read-announcement', async ({ request }) => {
action('POST /api/i/read-announcement')(await request.json());
return HttpResponse.json();
}),
],
},
},
} satisfies StoryObj<typeof MkAnnouncementDialog>;