From 3b01af66b346f68b7aa40816665daef208f2a877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Mon, 10 Sep 2018 12:36:13 -0300 Subject: [PATCH] Two working examples, primary and secondary --- src/core/client/ui/components/Tabs/TabBar.tsx | 9 +++--- .../client/ui/components/Tabs/TabContent.tsx | 2 +- .../client/ui/components/Tabs/TabPane.tsx | 23 ++++---------- src/docs/tabs.mdx | 31 +++++++++++++++++-- 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/core/client/ui/components/Tabs/TabBar.tsx b/src/core/client/ui/components/Tabs/TabBar.tsx index e3f947d47..faef9f09e 100644 --- a/src/core/client/ui/components/Tabs/TabBar.tsx +++ b/src/core/client/ui/components/Tabs/TabBar.tsx @@ -15,7 +15,7 @@ export interface TabBarProps { color: "primary" | "secondary"; - activeId?: string; + activeTab?: string; defaultActiveId?: string; onChange?: (activeId: string) => void; @@ -28,7 +28,7 @@ const TabBar: StatelessComponent = props => { classes, children, onTabClick, - activeId, + activeTab, color, defaultActiveId, } = props; @@ -46,13 +46,12 @@ const TabBar: StatelessComponent = props => { const tabs = React.Children.toArray(children).map( (child: React.ReactElement, index: number) => - console.log(child) || React.cloneElement(child, { index, active: - defaultActiveId && !activeId + defaultActiveId && !activeTab ? child.props.tabId === defaultActiveId - : child.props.tabId === activeId, + : child.props.tabId === activeTab, color, onTabClick, }) diff --git a/src/core/client/ui/components/Tabs/TabContent.tsx b/src/core/client/ui/components/Tabs/TabContent.tsx index 27f37930c..4ce407db7 100644 --- a/src/core/client/ui/components/Tabs/TabContent.tsx +++ b/src/core/client/ui/components/Tabs/TabContent.tsx @@ -14,7 +14,7 @@ const TabContent: StatelessComponent = props => { ) .map((child: React.ReactElement, i) => React.cloneElement(child, { - tabId: child.props.tabId !== undefined ? child.props.tabId : i, + tabId: child.props.tabId ? child.props.tabId : i, }) )} diff --git a/src/core/client/ui/components/Tabs/TabPane.tsx b/src/core/client/ui/components/Tabs/TabPane.tsx index e24560f33..485eb5e53 100644 --- a/src/core/client/ui/components/Tabs/TabPane.tsx +++ b/src/core/client/ui/components/Tabs/TabPane.tsx @@ -1,7 +1,4 @@ -import cn from "classnames"; import React, { StatelessComponent } from "react"; -import { withStyles } from "talk-ui/hocs"; -import * as styles from "./TabPane.css"; export interface TabBarProps { /** @@ -9,32 +6,24 @@ export interface TabBarProps { */ className?: string; /** - * Override or extend the styles applied to the component. + * Name of the tab */ - classes: typeof styles; - tabId: string; - hidden: boolean; } -const TabContent: StatelessComponent = props => { - const { className, classes, children, tabId, hidden } = props; - - const rootClassName = cn(classes.root, className); - +const TabPane: StatelessComponent = props => { + const { className, children, tabId } = props; return ( ); }; -const enhanced = withStyles(styles)(TabContent); -export default enhanced; +export default TabPane; diff --git a/src/docs/tabs.mdx b/src/docs/tabs.mdx index 63efef0e9..1fc0f50bc 100644 --- a/src/docs/tabs.mdx +++ b/src/docs/tabs.mdx @@ -11,15 +11,42 @@ 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 +## Primary Tabs ( - props.setActiveId(id)}> +
+ props.setActiveId(id)}> One Two Three + + Hola One + Hola Two + Hola Three + +
+ )}/> +
+ +## Secondary Tabs + + ( +
+ props.setActiveId(id)}> + One + Two + Three + + + Hola One + Hola Two + Hola Three + +
)}/>