Skip to content

Commit

Permalink
Use fullscreen bug fixes (#196)
Browse files Browse the repository at this point in the history
* Update readme

* v3.6.0
  • Loading branch information
imbhargav5 authored Dec 26, 2019
1 parent 68e4ac2 commit d375600
Show file tree
Hide file tree
Showing 46 changed files with 209 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packages/*"
],
"useWorkspaces": true,
"version": "3.6.0-canary.0",
"version": "3.6.0",
"changelog": {
"repo": "imbhargav5/rooks",
"cacheDir": ".changelog",
Expand Down
2 changes: 1 addition & 1 deletion packages/boundingclientrect-ref/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-boundingclientrect-ref@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/boundingclientrect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"rooks",
"react-hooks.org"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-boundingclientrect@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/countdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-countdown@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"react-hooks.org",
"counter hook"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/debounce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"rooks",
"react-hooks.org"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-debounce@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/did-mount/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"componentDidMount",
"lifecycle"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-did-mount@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/did-update/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"rooks",
"react-hooks.org"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-did-update@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docusaurus",
"version": "3.6.0-canary.0",
"version": "3.6.0",
"private": true,
"scripts": {
"examples": "docusaurus-examples",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-rooks",
"version": "3.6.0-canary.0",
"version": "3.6.0",
"description": "Eslint config for rooks.",
"keywords": [
"eslint",
Expand Down
2 changes: 1 addition & 1 deletion packages/fork-ref/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-fork-ref@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
174 changes: 163 additions & 11 deletions packages/fullscreen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,171 @@ import useFullscreen from "@rooks/use-fullscreen"
### Usage

```jsx
import React, { useState, useRef } from "react";
import ReactDOM from "react-dom";
import { useFullscreen } from "rooks";

const styles = {
html: {
fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
padding: "30px 10px 0 0",
fontSize: "20px",
lineHeight: "1.4",
color: "#737373",
background: "#f0f0f0",
WebkitFontSmoothing: "antialiased"
},
hr: {
border: "none",
borderTop: "1px solid #e6e6e6",
margin: "20px 0"
},
a: {
color: "#666"
},
h1: {
margin: "0",
fontSize: "40px",
textAlign: "center"
},
ul: {
padding: "0 0 0 40px",
margin: "1em 0",
padding: "0",
margin: "40px 0 0 0",
listStyle: "none"
},
button: {
fontSize: "13px"
},
container: {
width: "500px",
padding: "30px 20px",
margin: "0 auto 50px auto",
background: "#fcfcfc",
textAlign: "center",
border: "1px solid #b3b3b3",
borderRadius: "4px",
boxShadow: "0 1px 10px #a7a7a7, inset 0 1px 0 #fff"
},
demo_img: {
cursor: "pointer"
},
header_p: {
fontSize: "17px"
}
};

function Demo() {
const {isEnabled, toggle} = useFullscreen();
return (
<img
src=""
onClick={(e) => {
if(isEnabled) {
toggle(e.target)}
}
}
/>
)
const container = useRef();
const {
isEnabled,
toggle,
onChange,
onError,
request,
exit,
isFullscreen,
element
} = useFullscreen();
const [changeCount, setChangeCount] = useState(0);
const [errorCount, setErrorCount] = useState(0);

onChange(() => {
setChangeCount(changeCount + 1);
});
onError(() => {
setErrorCount(errorCount + 1);
});

return (
<div id="document" style={styles.html}>
<section ref={container} id="container" style={styles.container}>
<header>
<h1 styles={styles.h1}>useFullscreen</h1>
<p style={styles.header_p}>
Simple react hook for cross-browser usage of the JavaScript{" "}
<a
style={styles.a}
href="https://developer.mozilla.org/en/DOM/Using_full-screen_mode"
>
Fullscreen API
</a>
, which lets you bring the page or any element into fullscreen.
Smoothens out the browser implementation differences, so you don't
have too.
</p>
</header>
<hr style={styles.hr} />
<section>
<p>Try out the Fullscreen API</p>
<button
style={styles.button}
onClick={() => {
request(container.current);
}}
>
Request
</button>
<button
style={styles.button}
onClick={() => {
exit();
}}
>
Exit
</button>
<button
style={styles.button}
onClick={() => {
toggle();
}}
>
Toggle
</button>
<button style={styles.button} onClick={() => request()}>
Request document
</button>
</section>
<section>
<ul style={styles.ul}>
<li id="supported">
Supported/allowed: {JSON.stringify(isEnabled)}
</li>
<li id="status">Is fullscreen: {JSON.stringify(isFullscreen)}</li>
<li>
Changed {changeCount} {changeCount !== 1 ? "times" : "time"}
</li>
<li>
{errorCount} {errorCount !== 1 ? "errors" : "error"}
</li>
<li id="element">
Element:{" "}
{element
? `${element.tagName.toLowerCase()} ${element.id}`
: "null"}
</li>
</ul>
</section>
<input placeholder="Keyboard test" />
<hr style={styles.hr} />
<section>
<p>Click the image to make it fullscreen</p>
<img
id="demo-img"
src="https://sindresorhus.com/unicorn"
width="500"
style={styles.demo_img}
onClick={e => {
toggle(e.target);
}}
/>
</section>
</section>
</div>
);
}
render(<Demo/>)
```
2 changes: 1 addition & 1 deletion packages/fullscreen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-fullscreen@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/geolocation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-geolocation@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"rooks",
"input hook"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-input@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/intersection-observer-ref/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-intersection-observer-ref@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/interval/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"setInterval",
"interval"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-interval@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/isomorphic-effect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-isomorphic-effect@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/key/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"keyboard event",
"key"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-key@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/keys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-keys@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/localstorage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"rooks",
"hooks"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-localstorage@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/mouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"mouse",
"mouse hook"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-mouse@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/mutation-observer-ref/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"react": ">=16.8.0"
},
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-mutation-observer-ref@",
"readme": "ERROR: No README data found!",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/mutation-observer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"mutation observer",
"mutation observer hook"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-mutation-observer@",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/navigator-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"navigator language",
"navigator language hook"
],
"version": "3.6.0-canary.0",
"version": "3.6.0",
"_id": "@rooks/use-navigator-language@",
"publishConfig": {
"access": "public"
Expand Down
Loading

0 comments on commit d375600

Please sign in to comment.