mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +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 slideThemeStylesheet from "reveal.js/dist/theme/black.css?raw";
|
||||||
import { buildPresentationModel, PresentationModel, PresentationSlideModel } from "./model";
|
import { buildPresentationModel, PresentationModel, PresentationSlideModel } from "./model";
|
||||||
import ShadowDom from "../../react/ShadowDom";
|
import ShadowDom from "../../react/ShadowDom";
|
||||||
|
import ActionButton from "../../react/ActionButton";
|
||||||
|
import "./index.css";
|
||||||
|
import { RefObject } from "preact";
|
||||||
|
|
||||||
const stylesheets = [
|
const stylesheets = [
|
||||||
slideBaseStylesheet,
|
slideBaseStylesheet,
|
||||||
@ -13,16 +16,37 @@ const stylesheets = [
|
|||||||
|
|
||||||
export default function PresentationView({ note }: ViewModeProps<{}>) {
|
export default function PresentationView({ note }: ViewModeProps<{}>) {
|
||||||
const [ presentation, setPresentation ] = useState<PresentationModel>();
|
const [ presentation, setPresentation ] = useState<PresentationModel>();
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
buildPresentationModel(note).then(setPresentation);
|
buildPresentationModel(note).then(setPresentation);
|
||||||
}, [ note ]);
|
}, [ note ]);
|
||||||
|
|
||||||
return presentation && (
|
return presentation && (
|
||||||
<ShadowDom className="presentation-container" style={{ width: "100%", height: "100%" }}>
|
<>
|
||||||
|
<ShadowDom
|
||||||
|
className="presentation-container"
|
||||||
|
style={{ width: "100%", height: "100%" }}
|
||||||
|
containerRef={containerRef}
|
||||||
|
>
|
||||||
{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}
|
{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}
|
||||||
<Presentation presentation={presentation} />
|
<Presentation presentation={presentation} />
|
||||||
</ShadowDom>
|
</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 { ComponentChildren, HTMLAttributes, JSX, RefObject, render } from "preact";
|
||||||
import { useEffect, useRef, useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
import { useSyncedRef } from "./hooks";
|
||||||
|
|
||||||
interface ShadowDomProps extends HTMLAttributes<HTMLDivElement> {
|
interface ShadowDomProps extends Omit<HTMLAttributes<HTMLDivElement>, "ref"> {
|
||||||
children: ComponentChildren;
|
children: ComponentChildren;
|
||||||
|
containerRef?: RefObject<HTMLDivElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ShadowDom({ children, ...containerProps }: ShadowDomProps) {
|
export default function ShadowDom({ children, containerRef: externalContainerRef, ...containerProps }: ShadowDomProps) {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
|
||||||
const [ shadowRoot, setShadowRoot ] = useState<ShadowRoot | null>(null);
|
const [ shadowRoot, setShadowRoot ] = useState<ShadowRoot | null>(null);
|
||||||
|
|
||||||
// Create the shadow root.
|
// Create the shadow root.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user