gradient-generator-ui
Version:
Library to create a gradient generator in vanilla-js with interactive user interface in html
33 lines (32 loc) • 1.15 kB
TypeScript
import { colorPos } from '../Types';
import { ColorControl } from './ColorControl';
export declare class GradientUI {
private mainElement;
private gradientControls;
private observers;
constructor(mainElement: HTMLElement, initialColors: colorPos[]);
/**
* Initialize the UI creating the controls for each color in the list
* @param initialColors List of colors with their respective proportional position
*/
init(initialColors: colorPos[]): void;
/**
* Add an event listener when any color control change it values
* @param cb Callback
*/
onUpdateControls(cb: (ctrls: ColorControl[]) => void): void;
/**
* Get the list of color controls in the UI
*/
getGradientControls(): ColorControl[];
/**
* Add a new color control and add their respective listeners
* @param color A single colors with their respective proportional position
* @param indx Optional position to append in the UI
*/
addElement(newColor: colorPos): void;
/**
* Change the background gradient respect to the color controls
*/
changeGradientBg(): void;
}