├── src
├── react-app-env.d.ts
├── index.ts
└── __tests__
│ └── index.test.tsx
├── .eslintignore
├── .prettierrc
├── example
├── public
│ ├── favicon.ico
│ ├── manifest.json
│ └── index.html
├── src
│ ├── index.js
│ ├── App.test.js
│ ├── App.js
│ └── index.css
├── README.md
└── package.json
├── tsconfig.test.json
├── .editorconfig
├── .gitignore
├── .eslintrc
├── tsconfig.json
├── package.json
└── README.md
/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build/
2 | dist/
3 | node_modules/
4 | .snapshots/
5 | *.min.js
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "all",
3 | "singleQuote": true
4 | }
5 |
--------------------------------------------------------------------------------
/example/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cbadger85/react-use-ripple/HEAD/example/public/favicon.ico
--------------------------------------------------------------------------------
/tsconfig.test.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs"
5 | }
6 | }
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/example/src/index.js:
--------------------------------------------------------------------------------
1 | import './index.css'
2 |
3 | import React from 'react'
4 | import ReactDOM from 'react-dom'
5 | import App from './App'
6 |
7 | ReactDOM.render(, document.getElementById('root'))
8 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | This example was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | It is linked to the use-ripple package in the parent directory for development purposes.
4 |
5 | You can run `yarn install` and then `yarn start` to test your package.
6 |
--------------------------------------------------------------------------------
/example/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 | import App from './App'
4 |
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div')
7 | ReactDOM.render(, div)
8 | ReactDOM.unmountComponentAtNode(div)
9 | })
10 |
--------------------------------------------------------------------------------
/example/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "react-use-ripple",
3 | "name": "react-use-ripple",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | }
10 | ],
11 | "start_url": ".",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # See https://help.github.com/ignore-files/ for more about ignoring files.
3 |
4 | # dependencies
5 | node_modules
6 |
7 | # builds
8 | build
9 | dist
10 | .rpt2_cache
11 |
12 | # misc
13 | .DS_Store
14 | .env
15 | .env.local
16 | .env.development.local
17 | .env.test.local
18 | .env.production.local
19 |
20 | npm-debug.log*
21 | yarn-debug.log*
22 | yarn-error.log*
23 |
24 | coverage
25 |
--------------------------------------------------------------------------------
/example/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { useRef, useState } from 'react';
2 | import { useRipple } from 'react-use-ripple';
3 |
4 | const App = () => {
5 | const ref = useRef();
6 | const excludedRef = useRef();
7 | const [isShown, setIsShown] = useState(false);
8 | useRipple(ref, { excludedRefs: [excludedRef] });
9 |
10 | return (
11 |
16 | );
17 | };
18 |
19 | export default App;
20 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": [
4 | "standard",
5 | "standard-react",
6 | "plugin:prettier/recommended",
7 | "prettier/standard",
8 | "prettier/react"
9 | ],
10 | "env": {
11 | "node": true
12 | },
13 | "parserOptions": {
14 | "ecmaVersion": 2020,
15 | "ecmaFeatures": {
16 | "legacyDecorators": true,
17 | "jsx": true
18 | }
19 | },
20 | "settings": {
21 | "react": {
22 | "version": "16"
23 | }
24 | },
25 | "rules": {
26 | "space-before-function-paren": 0,
27 | "react/prop-types": 0,
28 | "react/jsx-handler-names": 0,
29 | "react/jsx-fragments": 0,
30 | "react/no-unused-prop-types": 0,
31 | "import/export": 0
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/example/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | padding: 0;
4 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
5 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
6 | sans-serif;
7 | -webkit-font-smoothing: antialiased;
8 | -moz-osx-font-smoothing: grayscale;
9 | }
10 |
11 | code {
12 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
13 | monospace;
14 | }
15 |
16 | .btn {
17 | margin-top: 100px;
18 | margin-left: 100px;
19 | display: inline-block;
20 | background-color: lightblue;
21 | border: none;
22 | text-align: center;
23 | box-sizing: border-box;
24 | padding: 20px 40px;
25 | min-width: 10vw;
26 | font-size: 20px;
27 | font-family: sans-serif;
28 | color: black;
29 | }
30 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-use-ripple-example",
3 | "homepage": "https://github.com/cbadger85/react-use-ripple",
4 | "version": "0.0.0",
5 | "private": true,
6 | "dependencies": {
7 | "react": "link:../node_modules/react",
8 | "react-dom": "link:../node_modules/react-dom",
9 | "react-scripts": "link:../node_modules/react-scripts",
10 | "react-use-ripple": "link:.."
11 | },
12 | "scripts": {
13 | "start": "node ../node_modules/react-scripts/bin/react-scripts.js start",
14 | "build": "node ../node_modules/react-scripts/bin/react-scripts.js build",
15 | "test": "node ../node_modules/react-scripts/bin/react-scripts.js test",
16 | "eject": "node ../node_modules/react-scripts/bin/react-scripts.js eject"
17 | },
18 | "eslintConfig": {
19 | "extends": "react-app"
20 | },
21 | "browserslist": [
22 | ">0.2%",
23 | "not dead",
24 | "not ie <= 11",
25 | "not op_mini all"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "dist",
4 | "module": "esnext",
5 | "lib": [
6 | "dom",
7 | "esnext"
8 | ],
9 | "moduleResolution": "node",
10 | "jsx": "react",
11 | "sourceMap": true,
12 | "declaration": true,
13 | "esModuleInterop": true,
14 | "noImplicitReturns": true,
15 | "noImplicitThis": true,
16 | "noImplicitAny": true,
17 | "strictNullChecks": true,
18 | "suppressImplicitAnyIndexErrors": true,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "allowSyntheticDefaultImports": true,
22 | "target": "es5",
23 | "allowJs": true,
24 | "skipLibCheck": true,
25 | "strict": true,
26 | "forceConsistentCasingInFileNames": true,
27 | "resolveJsonModule": true,
28 | "isolatedModules": true,
29 | "noEmit": true
30 | },
31 | "include": [
32 | "src"
33 | ],
34 | "exclude": [
35 | "node_modules",
36 | "dist",
37 | "example"
38 | ]
39 | }
40 |
--------------------------------------------------------------------------------
/example/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 |
11 |
12 |
16 |
17 |
18 |
27 | use-ripple
28 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-use-ripple",
3 | "version": "1.5.2",
4 | "description": "A react hook to create material design ripples for components",
5 | "author": "cbadger85",
6 | "keywords": [
7 | "react",
8 | "material design",
9 | "react-hooks",
10 | "ripple"
11 | ],
12 | "license": "MIT",
13 | "repository": "cbadger85/react-use-ripple",
14 | "main": "dist/index.js",
15 | "module": "dist/index.modern.js",
16 | "source": "src/index.ts",
17 | "engines": {
18 | "node": ">=10"
19 | },
20 | "scripts": {
21 | "build": "microbundle-crl --no-compress --format modern,cjs",
22 | "start": "microbundle-crl watch --no-compress --format modern,cjs",
23 | "prepublish": "run-s build",
24 | "test": "run-s test:unit test:lint test:build",
25 | "test:build": "run-s build",
26 | "test:lint": "eslint .",
27 | "test:unit": "cross-env CI=1 react-scripts test --env=jsdom --coverage",
28 | "test:watch": "react-scripts test --env=jsdom"
29 | },
30 | "peerDependencies": {
31 | "react": "^16.8.0"
32 | },
33 | "devDependencies": {
34 | "@testing-library/react": "^10.0.2",
35 | "@types/jest": "^25.2.1",
36 | "@types/react": "^16.9.27",
37 | "babel-eslint": "^10.0.3",
38 | "cross-env": "^7.0.2",
39 | "eslint": "^6.8.0",
40 | "eslint-config-prettier": "^6.7.0",
41 | "eslint-config-standard": "^14.1.0",
42 | "eslint-config-standard-react": "^9.2.0",
43 | "eslint-plugin-import": "^2.18.2",
44 | "eslint-plugin-node": "^11.0.0",
45 | "eslint-plugin-prettier": "^3.1.1",
46 | "eslint-plugin-promise": "^4.2.1",
47 | "eslint-plugin-react": "^7.17.0",
48 | "eslint-plugin-standard": "^4.0.1",
49 | "gh-pages": "^2.2.0",
50 | "microbundle-crl": "^0.13.8",
51 | "npm-run-all": "^4.1.5",
52 | "prettier": "^1.19.1",
53 | "react": "^16.13.1",
54 | "react-dom": "^16.13.1",
55 | "react-scripts": "^3.4.1"
56 | },
57 | "files": [
58 | "dist"
59 | ]
60 | }
61 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-use-ripple
2 |
3 | > A react hook to implement [Material Design ripple overlays](https://www.google.com)
4 |
5 | [](https://www.npmjs.com/package/react-use-ripple) [](https://standardjs.com)
6 |
7 | ## Demo
8 |
9 | [](https://codesandbox.io/s/heuristic-currying-kp08n?fontsize=14&hidenavigation=1&theme=dark)
10 |
11 | ## Install
12 |
13 | ```bash
14 | npm install --save react-use-ripple
15 | ```
16 |
17 | ## Usage
18 |
19 | `useRipple` only requires the ref of the DOM element that the ripple should be applied too.
20 |
21 | ```tsx
22 | import React from 'react';
23 | import { useRipple } from 'react-use-ripple';
24 | import { useRef } from 'react';
25 |
26 | const App = () => {
27 | const ref = useRef();
28 | useRipple(ref);
29 |
30 | return (
31 |
34 | );
35 | };
36 |
37 | export default App;
38 | ```
39 |
40 | ## Arguments
41 |
42 | `useRipple(ref [, options])`
43 |
44 | - ref `>`
45 | - options `