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