-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add stories test example for Image component (#31)
* feat(SkillsTag): establish component testing architecture based on storybook lib * refactor: refactor the structure of kawa-ui&kawa-foundation * feat: info components * feat: 初步完成技术栈组件,todo把skilltag的api抽到techstack层 * merge :package.json * feat(SkillsTag): establish component testing architecture based on storybook lib * refactor: refactor the structure of kawa-ui&kawa-foundation * feat: info components * feat: 初步完成技术栈组件,todo把skilltag的api抽到techstack层 * merge :package.json * fetch and merge from the upstream * refactor: 迁移kawa-ui至新架构 * chore: 删除init时的无效stories * feat: 完成skillList组件,teckstack组件 * feat: add storybook test example for Image component --------- Co-authored-by: dundun003 <[email protected]>
- Loading branch information
Showing
7 changed files
with
4,490 additions
and
1,925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
*storybook.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ | |
"echo" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { join, dirname } from "path"; | ||
|
||
/** | ||
* This function is used to resolve the absolute path of a package. | ||
* It is needed in projects that use Yarn PnP or are set up within a monorepo. | ||
*/ | ||
function getAbsolutePath(value) { | ||
return dirname(require.resolve(join(value, "package.json"))); | ||
} | ||
|
||
/** @type { import('@storybook/react-vite').StorybookConfig } */ | ||
const config = { | ||
stories: [ | ||
"../stories/**/*.mdx", | ||
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)", | ||
], | ||
addons: [ | ||
getAbsolutePath("@storybook/addon-onboarding"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@chromatic-com/storybook"), | ||
getAbsolutePath("@storybook/addon-interactions"), | ||
], | ||
framework: { | ||
name: getAbsolutePath("@storybook/react-vite"), | ||
options: {}, | ||
}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @type { import('@storybook/react').Preview } */ | ||
const preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from "react"; | ||
import Image from "../image/Image"; | ||
import type { Meta, StoryFn } from "@storybook/react"; | ||
|
||
export default { | ||
title: "Example/Image", | ||
component: Image, | ||
argTypes: { | ||
onClick: { action: "clicked" }, | ||
}, | ||
} as Meta; | ||
|
||
const Template: StoryFn = (args) => <Image userData={undefined} {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
src: "https://picsum.photos/200/200", | ||
alt: "示例图片", | ||
width: 200, | ||
height: 200, | ||
style: { border: "2px solid black" }, | ||
className: "custom-class", | ||
userData: {}, | ||
}; | ||
|
||
export const WithUserData = Template.bind({}); | ||
WithUserData.args = { | ||
src: "xxxxx", | ||
alt: "示例图片", | ||
width: 200, | ||
height: 200, | ||
style: { border: "2px solid black" }, | ||
className: "custom-class", | ||
userData: { | ||
photoUri: "https://picsum.photos/200/300", | ||
}, | ||
}; |
Oops, something went wrong.