https://github.com/rvenkatesh/ember-slider
Slider (and likert scale) addon for ember apps
https://github.com/rvenkatesh/ember-slider
ember ember-addon javascript likert likert-scale-survey range slider slider-component slider-plugin sliders
Last synced: 3 months ago
JSON representation
Slider (and likert scale) addon for ember apps
- Host: GitHub
- URL: https://github.com/rvenkatesh/ember-slider
- Owner: RVenkatesh
- License: mit
- Created: 2018-07-19T17:55:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-13T02:51:28.000Z (about 1 year ago)
- Last Synced: 2025-04-01T22:35:23.865Z (9 months ago)
- Topics: ember, ember-addon, javascript, likert, likert-scale-survey, range, slider, slider-component, slider-plugin, sliders
- Language: JavaScript
- Homepage: https://rvenkatesh.github.io/Ember-Slider/
- Size: 4.48 MB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ember-slider [](https://travis-ci.org/RVenkatesh/Ember-Slider) [](https://badge.fury.io/js/%40love-open-source%2Fember-slider)[](https://openbase.io/js/@love-open-source/ember-slider?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
This slider is built as an addon for ember applications. This also supports [likert scale](https://en.wikipedia.org/wiki/Likert_scale). Follow the instructions in the [demo](https://github.com/RVenkatesh/Ember-slider#demo) section to see it in action.
## Screenshots
##### Basic slider
| type="closed" | type="sleek" |
| --- | --- |
|  |  |
##### Likert scale slider
| type="closed" | type="sleek" |
| --- | --- |
|  |  |
## Demo
The demo for this addon is available at https://rvenkatesh.github.io/Ember-Slider/
or alternatively you can also clone the repository and run it locally by following the below instructions
* `git clone ` this repository
* `cd ember-slider`
* `npm install`
* `ember serve`
* Demo will be available at [http://localhost:4200](http://localhost:4200).
## Installation
```
npm install @love-open-source/ember-slider --save
```
or
```
ember install @love-open-source/ember-slider
```
Note that versions below v1.2.0 used [compass](http://compass-style.org/) for compiling the styles. If you do not have it already, please follow [this link](http://compass-style.org/install/) to install it before installing addon.
## How to use
Include the ember slider component in the template like any other normal ember component
```
{{ember-slider config=options}}
or
```
Add configuration options if necessary in the corresponding route's controller or component's class
```
{
type: 'closed',
range: {
min: 0,
max: 100
}
}
```
Refer [Configurations options](https://github.com/RVenkatesh/Ember-slider#configuration-options) section for details about the different options available.
## Parameters
The component provides different parameters as mentioned below. These can be used as ```{{ember-slider initialValue=50 config=options onChange=(action 'onChangeAction')}}```
| Params | Default value | Description |
| --- | --- | --- |
| initialValue | ```0``` | To load the slider with value other than min value. |
| config | ```null``` | General settings for the slider like range, likert and more. Refer [Configurations options](https://github.com/RVenkatesh/Ember-slider#configuration-options) section for details about the different options available. |
##### Callback parameters
Apart from the above parameters, following are the callbacks provided by the addon.
| Function | Params | Description |
| --- | --- | --- |
| onChange | ```( oldValue, newValue )``` | This is called when the value of the slider changes. |
## Options under _'config'_ options
These are the different options available under 'config' parameter of the slider.
| Option | Default value | Description |
| --- | --- | --- |
| type | 'sleek' | Changes the look and feel of the slider. Currently it supports only 'sleek' and 'closed'. |
| range | { min: 0, max: 100 } | This object can be used to change the min and max of the slider. This can be of following format. ```{ min: `min_value`, max: `max_value` }``` |
| hideValue | false | Boolean to show or hide the value of the slider. ```true``` hides the value. |
| likert | {} | Settings for likert scale. Refer section [Likert scale options](https://github.com/RVenkatesh/Ember-Slider#likert-scale-options) to know more about likert configuration. |
##### Likert scale options
The 'likert' property under config option provides the settings for likert scale. Likert scale can be enabled by passing the following to 'config' parameter of the slider
```
{
likert: {
enabled: true
}
}
```
Just enabling likert scale would provide a 3-point likert scale slider with values ranging from 0 to 2. It can be customised by the following configuration options available.
| Option | Default | Description |
| --- | --- | --- |
| enabled | false | Enable or disable likert scale |
| points | 3 | Number of likert points to be shown. As of now ```ember-slider``` supports 3, 5 and 7 points. |
| labels | [] | Label text to be displayed under each likert point of the slider. If nothing has to be displayed, pass ```null``` |
## Generating custom slider theme color
Ember slider provides a blueprint, using which you can change the look and feel (colors & size) of the slider within minutes. Run the blueprint with your preferred color values and the amount of scaling you need, it will give you the scss file with autogenerated code. To make use of the generator, you must have [ember-cli-compass-compiler](https://github.com/quaertym/ember-cli-compass-compiler) installed in your application.
##### Syntax
```
ember g custom-slider
```
Following are the options available.
- --pathcolor - `` Background color of the handle movement path
- --fillerColor - `` Background color of the region selected
- --handleColor - `` Background color of the handle
- --classList - `` CSS classname to be given to the generated slider
- --scale - `` Amount by which the entire slider needs to be scaled. Default is 1.
##### Examples
1. To generate a red colored slider, you can do
```
ember g custom-slider red-slider --pathColor="#f5f5f5" --classList="red" --fillerColor="rgba(#ff6b43, .3)" --handleColor="#ff6b43"
```
The above command will generate a file called `_red-slider.scss` inside `app/styles` directory of your application.
2. You can also generate 2 or more sliders at the same time.
```
ember g custom-slider all-sliders --classList="red green" --pathColor="#f5f5f5 #f5f5f5" --fillerColor="rgba(#ff6b43, .3) rgba(#79c03b, .3)" --handleColor="#ff6b43 #79c03b" --scale="1 0.9"
```
## Updating ember-slider
If you are updating one version of ember slider to other, please check out the [Release notes](https://github.com/RVenkatesh/Ember-Slider/wiki/Release-notes) page for any breaking changes (which are usually rare).