2.0.1 • Published 3 years ago

@kevinorriss/react-metronome v2.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

Metronome

React Metronome

A ReactJS Metronome component inspired by Google's implementation

Uses the Web Audio API and Web Worker API to create a metronome that doesn't drift and doesn't suffer from the non-guaranteed nature of Javascript's setInterval function.

Prerequisites

Installing

npm install @kevinorriss/react-metronome

Usage

Import the component

import Metronome from '@kevinorriss/react-metronome'
...

<!-- JSX -->
<div className="your-container">
    <Metronome />
</div>

Props

All of the Metronome props are optional, providing the ability to make style and functional changes

NameDatatypeDefaultDescription
playPauseStyleObject{}The style to apply to the PLAY / PAUSE button
bpmStyleObject{}The style to apply to the BPM number
bpmTagStyleObject{}The style to apply to the 'BPM' text after the number
plusStyleObject{}The style to apply to the PLUS BPM + button
minusStyleObject{}The style to apply to the MINUS BPM - button
handleStyleObject{}The style to apply to the slider handle
trackStyleObject{}The style to apply to the slider track
railStyleObject{}The style to apply to the slider rail
sliderStyleObject{}The style to apply to the DIV containing the slider and +/- buttons
minBpmNumber40The minimum BPM that can be set via the slider and buttons
maxBpmNumber200The maximum BPM that can be set via the slider and buttons
startBpmNumber100The default BPM
volumeNumber0.1The volume of the metronome (between 0 and 1)
frequencyNumber440The frequency (in hertz) of the beep

Development

This repo comes with a react app for development purposes. To get started, open a terminal in the root of the project and then:

Link the component to the app

cd ./component
npm link

cd ..
npm link @kevinorriss/react-metronome

Start the app

npm start

Start the rollup watcher

cd ./component
npm run dev

Whenever you make a change to the component code, the react app will update.

Tests

cd component
npm test

This project uses Jest and Enzyme for its unit tests, simply run the above code to run the test suites.

Author

License

This project is licensed under the ISC License