Skip to content

Commit

Permalink
docs: add story
Browse files Browse the repository at this point in the history
  • Loading branch information
eunsukimme committed Sep 9, 2023
1 parent d7c1eff commit 2da7d6d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
Expand All @@ -9,5 +10,34 @@ const config: StorybookConfig = {
docs: {
autodocs: 'tag',
},
webpackFinal(config) {
const imageRule = config.module!.rules!.find((rule) => {
if (rule && typeof rule !== 'string' && rule.test instanceof RegExp) {
return rule.test.test('.svg')
}
})
if (imageRule && typeof imageRule !== 'string') {
imageRule.exclude = /\.svg$/
}

config.module!.rules!.push({
test: /\.svg$/,
oneOf: [
{
resourceQuery: /rect/,
use: {
loader: '@svgr/webpack',
options: {
svgo: false,
},
},
},
{
use: '@svgr/webpack',
},
],
})
return config;
},
};
export default config;
35 changes: 35 additions & 0 deletions src/components/feed/FeedPostViewer/FeedPostViewer.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Meta, StoryObj } from '@storybook/react';

import FeedPostViewer from './FeedPostViewer';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<typeof FeedPostViewer> = {
title: 'FeedPostViewer',
component: FeedPostViewer,
tags: ['autodocs'],
};

export default meta;
type Story = StoryObj<typeof FeedPostViewer>;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default: Story = {
args: {
post: {
id: 1,
title: '하트시그널 시즌 1부터 시즌 4까지 중에 가장 인기가 많았던 출연자는?',
contents: `1번 김현우\n2번 오영주\n3번 임현주\n4번 박지현\n5번 기타`,
updatedDate: '2시간 전',
images: [],
user: {
id: 1,
name: '김지민',
profileImage: null,
},
viewCount: 1234,
likeCount: 0,
isLiked: false,
},
Actions: [],
},
};

0 comments on commit 2da7d6d

Please sign in to comment.