mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🚚 Improve component organization
This commit is contained in:
parent
9cd09c8dfa
commit
db7e5e0dae
7 changed files with 34 additions and 41 deletions
|
@ -2,13 +2,12 @@ import { useEffect, useMemo } from '@wordpress/element';
|
|||
import { __ } from '@wordpress/i18n';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { OnboardingHooks } from '../../data';
|
||||
import SpinnerOverlay from '../ReusableComponents/SpinnerOverlay';
|
||||
import { OnboardingHooks } from '../data';
|
||||
import SpinnerOverlay from './ReusableComponents/SpinnerOverlay';
|
||||
import OnboardingScreen from './Screens/Onboarding';
|
||||
import SettingsScreen from './Screens/Settings';
|
||||
|
||||
import OnboardingScreen from './Onboarding';
|
||||
import SettingsScreen from './Settings';
|
||||
|
||||
const Settings = () => {
|
||||
const SettingsApp = () => {
|
||||
const onboardingProgress = OnboardingHooks.useSteps();
|
||||
|
||||
// Disable the "Changes you made might not be saved" browser warning.
|
||||
|
@ -48,4 +47,4 @@ const Settings = () => {
|
|||
return <div className={ wrapperClass }>{ Content }</div>;
|
||||
};
|
||||
|
||||
export default Settings;
|
||||
export default SettingsApp;
|
|
@ -43,9 +43,7 @@ const TabNavigation = ( { tabs } ) => {
|
|||
onSelect={ updateActivePanel }
|
||||
tabs={ tabs }
|
||||
>
|
||||
{ ( tab ) => {
|
||||
return tab.component || <>{ tab.title ?? tab.name }</>;
|
||||
} }
|
||||
{ ( { Component } ) => Component }
|
||||
</TabPanel>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Button } from '@wordpress/components';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import data from '../../utils/data';
|
||||
import data from '../../../../utils/data';
|
||||
|
||||
const SettingsNavigation = ( {} ) => {
|
||||
return (
|
||||
|
|
|
@ -5,32 +5,36 @@ import TabPaymentMethods from '../../Overview/TabPaymentMethods';
|
|||
import TabSettings from '../../Overview/TabSettings';
|
||||
import TabStyling from '../../Overview/TabStyling';
|
||||
|
||||
export const getSettingsTabs = () => {
|
||||
const tabs = [];
|
||||
|
||||
tabs.push( {
|
||||
/**
|
||||
* List of all default settings tabs.
|
||||
*
|
||||
* The tabs are displayed in the order in which they appear in this array
|
||||
*
|
||||
* @type {[{name, title, Component}]}
|
||||
*/
|
||||
const DEFAULT_TABS = [
|
||||
{
|
||||
name: 'overview',
|
||||
title: __( 'Overview', 'woocommerce-paypal-payments' ),
|
||||
component: <TabOverview />,
|
||||
} );
|
||||
|
||||
tabs.push( {
|
||||
Component: <TabOverview />,
|
||||
},
|
||||
{
|
||||
name: 'payment-methods',
|
||||
title: __( 'Payment Methods', 'woocommerce-paypal-payments' ),
|
||||
component: <TabPaymentMethods />,
|
||||
} );
|
||||
|
||||
tabs.push( {
|
||||
Component: <TabPaymentMethods />,
|
||||
},
|
||||
{
|
||||
name: 'settings',
|
||||
title: __( 'Settings', 'woocommerce-paypal-payments' ),
|
||||
component: <TabSettings />,
|
||||
} );
|
||||
|
||||
tabs.push( {
|
||||
Component: <TabSettings />,
|
||||
},
|
||||
{
|
||||
name: 'styling',
|
||||
title: __( 'Styling', 'woocommerce-paypal-payments' ),
|
||||
component: <TabStyling />,
|
||||
} );
|
||||
Component: <TabStyling />,
|
||||
},
|
||||
];
|
||||
|
||||
return tabs;
|
||||
export const getSettingsTabs = () => {
|
||||
return DEFAULT_TABS;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { getSettingsTabs } from './tabs';
|
||||
import SettingsNavigation from './Components/SettingsNavigation';
|
||||
import Container from '../../ReusableComponents/Container';
|
||||
import TabNavigation from '../../ReusableComponents/TabNavigation';
|
||||
import { getSettingsTabs } from './Tabs';
|
||||
import SettingsNavigation from './Components/SettingsNavigation';
|
||||
|
||||
const SettingsScreen = () => {
|
||||
const tabs = getSettingsTabs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue