Colorpicker
ES6 color picker extension for Base framework.
Getting Started
Installation
You can install colorpicker as part of base.extensions.
npm install @baianat/base.extensions
yarn add @baianat/base.extensions
If you want the standalone version.
npm install @baianat/colorpicker
yarn add @baianat/colorpicker
Include necessary files
<head>
<link rel="stylesheet" href="dist/css/colorpikcer.css">
</head>
<body>
...
<script type="text/javascript" src="dist/js/colorpikcer.js"></script>
</body>
HTML Layout
You need an input element to track the color value.
<input id="myPicker">
<script>
const picker = new Colorpicker('#myPicker', {
defaultColor = '#ffffff',
radius = 200,
mode = 'rgb',
recentColors = ['#c1c1c1', '#000000', '#ffffff'],
events = {
beforeSelect() {},
afterSelect() {},
beforeOpen() {},
afterOpen() {},
beforeSubmit() {},
afterSubmit() {},
clicked() {}
}
});
picker.el.addEventListener('change', () => {
})
</script>
Methods
You can call method on Colorpicker
instance
const newPicker = new Picker('#myPicker');
newPicker.selectColor('#ff00ff');
Method | Argument | Description |
---|
selectColor | [String] color, [Bool] mute | you can change the selected with color argument. If you want to stop the picker from dispatching events, you can set mute to true. It's false by default. |
getColorFromSliders | | It returns the rgb sliders values as string e.g. "rgb(71, 182, 148)" |
getColorFromWheel | [Object] mouse | It accepts an object, holds the x and y location on the wheel {x: 100, y: 100} , then returns its rgb value |
togglePicker | | show/hide picker menu |
closePicker | | hide picker menu |
openPicker | | show picker menu |
License
MIT
Copyright (c) 2017 Baianat