diff --git a/examples/official-storybook/config.js b/examples/official-storybook/config.js
index 463772a60e7e..dcc4a87dde88 100644
--- a/examples/official-storybook/config.js
+++ b/examples/official-storybook/config.js
@@ -121,7 +121,7 @@ function loadStories() {
req = require.context('../../lib/ui/src', true, /\.stories\.js$/);
importAll(req);
- req = require.context('../../lib/components/src', true, /\.stories\.js$/);
+ req = require.context('../../lib/components/src', true, /\.stories\.tsx?$/);
importAll(req);
req = require.context('./stories', true, /\.stories\.js$/);
diff --git a/examples/official-storybook/tests/__snapshots__/storyshots.test.js.snap b/examples/official-storybook/tests/__snapshots__/storyshots.test.js.snap
index cd7d301aba36..cd315eb7322c 100644
--- a/examples/official-storybook/tests/__snapshots__/storyshots.test.js.snap
+++ b/examples/official-storybook/tests/__snapshots__/storyshots.test.js.snap
@@ -247,6 +247,9 @@ exports[`Storyshots Basics|Brand/StorybookLogo normal 1`] = `
viewBox="0 0 200 40"
width="200px"
>
+
+ Storybook logo
+
@@ -9834,7 +9838,6 @@ exports[`Storyshots UI|Sidebar/Sidebar simple 1`] = `
class="emotion-0"
height="40px"
role="img"
- title="Storybook"
viewBox="0 0 200 40"
width="200px"
>
@@ -11352,7 +11355,6 @@ exports[`Storyshots UI|Sidebar/SidebarHeading menuHighlighted 1`] = `
class="emotion-0"
height="40px"
role="img"
- title="Storybook"
viewBox="0 0 200 40"
width="200px"
>
@@ -11993,7 +11995,6 @@ exports[`Storyshots UI|Sidebar/SidebarHeading standard 1`] = `
class="emotion-0"
height="40px"
role="img"
- title="Storybook"
viewBox="0 0 200 40"
width="200px"
>
@@ -12331,7 +12332,6 @@ exports[`Storyshots UI|Sidebar/SidebarHeading standardNoLink 1`] = `
class="emotion-0"
height="40px"
role="img"
- title="Storybook"
viewBox="0 0 200 40"
width="200px"
>
diff --git a/lib/components/package.json b/lib/components/package.json
index 3e45c7edbac9..c576a7d654bd 100644
--- a/lib/components/package.json
+++ b/lib/components/package.json
@@ -16,7 +16,7 @@
},
"license": "MIT",
"main": "dist/index.js",
- "jsnext:main": "src/index.js",
+ "types": "dist/index.d.ts",
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
@@ -29,7 +29,9 @@
"core-js": "^2.6.5",
"global": "^4.3.2",
"js-beautify": "^1.8.9",
+ "markdown-to-jsx": "^6.9.1",
"memoizerific": "^1.11.3",
+ "popper.js": "^1.14.7",
"polished": "^3.0.0",
"prop-types": "^15.7.2",
"react": "^16.8.4",
@@ -42,6 +44,17 @@
"recompose": "^0.30.0",
"simplebar-react": "^0.1.5"
},
+ "devDependencies": {
+ "@storybook/addon-actions": "5.1.0-alpha.22",
+ "@storybook/react": "5.1.0-alpha.22",
+ "@types/js-beautify": "^1.8.0",
+ "@types/react-syntax-highlighter": "^10.1.0",
+ "@types/react-textarea-autosize": "^4.3.3",
+ "@types/recompose": "^0.30.5",
+ "enzyme": "^3.9.0",
+ "jest": "^24.7.1",
+ "jest-enzyme": "^7.0.2"
+ },
"peerDependencies": {
"react": "*",
"react-dom": "*"
diff --git a/lib/components/src/ActionBar/ActionBar.stories.js b/lib/components/src/ActionBar/ActionBar.stories.tsx
similarity index 88%
rename from lib/components/src/ActionBar/ActionBar.stories.js
rename to lib/components/src/ActionBar/ActionBar.stories.tsx
index 33cfaface8ff..b620bd370dfb 100644
--- a/lib/components/src/ActionBar/ActionBar.stories.js
+++ b/lib/components/src/ActionBar/ActionBar.stories.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { ReactNode } from 'react';
import { action } from '@storybook/addon-actions';
import { ActionBar } from './ActionBar';
@@ -11,7 +11,7 @@ export default {
Component: ActionBar,
title: 'Basics|ActionBar',
decorators: [
- storyFn => (
+ (storyFn: () => ReactNode) => (
;
+export const singleItem = () =>
;
export const manyItems = () => (
({
}));
ActionButton.displayName = 'ActionButton';
-export const ActionBar = ({ actionItems, ...props }) => (
+export interface ActionItem {
+ title: string | JSX.Element;
+ onClick: (e: React.MouseEvent) => void;
+}
+
+export interface ActionBarProps {
+ actionItems: ActionItem[];
+}
+
+export const ActionBar: FunctionComponent = ({ actionItems, ...props }) => (
- {actionItems.map(({ title, onClick }, index) => (
-
+ {actionItems.map(({ title, onClick }, index: number) => (
+
{title}
))}
);
-
-ActionBar.propTypes = {
- actionItems: PropTypes.arrayOf(
- PropTypes.shape({
- title: PropTypes.node.isRequired,
- onClick: PropTypes.func.isRequired,
- })
- ).isRequired,
-};
diff --git a/lib/components/src/Badge/Badge.stories.js b/lib/components/src/Badge/Badge.stories.tsx
similarity index 100%
rename from lib/components/src/Badge/Badge.stories.js
rename to lib/components/src/Badge/Badge.stories.tsx
diff --git a/lib/components/src/Badge/Badge.js b/lib/components/src/Badge/Badge.tsx
similarity index 76%
rename from lib/components/src/Badge/Badge.js
rename to lib/components/src/Badge/Badge.tsx
index fe3ee497e222..c78410823082 100644
--- a/lib/components/src/Badge/Badge.js
+++ b/lib/components/src/Badge/Badge.tsx
@@ -1,7 +1,9 @@
-import React from 'react';
+import React, { FunctionComponent } from 'react';
import { styled, css } from '@storybook/theming';
-const BadgeWrapper = styled.div`
+type BadgeWrapperProps = BadgeProps;
+
+const BadgeWrapper = styled.div`
display: inline-block;
vertical-align: top;
font-size: 11px;
@@ -43,8 +45,12 @@ const BadgeWrapper = styled.div`
`};
`;
-function Badge({ ...props }) {
- return ;
+export interface BadgeProps {
+ status: 'positive' | 'negative' | 'neutral';
}
+const Badge: FunctionComponent = ({ ...props }) => {
+ return ;
+};
+
export default Badge;
diff --git a/lib/components/src/Button/Button.stories.js b/lib/components/src/Button/Button.stories.tsx
similarity index 100%
rename from lib/components/src/Button/Button.stories.js
rename to lib/components/src/Button/Button.stories.tsx
diff --git a/lib/components/src/Button/Button.js b/lib/components/src/Button/Button.tsx
similarity index 93%
rename from lib/components/src/Button/Button.js
rename to lib/components/src/Button/Button.tsx
index 38e2fe95662f..aab57b088385 100644
--- a/lib/components/src/Button/Button.js
+++ b/lib/components/src/Button/Button.tsx
@@ -1,9 +1,10 @@
-import React from 'react';
-import PropTypes from 'prop-types';
+import React, { FunctionComponent } from 'react';
import { styled, css } from '@storybook/theming';
import { darken, lighten, rgba, transparentize } from 'polished';
-const ButtonWrapper = styled.button`
+type ButtonWrapperProps = ButtonProps;
+
+const ButtonWrapper = styled.button`
border: 0;
border-radius: 3em;
cursor: pointer;
@@ -220,16 +221,23 @@ const ButtonWrapper = styled.button`
const ButtonLink = ButtonWrapper.withComponent('a');
-function Button({ isLink, children, ...props }) {
+interface ButtonProps {
+ isLink?: boolean;
+ primary?: boolean;
+ secondary?: boolean;
+ tertiary?: boolean;
+ inForm?: boolean;
+ disabled?: boolean;
+ small?: boolean;
+ outline?: boolean;
+ containsIcon?: boolean;
+}
+
+const Button: FunctionComponent = ({ isLink, children, ...props }) => {
if (isLink) {
return {children};
}
return {children};
-}
-
-Button.propTypes = {
- isLink: PropTypes.bool,
- children: PropTypes.node.isRequired,
};
Button.defaultProps = {
diff --git a/lib/components/src/ScrollArea/ScrollArea.stories.js b/lib/components/src/ScrollArea/ScrollArea.stories.tsx
similarity index 82%
rename from lib/components/src/ScrollArea/ScrollArea.stories.js
rename to lib/components/src/ScrollArea/ScrollArea.stories.tsx
index 811716a8d80c..a432d443d7c1 100644
--- a/lib/components/src/ScrollArea/ScrollArea.stories.js
+++ b/lib/components/src/ScrollArea/ScrollArea.stories.tsx
@@ -22,12 +22,20 @@ const Wrapper = styled.div({
overflow: 'hidden',
});
-const list = filler => [...new Array(20)].map((x, i) => filler(i));
+const list = (filler: (data: number) => JSX.Element) => {
+ const data = [];
+
+ for (let i = 0; i < 20; i++) {
+ data.push(filler(i));
+ }
+
+ return data;
+};
export default {
component: ScrollArea,
title: 'Basics|ScrollArea',
- decorators: [storyFn => {storyFn()}],
+ decorators: [(storyFn: () => any) => {storyFn()}],
};
export const vertical = () => (
diff --git a/lib/components/src/ScrollArea/ScrollArea.js b/lib/components/src/ScrollArea/ScrollArea.tsx
similarity index 63%
rename from lib/components/src/ScrollArea/ScrollArea.js
rename to lib/components/src/ScrollArea/ScrollArea.tsx
index cae9b2652f52..c95b5c6fffa7 100644
--- a/lib/components/src/ScrollArea/ScrollArea.js
+++ b/lib/components/src/ScrollArea/ScrollArea.tsx
@@ -1,14 +1,19 @@
// Storybook's implementation of SimpleBar https://github.com/Grsmto/simplebar
// Note: "SimpleBar can't be used on the ,