Newer
Older
import React from 'react'
import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles'
import Tabs from '@material-ui/core/Tabs'
import Tab from '@material-ui/core/Tab'
import { Link } from 'react-router-dom'
import Paper from '@material-ui/core/Paper'
import intl from 'react-intl-universal'
borderBottomRightRadius: 0
}
})
/**
* A component for generating view tabs for a faceted search perspective or an entity landing page.
*/
constructor (props) {
super(props)
const value = this.pathnameToValue(this.props.routeProps.location.pathname)
this.state = { value }
}
componentDidUpdate = prevProps => {
const newPath = this.props.routeProps.location.pathname
const oldPath = prevProps.routeProps.location.pathname
if (newPath !== oldPath) {
this.setState({ value: this.pathnameToValue(newPath) })
}
}
pathnameToValue = pathname => {
const activeID = pathname.split('/').pop()
let value = 0
if (tab.id === activeID) {
value = tab.value
const { classes, tabs } = this.props
// const largeScreen = screenSize === 'xl'
const variant = tabs.length > 3 ? 'scrollable' : 'fullWidth'
const scrollButtons = tabs.length > 3 ? 'auto' : 'on'
<Tabs
value={this.state.value}
onChange={this.handleChange}
indicatorColor='secondary'
textColor='secondary'
icon={tab.icon}
label={intl.get(`tabs.${tab.id}`)}
tabs: PropTypes.array.isRequired,
screenSize: PropTypes.string.isRequired
export default withStyles(styles)(PerspectiveTabs)