diff --git a/web/components/tabs.css b/web/components/tabs.css new file mode 100644 --- /dev/null +++ b/web/components/tabs.css @@ -0,0 +1,29 @@ +div.tabsContainer { + color: var(--fg); + display: flex; + flex-direction: column; + overflow: hidden; +} +div.tabsHeaderContainer { + display: flex; +} + +div.tabHeader { + flex: 1; + padding: 16px; + display: flex; + justify-content: center; + color: var(--tabs-header-active-color); + border-bottom: 2px solid var(--tabs-header-active-border); +} + +div.backgroundTabHeader { + cursor: pointer; + color: var(--tabs-header-background-color); + border-bottom: 2px solid var(--tabs-header-background-border); +} + +div.backgroundTabHeader:hover { + color: var(--tabs-header-background-color-hover); + border-bottom: 2px solid var(--tabs-header-background-border-hover); +} diff --git a/web/components/tabs.react.js b/web/components/tabs.react.js new file mode 100644 --- /dev/null +++ b/web/components/tabs.react.js @@ -0,0 +1,60 @@ +// @flow + +import classnames from 'classnames'; +import * as React from 'react'; + +import css from './tabs.css'; + +type TabsContainerProps = { + +children?: React.ChildrenArray>, + +activeTab: string, + +setTab: string => mixed, +}; + +function TabsContainer(props: TabsContainerProps): React.Node { + const { children, activeTab, setTab } = props; + + const headers = React.Children.map(children, tab => { + const { id, header } = tab.props; + const isActive = id === activeTab; + const headerClasses = classnames(css.tabHeader, { + [css.backgroundTabHeader]: !isActive, + }); + return ( +