Skip to content

Commit

Permalink
Button to toggle presentation mode in export menu (#2660)
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Oct 2, 2023
1 parent 049ff09 commit 3f108c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
11 changes: 11 additions & 0 deletions frontend/components/ExportBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ export const ExportBanner = ({ notebook_id, open, onClose, notebookfile_url, not
>
<span></span>
</button>
<button
title="Start presentation"
class="toggle_presentation"
onClick=${() => {
onClose()
// @ts-ignore
window.present()
}}
>
<span></span>
</button>
<button title="Close" class="toggle_export" onClick=${() => onClose()}>
<span></span>
</button>
Expand Down
12 changes: 6 additions & 6 deletions frontend/components/SlideControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export const SlideControls = () => {
const height = window.innerHeight
const headers = Array.from(notebook_node.querySelectorAll("pluto-output h1, pluto-output h2"))
const pos = headers.map((el) => el.getBoundingClientRect())
const edges = pos.map((rect) => rect.top + window.pageYOffset)
const edges = pos.map((rect) => rect.top + window.scrollY)

edges.push(notebook_node.getBoundingClientRect().bottom + window.pageYOffset)
edges.push(notebook_node.getBoundingClientRect().bottom + window.scrollY)

const scrollPositions = headers.map((el, i) => {
if (el.tagName == "H1") {
Expand All @@ -58,15 +58,15 @@ export const SlideControls = () => {
const go_previous_slide = (/** @type {Event} */ e) => {
const positions = calculate_slide_positions(e)

const pos = positions.reverse().find((y) => y < window.pageYOffset - 10)
const pos = positions.reverse().find((y) => y < window.scrollY - 10)

if (pos) window.scrollTo(window.pageXOffset, pos)
if (pos) window.scrollTo(window.scrollX, pos)
}

const go_next_slide = (/** @type {Event} */ e) => {
const positions = calculate_slide_positions(e)
const pos = positions.find((y) => y - 10 > window.pageYOffset)
if (pos) window.scrollTo(window.pageXOffset, pos)
const pos = positions.find((y) => y - 10 > window.scrollY)
if (pos) window.scrollTo(window.scrollX, pos)
}

const presenting_ref = useRef(false)
Expand Down
5 changes: 5 additions & 0 deletions frontend/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ aside#export div#container {
max-width: 1000px;
padding-right: 10em;
margin: 0 auto;
position: relative;
}
header aside#export div#container {
/* to prevent the div from taking up horizontal page when the export pane is closed. On small screen this causes overscroll on the right. */
Expand Down Expand Up @@ -732,6 +733,10 @@ aside#export button.toggle_frontmatter_edit span {
background-image: url("https://cdn.jsdelivr.net/gh/ionic-team/[email protected]/src/svg/newspaper-outline.svg");
filter: invert(1);
}
aside#export button.toggle_presentation span {
background-image: url("https://cdn.jsdelivr.net/gh/ionic-team/[email protected]/src/svg/easel-outline.svg");
filter: invert(1);
}
nav#at_the_top:after {
margin-left: auto;
align-self: center;
Expand Down

0 comments on commit 3f108c0

Please sign in to comment.