39 |
40 |
44 | {props.children}
45 |
46 | {renderLockScreenUi()}
47 |
48 | );
49 | }
50 |
51 | LockScreen.defaultProps = {
52 | onScreenLocked: () => {},
53 | onScreenUnlocked: () => {}
54 | };
55 |
56 | LockScreen.propTypes = {
57 | timeout: PropTypes.number.isRequired,
58 | ui: PropTypes.func.isRequired,
59 | className: PropTypes.string,
60 | onScreenLocked: PropTypes.func,
61 | onScreenUnlocked: PropTypes.func
62 | };
63 |
64 | export default LockScreen;
65 |
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Luqman Olushi O.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-lock-screen",
3 | "version": "0.1.1",
4 | "description": "Simple lock-screen for idle React applications",
5 | "source": "index.js",
6 | "main": "dist/react-lock-screen.js",
7 | "module": "dist/react-lock-screen.m.js",
8 | "scripts": {
9 | "clean": "rimraf dist",
10 | "bundle": "rollup -c",
11 | "build": "npm-run-all clean bundle",
12 | "release": "npm run build && np"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/codeshifu/react-lock-screen.git"
17 | },
18 | "files": [
19 | "dist",
20 | "readme.md"
21 | ],
22 | "keywords": [
23 | "react",
24 | "lock-screen",
25 | "react-lock-screen",
26 | "lock",
27 | "screen",
28 | "idle",
29 | "session"
30 | ],
31 | "author": "",
32 | "license": "MIT",
33 | "bugs": {
34 | "url": "https://github.com/codeshifu/react-lock-screen/issues"
35 | },
36 | "homepage": "https://github.com/codeshifu/react-lock-screen#readme",
37 | "dependencies": {
38 | "prop-types": "15.7.2",
39 | "react-idle-timer": "4.2.11"
40 | },
41 | "peerDependencies": {
42 | "react": "16.8.x",
43 | "react-dom": "16.8.x"
44 | },
45 | "devDependencies": {
46 | "@babel/cli": "7.7.0",
47 | "@babel/core": "7.7.2",
48 | "@babel/preset-env": "7.7.1",
49 | "@babel/preset-react": "7.7.0",
50 | "np": "3.1.0",
51 | "npm-run-all": "4.1.5",
52 | "react": "16.11.0",
53 | "react-dom": "16.11.0",
54 | "rimraf": "3.0.0",
55 | "rollup": "1.26.3",
56 | "rollup-plugin-babel": "4.3.3",
57 | "rollup-plugin-commonjs": "10.1.0",
58 | "rollup-plugin-node-resolve": "5.2.0",
59 | "rollup-plugin-peer-deps-external": "2.2.0",
60 | "rollup-plugin-terser": "5.1.2"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # react-lock-screen
2 |
3 | > Simple lock-screen for idle React applications
4 |
5 | Display a custom lock-screen when your React applications becomes idle
6 |
7 | ## Demo
8 | See it in action [here](https://codesandbox.io/s/react-lock-screen-demo-q2zx3)
9 |
10 | ## Prerequisites
11 |
12 | - [React 16.8+](https://reactjs.org/blog/2019/02/06/react-v16.8.0.html)
13 |
14 | ## Installation
15 |
16 | ```bash
17 | $ npm install react-lock-screen
18 | ```
19 |
20 | ## Usage
21 |
22 | ```jsx
23 | import LockScreen from 'react-lock-screen'
24 | ...
25 |
26 | function App() {
27 |
28 | const getLockScreenUi = (setLock) => {
29 | return