get slotfill_placeholder type working
This commit is contained in:
parent
884f00cf73
commit
63e751a3a2
|
@ -26,6 +26,14 @@ export const Content = ( { data } ) => {
|
||||||
return (
|
return (
|
||||||
<SettingsCheckbox setting={ setting } key={ key } />
|
<SettingsCheckbox setting={ setting } key={ key } />
|
||||||
);
|
);
|
||||||
|
case 'slotfill_placeholder':
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={ key }
|
||||||
|
id={ setting.id }
|
||||||
|
className={ setting.class }
|
||||||
|
></div>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { getQuery } from '@woocommerce/navigation';
|
import { getQuery } from '@woocommerce/navigation';
|
||||||
|
import { useEffect } from '@wordpress/element';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -9,12 +10,26 @@ import { getQuery } from '@woocommerce/navigation';
|
||||||
import { Tabs } from './tabs';
|
import { Tabs } from './tabs';
|
||||||
import { SectionNav } from './section-nav';
|
import { SectionNav } from './section-nav';
|
||||||
import { Content } from './content';
|
import { Content } from './content';
|
||||||
|
import { possiblyRenderSettingsSlots } from './settings-slots';
|
||||||
|
import { registerTaxSettingsConflictErrorFill } from './conflict-error-slotfill';
|
||||||
|
import { registerPaymentsSettingsBannerFill } from '../payments/payments-settings-banner-slotfill';
|
||||||
|
import { registerSiteVisibilitySlotFill } from '../launch-your-store';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
const Settings = ( { params } ) => {
|
const Settings = ( { params } ) => {
|
||||||
const settingsData = window.wcSettings?.admin?.settingsPages;
|
const settingsData = window.wcSettings?.admin?.settingsPages;
|
||||||
const { section } = getQuery();
|
const { section } = getQuery();
|
||||||
|
|
||||||
|
useEffect( () => {
|
||||||
|
possiblyRenderSettingsSlots();
|
||||||
|
}, [ params ] );
|
||||||
|
|
||||||
|
useEffect( () => {
|
||||||
|
registerTaxSettingsConflictErrorFill();
|
||||||
|
registerPaymentsSettingsBannerFill();
|
||||||
|
registerSiteVisibilitySlotFill();
|
||||||
|
}, [] );
|
||||||
|
|
||||||
if ( ! settingsData ) {
|
if ( ! settingsData ) {
|
||||||
return <div>Error getting data</div>;
|
return <div>Error getting data</div>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { render } from '@wordpress/element';
|
import { render, createRoot } from '@wordpress/element';
|
||||||
import { createSlotFill, SlotFillProvider } from '@wordpress/components';
|
import { createSlotFill, SlotFillProvider } from '@wordpress/components';
|
||||||
import { PluginArea } from '@wordpress/plugins';
|
import { PluginArea } from '@wordpress/plugins';
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ export const SETTINGS_SLOT_FILL_CONSTANT =
|
||||||
|
|
||||||
const { Slot } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT );
|
const { Slot } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT );
|
||||||
|
|
||||||
|
const roots = {};
|
||||||
|
|
||||||
export const possiblyRenderSettingsSlots = () => {
|
export const possiblyRenderSettingsSlots = () => {
|
||||||
const slots = [
|
const slots = [
|
||||||
{
|
{
|
||||||
|
@ -28,6 +30,29 @@ export const possiblyRenderSettingsSlots = () => {
|
||||||
const slotDomElement = document.getElementById( slot.id );
|
const slotDomElement = document.getElementById( slot.id );
|
||||||
|
|
||||||
if ( slotDomElement ) {
|
if ( slotDomElement ) {
|
||||||
|
if ( createRoot ) {
|
||||||
|
if ( roots[ slot.id ] ) {
|
||||||
|
roots[ slot.id ].render(
|
||||||
|
<>
|
||||||
|
<SlotFillProvider>
|
||||||
|
<Slot />
|
||||||
|
<PluginArea scope={ slot.scope } />
|
||||||
|
</SlotFillProvider>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const root = createRoot( slotDomElement );
|
||||||
|
root.render(
|
||||||
|
<>
|
||||||
|
<SlotFillProvider>
|
||||||
|
<Slot />
|
||||||
|
<PluginArea scope={ slot.scope } />
|
||||||
|
</SlotFillProvider>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
roots[ slot.id ] = root;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
render(
|
render(
|
||||||
<>
|
<>
|
||||||
<SlotFillProvider>
|
<SlotFillProvider>
|
||||||
|
@ -38,5 +63,6 @@ export const possiblyRenderSettingsSlots = () => {
|
||||||
slotDomElement
|
slotDomElement
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue