# j-ColorPicker

> j-ColorPicker: Component is singleton; Simple color picker

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 84ee07ce8fa88a978c47b0652aeeca48ac152ef9cb0e593b870aa82361df5844
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- Component is __singleton__
- Simple color picker
- Supports __Dark theme__


## Usage

```javascript
var opt = {};

// opt.offsetX {Number}    : adds X offset (default: 0)
// opt.offsetY {Number}    : adds Y offset (default: 0)
// opt.align {String}      : align `left` (default), `center` or `right`
// opt.position {String}   : position `top` (default) or `bottom`
// opt.opacity {Number}    : converts hex color to RGBA with the opacity e.g. 0.3

opt.element = YOUR_ELEMENT;
// or if you want to use a fixed position:
// opt.x {Number}          : `x` position
// opt.y {Number}          : `y` position

opt.callback = function(color) {
	console.log(color); // callback parameter has string with HEX color (like #bada55)
};

SETTER('colorpicker/show', opt);
```

Use it with `<ui-component name="colorpicker">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Denis Granec. Source: the Componentator components repository, MIT license.

```html example.html
<ui-component name="colorpicker"></ui-component>

<div class="container">
	<div class="row">
		<div class="col-xs-4 col-xs-offset-4" style="text-align:center">
			<a href="javascript:void(0)" style="color:black;font-size:30px"><i class="ti ti-dropper"></i></a>
		</div>
	</div>
</div>

<script>
	$(document).on('click', 'a', function() {
		var opt = {};
		opt.align = 'center';
		opt.position = 'top';
		opt.element = this;
		opt.callback = function(color) {
			alert(color);
		};
		SETTER('colorpicker/show', opt);
	});
</script>
```
