♻️ Integrate the new TabNavigation component

This commit is contained in:
Philipp Stracker 2024-10-28 15:47:53 +01:00
parent 3c31297e10
commit 7ecbd6a1ca
No known key found for this signature in database
3 changed files with 13 additions and 44 deletions

View file

@ -1,43 +1,19 @@
import { TabPanel } from '@wordpress/components'; import { TabPanel } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
const onSelect = ( tabName ) => { const TabNavigation = ( { tabs } ) => {
console.log( 'Selecting tab', tabName );
}; const updatePanelUri = ( tabName ) => {
};
const TabNavigation = () => {
return ( return (
<TabPanel <TabPanel
className="my-tab-panel" className={ `ppcp-r-tabs ${ panel }` }
activeClass="active-tab" onSelect={ updatePanelUri }
onSelect={ onSelect } tabs={ tabs }
tabs={ [
{
name: 'dashboard',
title: __( 'Dashboard', 'woocommerce-paypal-payments' ),
className: 'ppcp-r-tab-dashboard',
},
{
name: 'payment-methods',
title: __(
'Payment Methods',
'woocommerce-paypal-payments'
),
className: 'ppcp-r-tab-payment-methods',
},
{
name: 'settings',
title: __( 'Settings', 'woocommerce-paypal-payments' ),
className: 'ppcp-r-tab-settings',
},
{
name: 'styling',
title: __( 'Styling', 'woocommerce-paypal-payments' ),
className: 'ppcp-r-tab-styling',
},
] }
> >
{ ( tab ) => <p>{ tab.title }</p> } { ( tab ) => {
return tab.component || <>{ tab.title ?? tab.name }</>;
} }
</TabPanel> </TabPanel>
); );
}; };

View file

@ -1,11 +1,7 @@
import TabNavigation from '../../ReusableComponents/TabNavigation'; import TabNavigation from '../../ReusableComponents/TabNavigation';
const Dashboard = () => { const Dashboard = () => {
return ( return <div>Settings Page</div>;
<div>
<TabNavigation />
</div>
);
}; };
export default Dashboard; export default Dashboard;

View file

@ -1,13 +1,10 @@
import Onboarding from './Onboarding/Onboarding'; import TabNavigation from '../ReusableComponents/TabNavigation';
import { useState } from '@wordpress/element';
import Dashboard from './Dashboard/Dashboard';
import { getSettingsTabs } from './tabs'; import { getSettingsTabs } from './tabs';
const Settings = () => { const Settings = () => {
const [ onboarded, setOnboarded ] = useState( true );
const tabs = getSettingsTabs(); const tabs = getSettingsTabs();
return <>{ onboarded ? <Onboarding /> : <Dashboard /> }</>; return <TabNavigation tabs={ tabs }></TabNavigation>;
}; };
export default Settings; export default Settings;