Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit 2390955

Browse files
author
John Richard Chipps-Harding
authored
Fullscreen Support (onClick) (#4)
1 parent 0f4fdfd commit 2390955

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

package-lock.json

Lines changed: 63 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"dependencies": {
1515
"next": "12.3.1",
1616
"react": "18.2.0",
17-
"react-dom": "18.2.0"
17+
"react-dom": "18.2.0",
18+
"rooks": "^7.4.0"
1819
},
1920
"devDependencies": {
2021
"@types/node": "18.8.3",

src/pages/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { useRef } from "react";
2+
3+
import { useFullscreen } from "rooks";
14
import Head from "next/head";
25
import type { NextPage } from "next";
36

@@ -6,13 +9,17 @@ import { ImageStack } from "@/components/ImageStack";
69

710
const Home: NextPage = () => {
811
const images = useImages();
12+
const fullscreenContainerRef = useRef<HTMLDivElement>(null);
13+
const { toggleFullscreen } = useFullscreen({
14+
target: fullscreenContainerRef,
15+
});
916
return (
10-
<>
17+
<div ref={fullscreenContainerRef} onClick={toggleFullscreen}>
1118
<Head>
1219
<title>Phantom Diffusion</title>
1320
</Head>
1421
<ImageStack images={images} />
15-
</>
22+
</div>
1623
);
1724
};
1825

0 commit comments

Comments
 (0)