├── .babelrc ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── demo.gif ├── example ├── .env.local ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt └── src │ ├── App.css │ ├── App.js │ ├── index.css │ ├── index.js │ ├── reportWebVitals.js │ └── setupTests.js ├── package.json ├── public └── index.html ├── src ├── index.js └── react-bubbly-effect-button.js ├── webpack.config.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env", 4 | "@babel/preset-react" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | example/ 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Microbundle cache 58 | .rpt2_cache/ 59 | .rts2_cache_cjs/ 60 | .rts2_cache_es/ 61 | .rts2_cache_umd/ 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # dotenv environment variables file 73 | .env 74 | .env.test 75 | .env.production 76 | 77 | # parcel-bundler cache (https://parceljs.org/) 78 | .cache 79 | .parcel-cache 80 | 81 | # Next.js build output 82 | .next 83 | out 84 | 85 | # Nuxt.js build / generate output 86 | .nuxt 87 | dist 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and not Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # Serverless directories 99 | .serverless/ 100 | 101 | # FuseBox cache 102 | .fusebox/ 103 | 104 | # DynamoDB Local files 105 | .dynamodb/ 106 | 107 | # TernJS port file 108 | .tern-port 109 | 110 | # Stores VSCode versions used for testing VSCode extensions 111 | .vscode-test 112 | 113 | # yarn v2 114 | .yarn/cache 115 | .yarn/unplugged 116 | .yarn/build-state.yml 117 | .yarn/install-state.gz 118 | .pnp.* 119 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Ankit Kumar () 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-bubbly-effect-button 2 | > Bubbling effect on buttons 3 | 4 | [![NPM](https://img.shields.io/npm/v/react-bubbly-effect-button.svg)](https://www.npmjs.com/package/react-bubbly-effect-button) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 5 | ## Intro 6 | 7 |

8 | 9 |

