Skip to content

Commit b2445c1

Browse files
committed
resolving conflict
2 parents 739e02d + 6ffd50d commit b2445c1

File tree

5 files changed

+15
-45
lines changed

5 files changed

+15
-45
lines changed

components/iframeCommunication.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useEffect, useRef } from 'react';
22
import { useRouter } from 'next/router';
33

4+
const HEIGHT_DIFFERENCE_THRESHOLD = 130; // ~30 locally and 122 on Sandbox (Donna PC)
5+
46
const allowedOrigins = ['https://alkem.io', 'https://dev-alkem.io', 'https://acc-alkem.io', 'https://sandbox-alkem.io', 'http://localhost:3000'];
57
const isOriginValid = (origin) => allowedOrigins.includes(origin);
68

@@ -40,24 +42,25 @@ const IframeCommunication = () => {
4042

4143
const sendPageHeight = () => {
4244
const pageHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
45+
console.log('Scroll change new/old: ', pageHeight, lastHeight.current);
4346

4447
// Only send if there's a meaningful difference in height
45-
if (Math.abs(pageHeight - lastHeight.current) > 40) {
48+
if (Math.abs(pageHeight - lastHeight.current) > HEIGHT_DIFFERENCE_THRESHOLD) {
4649
lastHeight.current = pageHeight;
4750

4851
// Debounce the message to avoid excessive calls
4952
clearTimeout(debounceTimeout.current);
5053
debounceTimeout.current = setTimeout(() => {
54+
console.log('Scroll change SENT: ', pageHeight, lastHeight.current);
5155
sendMessageToParent({ type: SupportedMessageTypes.PageHeight, height: pageHeight });
5256
}, 50);
5357
}
5458
};
5559

5660

5761
useEffect(() => {
58-
// Send initial page height and path
62+
// Send path
5963
sendMessageToParent({ type: SupportedMessageTypes.PageChange, url: router.pathname });
60-
sendPageHeight();
6164

6265
// Observe changes to the body size
6366
const resizeObserver = new ResizeObserver(sendPageHeight);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alkemio/documentation",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Alkemio platform documentation",
55
"author": "Alkemio Foundation",
66
"repository": {

pages/_app.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import IframeCommunication from '../components/iframeCommunication';
44

55
export default function MyApp({ Component, pageProps }) {
66
useEffect(() => {
7-
if (typeof window === 'undefined') return;
8-
if (window.self !== window.top) {
9-
document.body.classList.add("in-iframe");
10-
} else {
11-
document.body.classList.remove("in-iframe");
12-
}
7+
try {
8+
if (window.self === window.top) {
9+
document.body.classList.add("not-in-iframe");
10+
}
11+
} catch (e) {}
1312
}, []);
1413

1514
return (

styles.css

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,11 @@
1-
html, body {
2-
height: 100vh;
3-
max-height: 100vh;
4-
overflow: hidden;
5-
}
6-
71
body {
82
font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica',
93
'Arial', sans-serif;
104
overflow-y: hidden;
115
}
126

13-
body:not(.in-iframe) {
7+
body.not-in-iframe {
148
overflow-y: auto;
159
}
1610

17-
.main-content {
18-
flex: 1;
19-
height: 100%;
20-
max-height: 100vh;
21-
overflow-y: auto; /* Zorgt ervoor dat de inhoud in de iframe kan scrollen */
22-
padding: 20px;
23-
background: white;
24-
}
25-
26-
iframe {
27-
width: 100%;
28-
height: 100vh !important; /* Zorgt dat de iframe altijd de volle hoogte krijgt */
29-
overflow-y: auto !important; /* Voorkomt dat de iframe-inhoud wordt afgesneden */
30-
border: none;
31-
}
32-
33-
body.in-iframe {
34-
overflow-y: auto !important;
35-
height: auto !important;
36-
max-height: 100vh !important;
37-
}
3811

39-
body.in-iframe .main-content {
40-
overflow-y: auto !important;
41-
height: auto !important;
42-
max-height: 100vh !important;
43-
}

0 commit comments

Comments
 (0)