├── .babelrc ├── .gitignore ├── .npmignore ├── README.md ├── Spinner.js ├── __snapshots__ └── test.js.snap ├── docs ├── build.js └── index.html ├── package.json └── test.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env", 4 | "stage-0", 5 | "react" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | __snapshots__ 2 | docs 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Respin 3 | 4 | React SVG loading spinner based on jxnblk.com/loading 5 | 6 | ```sh 7 | npm i respin 8 | ``` 9 | 10 | ```js 11 | const React = require('react') 12 | const Spinner = require('respin') 13 | 14 | const MyComponent = props => ( 15 |
16 | Loading... 17 |
18 | ) 19 | ``` 20 | 21 | ## Props 22 | 23 | - `size = 16` - (number) - width and height in pixels 24 | - `duration = 1000` - (number) - duration of animation in milliseconds 25 | - `spokes = 8` - (number) - number of spokes in spinner 26 | 27 | Respin passes all other props to the root `` element. 28 | 29 | MIT License 30 | 31 | -------------------------------------------------------------------------------- /Spinner.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | 3 | module.exports = props => { 4 | const { 5 | size = 16, 6 | spokes = 8, 7 | duration = 1000, 8 | ...rest 9 | } = props 10 | 11 | return ( 12 | 19 | {getPaths(spokes, duration)} 20 | 21 | ) 22 | } 23 | 24 | const getPaths = (length, dur) => Array.from({ length }) 25 | .map((n, i) => ( 26 | 32 | 40 | 41 | )) 42 | 43 | const style = { 44 | display: 'inline-flex', 45 | margin: 0 46 | } 47 | -------------------------------------------------------------------------------- /__snapshots__/test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`snapshot 1`] = ` 4 | 16 | 21 | 29 | 30 | 35 | 43 | 44 | 49 | 57 | 58 | 63 | 71 | 72 | 77 | 85 | 86 | 91 | 99 | 100 | 105 | 113 | 114 | 119 | 127 | 128 | 129 | `; 130 | -------------------------------------------------------------------------------- /docs/build.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const path = require('path') 3 | const React = require('react') 4 | const { renderToStaticMarkup } = require('react-dom/server') 5 | const Spinner = require('../Spinner') 6 | 7 | const App = () => ( 8 | 9 | 10 | 11 |

12 | 13 | Respin 14 | 15 |

16 | 17 | ) 18 | 19 | const css = `*{box-sizing:border-box} 20 | body{ 21 | font-family:-apple-system,BlinkMacSystemFont,sans-serif; 22 | margin:0; 23 | padding:32px; 24 | display:flex; 25 | flex-direction:column; 26 | align-items:center; 27 | justify-content:center; 28 | min-height:100vh; 29 | } 30 | a{color:inherit}` 31 | 32 | const html = renderToStaticMarkup() 33 | 34 | const filename = path.join(__dirname, 'index.html') 35 | fs.writeFileSync(filename, `${html}`) 36 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 |

Respin

-------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "respin", 3 | "version": "1.0.1", 4 | "description": "React SVG loading spinner based on jxnblk.com/loading", 5 | "main": "dist/Spinner.js", 6 | "scripts": { 7 | "prepublish": "babel Spinner.js --out-dir dist", 8 | "docs": "babel-node docs/build", 9 | "test": "ava" 10 | }, 11 | "keywords": [ 12 | "react", 13 | "react-component", 14 | "spinner", 15 | "loading", 16 | "loading-indicator" 17 | ], 18 | "author": "Brent Jackson", 19 | "license": "MIT", 20 | "devDependencies": { 21 | "ava": "^0.19.1", 22 | "babel-cli": "^6.24.1", 23 | "babel-core": "^6.24.1", 24 | "babel-preset-env": "^1.4.0", 25 | "babel-preset-react": "^6.24.1", 26 | "babel-preset-stage-0": "^6.24.1", 27 | "babel-register": "^6.24.1", 28 | "react": "^15.5.4", 29 | "react-dom": "^15.5.4", 30 | "react-test-renderer": "^15.5.4" 31 | }, 32 | "ava": { 33 | "require": [ 34 | "babel-register" 35 | ], 36 | "babel": "inherit" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const test = require('ava') 2 | const React = require('react') 3 | const render = require('react-test-renderer').create 4 | const Spinner = require('./Spinner') 5 | 6 | test('snapshot', t => { 7 | const tree = render().toJSON() 8 | t.snapshot(tree) 9 | }) 10 | --------------------------------------------------------------------------------