function fullscreen({className = 'custom-fullscreen', style = null} = {}) {
const buttonStyle = style != null ? style : 'font-size:1rem;font-weight:bold;padding:8px;background:hsl(,100%,90%);border:1px solid hsl(40,100%,50%); border-radius:4px;box-shadow:0 .5px 2px 1px rgba(0,0,0,.2);cursor: pointer';
const button = html`<button style="${buttonStyle}">Go fullscreen!`;
if(document.documentElement.requestFullscreen) {
button.onclick = () => {
mutable is_fullscreen = true
const parent = document.documentElement;
parent.requestFullscreen().then(() => {
const cleanup = () => {
if(document.fullscreenElement) return;
parent.classList.remove(className);
document.removeEventListener('fullscreenchange', cleanup);
};
parent.classList.add(className);
document.addEventListener('fullscreenchange', cleanup);
});
}
}
else {
const screenfull = require('screenfull@4.2.0/dist/screenfull.js').catch(() => window['screenfull']);
button.onclick = () => {
mutable is_fullscreen = true
screenfull.then(sf => {
const parent = document.documentElement;
sf.request(parent).then(() => {
const cleanup = () => {
if(sf.isFullscreen) return;
parent.classList.remove(className);
sf.off('change', cleanup);
};
parent.classList.add(className);
sf.on('change', cleanup);
});
});
};
}
// Styles don't rely on the :fullscreen selector to avoid interfering with
// Observable's fullscreen mode. Instead a class is applied to html during
// fullscreen.
return html`
${button}
<style>
html.${className},
html.${className} body {
overflow: auto;
height: 100vh;
width: 100vw;
}
html.${className} body > div {
// display: flex; // disable in order ot have map show up
// flex-direction: col; // disable in order ot have map show up
// flex-wrap: wrap;
background: white;
// height: 100%; // causes tooltip to be too tall
width: auto;
overflow: auto;
position: relative;
}
html.${className} body > div > div {
// margin-bottom: 0 !important;
// margin-bottom: 0;
// margin-top: 0px;
// min-height: 0 !important;
// width: 100vw; // causes tooltip to be too wide
// max-height: 100%;
// overflow: auto;
// padding: .5rem;
// box-sizing: border-box;
}
html.sw body > div > div {
margin-bottom: 0 !important;
margin-top: -5px !important;
// margin-left: 5px !important;
// min-height: 0 !important;
// width: 100vw; // causes tooltip to be too wide
// max-height: 100%;
// overflow: auto;
padding-left: 5px;//.5rem;
// box-sizing: border-box;
}
`;
}