add @storybook/addon-actions

This commit is contained in:
Joscha Feth
2017-06-26 17:52:16 +02:00
parent 3b438428d5
commit e2c87fc5b8
4 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
// Type definitions for @storybook/addon-actions 3.0
// Project: https://github.com/storybooks/storybook
// Definitions by: Joscha Feth <https://github.com/joscha>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TODO: Once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17434 is merged
// Remove the `declare module` wrapper.
// tslint:disable-next-line no-single-declare-module
declare module '@storybook/addon-actions' {
type HandlerFunction = (...args: any[]) => undefined;
type DecoratorFunction = (args: any[]) => any[];
function decorateAction(decorators: DecoratorFunction[]): HandlerFunction;
function action(name: string): HandlerFunction;
}

View File

@@ -0,0 +1,19 @@
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action, decorateAction } from '@storybook/addon-actions';
const firstArgAction = decorateAction([
args => args.slice(0, 1)
]);
storiesOf('Button', module)
.add('action', () => (
<button onClick={ action('my-action') }>
Hello World!
</button>
))
.add('decorated action', () => (
<button onClick={ firstArgAction('button-click') }>
Hello World!
</button>
));

View File

@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@storybook/addon-actions": ["storybook__addon-actions"],
"@storybook/react": ["storybook__react"]
}
},
"files": [
"index.d.ts",
"storybook__addon-actions-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }