-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1302 from incubateur-ademe/iframe-resizing
Nouvel Iframe de simulation
- Loading branch information
Showing
18 changed files
with
358 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="fr"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="initial-scale=1" /> | ||
</head> | ||
<body> | ||
<h2>Exemple d'intégration du test avec région fixée par l'intégrateur.</h2> | ||
Ci-dessous, nosgestesclimat.fr intégré comme un iframe paramétré ne | ||
contenant que la partie simulation du test. Dans cet exemple, la Suisse a | ||
été définie comme étant la région par défaut du test. | ||
<script | ||
id="nosgestesclimat" | ||
src="/iframeSimulation.js" | ||
data-only-simulation="true" | ||
data-localisation="CH" | ||
data-pr="1872" | ||
></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getIsIframe } from '@/utils' | ||
import { useEffect } from 'react' | ||
|
||
export function IframeResizer() { | ||
const isIframe = getIsIframe() | ||
useEffect(() => { | ||
// The code below communicate with the iframe.js script on a host site | ||
// to automatically resize the iframe when its inner content height | ||
// change. | ||
|
||
if (!isIframe) { | ||
return | ||
} | ||
|
||
const minHeight = 800 // Also used in iframe.js | ||
const observer = new ResizeObserver(([entry]) => { | ||
const value = Math.max(minHeight, entry.contentRect.height) | ||
window.parent?.postMessage({ kind: 'resize-height', value }, '*') | ||
}) | ||
observer.observe(window.document.body) | ||
return () => observer.disconnect() | ||
}, [isIframe]) | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,75 @@ | ||
import { AppState } from '@/reducers/rootReducer' | ||
import { useSelector } from 'react-redux' | ||
import { Link } from 'react-router-dom' | ||
|
||
export default ({ showText, size = 'large' }) => ( | ||
<div | ||
css={` | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`} | ||
> | ||
<Link | ||
to="/" | ||
data-cypress-id="home-logo-link" | ||
export default ({ showText, size = 'large' }) => { | ||
const iframeOnlySimulationOption = useSelector( | ||
(state: AppState) => state?.iframeOptions?.iframeOnlySimulation | ||
) | ||
return ( | ||
<div | ||
css={` | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
text-decoration: none; | ||
margin: ${{ | ||
large: '1rem auto', | ||
medium: '1rem 3rem 0rem 0rem', | ||
small: '.1rem auto', | ||
}[size]}; | ||
img { | ||
width: ${{ large: '100px', medium: '55px', small: '30px' }[size]}; | ||
height: auto; | ||
} | ||
${iframeOnlySimulationOption && | ||
` | ||
pointer-events: none; | ||
`} | ||
`} | ||
> | ||
<img | ||
src={`/images/petit-logo${size === 'large' ? '@2x' : ''}.png`} | ||
srcSet="/images/petit-logo@2x.png 2x, | ||
<Link | ||
to="/" | ||
data-cypress-id="home-logo-link" | ||
css={` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
text-decoration: none; | ||
margin: ${{ | ||
large: '1rem auto', | ||
medium: '1rem 3rem 0rem 0rem', | ||
small: '.1rem auto', | ||
}[size]}; | ||
img { | ||
width: ${{ large: '100px', medium: '55px', small: '30px' }[size]}; | ||
height: auto; | ||
} | ||
`} | ||
> | ||
<img | ||
src={`/images/petit-logo${size === 'large' ? '@2x' : ''}.png`} | ||
srcSet="/images/petit-logo@2x.png 2x, | ||
/images/petit-logo@3x.png 3x" | ||
width="75" | ||
height="75" | ||
/> | ||
{showText && ( | ||
<div | ||
css={` | ||
font-weight: 900; | ||
line-height: ${{ | ||
large: '1.5rem', | ||
medium: '1.05rem', | ||
small: '1rem', | ||
}[size]}; | ||
color: var(--darkColor); | ||
text-transform: uppercase; | ||
font-size: ${{ large: '160%', medium: '113%', small: '60%' }[size]}; | ||
margin-left: 0.2rem; | ||
`} | ||
> | ||
Nos | ||
<br /> | ||
Gestes | ||
<br /> | ||
Climat | ||
</div> | ||
)} | ||
</Link> | ||
</div> | ||
) | ||
width="75" | ||
height="75" | ||
/> | ||
{showText && ( | ||
<div | ||
css={` | ||
font-weight: 900; | ||
line-height: ${{ | ||
large: '1.5rem', | ||
medium: '1.05rem', | ||
small: '1rem', | ||
}[size]}; | ||
color: var(--darkColor); | ||
text-transform: uppercase; | ||
font-size: ${{ large: '160%', medium: '113%', small: '60%' }[ | ||
size | ||
]}; | ||
margin-left: 0.2rem; | ||
`} | ||
> | ||
Nos | ||
<br /> | ||
Gestes | ||
<br /> | ||
Climat | ||
</div> | ||
)} | ||
</Link> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.