Skip to content

Commit f8d7f30

Browse files
committed
feat: add fullscreen mode
1 parent cb95b78 commit f8d7f30

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/instrument-renderer/src/components/InteractiveContent/InteractiveContent.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useCallback, useEffect, useState } from 'react';
22

3-
import { Button } from '@douglasneuroinformatics/libui/components';
3+
import { Button, Separator } from '@douglasneuroinformatics/libui/components';
44
import { type Theme, useTheme, useTranslation } from '@douglasneuroinformatics/libui/hooks';
55
import type { Language } from '@opendatacapture/runtime-core';
66
import { $Json, type Json } from '@opendatacapture/schemas/core';
7-
import { ZoomInIcon, ZoomOutIcon } from 'lucide-react';
7+
import { FullscreenIcon, ZoomInIcon, ZoomOutIcon } from 'lucide-react';
88
import type { Promisable } from 'type-fest';
99

1010
import bootstrapScript from './bootstrap?raw';
@@ -54,6 +54,14 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I
5454
[onSubmit]
5555
);
5656

57+
const handleToggleFullScreen = async () => {
58+
if (!document.fullscreenElement) {
59+
await document.documentElement.requestFullscreen();
60+
} else if (document.exitFullscreen) {
61+
await document.exitFullscreen();
62+
}
63+
};
64+
5765
useEffect(() => {
5866
document.addEventListener('changeLanguage', handleChangeLanguageEvent, false);
5967
return () => document.removeEventListener('changeLanguage', handleChangeLanguageEvent, false);
@@ -90,6 +98,10 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I
9098
<Button size="icon" type="button" variant="outline" onClick={() => setScale(scale + 25)}>
9199
<ZoomInIcon />
92100
</Button>
101+
<Separator className="mx-1 h-6" orientation="vertical" />
102+
<Button size="icon" type="button" variant="outline" onClick={() => void handleToggleFullScreen()}>
103+
<FullscreenIcon />
104+
</Button>
93105
</div>
94106
<div className="h-full w-full overflow-hidden rounded-md border border-slate-300 dark:border-slate-700">
95107
<iframe

0 commit comments

Comments
 (0)