Skip to content

Commit

Permalink
fix: html block margin and height
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Mar 19, 2023
1 parent f9076a3 commit 09f6ef4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/molecules/Visualizer/Block/HTML/index.tsx
Expand Up @@ -104,6 +104,7 @@ const HTMLBlock: React.FC<Props> = ({
}

// Initialize styles
frameWindow.document.documentElement.style.margin = "0";
frameWindow.document.body.style.color = themeColor ?? getComputedStyle(frameRef).color;
frameWindow.document.body.style.margin = "0";

Expand All @@ -116,8 +117,7 @@ const HTMLBlock: React.FC<Props> = ({
}

const resize = () => {
const rect = frameWindow.document.body.getBoundingClientRect();
setHeight(rect.top + rect.bottom);
setHeight(frameWindow.document.documentElement.scrollHeight);
};

// Resize
Expand Down Expand Up @@ -207,6 +207,7 @@ const IFrame = styled.iframe<{ $height: number }>`
height: ${({ $height }) => $height}px;
width: 100%;
min-width: 100%;
box-sizing: border-box;
`;

const InputField = styled.textarea<{ minHeight: number }>`
Expand Down
5 changes: 3 additions & 2 deletions src/core/Crust/Infobox/Block/HTML/index.tsx
Expand Up @@ -102,6 +102,7 @@ const HTMLBlock: React.FC<Props> = ({
}

// Initialize styles
frameWindow.document.documentElement.style.margin = "0";
frameWindow.document.body.style.color = themeColor ?? getComputedStyle(frameRef).color;
frameWindow.document.body.style.margin = "0";

Expand All @@ -114,8 +115,7 @@ const HTMLBlock: React.FC<Props> = ({
}

const resize = () => {
const rect = frameWindow.document.body.getBoundingClientRect();
setHeight(rect.top + rect.bottom);
setHeight(frameWindow.document.documentElement.scrollHeight);
};

// Resize
Expand Down Expand Up @@ -205,6 +205,7 @@ const IFrame = styled.iframe<{ $height: number }>`
height: ${({ $height }) => $height}px;
width: 100%;
min-width: 100%;
box-sizing: border-box;
`;

const InputField = styled.textarea<{ minHeight: number }>`
Expand Down

0 comments on commit 09f6ef4

Please sign in to comment.