Skip to content

Commit

Permalink
2 new test page
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse23 committed Aug 28, 2024
1 parent a2e36f7 commit 8ba5dec
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const ROUTES: Record<string, JSX.ElementType> = {
ops: lazy(() => import("./pages/OpsSamplePage")),
ctx: lazy(() => import("./pages/CtxSamplePage")),
report: lazy(() => import("./pages/ReportSamplePage")),
iframe: lazy(() => import("./pages/IframeSamAuthSamplePage")),
portal: lazy(() => import("./pages/PortalStateSamplePage")),
};

const Router = () => {
Expand Down
16 changes: 16 additions & 0 deletions src/pages/IframeSamAuthSamplePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


const IframeSamAuthSamplePage = () => {
return (
<div>
<iframe src="https://tcrevolution.industrysoftware.automation.siemens.com/" title="ops" width="100%" height="1000px"></iframe>
{/*
<iframe src="https://outlook.live.com/mail/0" title="ops" width="100%" height="1000px"></iframe>
<iframe src="https://tcrevolution.industrysoftware.automation.siemens.com/" title="ops" width="100%" height="1000px"></iframe>
*/}
</div>
);
}

export default IframeSamAuthSamplePage;

46 changes: 46 additions & 0 deletions src/pages/PortalStateSamplePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { useState } from 'react';
import ReactDOM from 'react-dom';

function PortalStateSamplePage() {
const [toSecContainer, setToSecContainer] = useState(false);

return (
<div>
<h1>React Portal State Preservation</h1>
<button onClick={() => setToSecContainer(!toSecContainer)}>
Move Portal to {toSecContainer ? 'First' : 'Second'} Container
</button>
<div id="first-container" style={{ border: '1px solid black', padding: '10px' }}>
<p>First Container</p>
</div>
<div id="second-container" style={{ border: '1px solid red', padding: '10px' }}>
<p>Second Container</p>
</div>
<PortalComponent parentElemId={ toSecContainer ? 'second-container' : 'first-container'} />
</div>
);
}

function Parent() {

return (
<div>
<h2>Parent Component</h2>

</div>
);
}

function PortalComponent({parentElemId}: {parentElemId: string}) {
const [count, setCount] = useState(0);

return document.getElementById(parentElemId) && ReactDOM.createPortal(
<div>
<p>Portal Component Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>,
document.getElementById(parentElemId) as HTMLElement
);
}

export default PortalStateSamplePage;

0 comments on commit 8ba5dec

Please sign in to comment.