mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 14:49:01 +02:00
feat(collection/presentation): button to enter full screen
This commit is contained in:
parent
9f993363d7
commit
15fc98fca1
@ -0,0 +1,5 @@
|
||||
.presentation-button-bar {
|
||||
position: absolute;
|
||||
top: 1em;
|
||||
right: 1em;
|
||||
}
|
@ -5,6 +5,9 @@ import slideBaseStylesheet from "reveal.js/dist/reveal.css?raw";
|
||||
import slideThemeStylesheet from "reveal.js/dist/theme/black.css?raw";
|
||||
import { buildPresentationModel, PresentationModel, PresentationSlideModel } from "./model";
|
||||
import ShadowDom from "../../react/ShadowDom";
|
||||
import ActionButton from "../../react/ActionButton";
|
||||
import "./index.css";
|
||||
import { RefObject } from "preact";
|
||||
|
||||
const stylesheets = [
|
||||
slideBaseStylesheet,
|
||||
@ -13,16 +16,37 @@ const stylesheets = [
|
||||
|
||||
export default function PresentationView({ note }: ViewModeProps<{}>) {
|
||||
const [ presentation, setPresentation ] = useState<PresentationModel>();
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
buildPresentationModel(note).then(setPresentation);
|
||||
}, [ note ]);
|
||||
|
||||
return presentation && (
|
||||
<ShadowDom className="presentation-container" style={{ width: "100%", height: "100%" }}>
|
||||
{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}
|
||||
<Presentation presentation={presentation} />
|
||||
</ShadowDom>
|
||||
<>
|
||||
<ShadowDom
|
||||
className="presentation-container"
|
||||
style={{ width: "100%", height: "100%" }}
|
||||
containerRef={containerRef}
|
||||
>
|
||||
{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}
|
||||
<Presentation presentation={presentation} />
|
||||
</ShadowDom>
|
||||
<ButtonOverlay containerRef={containerRef} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function ButtonOverlay({ containerRef }: { containerRef: RefObject<HTMLDivElement> }) {
|
||||
return (
|
||||
<div className="presentation-button-bar">
|
||||
<ActionButton
|
||||
icon="bx bx-fullscreen" text="Start presentation"
|
||||
onClick={() => {
|
||||
containerRef.current?.requestFullscreen();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
import { ComponentChildren, HTMLAttributes, JSX, render } from "preact";
|
||||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
import { ComponentChildren, HTMLAttributes, JSX, RefObject, render } from "preact";
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import { useSyncedRef } from "./hooks";
|
||||
|
||||
interface ShadowDomProps extends HTMLAttributes<HTMLDivElement> {
|
||||
interface ShadowDomProps extends Omit<HTMLAttributes<HTMLDivElement>, "ref"> {
|
||||
children: ComponentChildren;
|
||||
containerRef?: RefObject<HTMLDivElement>;
|
||||
}
|
||||
|
||||
export default function ShadowDom({ children, ...containerProps }: ShadowDomProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
export default function ShadowDom({ children, containerRef: externalContainerRef, ...containerProps }: ShadowDomProps) {
|
||||
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
|
||||
const [ shadowRoot, setShadowRoot ] = useState<ShadowRoot | null>(null);
|
||||
|
||||
// Create the shadow root.
|
||||
|
Loading…
x
Reference in New Issue
Block a user