Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/binocarlos/percent-string

create '%' appended strings for settings CSS properties
https://github.com/binocarlos/percent-string

Last synced: 11 days ago
JSON representation

create '%' appended strings for settings CSS properties

Awesome Lists containing this project

README

        

percent-string
==============

create '%' appended strings for settings CSS properties

## installation

npm:

```
$ npm install percent-string
```

component:

```
$ component install binocarlos/percent-string
```

## usage

Use this module to convert numbers into percent strings

```js
var percent = require('percent-string')

document.querySelector('#thing').style.left = percent(24)
document.querySelector('#thing').style.top = percent('24%')
```

## api

#### `var string = percent(value, max)`

returns a string of the form: [num] + '%' regardless of the input type.

The zero value is '0%'

max indicates the scale so you can do 0.4 = 40%

```js
var st = percent(.4, 1)

// st = '40%'
```

### license

MIT