The ColorPicker component for Angular allows you to easily pick a color. You can configure the ColorPicker's color mode, input a color in hex or RGB format.
npm install -g @angular/cli ng new jqwidgets-project cd jqwidgets-project
ng add jqwidgets-ng
jQWidgets UI for Angular is distributed as jqwidgets-ng NPM package
npm install jqwidgets-ng
@import 'jqwidgets-ng/jqwidgets/styles/jqx.base.css';
"styles": [ "node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css" ]
<jqxScrollView [theme]="'fluent'" [width]='500' [height]='350' [slideShow]='true' [showButtons]='false'>
<div>
<div class="photo" style="background-image: url(https://www.jqwidgets.com/angular/images/imageNature1.jpg)"></div>
</div>
<div>
<div class="photo" style="background-image: url(https://www.jqwidgets.com/angular/images/imageNature2.jpg)"></div>
</div>
<div>
<div class="photo" style="background-image: url(https://www.jqwidgets.com/angular/images/imageNature3.jpg)"></div>
</div>
<div>
<div class="photo" style="background-image: url(https://www.jqwidgets.com/angular/images/imageNature4.jpg)"></div>
</div>
<div>
<div class="photo" style="background-image: url(https://www.jqwidgets.com/angular/images/imageNature5.jpg)"></div>
</div>
</jqxScrollView>
<br />
<label style="margin-left: 5px; font-size: 12px; font-family: Verdana;">
Select Frame color
</label>
<br />
<jqxDropDownButton [theme]="'fluent'" #dropDownButton style="margin: 3px; float: left"
[width]='150' [height]='22'>
<div style="padding: 3px;">
<jqxColorPicker (onColorchange)="colorPickerEvent($event)"
[width]='220' [height]='220' [colorMode]='"hue"'>
</jqxColorPicker>
</div>
</jqxDropDownButton>
import { Component, ViewChild, AfterViewInit, ViewEncapsulation } from '@angular/core';
import { jqxDropDownButtonModule, jqxDropDownButtonComponent } from 'jqwidgets-ng/jqxdropdownbutton';
import { jqxColorPickerModule } from 'jqwidgets-ng/jqxcolorpicker';
import { jqxScrollViewModule } from 'jqwidgets-ng/jqxscrollview';
@Component({
selector: 'app-root',
imports: [jqxDropDownButtonModule, jqxScrollViewModule, jqxColorPickerModule],
standalone: true,
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
encapsulation: ViewEncapsulation.None
})
export class AppComponent implements AfterViewInit {
@ViewChild('dropDownButton') myDropDown: jqxDropDownButtonComponent;
ngAfterViewInit(): void {
this.myDropDown.setContent(this.getTextElementByColor({ hex: "FFAABB" }));
}
getTextElementByColor(color: any): any {
if (color == 'transparent' || color.hex == "") {
return '<div style="text-shadow: none; position: relative; padding-bottom: 2px; margin-top: 2px;">transparent</div>';
}
let nThreshold = 105;
let bgDelta = (color.r * 0.299) + (color.g * 0.587) + (color.b * 0.114);
let foreColor = (255 - bgDelta < nThreshold) ? 'Black' : 'White';
let element = '<div style="text-shadow: none; position: relative; padding-bottom: 2px; margin-top: 2px;color:' + foreColor + '; background: #' + color.hex + '">#' + color.hex + '</div>';
return element;
}
colorPickerEvent(event: any): void {
this.myDropDown.setContent(this.getTextElementByColor(event.args.color));
(<HTMLElement>document.getElementsByClassName('jqx-scrollview')[0]).style.borderColor = '#' + event.args.color.hex;
}
}