├── .travis.yml ├── example ├── src │ ├── index.css │ ├── ribbon.png │ ├── index.js │ ├── DemoBlock.css │ ├── App.js │ ├── DemoBlock.js │ └── demos.js ├── demo.gif ├── public │ ├── manifest.json │ └── index.html ├── package.json └── README.md ├── src ├── .eslintrc ├── test.js ├── styles.css └── index.js ├── .babelrc ├── .editorconfig ├── .gitignore ├── .eslintrc ├── rollup.config.js ├── LICENSE ├── package.json └── readme.md /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 9 4 | - 8 5 | -------------------------------------------------------------------------------- /example/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /example/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transitive-bullshit/react-particle-effect-button/HEAD/example/demo.gif -------------------------------------------------------------------------------- /src/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "expect": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /example/src/ribbon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transitive-bullshit/react-particle-effect-button/HEAD/example/src/ribbon.png -------------------------------------------------------------------------------- /src/test.js: -------------------------------------------------------------------------------- 1 | import ExampleComponent from './' 2 | 3 | describe('ExampleComponent', () => { 4 | it('is truthy', () => { 5 | expect(ExampleComponent).toBeTruthy() 6 | }) 7 | }) 8 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false 5 | }], 6 | "stage-0", 7 | "react" 8 | ], 9 | "plugins": [ 10 | "external-helpers" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.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 React from 'react' 2 | import ReactDOM from 'react-dom' 3 | 4 | import './index.css' 5 | import App from './App' 6 | 7 | ReactDOM.render(, document.getElementById('root')) 8 | -------------------------------------------------------------------------------- /example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "react-particle-effect-button", 3 | "name": "react-particle-effect-button", 4 | "start_url": "./index.html", 5 | "display": "standalone", 6 | "theme_color": "#000000", 7 | "background_color": "#ffffff" 8 | } 9 | -------------------------------------------------------------------------------- /.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 | 11 | # misc 12 | .DS_Store 13 | .env 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | .particles { 2 | position: relative; 3 | display: inline-block; 4 | } 5 | 6 | .wrapper { 7 | position: relative; 8 | display: inline-block; 9 | overflow: hidden; 10 | } 11 | 12 | .content:focus, 13 | .content > *:focus { 14 | outline: none; 15 | } 16 | 17 | .canvas { 18 | position: absolute; 19 | top: 50%; 20 | left: 50%; 21 | transform: translate3d(-50%, -50%, 0); 22 | pointer-events: none; 23 | } 24 | -------------------------------------------------------------------------------- /example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | react-particle-effect-button 11 | 12 | 13 | 14 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-particle-effect-button-example", 3 | "homepage": "https://transitive-bullshit.github.io/react-particle-effect-button", 4 | "version": "0.0.0", 5 | "private": true, 6 | "license": "MIT", 7 | "dependencies": { 8 | "prop-types": "^15.6.1", 9 | "react": "^16.2.0", 10 | "react-dom": "^16.2.0", 11 | "react-particle-effect-button": "link:..", 12 | "react-scripts": "^1.1.1" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test --env=jsdom", 18 | "eject": "react-scripts eject" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": [ 4 | "standard", 5 | "standard-react" 6 | ], 7 | "env": { 8 | "es6": true 9 | }, 10 | "plugins": [ 11 | "react" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module", 15 | "allowImportExportEverywhere": true 16 | }, 17 | "rules": { 18 | // don't force es6 functions to include space before paren 19 | "space-before-function-paren": 0, 20 | 21 | // allow specifying true explicitly for boolean props 22 | "react/jsx-boolean-value": 0, 23 | 24 | // allow imports mixed with non-import statements at top of file 25 | "import/first": 0 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel' 2 | import commonjs from 'rollup-plugin-commonjs' 3 | import external from 'rollup-plugin-peer-deps-external' 4 | import postcss from 'rollup-plugin-postcss' 5 | import resolve from 'rollup-plugin-node-resolve' 6 | import url from 'rollup-plugin-url' 7 | 8 | import pkg from './package.json' 9 | 10 | export default { 11 | input: 'src/index.js', 12 | output: [ 13 | { 14 | file: pkg.main, 15 | format: 'cjs' 16 | }, 17 | { 18 | file: pkg.module, 19 | format: 'es' 20 | } 21 | ], 22 | plugins: [ 23 | external(), 24 | postcss({ 25 | modules: true 26 | }), 27 | url(), 28 | babel({ 29 | exclude: 'node_modules/**' 30 | }), 31 | resolve(), 32 | commonjs() 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /example/src/DemoBlock.css: -------------------------------------------------------------------------------- 1 | .buttons-div-container{ 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | align-items: center; 6 | justify-content: center; 7 | width: 46vmax; 8 | height: 4vmax; 9 | margin: 2vmax 2vmax 0 0; 10 | } 11 | 12 | .animation-reset-button{ 13 | position: absolute; 14 | top: 1rem; 15 | right: 1rem; 16 | background-color: #32bafa; 17 | color : #fff; 18 | border: 0; 19 | border-radius: 4; 20 | font-size: 1rem; 21 | padding: 0.7rem 1.2rem; 22 | cursor: pointer; 23 | outline: none; 24 | } 25 | 26 | 27 | .particle-effect-button{ 28 | background-color: #121019; 29 | color: #fff; 30 | font-size: 1.2rem; 31 | border: 0; 32 | padding: 1.5rem 3rem; 33 | border-radius: 5; 34 | cursor: pointer; 35 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Travis Fischer 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 | -------------------------------------------------------------------------------- /example/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | 3 | import DemoBlock from './DemoBlock' 4 | import demos from './demos' 5 | import ribbon from './ribbon.png' 6 | 7 | export default class App extends Component { 8 | render () { 9 | return ( 10 |
19 | 20 | Fork me on GitHub 31 | 32 | 33 |

