diff --git a/src/core/client/ui/components/Tabs/Tab.mdx b/src/core/client/ui/components/Tabs/Tab.mdx
deleted file mode 100644
index add6f01cf..000000000
--- a/src/core/client/ui/components/Tabs/Tab.mdx
+++ /dev/null
@@ -1,52 +0,0 @@
----
-name: Tab
-menu: UI Kit
----
-
-import { Playground, PropsTable } from 'docz'
-import HorizontalGutter from '../HorizontalGutter'
-
-
-import TabBar from './TabBar'
-import Tab from './Tab'
-
-
-# Tab
-
-## Basic Use
-
-
-
-
- Tab one
- Active Tab
- Tab Three
-
-
-
- Tab one
- Active Tab
- Tab Three
-
-
-
- Tab one
- Active Tab
- Tab Three
-
-
-
-
-
-## Secondary Color
-
-
-
-
- Tab one
- Active Tab
- Tab Three
-
-
-
-
diff --git a/src/core/client/ui/components/Tabs/Tab.tsx b/src/core/client/ui/components/Tabs/Tab.tsx
index f1f8e245a..70f2a5f5d 100644
--- a/src/core/client/ui/components/Tabs/Tab.tsx
+++ b/src/core/client/ui/components/Tabs/Tab.tsx
@@ -16,44 +16,44 @@ export interface TabBarProps {
tabId: string;
active: boolean;
color: string;
- onTabClick?: () => void;
+ onTabClick?: (tabId: string) => void;
}
-const TabBar: StatelessComponent = props => {
- const {
- className,
- classes,
- children,
- tabId,
- active,
- color,
- onTabClick,
- } = props;
+class TabBar extends React.Component {
+ public handleTabClick = () => {
+ if (this.props.onTabClick) {
+ this.props.onTabClick(this.props.tabId);
+ }
+ };
- const rootClassName = cn(
- classes.root,
- {
- [classes.primary]: color === "primary",
- [classes.secondary]: color === "secondary",
- [classes.active]: active,
- },
- className
- );
+ public render() {
+ const { className, classes, children, tabId, active, color } = this.props;
- return (
-
- {children}
-
- );
-};
+ const rootClassName = cn(
+ classes.root,
+ {
+ [classes.primary]: color === "primary",
+ [classes.secondary]: color === "secondary",
+ [classes.active]: active,
+ },
+ className
+ );
+
+ return (
+
+ {children}
+
+ );
+ }
+}
const enhanced = withStyles(styles)(TabBar);
export default enhanced;
diff --git a/src/core/client/ui/components/Tabs/TabBar.mdx b/src/core/client/ui/components/Tabs/TabBar.mdx
index 5b7e47727..847efe843 100644
--- a/src/core/client/ui/components/Tabs/TabBar.mdx
+++ b/src/core/client/ui/components/Tabs/TabBar.mdx
@@ -10,7 +10,6 @@ import HorizontalGutter from '../HorizontalGutter'
import TabBar from './TabBar'
import Tab from './Tab'
-
# TabBar
## Basic Use
diff --git a/src/core/client/ui/components/Tabs/TabBar.tsx b/src/core/client/ui/components/Tabs/TabBar.tsx
index 8bb3d18f1..e3f947d47 100644
--- a/src/core/client/ui/components/Tabs/TabBar.tsx
+++ b/src/core/client/ui/components/Tabs/TabBar.tsx
@@ -14,10 +14,12 @@ export interface TabBarProps {
classes: typeof styles;
color: "primary" | "secondary";
+
activeId?: string;
defaultActiveId?: string;
+
onChange?: (activeId: string) => void;
- onTabClick?: () => void;
+ onTabClick?: (tabId: string) => void;
}
const TabBar: StatelessComponent = props => {
@@ -44,8 +46,9 @@ const TabBar: StatelessComponent = props => {
const tabs = React.Children.toArray(children).map(
(child: React.ReactElement, index: number) =>
+ console.log(child) ||
React.cloneElement(child, {
- tabId: index,
+ index,
active:
defaultActiveId && !activeId
? child.props.tabId === defaultActiveId
diff --git a/src/core/client/ui/components/Tabs/TabContent.tsx b/src/core/client/ui/components/Tabs/TabContent.tsx
index 50653284d..27f37930c 100644
--- a/src/core/client/ui/components/Tabs/TabContent.tsx
+++ b/src/core/client/ui/components/Tabs/TabContent.tsx
@@ -1,8 +1,24 @@
import React, { StatelessComponent } from "react";
-const TabContent: StatelessComponent<{}> = props => {
- const { children } = props;
- return <>{children}>;
+export interface TabContentProps {
+ activeTab?: string;
+}
+
+const TabContent: StatelessComponent = props => {
+ const { children, activeTab } = props;
+ return (
+ <>
+ {React.Children.toArray(children)
+ .filter(
+ (child: React.ReactElement) => child.props.tabId === activeTab
+ )
+ .map((child: React.ReactElement, i) =>
+ React.cloneElement(child, {
+ tabId: child.props.tabId !== undefined ? child.props.tabId : i,
+ })
+ )}
+ >
+ );
};
export default TabContent;
diff --git a/src/core/client/ui/components/Tabs/index.ts b/src/core/client/ui/components/Tabs/index.ts
index 58ecee89f..f8818e9ea 100644
--- a/src/core/client/ui/components/Tabs/index.ts
+++ b/src/core/client/ui/components/Tabs/index.ts
@@ -1 +1,4 @@
-export { default } from "./TabBar";
+export { default as TabBar } from "./TabBar";
+export { default as Tab } from "./Tab";
+export { default as TabPane } from "./TabPane";
+export { default as TabContent } from "./TabContent";
diff --git a/src/core/client/ui/components/index.ts b/src/core/client/ui/components/index.ts
index f701660dd..28a3f5c36 100644
--- a/src/core/client/ui/components/index.ts
+++ b/src/core/client/ui/components/index.ts
@@ -20,3 +20,4 @@ export { default as Spinner } from "./Spinner";
export { default as HorizontalGutter } from "./HorizontalGutter";
export { default as Icon } from "./Icon";
export { default as AriaInfo } from "./AriaInfo";
+export { Tab, TabBar, TabContent, TabPane } from "./Tabs";
diff --git a/src/docs/tabs.mdx b/src/docs/tabs.mdx
new file mode 100644
index 000000000..63efef0e9
--- /dev/null
+++ b/src/docs/tabs.mdx
@@ -0,0 +1,25 @@
+---
+name: Tabs
+route: '/Tabs'
+---
+
+# Tabs
+
+### Examples
+
+import { Playground, PropsTable } from 'docz'
+import { Flex, TabBar, Tab, TabContent, TabPane } from '../core/client/ui/components'
+import Container from "react-with-state-props"
+
+## Simple Form
+
+ (
+ props.setActiveId(id)}>
+ One
+ Two
+ Three
+
+ )}/>
+