From 6d901648a9e565416e0912e467ed89b364259f5b Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 17 May 2019 22:03:47 +0200 Subject: [PATCH] FIX some bs --- examples/cra-ts-kitchen-sink/tsconfig.json | 2 ++ .../types/@storybook/react.d.ts | 8 +++++ lib/components/src/StoryLinkWrapper.ts | 34 ------------------- .../src/tooltip/TooltipLinkList.stories.tsx | 33 ++++++++++++++++-- 4 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 examples/cra-ts-kitchen-sink/types/@storybook/react.d.ts delete mode 100644 lib/components/src/StoryLinkWrapper.ts diff --git a/examples/cra-ts-kitchen-sink/tsconfig.json b/examples/cra-ts-kitchen-sink/tsconfig.json index 69d9d5934107..c96a8072f85a 100644 --- a/examples/cra-ts-kitchen-sink/tsconfig.json +++ b/examples/cra-ts-kitchen-sink/tsconfig.json @@ -1,5 +1,7 @@ { "compilerOptions": { + "baseUrl": ".", + "paths": { "*": ["types/*"] }, "target": "es5", "module": "esnext", "lib" : ["esnext", "dom"], diff --git a/examples/cra-ts-kitchen-sink/types/@storybook/react.d.ts b/examples/cra-ts-kitchen-sink/types/@storybook/react.d.ts new file mode 100644 index 000000000000..942a8398e7b5 --- /dev/null +++ b/examples/cra-ts-kitchen-sink/types/@storybook/react.d.ts @@ -0,0 +1,8 @@ +export const addDecorator: any; +export const addParameters: any; +export const configure: any; +export const forceReRender: any; +export const getStorybook: any; +export const raw: any; +export const setAddon: any; +export const storiesOf: any; diff --git a/lib/components/src/StoryLinkWrapper.ts b/lib/components/src/StoryLinkWrapper.ts deleted file mode 100644 index 1d5779cbf4cc..000000000000 --- a/lib/components/src/StoryLinkWrapper.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint-disable import/no-extraneous-dependencies */ -// This is allows us to test whether the link works via the actions addon -import React, { Children, FunctionComponent, ReactElement, ReactNode } from 'react'; -import PropTypes from 'prop-types'; -import { action } from '@storybook/addon-actions'; - -const onLinkClick = action('onLinkClick'); - -interface StoryLinkWrapperProps { - href: string; - passHref?: boolean; -} - -const StoryLinkWrapper: FunctionComponent = ({ - href, - passHref, - children, -}) => { - const child = Children.only(children) as ReactElement; - - return React.cloneElement(child, { - href: passHref && href, - onClick: (e: React.MouseEvent) => { - e.preventDefault(); - onLinkClick(href); - }, - }); -}; - -StoryLinkWrapper.defaultProps = { - passHref: false, -}; - -export default StoryLinkWrapper; diff --git a/lib/components/src/tooltip/TooltipLinkList.stories.tsx b/lib/components/src/tooltip/TooltipLinkList.stories.tsx index bfa9f629c7e4..aca767c474ef 100644 --- a/lib/components/src/tooltip/TooltipLinkList.stories.tsx +++ b/lib/components/src/tooltip/TooltipLinkList.stories.tsx @@ -1,10 +1,39 @@ -import React from 'react'; +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-extraneous-dependencies */ +import React, { Children, FunctionComponent, ReactElement, ReactNode } from 'react'; import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { WithTooltip } from './WithTooltip'; import { TooltipLinkList } from './TooltipLinkList'; -import StoryLinkWrapper from '../StoryLinkWrapper'; + +const onLinkClick = action('onLinkClick'); + +interface StoryLinkWrapperProps { + href: string; + passHref?: boolean; +} + +const StoryLinkWrapper: FunctionComponent = ({ + href, + passHref, + children, +}) => { + const child = Children.only(children) as ReactElement; + + return React.cloneElement(child, { + href: passHref && href, + onClick: (e: React.MouseEvent) => { + e.preventDefault(); + onLinkClick(href); + }, + }); +}; + +StoryLinkWrapper.defaultProps = { + passHref: false, +}; export const links = [ { id: '1', title: 'Link', href: 'http://google.com' },