Simple Ember component wrapper for the Spectrum.js color picker.
npm install ember-spectrum-color-pickerember-spectrum-color-picker
==============================================================================
Simple Ember color picker component based on spectrum.js.
Compatibility
------------------------------------------------------------------------------
* Ember.js v3.4 or above
* Ember CLI v2.13 or above
* Node.js v8 or above
Installation
------------------------------------------------------------------------------
```
ember install ember-spectrum-color-picker
Usage
------------------------------------------------------------------------------
Example:
` handlebars`
{{spectrum-color-picker color=teamColor}}
The color property should be set and will be updated through Ember's two-way bindings.
It's also possible to bind actions to the onChange, onMove, onShow, and onHide attributes. The action handler will receive the new color as a
parameter:
` handlebars`
{{spectrum-color-picker
color=teamColor
onChange=(action "colorChanged")
onShow=(action "pickerOpened")
onHide=(action "pickerClosed")
onMove=(action "userMovedColorPicker")
}}
The following properties can be set to customize a particular color picker:
* allowEmpty (default: false): whether or not the color value may be null.disabled
* (default: false): when set to true, the color picker is disabled.showInput
* (default: false): whether or not to show an input field in the color picker with the current colorpreferredFormat
value.
* (default: null): the preferred format for the color values displayed in the input. Values can be"hex"
, "hex3", "hsl", "rgb" or "name". When set to null, the format will adapt to a previously enteredshowAlpha
format.
* (default: false): whether or not to allow setting the alpha value in the color picker.showInitial
* (default: false): whether or not to show a box with the original color for comparison.showButtons
* (default: true): whether or not to show the 'choose' and 'cancel' buttons.showPalette
* (default: false): whether or not to show a color palette.showPaletteOnly
* (default: false): when set to true, only a color palette is shown.palette
* (default: []): array of color values to show in the palette. Can be an array of arrays, where each arraypalette='[["red","lime"],["yellow","blue"]]'
is a row in the palette. Pass this as a JSON string in the HBS file, like
.togglePaletteOnly
* (default: false): initialy shows only the palette, but a 'more' button can be clicked for customshowSelectionPalette
colors.
* (default: false): shows a palette with the colors that were picked previously by the user.hideAfterPaletteSelect
* (default: false): when set to true, the palette will close when a color is selected.maxSelectionSize
* (default: 7): sets the maximum number of colors shown on the palette.moveFiresChange
* (default: false): when set to true, the color value will be updated in real time, instead of onlyclickoutFiresChange
once the user clicks the 'choose' button.
* (default: false): when set to true, the color value will also update when the user clickschooseText
outside the widget, instead of only once the user clicks the 'choose' button.
* (default: 'Choose'): the text displayed on the 'choose' button.cancelText
* (default: 'Cancel'): the text displayed on the 'cancel' button.togglePaletteMoreText
* (default: 'More'): the text displayed on the 'more' button when togglePaletteOnly is settogglePaletteLessText
to true.
* (default: 'Less'): the text displayed on the 'less' button when togglePaletteOnly is setappendTo
to true.
* (default: 'body'): the element the color picker widget is appended to. Changing this can help resolvelocalStorageKey
issues with opening the colorpicker in a modal dialog or fixed position container, for instance.
* (default: 'spectrum-color-picker'): the key used for local storage when showSelectionPalette isflatMode
set to true.
* (default: false): when set to true, the color picker is always shown fully expanded.
For a more detailed documentation on these options, see the spectrum.js documentation.
If you want to set different defaults for all color pickers in your application, extend the component and override the
defaults with your own:
`javascript
// app/components/spectrum-color-picker.js
import SpectrumColorPickerComponent from 'ember-spectrum-color-picker/components/spectrum-color-picker';
export default SpectrumColorPickerComponent.extend({
showInput: true,
showAlpha: true
});
``
Contributing
------------------------------------------------------------------------------
See the Contributing guide for details.
License
------------------------------------------------------------------------------
This project is licensed under the MIT License.