-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathuseFullscreen.story.tsx
55 lines (49 loc) · 1.46 KB
/
useFullscreen.story.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { useFullscreen, useToggle } from '../src';
import ShowDocs from './util/ShowDocs';
const Demo = () => {
const [show, toggle] = useToggle(false);
const ref = React.useRef(null);
const videoRef = React.useRef(null);
const isFullScreen = useFullscreen(ref, show, {
onClose: () => toggle(false),
video: videoRef,
});
const controls = (
<div style={{ background: 'white', padding: '20px' }}>
<div>{isFullScreen ? 'is full screen' : 'not full screen'}</div>
<button onClick={() => toggle()}>Toggle</button>
<button onClick={() => toggle(true)}>set ON</button>
<button onClick={() => toggle(false)}>set OFF</button>
</div>
);
return (
<div>
<div
ref={ref}
style={{
backgroundColor: isFullScreen ? 'black' : 'grey',
width: 400,
height: 300,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}>
<video
ref={videoRef}
style={{ width: '70%' }}
src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
autoPlay={true}
/>
{isFullScreen && controls}
</div>
<br />
<br />
{!isFullScreen && controls}
</div>
);
};
storiesOf('UI/useFullscreen', module)
.add('Docs', () => <ShowDocs md={require('../docs/useFullscreen.md')} />)
.add('Demo', () => <Demo />);