-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
7,179 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as React from 'react'; | ||
import {ReactFocusLockProps, AutoFocusProps, FreeFocusProps, InFocusGuardProps} from "../interfaces"; | ||
|
||
/** | ||
* Traps Focus inside a Lock | ||
*/ | ||
export default class ReactFocusLock extends React.Component<ReactFocusLockProps & { | ||
sideCar: React.SFC | ||
}> { | ||
} | ||
|
||
/** | ||
* Autofocus on children on Lock activation | ||
*/ | ||
export class AutoFocusInside extends React.Component<AutoFocusProps> { | ||
} | ||
|
||
/** | ||
* Autofocus on children | ||
*/ | ||
export class MoveFocusInside extends React.Component<AutoFocusProps> { | ||
} | ||
|
||
/** | ||
* Allow free focus inside on children | ||
*/ | ||
export class FreeFocusInside extends React.Component<FreeFocusProps> { | ||
} | ||
|
||
/** | ||
* Secures the focus around the node | ||
*/ | ||
export class InFocusGuard extends React.Component<InFocusGuardProps> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"private": true, | ||
"main": "../dist/cjs/sidecar.js", | ||
"jsnext:main": "../dist/es2015/sidecar.js", | ||
"module": "../dist/es2015/sidecar.js", | ||
"types": "sidecar.d.ts", | ||
"sideEffects": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { h } from 'preact'; | ||
import React, {Component} from "react"; | ||
import {FocusLockUI} from "react-focus-lock"; | ||
import {sidecar} from "use-sidecar"; | ||
|
||
const styles = { | ||
fontFamily: "sans-serif", | ||
textAlign: "center", | ||
fontSize: "16px" | ||
}; | ||
|
||
const bg = { | ||
backgroundColor: '#FEE' | ||
}; | ||
|
||
const FocusLockSidecar = sidecar(() => import("react-focus-lock/sidecar")); | ||
|
||
class Trap extends Component { | ||
state = { | ||
disabled: true | ||
} | ||
|
||
toggle = () => this.setState({disabled: !this.state.disabled}); | ||
|
||
render() { | ||
const {disabled} = this.state; | ||
return ( | ||
<FocusLockUI | ||
disabled={this.state.disabled} | ||
sideCar={FocusLockSidecar} | ||
> | ||
{disabled && <div> | ||
<button onClick={this.toggle}>!ACTIVATE THE TRAP!</button> | ||
<br/> | ||
<br/> | ||
</div> | ||
} | ||
You will cycle over this. Never leaving <br/> | ||
<input placeholder="input1"/> | ||
|
||
<input placeholder="input2"/> | ||
|
||
<input placeholder="input3"/> <br/> | ||
|
||
<button>A BUTTON</button> | ||
<br/> | ||
|
||
<a href='#'>link somethere</a> <br/> | ||
|
||
{!disabled && <div> | ||
<br/><br/>PRESS this to end the trial.<br/><br/> | ||
<button onClick={this.toggle}>ESCAPE!!!</button> | ||
<br/> | ||
</div>} | ||
</FocusLockUI> | ||
) | ||
} | ||
} | ||
|
||
const Lock = () => | ||
<div style={styles}> | ||
<input placeholder="input1"/> | ||
<div style={bg}> Inaccessible <a href='#'>Link</a> outside</div> | ||
<Trap/> | ||
<div style={bg}> Inaccessible <a href='#'>Link</a> outside</div> | ||
<input placeholder="input1"/> | ||
</div>; | ||
|
||
export default Lock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { h } from 'preact'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Lock from "./Lock"; | ||
|
||
const element = document.getElementById('app'); | ||
const app = (<Lock/>); | ||
|
||
|
||
ReactDOM.render(app, element); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- This file will be used as is in development mode --> | ||
<!-- In production, it will be used as a template on server-rendering --> | ||
<!-- and changed on the fly using cheerio --> | ||
<!-- You can also use your own template engine if you want --> | ||
<!-- but I like to keep things simple --> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script src="./client.js"></script> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.