atomic-spinner
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -11,11 +11,3 @@ "use strict"; | ||
const React = __importStar(require("react")); | ||
const defaultColors = ['red', 'green', 'blue']; | ||
let unusedColors = []; | ||
const getRandomElectronPathOrbitTime = () => 2 + Math.random() * 1; | ||
const getNextRandomColor = () => { | ||
if (!unusedColors.length) { | ||
unusedColors = [...defaultColors]; | ||
} | ||
return unusedColors.splice(Math.floor(Math.random() * (unusedColors.length)), 1)[0]; | ||
}; | ||
function Nucleus({ particleFillColor, particleBorderColor, particleCount, particleSize, distanceFromCenter }) { | ||
@@ -40,5 +32,12 @@ const startingAngle = Math.random() * 2 * Math.PI; | ||
exports.ElectronPath = ElectronPath; | ||
function Electron({ rotationAngle, orbitTime, spacetimeOffset, size }) { | ||
function Electron({ rotationAngle, orbitTime, spacetimeOffset, size, colorPalette }) { | ||
let unusedColors = []; | ||
const getRandomElectronColor = () => { | ||
if (!unusedColors.length) { | ||
unusedColors = [...colorPalette]; | ||
} | ||
return unusedColors.splice(Math.floor(Math.random() * (unusedColors.length)), 1)[0]; | ||
}; | ||
return (React.createElement("g", { transform: `rotate(${rotationAngle} 50 50)` }, | ||
React.createElement("circle", { cx: "50", cy: "15", r: size, fill: getNextRandomColor() }, | ||
React.createElement("circle", { cx: "50", cy: "15", r: size, fill: getRandomElectronColor() }, | ||
React.createElement("animateMotion", { dur: `${orbitTime}s`, repeatCount: "indefinite", begin: `${spacetimeOffset}s` }, | ||
@@ -48,3 +47,3 @@ React.createElement("mpath", { xlinkHref: "#electron" }))))); | ||
exports.Electron = Electron; | ||
function AtomicSpinner({ atomSize = 200, displayElectronPaths = true, displayNucleus = true, electronPathCount = 3, electronPathColor = '#707070', electronPathWidth = 0.5, electronsPerPath = 2, electronSize = 1.5, nucleusParticleFillColor = '#707070', nucleusParticleBorderColor = '#999', nucleusParticleCount = 6, nucleusParticleSize = 2.5, nucleusDistanceFromCenter = 2.5 }) { | ||
function AtomicSpinner({ atomSize = 200, displayElectronPaths = true, displayNucleus = true, electronColorPalette = ['#0081C9', '#5BC0F8', '#86E5FF'], electronPathCount = 3, electronPathColor = '#707070', electronPathWidth = 0.5, electronsPerPath = 2, electronSize = 1.5, nucleusParticleFillColor = '#707070', nucleusParticleBorderColor = '#999', nucleusParticleCount = 6, nucleusParticleSize = 2.5, nucleusDistanceFromCenter = 2.5 }) { | ||
const electronPaths = Array.from({ length: electronPathCount }) | ||
@@ -65,4 +64,4 @@ .map((_, i) => ({ | ||
electronPaths.map(({ electronCount, rotationAngle, electronOrbitTime }) => Array.from({ length: electronCount }) | ||
.map((_, i) => (React.createElement(Electron, { key: `electron-${i}`, rotationAngle: rotationAngle, orbitTime: electronOrbitTime, size: electronSize, spacetimeOffset: -electronOrbitTime + i * (electronOrbitTime / (electronCount)) })))))); | ||
.map((_, i) => (React.createElement(Electron, { key: `electron-${i}`, rotationAngle: rotationAngle, orbitTime: electronOrbitTime, size: electronSize, spacetimeOffset: -electronOrbitTime + i * (electronOrbitTime / (electronCount)), colorPalette: electronColorPalette })))))); | ||
} | ||
exports.default = React.memo(AtomicSpinner); |
{ | ||
"name": "atomic-spinner", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Loading spinner that looks like an atom", | ||
@@ -8,3 +8,3 @@ "author": "David Lounsbrough", | ||
"repository": "Codenough-LLC/atomic-spinner", | ||
"main": "dist/index.js", | ||
"main": "dist/index.min.js", | ||
"engines": { | ||
@@ -14,3 +14,4 @@ "node": ">=14" | ||
"scripts": { | ||
"build": "rm -rf dist && tsc" | ||
"build": "rm -rf dist && tsc && pnpm minify", | ||
"minify": "uglifyjs --compress -o dist/index.min.js -- dist/index.js" | ||
}, | ||
@@ -39,8 +40,7 @@ "keywords": [ | ||
"@types/react-dom": "^18.0.10", | ||
"babel-core": "^6.26.3", | ||
"babel-runtime": "^6.26.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"typescript": "^2.9.2" | ||
"typescript": "^2.9.2", | ||
"uglify-js": "^3.17.4" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10543
6
5
64
2