diff --git a/src/components/EmbedOverlay/index.tsx b/src/components/EmbedOverlay/index.tsx new file mode 100644 index 000000000..377081741 --- /dev/null +++ b/src/components/EmbedOverlay/index.tsx @@ -0,0 +1,19 @@ +import React from "react"; + +import styles from "./style.css"; + +interface ViewerOverlayTargetProps { + title: string; +} + +const EmbedOverlay = ({ + title, +}: ViewerOverlayTargetProps): JSX.Element | null => { + return ( +
+

{title}

+
+ ); +}; + +export default EmbedOverlay; diff --git a/src/components/EmbedOverlay/style.css b/src/components/EmbedOverlay/style.css new file mode 100644 index 000000000..e4ddfe0b8 --- /dev/null +++ b/src/components/EmbedOverlay/style.css @@ -0,0 +1,13 @@ +.container{ + position: absolute; + height: 100%; + width: 100%; + z-index: 300; + display: flex; + pointer-events: none; +} + +.container h4 { + color: var(--dark-theme-text-color); + margin: 0 auto; +} diff --git a/src/components/SideBar/index.tsx b/src/components/SideBar/index.tsx index a0f4511c8..f1ce50414 100644 --- a/src/components/SideBar/index.tsx +++ b/src/components/SideBar/index.tsx @@ -13,6 +13,7 @@ interface SiderProps { type: string; onCollapse: (open: boolean) => void; children?: React.ReactNode; + isEmbedded?: boolean; } interface SiderState { @@ -36,12 +37,12 @@ export default class SideBar extends React.Component { }; public render(): JSX.Element { - const { type, children } = this.props; - + const { type, children, isEmbedded } = this.props; // Ex) class="style__sider--30dA5 style__left--1KLfS" const siderClass: string = classNames({ [styles.sider]: true, [styles[type]]: true, + [styles.embed]: isEmbedded, }); // Ex) class="style__trigger--30dA5 style__left--1KLfS style__collapsed--ncLRy" diff --git a/src/components/SideBar/style.css b/src/components/SideBar/style.css index 55c218910..6a1917ca6 100644 --- a/src/components/SideBar/style.css +++ b/src/components/SideBar/style.css @@ -8,6 +8,9 @@ background-color: var(--dark-theme-sidebar-bg); padding: 0 10px 0 0; } +.sider.embed { + height: 100vh; +} .sider.right { right: 0; diff --git a/src/containers/Simularium/index.tsx b/src/containers/Simularium/index.tsx index 48dac89fa..c0ea89777 100644 --- a/src/containers/Simularium/index.tsx +++ b/src/containers/Simularium/index.tsx @@ -50,6 +50,9 @@ import { const { Content } = Layout; import styles from "./style.css"; +import classNames from "classnames"; +import { EMBED_PATHNAME } from "../../routes"; +import EmbedOverlay from "../../components/EmbedOverlay"; interface AppProps { onSidePanelCollapse: (number: number) => void; @@ -194,32 +197,54 @@ class App extends React.Component { } } - public render(): JSX.Element { + public renderOverlay(isEmbedded: boolean) { const { - simulariumController, - changeToLocalSimulariumFile, + simulariumFile, resetDragOverViewer, + changeToLocalSimulariumFile, viewerStatus, fileIsDraggedOverViewer, setViewerStatus, clearSimulariumFile, setError, } = this.props; + if (isEmbedded) { + return ; + } else { + return ( + + ); + } + } + + public render(): JSX.Element { + const { simulariumController, changeToLocalSimulariumFile } = + this.props; + const isEmbedded = location.pathname === EMBED_PATHNAME; return ( - +
- - + {this.renderOverlay(isEmbedded)} + @@ -230,7 +255,11 @@ class App extends React.Component { /> )} - + diff --git a/src/containers/Simularium/style.css b/src/containers/Simularium/style.css index 26560d9c1..2cb522b1e 100644 --- a/src/containers/Simularium/style.css +++ b/src/containers/Simularium/style.css @@ -15,6 +15,12 @@ background: var(--dark-theme-body-bg); } +.container.embed :global(.ant-layout-content) { + height: 100vh; + /* Prevents a light gray background from flashing upon collapsing the right sidebar */ + background: var(--dark-theme-body-bg); +} + .content { position: relative; height: 100%; diff --git a/src/index.tsx b/src/index.tsx index cb65a0726..86724fd87 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -11,7 +11,7 @@ import { BrowserRouter, Switch, Route, useLocation } from "react-router-dom"; import { APP_ID } from "./constants"; import { createReduxStore } from "./state"; -import routes, { VIEWER_PATHNAME } from "./routes"; +import routes, { EMBED_PATHNAME, VIEWER_PATHNAME } from "./routes"; import ScrollToTop from "./components/ScrollToTop"; import AppHeader from "./containers/AppHeader"; @@ -32,7 +32,10 @@ function useLocationChange() { const dispatch = useDispatch(); React.useEffect(() => { - if (location.pathname !== VIEWER_PATHNAME) { + if ( + location.pathname !== VIEWER_PATHNAME && + location.pathname !== EMBED_PATHNAME + ) { batch(() => { // if we're navigating away from the viewer, stop playing and reset state dispatch(setIsPlaying(false)); @@ -76,9 +79,11 @@ const App = () => { } > -
- -
+ {location.pathname !== EMBED_PATHNAME && ( +
+ +
+ )} diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 0d20a8c9f..eb473fce1 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -4,6 +4,7 @@ import Simularium from "../containers/Simularium"; export const VIEWER_PATHNAME = "/viewer"; export const TUTORIAL_PATHNAME = "/tutorial"; +export const EMBED_PATHNAME = "/embed"; export default [ { @@ -21,4 +22,9 @@ export default [ component: Simularium, path: VIEWER_PATHNAME, }, + { + name: "Embed", + component: Simularium, + path: EMBED_PATHNAME, + }, ];