Skip to content

Commit

Permalink
Revert "refactor: rewrite some code to avoid anonymous fct in JS comp…
Browse files Browse the repository at this point in the history
…iled code"

This reverts commit 538ee0f as TS is now compiled using Babel instead of tsc
  • Loading branch information
gaetanmaisse committed Apr 7, 2019
1 parent 57fd649 commit d8b0858
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 39 deletions.
27 changes: 9 additions & 18 deletions lib/components/src/ActionBar/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,12 @@ export interface ActionBarProps {
actionItems: ActionItem[];
}

// Need to define ActionBar using old fashioned `function ActionBar` to avoid TS compiler to
// generate an anonymous function instead of naming it ActionBar...
// See https://github.com/storybooks/storybook/pull/6095#issuecomment-477480930
// tslint:disable-next-line:no-shadowed-variable
export const ActionBar: FunctionComponent<ActionBarProps> = function ActionBar({
actionItems,
...props
}) {
return (
<Container {...props}>
{actionItems.map(({ title, onClick }, index: number) => (
<ActionButton key={index} onClick={onClick}>
{title}
</ActionButton>
))}
</Container>
);
};
export const ActionBar: FunctionComponent<ActionBarProps> = ({ actionItems, ...props }) => (
<Container {...props}>
{actionItems.map(({ title, onClick }, index: number) => (
<ActionButton key={index} onClick={onClick}>
{title}
</ActionButton>
))}
</Container>
);
26 changes: 10 additions & 16 deletions lib/components/src/ScrollArea/ScrollArea.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Storybook's implementation of SimpleBar https://github.com/Grsmto/simplebar
// Note: "SimpleBar can't be used on the <body>, <textarea> or <iframe> elements."

import React, { Fragment, FunctionComponent, ReactNode } from 'react';
import React, { Fragment, FunctionComponent } from 'react';
import { styled, Global } from '@storybook/theming';

import SimpleBar from 'simplebar-react';
Expand Down Expand Up @@ -38,25 +38,19 @@ export interface ScrollAreaProps {
className?: string;
}

// Need to define ScrollArea using old fashioned `function ScrollArea` to avoid TS compiler to
// generate an anonymous function instead of naming it ScrollArea...
// See https://github.com/storybooks/storybook/pull/6095#issuecomment-477480930
// tslint:disable-next-line:no-shadowed-variable
export const ScrollArea: FunctionComponent<ScrollAreaProps> = function ScrollArea({
export const ScrollArea: FunctionComponent<ScrollAreaProps> = ({
children,
vertical,
horizontal,
...props
}) {
return (
<Fragment>
<Global styles={getScrollAreaStyles} />
<Scroll vertical={vertical} horizontal={horizontal} {...props}>
{children}
</Scroll>
</Fragment>
);
};
}) => (
<Fragment>
<Global styles={getScrollAreaStyles} />
<Scroll vertical={vertical} horizontal={horizontal} {...props}>
{children}
</Scroll>
</Fragment>
);

ScrollArea.defaultProps = {
horizontal: false,
Expand Down
6 changes: 1 addition & 5 deletions lib/components/src/placeholder/placeholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ const Message = styled.div`
font-size: ${props => props.theme.typography.size.s2 - 1}px;
`;

// Need to define Placeholder using old fashioned `function Placeholder` to avoid TS compiler to
// generate an anonymous function instead of naming it Placeholder...
// See https://github.com/storybooks/storybook/pull/6095#issuecomment-477480930
// tslint:disable-next-line:no-shadowed-variable
export const Placeholder: FunctionComponent = function Placeholder({ children, ...props }) {
export const Placeholder: FunctionComponent = ({ children, ...props }) => {
const [title, desc] = Children.toArray(children);
return (
<Message {...props}>
Expand Down

0 comments on commit d8b0858

Please sign in to comment.