/** * External dependencies */ import { withInstanceId } from '@woocommerce/base-hocs/with-instance-id'; import classnames from 'classnames'; import { __ } from '@wordpress/i18n'; import { useTabState, Tab, TabList, TabPanel } from 'reakit/Tab'; /** * Internal dependencies */ import './style.scss'; const Tabs = ( { className, onSelect = () => null, tabs, activeClass = 'is-active', initialTabName, ariaLabel = __( 'Tabbed Content', 'woo-gutenberg-products-block' ), instanceId, id, } ) => { const initialTab = initialTabName ? { selectedId: `${ instanceId }-${ initialTabName }` } : undefined; const tabState = useTabState( initialTab ); if ( tabs.length === 0 ) { return null; } return (
{ tabs.map( ( { name, title, ariaLabel: tabAriaLabel } ) => ( onSelect( name ) } type="button" key={ name } aria-label={ tabAriaLabel } > { title } ) ) } { tabs.map( ( { name, content } ) => ( { content } ) ) }
); }; export default withInstanceId( Tabs );