woocommerce-paypal-payments/modules/ppcp-settings/resources/js/Components/ReusableComponents/TabNavigation.js

27 lines
612 B
JavaScript
Raw Normal View History

2024-10-24 13:54:50 +02:00
import { TabPanel } from '@wordpress/components';
import { useState } from '@wordpress/element';
2024-10-24 13:54:50 +02:00
const TabNavigation = ( { tabs } ) => {
const initialPanel = tabs[ 0 ].name;
const [ activePanel, setActivePanel ] = useState( initialPanel );
const updatePanelUri = ( tabName ) => {
setActivePanel( tabName );
};
2024-10-24 13:54:50 +02:00
return (
<TabPanel
className={ `ppcp-r-tabs ${ activePanel }` }
initialTabName={ activePanel }
onSelect={ updatePanelUri }
tabs={ tabs }
2024-10-24 13:54:50 +02:00
>
{ ( tab ) => {
return tab.component || <>{ tab.title ?? tab.name }</>;
} }
2024-10-24 13:54:50 +02:00
</TabPanel>
);
};
export default TabNavigation;