futurice / symptomradar

Symptomradar (Oiretutka) crowdsources coronavirus symptoms from news media audience
MIT License
25 stars 2 forks source link

Auto resize overview embed #317

Closed nathandao closed 4 years ago

nathandao commented 4 years ago

To test, we could modify the Survey.tsx file (which already has iframeResizer "parent" part loaded).

Change the Survey component's code to:

const Survey = (props: RouteComponentProps) => {
  const [iframeSrc, setIframeSrc] = useState('/embed/v1/?variant=plain');
  const currentLanguage = i18n.language;

  useEffect(() => {
    iframeResizer({ log: false }, '.formIframe');
    const newUrl =
      currentLanguage === 'fi' ? 'http://localhost:3000/map-embed/overview' : 'http://localhost:3000/map-embed';
    setIframeSrc(newUrl);
  }, [currentLanguage]);

  return (
    <Container>
      <Iframe className="formIframe" title="Map embed" src="http://localhost:3000/map-embed" height="400px" />
      <Iframe className="formIframe" title="Oiretutka-kysely" src={iframeSrc} />
    </Container>
  );
};

Both iframes are set with fixed heights, but map content height should stay at 400px, indicating that iframe-resizer/js/iframeResizer.contentWindow is not activated there.

Hold your breath before clicking Karttaan button at the bottom of Overview

nathandao commented 4 years ago

This could work! Didn't notice any problems when testing locally through the Survey page. But maybe let's just hide the map link button in overview, when it is viewed as an embed?

Yup. Removed button from embed view, now the self-collapsing map can't be witnessed any more : D