Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/felixroos/claviature

A versatile SVG piano for the web
https://github.com/felixroos/claviature

Last synced: 2 months ago
JSON representation

A versatile SVG piano for the web

Awesome Lists containing this project

README

        

# Claviature

This lib allows you to render a flexible SVG piano claviature on the web. This package is a successor to [svg-piano](https://github.com/felixroos/svg-piano). To find out more about why this lib exists, check out the [blog post](https://loophole-letters.vercel.app/claviature).

## Install

```sh
npm i claviature --save
```

## Usage

```js
import { getClaviature } from 'claviature';
const svg = getClaviature({
options,
onClick,
onMouseDown,
onMouseUp,
onMouseLeave,
});
console.log(svg);
// do something with svg
```

This library is framework agnostic, which allows it to be framework agnostic.
To render the object you get from `getClaviature`, just wire it up with your favorite view library.

## React example

This is how you render with react:

```js
import { getClaviature } from "claviature";

export default function Claviature({
options,
onClick,
onMouseDown,
onMouseUp,
onMouseLeave,
}: any) {
const svg = getClaviature({
options,
onClick,
onMouseDown,
onMouseUp,
onMouseLeave,
});
return (

{svg.children.map((el, i) => {
const TagName = el.name;
return (

{el.value}

);
})}

);
}
```

## Options

You can customize the claviature using the following options:

### range

```js

```

### palette

```js

```

### stroke

```js

```

### colorize

```js

```

### scaleX + scaleX

```js

```

### upperHeight + lowerHeight

```js

```

### onClick

```js
{
console.log('clicked', key);
alert(`clicked ${key}`);
}}
/>
```

### labels

```js

```

### topLabels

```js

```