mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 19:43:20 +08:00
add @storybook/addon-actions
This commit is contained in:
16
types/storybook__addon-actions/index.d.ts
vendored
Normal file
16
types/storybook__addon-actions/index.d.ts
vendored
Normal 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;
|
||||
}
|
||||
@@ -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>
|
||||
));
|
||||
28
types/storybook__addon-actions/tsconfig.json
Normal file
28
types/storybook__addon-actions/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/storybook__addon-actions/tslint.json
Normal file
1
types/storybook__addon-actions/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user