woocommerce/plugins/woocommerce-admin/client/settings/tabs.js

28 lines
547 B
JavaScript
Raw Normal View History

2024-05-28 23:32:10 +00:00
/**
* External dependencies
*/
import { TabPanel } from '@wordpress/components';
export const Tabs = ( { data, page } ) => {
const onSelect = ( tabName ) => {
console.log( 'Selecting tab', tabName );
};
return (
<>
<TabPanel
2024-05-29 00:17:39 +00:00
className="woocommerce-settings-tabs"
2024-05-28 23:32:10 +00:00
activeClass="active-tab"
onSelect={ onSelect }
initialTabName={ page }
tabs={ Object.keys( data ).map( ( key ) => ( {
name: key,
title: data[ key ].label,
} ) ) }
>
{ ( tab ) => <p>{ tab.title }</p> }
</TabPanel>
</>
);
};