aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-tools-pages/ts/components/Tabs.tsx
diff options
context:
space:
mode:
authorAugust Skare <post@augustskare.no>2018-11-16 18:05:30 +0800
committerAugust Skare <post@augustskare.no>2018-11-16 18:05:30 +0800
commit54bd7df900316504e4403bc94cffd92930a6c763 (patch)
tree7b386224e5746be65bfddc094cc5b26f7c018e19 /packages/dev-tools-pages/ts/components/Tabs.tsx
parent5afef5fe820674abfbdf58226ed0a6920b5c74f7 (diff)
downloaddexon-sol-tools-54bd7df900316504e4403bc94cffd92930a6c763.tar
dexon-sol-tools-54bd7df900316504e4403bc94cffd92930a6c763.tar.gz
dexon-sol-tools-54bd7df900316504e4403bc94cffd92930a6c763.tar.bz2
dexon-sol-tools-54bd7df900316504e4403bc94cffd92930a6c763.tar.lz
dexon-sol-tools-54bd7df900316504e4403bc94cffd92930a6c763.tar.xz
dexon-sol-tools-54bd7df900316504e4403bc94cffd92930a6c763.tar.zst
dexon-sol-tools-54bd7df900316504e4403bc94cffd92930a6c763.zip
fix linting + code syntax for statless components
Diffstat (limited to 'packages/dev-tools-pages/ts/components/Tabs.tsx')
-rw-r--r--packages/dev-tools-pages/ts/components/Tabs.tsx51
1 files changed, 24 insertions, 27 deletions
diff --git a/packages/dev-tools-pages/ts/components/Tabs.tsx b/packages/dev-tools-pages/ts/components/Tabs.tsx
index 36c707b06..c1d5f6b7f 100644
--- a/packages/dev-tools-pages/ts/components/Tabs.tsx
+++ b/packages/dev-tools-pages/ts/components/Tabs.tsx
@@ -1,9 +1,10 @@
import * as React from 'react';
+import { Tab, TabList, TabPanel, Tabs as ReactTabs } from 'react-tabs';
import styled from 'styled-components';
+
import { colors } from 'ts/variables';
-import { Tabs as ReactTabs, Tab, TabList, TabPanel } from 'react-tabs';
-import Breakout from './Breakout';
-import { withContext, Props } from './withContext';
+
+import { Breakout } from './Breakout';
const StyledTabList = styled(TabList)`
text-transform: uppercase;
@@ -31,7 +32,7 @@ const Root =
{ colors: any } >
`
${StyledTab} {
- background-color: ${props => props.colors.secondary};
+ background-color: ${props => props.theme.colors.secondary};
&[aria-selected="true"] {
background-color: ${colors.gray};
@@ -39,44 +40,40 @@ const Root =
&[aria-selected="false"]:focus,
&[aria-selected="false"]:hover {
- background-color: ${props => props.colors.secondary_alt};
+ background-color: ${props => props.theme.colors.secondary_alt};
cursor: pointer;
}
}
`;
-interface TabsProps extends Props {
+interface TabsProps {
children: React.ReactNode;
}
-function Tabs(props: TabsProps) {
- return (
- <Breakout>
- <Root colors={props.colors}>
- <ReactTabs>
- <StyledTabList>
- {React.Children.map(props.children, child => {
- const { props } = React.cloneElement(child as React.ReactElement<any>);
- return <StyledTab>{props.title}</StyledTab>;
- })}
- </StyledTabList>
+const Tabs: React.StatelessComponent<TabsProps> = props => (
+ <Breakout>
+ <Root>
+ <ReactTabs>
+ <StyledTabList>
+ {React.Children.map(props.children, child => {
+ const { title } = React.cloneElement(child as React.ReactElement<any>).props;
+ return <StyledTab>{title}</StyledTab>;
+ })}
+ </StyledTabList>
- {React.Children.map(props.children, child => <TabPanel>{child}</TabPanel>)}
- </ReactTabs>
- </Root>
- </Breakout>
- );
-}
+ {React.Children.map(props.children, child => <TabPanel>{child}</TabPanel>)}
+ </ReactTabs>
+ </Root>
+ </Breakout>
+);
interface TabBlockProps {
title: string;
children: React.ReactNode;
}
-function TabBlock(props: TabBlockProps) {
- return <React.Fragment>{props.children}</React.Fragment>;
-}
+const TabBlock: React.StatelessComponent<TabBlockProps> = props => <React.Fragment>{props.children}</React.Fragment>;
-const ContextTabs = withContext(Tabs);
+const ContextTabs = Tabs;
export { ContextTabs as Tabs, TabBlock };