Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button to toggle presentation mode in export menu #2660

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/ionicons@5.5.1/src/svg/newspaper-outline.svg");
filter: invert(1);
}
aside#export button.toggle_presentation span {
background-image: url("https://cdn.jsdelivr.net/gh/ionic-team/ionicons@5.5.1/src/svg/easel-outline.svg");
filter: invert(1);
}
nav#at_the_top:after {
margin-left: auto;
align-self: center;
Expand Down
Loading