2.0.6 • Published 12 months ago

xylophone-react v2.0.6

Weekly downloads
149
License
ISC
Repository
github
Last release
12 months ago

Xylophone

A React based xylophone ready to use out of the box

Play!

šŸŽ¶ https://lauraaubin.github.io/xylophone/

Install

Your app must be using React and ReactDom.

$ npm install xylophone-react

Usage

import Xylophone from 'xylophone-react';

return <Xylophone />;

Props

PropDefaultValuesTypeDescription
keyCount121 - āˆžnumberThe number of keys
colorsDefault color mapNo limits{color?: string, colorPressed?: string, background?: string}[]The color scheme of all keys
shapeshrinkingshrinking, growing, flatstringThe shape of the whole xylophone
height2001 - āˆžnumberThe height of the smallest key (px)
widthStretch to fit container1 - āˆžnumberThe width of all keys (px)
startingOctave21 - āˆžnumberThe starting octave of the first key
pressedKeyNoneNone(number) => voidReturns which key was pressed most recently

numberOfKeys

  • 12 colors have been set by default. In order to increase the numberOfKeys over 12, you need to create your own custom color scheme.

colors

  • Pass in a custom color in the form of a hex code or named value.
  • colors will use the last element to paint all remaining keys. For example, the following will paint the first key pink, and all remaining keys teal:
colors={[
  {
    color: 'pink',
    colorPressed: 'grey',
    background: 'salmon'
  },
  {
    color: 'teal'
  }
]}

pressedKey:

  • pressedKey allows you to pass in a function which can be used to determine which key was pressed most recently:
const handleKeyPress = (number) => {
  ...
}

...

<Xylophone
  pressedKey={handleKeyPress}
/>

Develop

Changes should only be made within the ./components folder. The ES5 folder is the compiled equivalent. ES5 compiles Sass to CSS:

yarn compile-files

Install package locally via:

npm install path/to/this/folder

Feedback

Feel free to open an issue with feedback or a feature request. All are welcome šŸ¤—!

2.0.3

12 months ago

2.0.2

12 months ago

2.0.5

12 months ago

2.0.4

12 months ago

2.0.6

12 months ago

2.0.1

12 months ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago