File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 130130 font-size : 0.8rem ;
131131}
132132
133+ .widget : fullscreen ,
134+ .widget : -webkit-full-screen {
135+ max-width : 100% ;
136+ width : 100% ;
137+ height : 100% ;
138+ border-radius : 0 ;
139+ border : none;
140+ background : var (--bg );
141+ }
142+
133143@media (max-width : 1024px ) {
134144 .section {
135145 padding : 4rem 1.5rem ;
Original file line number Diff line number Diff line change 1+ import { useFullscreen } from '../hooks/useFullscreen'
12import './Viz1.css'
23
34const Viz1 : React . FC = ( ) => {
5+ const { ref, isFullscreen, toggle } = useFullscreen ( )
46 return (
57 < div className = "section" >
68 < div className = "viz-container" >
@@ -14,10 +16,13 @@ const Viz1: React.FC = () => {
1416 nisi ut aliquip ex ea commodo consequat.
1517 </ p >
1618 </ div >
17- < div className = "widget" >
18- < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" >
19+ < div className = "widget" ref = { ref } >
20+ < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" onClick = { toggle } >
1921 < svg viewBox = "0 0 24 24" width = "18" height = "18" fill = "none" stroke = "currentColor" strokeWidth = "2" >
20- < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
22+ { isFullscreen
23+ ? < path d = "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" />
24+ : < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
25+ }
2126 </ svg >
2227 </ button >
2328 < h2 >
Original file line number Diff line number Diff line change 1+ import { useFullscreen } from '../hooks/useFullscreen'
12import './Viz2.css'
23
34const Viz2 : React . FC = ( ) => {
5+ const { ref, isFullscreen, toggle } = useFullscreen ( )
46 return (
57 < div className = "section" >
68 < div className = "viz-container" >
7- < div className = "widget" >
8- < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" >
9+ < div className = "widget" ref = { ref } >
10+ < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" onClick = { toggle } >
911 < svg viewBox = "0 0 24 24" width = "18" height = "18" fill = "none" stroke = "currentColor" strokeWidth = "2" >
10- < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
12+ { isFullscreen
13+ ? < path d = "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" />
14+ : < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
15+ }
1116 </ svg >
1217 </ button >
1318 < h2 >
Original file line number Diff line number Diff line change 1+ import { useFullscreen } from '../hooks/useFullscreen'
12import './Viz3.css'
23
34const Viz3 : React . FC = ( ) => {
5+ const { ref, isFullscreen, toggle } = useFullscreen ( )
46 return (
57 < div className = "section" >
68 < div className = "viz-container" >
@@ -14,10 +16,13 @@ const Viz3: React.FC = () => {
1416 nisi ut aliquip ex ea commodo consequat.
1517 </ p >
1618 </ div >
17- < div className = "widget" >
18- < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" >
19+ < div className = "widget" ref = { ref } >
20+ < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" onClick = { toggle } >
1921 < svg viewBox = "0 0 24 24" width = "18" height = "18" fill = "none" stroke = "currentColor" strokeWidth = "2" >
20- < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
22+ { isFullscreen
23+ ? < path d = "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" />
24+ : < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
25+ }
2126 </ svg >
2227 </ button >
2328 < h2 >
Original file line number Diff line number Diff line change 1+ import { useFullscreen } from '../hooks/useFullscreen'
12import './Viz4.css'
23
34const Viz4 : React . FC = ( ) => {
5+ const { ref, isFullscreen, toggle } = useFullscreen ( )
46 return (
57 < div className = "section" >
68 < div className = "viz-container" >
7- < div className = "widget" >
8- < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" >
9+ < div className = "widget" ref = { ref } >
10+ < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" onClick = { toggle } >
911 < svg viewBox = "0 0 24 24" width = "18" height = "18" fill = "none" stroke = "currentColor" strokeWidth = "2" >
10- < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
12+ { isFullscreen
13+ ? < path d = "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" />
14+ : < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
15+ }
1116 </ svg >
1217 </ button >
1318 < h2 >
Original file line number Diff line number Diff line change 1+ import { useFullscreen } from '../hooks/useFullscreen'
12import './Viz5.css'
23
34const Viz5 : React . FC = ( ) => {
5+ const { ref, isFullscreen, toggle } = useFullscreen ( )
46 return (
57 < div className = "section" >
68 < div className = "viz-container" >
@@ -14,10 +16,13 @@ const Viz5: React.FC = () => {
1416 nisi ut aliquip ex ea commodo consequat.
1517 </ p >
1618 </ div >
17- < div className = "widget" >
18- < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" >
19+ < div className = "widget" ref = { ref } >
20+ < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" onClick = { toggle } >
1921 < svg viewBox = "0 0 24 24" width = "18" height = "18" fill = "none" stroke = "currentColor" strokeWidth = "2" >
20- < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
22+ { isFullscreen
23+ ? < path d = "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" />
24+ : < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
25+ }
2126 </ svg >
2227 </ button >
2328 < h2 >
Original file line number Diff line number Diff line change 1+ import { useFullscreen } from '../hooks/useFullscreen'
12import './Viz6.css'
23
34const Viz6 : React . FC = ( ) => {
5+ const { ref, isFullscreen, toggle } = useFullscreen ( )
46 return (
57 < div className = "section" >
68 < div className = "viz-container" >
7- < div className = "widget" >
8- < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" >
9+ < div className = "widget" ref = { ref } >
10+ < button className = "fullscreen-btn" aria-label = "Toggle Fullscreen" onClick = { toggle } >
911 < svg viewBox = "0 0 24 24" width = "18" height = "18" fill = "none" stroke = "currentColor" strokeWidth = "2" >
10- < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
12+ { isFullscreen
13+ ? < path d = "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" />
14+ : < path d = "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
15+ }
1116 </ svg >
1217 </ button >
1318 < h2 >
Original file line number Diff line number Diff line change 1+ import { useRef , useState , useEffect } from 'react'
2+
3+ export function useFullscreen ( ) {
4+ const ref = useRef < HTMLDivElement > ( null )
5+ const [ isFullscreen , setIsFullscreen ] = useState ( false )
6+
7+ useEffect ( ( ) => {
8+ const handleChange = ( ) => {
9+ setIsFullscreen ( document . fullscreenElement === ref . current )
10+ }
11+ document . addEventListener ( 'fullscreenchange' , handleChange )
12+ return ( ) => document . removeEventListener ( 'fullscreenchange' , handleChange )
13+ } , [ ] )
14+
15+ const toggle = ( ) => {
16+ if ( ! document . fullscreenElement ) {
17+ ref . current ?. requestFullscreen ( )
18+ } else {
19+ document . exitFullscreen ( )
20+ }
21+ }
22+
23+ return { ref, isFullscreen, toggle }
24+ }
You can’t perform that action at this time.
0 commit comments