diff --git a/src/components/TabNavHorizontal/TabNavHorizontal.css b/src/components/TabNavHorizontal/TabNavHorizontal.css index e2558b1a..cc4db63f 100644 --- a/src/components/TabNavHorizontal/TabNavHorizontal.css +++ b/src/components/TabNavHorizontal/TabNavHorizontal.css @@ -22,7 +22,7 @@ } } -.link { +.tabContent { display: flex; flex-direction: column; justify-content: flex-end; @@ -51,7 +51,7 @@ } } -.selectedLink { +.selectedTabContent { border-bottom-color: var(--matterColorDark); color: var(--matterColorDark); } @@ -63,7 +63,7 @@ } /* Dark skin */ -.linkDarkSkin { +.tabContentDarkSkin { color: var(--matterColorAnti); &:hover { @@ -71,7 +71,7 @@ } } -.selectedLinkDarkSkin { +.selectedTabContentDarkSkin { border-bottom-color: var(--matterColorLight); color: var(--matterColorLight); } diff --git a/src/components/TabNavHorizontal/TabNavHorizontal.example.js b/src/components/TabNavHorizontal/TabNavHorizontal.example.js index 61077c50..69024a1d 100644 --- a/src/components/TabNavHorizontal/TabNavHorizontal.example.js +++ b/src/components/TabNavHorizontal/TabNavHorizontal.example.js @@ -1,17 +1,30 @@ import TabNavHorizontal from './TabNavHorizontal'; +import { TYPE_BUTTON, TYPE_LINK } from './TabNavHorizontal'; const selfLinkProps = { name: 'StyleguideComponent', params: { component: 'TabNavHorizontal' }, }; -export const Empty = { +export const LinkTabs = { component: TabNavHorizontal, props: { tabs: [ { text: 'Normal', linkProps: selfLinkProps }, { text: 'Selected', linkProps: selfLinkProps, selected: true }, ], + type: TYPE_LINK, + }, + group: 'navigation', +}; + +const noop = () => {}; + +export const ButtonTabs = { + component: TabNavHorizontal, + props: { + tabs: [{ text: 'Normal', onClick: noop }, { text: 'Selected', onClick: noop, selected: true }], + type: TYPE_BUTTON, }, group: 'navigation', }; diff --git a/src/components/TabNavHorizontal/TabNavHorizontal.js b/src/components/TabNavHorizontal/TabNavHorizontal.js index 2d95f803..5358ce5f 100644 --- a/src/components/TabNavHorizontal/TabNavHorizontal.js +++ b/src/components/TabNavHorizontal/TabNavHorizontal.js @@ -1,26 +1,82 @@ +/** + * A horizontal tab bar. + * + * Tabs can be of links or buttons, denoted by the type param + * which accepts values 'link' and 'button'. + * + * The required tab params vary based on the main component type. For + * link tab bar linkProps is required for the tabs. For a button type + * of tab bar onClick function is required. + * + * By default the type of TabNavHorizontal is 'link'. + */ + import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; -import { NamedLink } from '../../components'; +import { InlineTextButton, NamedLink } from '../../components'; import css from './TabNavHorizontal.css'; export const LIGHT_SKIN = 'light'; export const DARK_SKIN = 'dark'; -const Tab = props => { +export const TYPE_LINK = 'link'; +export const TYPE_BUTTON = 'button'; + +const { arrayOf, bool, func, node, object, oneOf, string } = PropTypes; + +const ButtonTab = props => { + const { className, disabled, text, selected, onClick, isDark } = props; + const darkSkinClasses = isDark + ? classNames(css.tabContentDarkSkin, { + [css.selectedTabContentDarkSkin]: selected, + [css.disabledDarkSkin]: disabled, + }) + : null; + + const buttonClasses = classNames( + css.tabContent, + { + [css.selectedTabContent]: selected, + [css.disabled]: disabled, + }, + darkSkinClasses + ); + + return ( +