10 | 11 | ## Install 12 | 13 | ```bash 14 | npm install react-bubbly-effect-button --save 15 | ``` 16 | 17 | If you prefer yarn then 18 | 19 | ```bash 20 | yarn react-bubbly-effect-button 21 | ``` 22 | 23 | ## Props 24 | 25 | | Property | Type | Default | Description 26 | | ----------- | ----------- | ----------- | ----------- | 27 | | text | string | 'Dummy | Button text | 28 | | bgColor | string | #ff2e2e | Button and particle color | 29 | | color | string | white | Button text color | 30 | | onClick | func | null | Callback for on click for the button | 31 | 32 | 33 | ## Usage 34 | 35 | Check out the [demo](https://knowankit.github.io/react-bubbly-effect-button/) to see in action 36 | 37 | ```jsx 38 | import React from 'react' 39 | import ReactBubblyEffectButton from "react-bubbly-effect-button"; 40 | 41 | const onClick = () => { 42 | console.log('Clicked') 43 | } 44 | 45 | const BubblyButton = () => { 46 | return 47 | } 48 | 49 | export default BubblyButton; 50 | ``` 51 | 52 | ## Info 53 | 54 | This module was bootstrapped with [build-react-npm](https://github.com/knowankit/build-react-npm). 55 | 56 | ## License 57 | 58 | MIT © [Ankit Kumar](https://github.com/knowankit) 59 | 60 | Support my OSS work by following me on twitter twitter 61 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phoolstack/react-bubbly-effect-button/d9fecbf6f488fec28ccec460592a369bdaa9b9a9/demo.gif -------------------------------------------------------------------------------- /example/.env.local: -------------------------------------------------------------------------------- 1 | SKIP_PREFLIGHT_CHECK=true 2 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `yarn start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `yarn test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `yarn build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `yarn eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `yarn build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "private": false, 4 | "homepage": ".", 5 | "version": "0.0.0", 6 | "dependencies": { 7 | "react": "^17.0.2", 8 | "react-dom": "^17.0.2", 9 | "react-scripts": "4.0.3", 10 | "react-bubbly-effect-button": "file:../react-bubbly-effect-button-1.0.0.tgz", 11 | "web-vitals": "^1.0.1" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build" 16 | }, 17 | "eslintConfig": { 18 | "extends": [ 19 | "react-app", 20 | "react-app/jest" 21 | ] 22 | }, 23 | "browserslist": { 24 | "production": [ 25 | ">0.2%", 26 | "not dead", 27 | "not op_mini all" 28 | ], 29 | "development": [ 30 | "last 1 chrome version", 31 | "last 1 firefox version", 32 | "last 1 safari version" 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phoolstack/react-bubbly-effect-button/d9fecbf6f488fec28ccec460592a369bdaa9b9a9/example/public/favicon.ico -------------------------------------------------------------------------------- /example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /example/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phoolstack/react-bubbly-effect-button/d9fecbf6f488fec28ccec460592a369bdaa9b9a9/example/public/logo192.png -------------------------------------------------------------------------------- /example/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phoolstack/react-bubbly-effect-button/d9fecbf6f488fec28ccec460592a369bdaa9b9a9/example/public/logo512.png -------------------------------------------------------------------------------- /example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /example/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /example/src/App.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phoolstack/react-bubbly-effect-button/d9fecbf6f488fec28ccec460592a369bdaa9b9a9/example/src/App.css -------------------------------------------------------------------------------- /example/src/App.js: -------------------------------------------------------------------------------- 1 | import "./App.css"; 2 | import ReactBubblyEffectButton from "react-bubbly-effect-button"; 3 | 4 | const onClick = () => { 5 | console.log('Clicked') 6 | } 7 | 8 | function App() { 9 | return
10 | 11 |
; 12 | } 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /example/src/index.css: -------------------------------------------------------------------------------- 1 | .container { 2 | display: flex; 3 | justify-content: center; 4 | align-items: center; 5 | height: 100vh 6 | } 7 | -------------------------------------------------------------------------------- /example/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /example/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /example/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-bubbly-effect-button", 3 | "version": "1.0.1", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "dev": "webpack serve --mode development --env development", 8 | "build": "webpack --mode production --env production && npm pack", 9 | "predeploy": "cd example && npm run build", 10 | "deploy": "gh-pages -d example/build" 11 | }, 12 | "keywords": [ 13 | "react-bubbly-effect-button" 14 | ], 15 | "devDependencies": { 16 | "@babel/core": "^7.15.5", 17 | "@babel/plugin-proposal-class-properties": "^7.14.5", 18 | "@babel/preset-env": "^7.15.6", 19 | "@babel/preset-react": "^7.14.5", 20 | "babel-loader": "^8.2.2", 21 | "clean-webpack-plugin": "^4.0.0-alpha.0", 22 | "css-loader": "^6.2.0", 23 | "file-loader": "^6.2.0", 24 | "gh-pages": "^3.2.3", 25 | "html-webpack-plugin": "^5.3.2", 26 | "mini-css-extract-plugin": "^2.3.0", 27 | "react": "^17.0.2", 28 | "react-dom": "^17.0.2", 29 | "style-loader": "^3.2.1", 30 | "typescript": "^4.3.5", 31 | "webpack": "^5.47.1", 32 | "webpack-cli": "^4.7.2", 33 | "webpack-dev-server": "^3.11.2" 34 | }, 35 | "peerDependencies": { 36 | "react": "^17.0.2" 37 | }, 38 | "files": [ 39 | "dist" 40 | ], 41 | "author": "Ankit Kumar", 42 | "license": "MIT" 43 | } 44 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Example npm component 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDom from "react-dom"; 3 | import ReactBubblyEffectButton from "./react-bubbly-effect-button"; 4 | 5 | const onClick = () => { 6 | console.log("Clicked"); 7 | }; 8 | 9 | ReactDom.render(, document.getElementById("app")); 10 | -------------------------------------------------------------------------------- /src/react-bubbly-effect-button.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const ReactBubblyEffectButton = ({ 4 | text = "Dummy", 5 | onClick = () => {}, 6 | bgColor = "#ff2e2e", 7 | color = "white" 8 | }) => { 9 | const handleClick = e => { 10 | animate(e); 11 | onClick(); 12 | }; 13 | 14 | const animate = e => { 15 | e.preventDefault; 16 | 17 | // reset animation 18 | e.target.classList.remove("animate"); 19 | 20 | e.target.classList.add("animate"); 21 | 22 | setTimeout(() => { 23 | e.target.classList.remove("animate"); 24 | }, 700); 25 | 26 | const bubblyButtons = document.getElementsByClassName("bubbly-button"); 27 | 28 | for (var i = 0; i < bubblyButtons.length; i++) { 29 | bubblyButtons[i].addEventListener("click", animate, false); 30 | } 31 | }; 32 | 33 | const hexToRGB = (h, opacity) => { 34 | let r = 0, 35 | g = 0, 36 | b = 0; 37 | 38 | // 3 digits 39 | if (h.length == 4) { 40 | r = "0x" + h[1] + h[1]; 41 | g = "0x" + h[2] + h[2]; 42 | b = "0x" + h[3] + h[3]; 43 | 44 | // 6 digits 45 | } else if (h.length == 7) { 46 | r = "0x" + h[1] + h[2]; 47 | g = "0x" + h[3] + h[4]; 48 | b = "0x" + h[5] + h[6]; 49 | } 50 | 51 | return "rgba(" + +r + "," + +g + "," + +b + "," + opacity + ")"; 52 | }; 53 | 54 | return ( 55 | <> 56 | 59 | 202 | 203 | ); 204 | }; 205 | 206 | export default ReactBubblyEffectButton; 207 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 3 | const { CleanWebpackPlugin } = require("clean-webpack-plugin"); 4 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 5 | 6 | module.exports = env => { 7 | const config = { 8 | mode: env.development ? "development" : "production", 9 | // devtool: "inline-source-map", 10 | entry: env.development 11 | ? `${path.resolve(__dirname, "./src/index.js")}` 12 | : `${path.resolve(__dirname, "./src/react-bubbly-effect-button.js")}`, 13 | devServer: { 14 | port: 3000, 15 | watchContentBase: true, 16 | hot: true, 17 | open: true, 18 | historyApiFallback: true 19 | }, 20 | module: { 21 | rules: [ 22 | { 23 | test: /\.js$/, 24 | exclude: /node_modules/, 25 | use: { 26 | loader: "babel-loader", 27 | options: { 28 | presets: ["@babel/preset-env"] 29 | } 30 | } 31 | }, 32 | { 33 | test: /\.(?:ico|gif|png|jpg|jpeg)$/i, 34 | type: "asset/resource" 35 | }, 36 | { 37 | test: /\.(woff(2)?|eot|ttf|otf|svg|)$/, 38 | type: "asset/inline" 39 | } 40 | ] 41 | }, 42 | output: { 43 | path: path.resolve(__dirname, "./dist"), 44 | filename: "index.js", 45 | libraryTarget: "commonjs2" 46 | }, 47 | resolve: { 48 | extensions: [".js", ".jsx"] 49 | }, 50 | plugins: [new CleanWebpackPlugin()] 51 | }; 52 | 53 | if (env.development) { 54 | config.plugins.push( 55 | new HtmlWebpackPlugin({ 56 | template: path.resolve(__dirname, "./public/index.html"), 57 | filename: "index.html" 58 | }) 59 | ); 60 | 61 | config.module.rules.push({ 62 | test: /\.css$/, 63 | use: ["style-loader", "css-loader"] 64 | }); 65 | } 66 | 67 | if (env.production) { 68 | config.plugins.push( 69 | new MiniCssExtractPlugin({ 70 | filename: "index.css" 71 | }) 72 | ); 73 | 74 | config.module.rules.push({ 75 | test: /\.css$/i, 76 | use: [MiniCssExtractPlugin.loader, "css-loader"] 77 | }); 78 | } 79 | 80 | return config; 81 | }; 82 | --------------------------------------------------------------------------------