🚚 Improve component organization

This commit is contained in:
Philipp Stracker 2025-01-10 13:57:53 +01:00
parent 9cd09c8dfa
commit db7e5e0dae
No known key found for this signature in database
7 changed files with 34 additions and 41 deletions

View file

@ -1,8 +0,0 @@
import Settings from './Components/Screens/Settings';
export function App() {
return (
<div>
<Settings />
</div>
);
}

View file

@ -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;

View file

@ -43,9 +43,7 @@ const TabNavigation = ( { tabs } ) => {
onSelect={ updateActivePanel }
tabs={ tabs }
>
{ ( tab ) => {
return tab.component || <>{ tab.title ?? tab.name }</>;
} }
{ ( { Component } ) => Component }
</TabPanel>
);
};

View file

@ -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 (

View file

@ -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;
};

View file

@ -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();

View file

@ -1,6 +1,6 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './App';
import App from './Components/App';
createRoot( document.getElementById( 'ppcp-settings-container' ) ).render(
<App />