-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (entity selector) render into panel, drawer or modal
- Loading branch information
1 parent
72b12ee
commit 2e584a7
Showing
38 changed files
with
1,127 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/@ourworldindata/grapher/src/bodyPortal/.eslintrc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rules: | ||
"@typescript-eslint/explicit-function-return-type": "warn" | ||
"@typescript-eslint/explicit-module-boundary-types": "warn" |
32 changes: 32 additions & 0 deletions
32
packages/@ourworldindata/grapher/src/bodyPortal/BodyPortal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react" | ||
import ReactDOM from "react-dom" | ||
|
||
interface BodyPortalProps { | ||
id?: string | ||
tagName?: string // default: "div" | ||
children: React.ReactNode | ||
} | ||
|
||
// Render a component on the Body instead of inside the current Tree. | ||
// https://reactjs.org/docs/portals.html | ||
export class BodyPortal extends React.Component<BodyPortalProps> { | ||
el: HTMLElement | ||
|
||
constructor(props: BodyPortalProps) { | ||
super(props) | ||
this.el = document.createElement(props.tagName || "div") | ||
if (props.id) this.el.id = props.id | ||
} | ||
|
||
componentDidMount(): void { | ||
document.body.appendChild(this.el) | ||
} | ||
|
||
componentWillUnmount(): void { | ||
document.body.removeChild(this.el) | ||
} | ||
|
||
render(): any { | ||
return ReactDOM.createPortal(this.props.children, this.el) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.