Skip to content

Commit

Permalink
Move story and add yoda image
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinNagpal committed Oct 25, 2021
1 parent 5dda04a commit cb5c8ad
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
stories: ['../stories/**/*.stories.@(ts|tsx|js|jsx)'],
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
typescript: {
check: true, // type-check stories during Storybook build
}
},
};
39 changes: 39 additions & 0 deletions src/components/Annotation.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ArgTypes } from '@storybook/addons/dist/ts3.9/types';
import { Meta, Story } from '@storybook/react';
import React from 'react';
import Annotation, { AnnotationPropsOptional } from './Annotation';

const argTypes: ArgTypes = {
src: {
defaultValue:
'https://raw.githubusercontent.com/RobinNagpal/react-image-annotation-ts/HEAD/demo.gif',
control: {
type: 'text',
},
},
};

const meta: Meta = {
title: 'Annotation',
component: Annotation,
argTypes,
parameters: {
controls: { expanded: true },
},
};

export default meta;

const Template: Story<AnnotationPropsOptional> = (args) => (
<Annotation {...args} />
);

// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
// https://storybook.js.org/docs/react/workflows/unit-testing
const defaultProps: AnnotationPropsOptional = {
src:
'https://raw.githubusercontent.com/RobinNagpal/react-image-annotation-ts/HEAD/demo.gif',
};
export const Default = Template.bind(defaultProps);

Default.args = {};
2 changes: 1 addition & 1 deletion src/components/Annotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Items = styled.div`

const Target = Items;

type AnnotationPropsOptional = {
export type AnnotationPropsOptional = {
[K in keyof AnnotationProps]?: AnnotationProps[K]; // so that it retains the types
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { Thing, Props } from '../src';
import { Thing, Props } from './index';

const meta: Meta = {
title: 'Welcome',
Expand All @@ -19,7 +19,7 @@ const meta: Meta = {

export default meta;

const Template: Story<Props> = args => <Thing {...args} />;
const Template: Story<Props> = (args) => <Thing {...args} />;

// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
// https://storybook.js.org/docs/react/workflows/unit-testing
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"include": ["src", "types"],
"include": ["src", "types", "stories"],
"compilerOptions": {
"module": "esnext",
"lib": ["dom", "esnext"],
Expand Down Expand Up @@ -32,5 +32,9 @@
"forceConsistentCasingInFileNames": true,
// `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
"noEmit": true,
"baseUrl": "." ,
"paths": {
"@components/*": ["src/components/*"]
}
}
}
Binary file added yoda_img.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cb5c8ad

Please sign in to comment.