Skip to content

Commit

Permalink
Address IFrame width changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Jan 29, 2024
1 parent 976f85d commit 3df09e0
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/pages/iframe.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { css } from "@emotion/css"
import { useRouter } from "next/router"
import React, { useCallback, useState } from "react"
import ReactDOM from "react-dom"

Expand Down Expand Up @@ -51,13 +49,6 @@ export type Url = {
const Iframe: React.FC<React.PropsWithChildren<unknown>> = () => {
const [state, setState] = useState<State | null>(null)

const router = useRouter()
const rawMaxWidth = router?.query?.width
let maxWidth: number | null = 500
if (rawMaxWidth) {
maxWidth = Number(rawMaxWidth)
}

const callback = useCallback((messageData: unknown, port: MessagePort) => {
if (isSetStateMessage(messageData)) {
ReactDOM.flushSync(() => {
Expand Down Expand Up @@ -108,13 +99,7 @@ const Iframe: React.FC<React.PropsWithChildren<unknown>> = () => {

return (
<HeightTrackingContainer port={port}>
<div
className={css`
width: 100%;
${maxWidth && `max-width: ${maxWidth}px;`}
margin: 0 auto;
`}
>
<div>
<Renderer port={port} setState={setState} state={state} />
</div>
</HeightTrackingContainer>
Expand Down

0 comments on commit 3df09e0

Please sign in to comment.