|
1 | 1 | import React, { useCallback, useEffect, useState } from 'react'; |
2 | 2 |
|
3 | | -import { Button } from '@douglasneuroinformatics/libui/components'; |
| 3 | +import { Button, Separator } from '@douglasneuroinformatics/libui/components'; |
4 | 4 | import { type Theme, useTheme, useTranslation } from '@douglasneuroinformatics/libui/hooks'; |
5 | 5 | import type { Language } from '@opendatacapture/runtime-core'; |
6 | 6 | import { $Json, type Json } from '@opendatacapture/schemas/core'; |
7 | | -import { ZoomInIcon, ZoomOutIcon } from 'lucide-react'; |
| 7 | +import { FullscreenIcon, ZoomInIcon, ZoomOutIcon } from 'lucide-react'; |
8 | 8 | import type { Promisable } from 'type-fest'; |
9 | 9 |
|
10 | 10 | import bootstrapScript from './bootstrap?raw'; |
@@ -54,6 +54,14 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I |
54 | 54 | [onSubmit] |
55 | 55 | ); |
56 | 56 |
|
| 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 | + |
57 | 65 | useEffect(() => { |
58 | 66 | document.addEventListener('changeLanguage', handleChangeLanguageEvent, false); |
59 | 67 | return () => document.removeEventListener('changeLanguage', handleChangeLanguageEvent, false); |
@@ -90,6 +98,10 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I |
90 | 98 | <Button size="icon" type="button" variant="outline" onClick={() => setScale(scale + 25)}> |
91 | 99 | <ZoomInIcon /> |
92 | 100 | </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> |
93 | 105 | </div> |
94 | 106 | <div className="h-full w-full overflow-hidden rounded-md border border-slate-300 dark:border-slate-700"> |
95 | 107 | <iframe |
|
0 commit comments