mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-26 13:45:30 +03:00
feat(PortalsProvider): add PortalsProvider
- will be used with ReactDOM.createPortal to render components to elements that are outside their tree hierarchy
This commit is contained in:
parent
4828c7ac02
commit
3be39eccc4
@ -49,6 +49,7 @@ import SidebarEditTags from "~/components/sidebars/SidebarEditTags";
|
||||
import ApplicationHeader from "~/components/core/ApplicationHeader";
|
||||
import ApplicationLayout from "~/components/core/ApplicationLayout";
|
||||
import WebsitePrototypeWrapper from "~/components/core/WebsitePrototypeWrapper";
|
||||
import PortalsProvider from "~/components/core/PortalsProvider";
|
||||
import CTATransition from "~/components/core/CTATransition";
|
||||
|
||||
import { GlobalModal } from "~/components/system/components/GlobalModal";
|
||||
@ -496,6 +497,7 @@ export default class ApplicationPage extends React.Component {
|
||||
// }
|
||||
return (
|
||||
<React.Fragment>
|
||||
<PortalsProvider>
|
||||
<ApplicationLayout
|
||||
sidebarName={this.state.sidebar}
|
||||
page={page}
|
||||
@ -503,6 +505,7 @@ export default class ApplicationPage extends React.Component {
|
||||
header={headerElement}
|
||||
sidebar={sidebarElement}
|
||||
onDismissSidebar={this._handleDismissSidebar}
|
||||
fileLoading={this.state.fileLoading}
|
||||
isMobile={this.state.isMobile}
|
||||
isMac={this.props.isMac}
|
||||
viewer={this.state.viewer}
|
||||
@ -521,6 +524,7 @@ export default class ApplicationPage extends React.Component {
|
||||
scene
|
||||
)}
|
||||
</ApplicationLayout>
|
||||
</PortalsProvider>
|
||||
<GlobalModal />
|
||||
<SearchModal
|
||||
viewer={this.state.viewer}
|
||||
|
16
components/core/PortalsProvider.js
Normal file
16
components/core/PortalsProvider.js
Normal file
@ -0,0 +1,16 @@
|
||||
import * as React from "react";
|
||||
|
||||
/**
|
||||
* NOTE(amine): Component used to assign Portals in client side
|
||||
*/
|
||||
|
||||
const LayoutContext = React.createContext({});
|
||||
|
||||
export default function PortalsProvider({ children }) {
|
||||
const filterNavbar = React.useState();
|
||||
const contextValue = React.useMemo(() => ({ filterNavbar }), [filterNavbar]);
|
||||
|
||||
return <LayoutContext.Provider value={contextValue}>{children}</LayoutContext.Provider>;
|
||||
}
|
||||
|
||||
export const usePortals = () => React.useContext(LayoutContext);
|
Loading…
Reference in New Issue
Block a user