From 98a091faef40b4213d93fc942e82a8641acd727d Mon Sep 17 00:00:00 2001 From: OWA Framework Date: Mon, 10 Dec 2018 14:29:28 -0800 Subject: [PATCH 1/4] Update typings for @storybook/addon-notes --- types/storybook__addon-notes/index.d.ts | 23 ++++++----- .../storybook__addon-notes-tests.tsx | 41 ++++++++++++------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/types/storybook__addon-notes/index.d.ts b/types/storybook__addon-notes/index.d.ts index f212cbce63..21cfc79648 100644 --- a/types/storybook__addon-notes/index.d.ts +++ b/types/storybook__addon-notes/index.d.ts @@ -1,18 +1,21 @@ -// Type definitions for @storybook/addon-notes 3.3 +// Type definitions for @storybook/addon-notes 4.0 // Project: https://github.com/storybooks/storybook // Definitions by: Joscha Feth // A.MacLeay +// Michael Loughry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 3.2.1 import * as React from 'react'; -import { RenderFunction } from '@storybook/react'; +import { RenderFunction, StoryDecorator } from '@storybook/react'; +import { MarkedOptions } from 'marked'; -export function withNotes(textOrOptions: string | object): (getStory: RenderFunction) => RenderFunction; -export function withMarkdownNotes(text: string): (getStory: RenderFunction) => RenderFunction; +export type WithNotesOptions = string | { + text: string; +} | { + markdown: string; + markdownOptions?: MarkedOptions; +}; -export interface WithNotesProps extends React.HTMLProps { - notes?: string; -} - -export const WithNotes: React.StatelessComponent; +export function withNotes(options?: WithNotesOptions): StoryDecorator; +export function withMarkdownNotes(markdown: string, options: MarkedOptions): StoryDecorator; diff --git a/types/storybook__addon-notes/storybook__addon-notes-tests.tsx b/types/storybook__addon-notes/storybook__addon-notes-tests.tsx index cf3108fc6d..ebf24ce227 100644 --- a/types/storybook__addon-notes/storybook__addon-notes-tests.tsx +++ b/types/storybook__addon-notes/storybook__addon-notes-tests.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { storiesOf } from '@storybook/react'; -import { withNotes, withMarkdownNotes, WithNotes } from '@storybook/addon-notes'; +import { withNotes, withMarkdownNotes, } from '@storybook/addon-notes'; const SIMPLE_MARKDOWN = ` ## Markdown for component @@ -10,18 +10,31 @@ A very simple component with markdown notes `; storiesOf('Component', module) - .add('with some emoji', () => ( - - my component - - )) + .addDecorator(withNotes()) .add('with withNotes', - withNotes('A very simple component')( - () => (
my component
) - ) - ) - .add('with withMarkdownNotes', - withMarkdownNotes(SIMPLE_MARKDOWN)( - () => (
my component
) - ) + () => (
my component
) + ); + +storiesOf('Component', module) + .addDecorator(withNotes('Some text')) + .add('with withNotes', + () => (
my component
) + ); + +storiesOf('Component', module) + .addDecorator(withNotes({ text: 'Some text' })) + .add('with withNotes', + () => (
my component
) + ); + +storiesOf('Component', module) + .addDecorator(withNotes({ markdown: 'Some text' })) + .add('with withNotes', + () => (
my component
) + ); + +storiesOf('Component', module) + .addDecorator(withNotes({ markdown: 'Some text', markdownOptions: { sanitize: true } })) + .add('with withNotes', + () => (
my component
) ); From 6f56a0355d81bee81c1095bad606c68605c67800 Mon Sep 17 00:00:00 2001 From: OWA Framework Date: Mon, 10 Dec 2018 14:39:31 -0800 Subject: [PATCH 2/4] Optional options to withMarkdownNotes --- types/storybook__addon-notes/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/storybook__addon-notes/index.d.ts b/types/storybook__addon-notes/index.d.ts index 21cfc79648..195f31638e 100644 --- a/types/storybook__addon-notes/index.d.ts +++ b/types/storybook__addon-notes/index.d.ts @@ -18,4 +18,4 @@ export type WithNotesOptions = string | { }; export function withNotes(options?: WithNotesOptions): StoryDecorator; -export function withMarkdownNotes(markdown: string, options: MarkedOptions): StoryDecorator; +export function withMarkdownNotes(markdown: string, options?: MarkedOptions): StoryDecorator; From 6b3e9bfda5e43c9bd45a3d0c6e74e2ce36d5e590 Mon Sep 17 00:00:00 2001 From: OWA Framework Date: Mon, 10 Dec 2018 15:11:23 -0800 Subject: [PATCH 3/4] Remove broken header line --- types/storybook__addon-notes/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/storybook__addon-notes/index.d.ts b/types/storybook__addon-notes/index.d.ts index 195f31638e..080e725585 100644 --- a/types/storybook__addon-notes/index.d.ts +++ b/types/storybook__addon-notes/index.d.ts @@ -4,7 +4,6 @@ // A.MacLeay // Michael Loughry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.2.1 import * as React from 'react'; import { RenderFunction, StoryDecorator } from '@storybook/react'; From 322938bd18110c9f63ae8a630b3153a2b36f2444 Mon Sep 17 00:00:00 2001 From: OWA Framework Date: Mon, 10 Dec 2018 15:53:51 -0800 Subject: [PATCH 4/4] Can't figure out how to specify higher TS version --- types/storybook__addon-notes/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/storybook__addon-notes/index.d.ts b/types/storybook__addon-notes/index.d.ts index 080e725585..b669ce0a9c 100644 --- a/types/storybook__addon-notes/index.d.ts +++ b/types/storybook__addon-notes/index.d.ts @@ -4,6 +4,7 @@ // A.MacLeay // Michael Loughry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 import * as React from 'react'; import { RenderFunction, StoryDecorator } from '@storybook/react';