How to use the @wordpress/element.createPortal function in @wordpress/element

To help you get started, we’ve selected a few @wordpress/element examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / packages / components / src / modal / index.js View on Github external
isDismissable, //Deprecated
			// Many of the documented props for Modal are passed straight through
			// to the ModalFrame component and handled there.
			...otherProps
		} = this.props;

		const headingId = aria.labelledby || `components-modal-header-${ instanceId }`;

		if ( isDismissable ) {
			deprecated( 'isDismissable prop of the Modal component', {
				alternative: 'isDismissible prop (renamed) of the Modal component',
			} );
		}
		// Disable reason: this stops mouse events from triggering tooltips and
		// other elements underneath the modal overlay.
		return createPortal(
			
				<div role="document" tabindex="0">
					</div>
github Automattic / wp-calypso / client / gutenberg / extensions / map / info-window / index.js View on Github external
render() {
		// Use React portal to render components directly into the info window.
		return this.el ? createPortal( this.props.children, this.el ) : null;
	}
	closeClick = () => {
github WordPress / gutenberg / packages / components / src / slot-fill / fill.js View on Github external
}
		unregisterFill( ref.current.name, ref.current );
		ref.current.name = name;
		registerFill( name, ref.current );
	}, [ name ] );

	if ( ! slot || ! slot.node || ! slot.props.bubblesVirtually ) {
		return null;
	}

	// If a function is passed as a child, provide it with the fillProps.
	if ( isFunction( children ) ) {
		children = children( slot.props.fillProps );
	}

	return createPortal( children, slot.node );
}
github Yoast / wordpress-seo / js / src / search-appearance.js View on Github external
const {
	showLocalSEOUpsell,
	localSEOUpsellURL,
	brushstrokeBackgroundURL,
	knowledgeGraphCompanyInfoMissing,
} = wpseoSearchAppearance;

render(
	
		
			
				
				{ createPortal( , wpUserSelector ) }
				{ companyInfoMissingElement &amp;&amp; createPortal(
					,
					companyInfoMissingElement
				) }
				{ showLocalSEOUpsell &amp;&amp; createPortal(
					,
					localSEOElement
				) }
github google / site-kit-wp / assets / js / components / modal.js View on Github external
render() {
		return createPortal(
			this.props.children,
			this.el,
		);
	}
}
github ampproject / amp-wp / assets / src / edit-story / components / overlay / index.js View on Github external
function InOverlayWithRef( { zIndex, pointerEvents, render, children }, ref ) {
	const { container, overlay } = useContext( Context );
	if ( ! container || ! overlay ) {
		return null;
	}
	const slot = (
		 evt.stopPropagation() }&gt;
			{ render ? render( { container, overlay } ) : children }
		
	);
	return createPortal( slot, overlay );
}
github Yoast / wordpress-seo / js / src / search-appearance.js View on Github external
showLocalSEOUpsell,
	localSEOUpsellURL,
	brushstrokeBackgroundURL,
	knowledgeGraphCompanyInfoMissing,
} = wpseoSearchAppearance;

render(
	
		
			
				
				{ createPortal( , wpUserSelector ) }
				{ companyInfoMissingElement &amp;&amp; createPortal(
					,
					companyInfoMissingElement
				) }
				{ showLocalSEOUpsell &amp;&amp; createPortal(
					,
					localSEOElement
				) }
			
		
	,
github Yoast / wordpress-seo / js / src / components / contentAnalysis / ReadabilityAnalysis.js View on Github external
if ( location === "sidebar" ) {
						return (
							
								{ this.renderResults() }
							
						);
					}

					if ( location === "metabox" ) {
						return createPortal(
							
								
								{ this.renderResults() }
							,
							document.getElementById( "wpseo-metabox-readability-root" )
						);
					}
				} }
github Yoast / wordpress-seo / js / src / search-appearance.js View on Github external
{ createPortal( , wpUserSelector ) }
				{ companyInfoMissingElement &amp;&amp; createPortal(
					,
					companyInfoMissingElement
				) }
				{ showLocalSEOUpsell &amp;&amp; createPortal(
					,
					localSEOElement
				) }
			
		
	,
	element
);
github Automattic / newspack-plugin / assets / components / src / web-preview / index.js View on Github external
getWebPreviewModal = () =&gt; {
		const { url } = this.props;
		const { device, loaded, isPreviewVisible } = this.state;

		if ( ! this.modalDOMElement || ! isPreviewVisible ) {
			return null;
		}

		const classes = classnames(
			'newspack-web-preview__container',
			device,
			loaded &amp;&amp; 'newspack-web-preview__is-loaded'
		);

		return createPortal(
			<div>
				<div>
					<div>
						<div>
							<button> this.setState( { device: 'desktop' } ) }
								isPrimary={ 'desktop' === device }
								isSecondary={ 'desktop' !== device }
								className="is-desktop"
							&gt;
								
								<span>{ __( 'Preview desktop size' ) }</span>
							</button>
							<button> this.setState( { device: 'tablet' } ) }
								isPrimary={ 'tablet' === device }</button></div></div></div></div>