/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' import { RewardsTabWrapper, StyledSlider, StyledBullet, StyledText, StyledTab, StyledSwitch } from './style' export interface Props { tabTitles?: string[] testId?: string tabIndexSelected?: number onChange?: (event: React.MouseEvent) => void } export default class Tab extends React.PureComponent { static defaultProps = { tabIndexSelected: 0 } getTabs = (tabTitles: string[]) => { const tabs: React.ReactNode[] = tabTitles.map((title: string, i: number) => { return ( {title} ) }) return tabs } onSwitchChange = (index: number, event: React.MouseEvent) => { if (index === this.props.tabIndexSelected) { return } if (this.props.onChange) { this.props.onChange(event) } } render () { const { testId, tabTitles, tabIndexSelected } = this.props if (!tabTitles || tabTitles.length !== 2) { console.warn('Rewards Tab currently supports 2 tab titles') return null } return ( {this.getTabs(tabTitles)} ) } }