34 | React Particle Effect Buttons 35 |

36 | 37 |
45 | {demos.map((demo, index) => ( 46 | 53 | ))} 54 |
55 |
56 | ) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /example/src/DemoBlock.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import './DemoBlock.css' 3 | import PropTypes from 'prop-types' 4 | 5 | import ParticleEffectButton from 'react-particle-effect-button' 6 | 7 | export default class DemoBlock extends Component { 8 | static propTypes = { 9 | background: PropTypes.string.isRequired, 10 | text: PropTypes.string.isRequired, 11 | buttonStyles: PropTypes.object.isRequired, 12 | buttonOptions: PropTypes.object.isRequired 13 | } 14 | 15 | state = { 16 | hidden: false, 17 | animating: false 18 | } 19 | 20 | render() { 21 | const { 22 | background, 23 | text, 24 | buttonStyles, 25 | buttonOptions 26 | } = this.props 27 | 28 | const { 29 | hidden, 30 | animating 31 | } = this.state 32 | 33 | return ( 34 |
38 | {hidden && !animating && ( 39 | 45 | )} 46 | 47 | 60 |
61 | ) 62 | } 63 | 64 | _onToggle = () => { 65 | if (this.state.animating) return 66 | 67 | this.setState({ 68 | hidden: !this.state.hidden, 69 | animating: true 70 | }) 71 | } 72 | 73 | _onAnimationComplete = () => { 74 | this.setState({ 75 | animating: false 76 | }) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-particle-effect-button", 3 | "version": "1.0.1", 4 | "description": "Bursting particle effect buttons for React.", 5 | "author": "transitive-bullshit", 6 | "license": "MIT", 7 | "repository": "transitive-bullshit/react-particle-effect-button", 8 | "main": "dist/index.js", 9 | "module": "dist/index.es.js", 10 | "jsnext:main": "dist/index.es.js", 11 | "scripts": { 12 | "test": "cross-env CI=1 react-scripts test --env=jsdom", 13 | "test:watch": "react-scripts test --env=jsdom", 14 | "build": "rollup -c", 15 | "start": "rollup -c -w", 16 | "prepare": "yarn run build", 17 | "predeploy": "cd example && yarn install && yarn run build", 18 | "deploy": "gh-pages -d example/build" 19 | }, 20 | "dependencies": { 21 | "animejs": "^2.2.0", 22 | "classnames": "^2.2.5", 23 | "raf": "^3.4.0" 24 | }, 25 | "peerDependencies": { 26 | "prop-types": "^15.5.4", 27 | "react": "^15.0.0 || ^16.0.0", 28 | "react-dom": "^15.0.0 || ^16.0.0" 29 | }, 30 | "devDependencies": { 31 | "babel-core": "^6.26.0", 32 | "babel-eslint": "^8.2.1", 33 | "babel-plugin-external-helpers": "^6.22.0", 34 | "babel-preset-env": "^1.6.0", 35 | "babel-preset-react": "^6.24.1", 36 | "babel-preset-stage-0": "^6.24.1", 37 | "cross-env": "^5.1.4", 38 | "eslint": "^4.19.1", 39 | "eslint-config-standard": "^11.0.0", 40 | "eslint-config-standard-react": "^6.0.0", 41 | "eslint-plugin-import": "^2.11.0", 42 | "eslint-plugin-node": "^6.0.1", 43 | "eslint-plugin-promise": "^3.7.0", 44 | "eslint-plugin-react": "^7.7.0", 45 | "eslint-plugin-standard": "^3.0.1", 46 | "gh-pages": "^1.1.0", 47 | "react": "^16.2.0", 48 | "react-dom": "^16.2.0", 49 | "react-scripts": "^1.1.1", 50 | "rollup": "^0.54.0", 51 | "rollup-plugin-babel": "^3.0.3", 52 | "rollup-plugin-commonjs": "^8.2.1", 53 | "rollup-plugin-node-resolve": "^3.0.2", 54 | "rollup-plugin-peer-deps-external": "^2.0.0", 55 | "rollup-plugin-postcss": "^1.1.0", 56 | "rollup-plugin-url": "^1.3.0" 57 | }, 58 | "files": [ 59 | "dist" 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # react-particle-effect-button ([demo](https://transitive-bullshit.github.io/react-particle-effect-button/)) 2 | 3 | > Bursting particle effect buttons for React. 4 | 5 | [![NPM](https://img.shields.io/npm/v/react-particle-effect-button.svg)](https://www.npmjs.com/package/react-particle-effect-button) [![Build Status](https://travis-ci.com/transitive-bullshit/react-particle-effect-button.svg?branch=master)](https://travis-ci.com/transitive-bullshit/react-particle-effect-button) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 6 | 7 | [![Demo](https://raw.githubusercontent.com/transitive-bullshit/react-particle-effect-button/master/example/demo.gif)](https://transitive-bullshit.github.io/react-particle-effect-button/) 8 | 9 | This library is a React port of an awesome [Codrops Article](https://tympanus.net/codrops/2018/04/25/particle-effects-for-buttons/) by [Luis Manuel](https://tympanus.net/codrops/author/luis/) (original [source](https://github.com/codrops/ParticleEffectsButtons/)). 10 | 11 | ## Install 12 | 13 | ```bash 14 | npm install --save react-particle-effect-button 15 | ``` 16 | 17 | ## Usage 18 | 19 | Check out the [Demo](https://transitive-bullshit.github.io/react-particle-effect-button/) to see it in action. 20 | 21 | ```jsx 22 | import React, { Component } from 'react' 23 | 24 | import ParticleEffectButton from 'react-particle-effect-button' 25 | 26 | class App extends Component { 27 | state = { 28 | hidden: false 29 | } 30 | 31 | render () { 32 | return ( 33 | 39 | ) 40 | } 41 | } 42 | ``` 43 | 44 | Note that `children` can be anything from a simple `