|
| 1 | +--- |
| 2 | +title: {Platform} Color Editor | Color Editor | Infragistics |
| 3 | +_description: Color Editor component provides an easily configurable option to change colors for any desirable component or aspect of your application. |
| 4 | +_keywords: {Platform} Color Editor, {ProductName}, Infragistics |
| 5 | +mentionedTypes: ["ColorEditor"] |
| 6 | +namespace: Infragistics.Controls |
| 7 | +--- |
| 8 | + |
| 9 | +# {Platform} Color Editor Overview (preview) |
| 10 | +The {ProductName} Color Editor is a lightweight color picker component. The Color Editor can pop open by clicking the eyedrop icon. Both the rgba and hex values can be obtained from the desired color along the bottom. These values will update when the three sliders are modified. The center box is designed for adjusting the saturation and brightness along with two adjacent sliders for adjusting the rgb and luminance values. Rgb registers between (1-255). The lightness registers between(0-1). |
| 11 | + |
| 12 | +## {Platform} Color Editor Example |
| 13 | + |
| 14 | +`sample="/layouts/color-editor/overview", height="320", alt="{Platform} Color Editor Example"` |
| 15 | + |
| 16 | +<div class="divider--half"></div> |
| 17 | + |
| 18 | +## Dependencies |
| 19 | + |
| 20 | +<!-- Angular, WebComponents, React --> |
| 21 | +First, you need to install the {ProductName} by running the following command: |
| 22 | + |
| 23 | +```cmd |
| 24 | +npm install {PackageCore} |
| 25 | +npm install {PackageInputs} |
| 26 | +``` |
| 27 | + |
| 28 | +Before using the `ColorEditor`, you need to register the following modules as follows: |
| 29 | + |
| 30 | +```ts |
| 31 | +import { IgcColorEditorModule } from "igniteui-angular-inputs"; |
| 32 | + |
| 33 | +@NgModule({ |
| 34 | + imports: [ |
| 35 | + IgcColorEditorModule |
| 36 | + ] |
| 37 | +}) |
| 38 | +export class AppModule {} |
| 39 | +``` |
| 40 | + |
| 41 | +```ts |
| 42 | +import { IgcColorEditorModule, IgcColorEditorComponent } from 'igniteui-webcomponents-inputs'; |
| 43 | + |
| 44 | +ModuleManager.register( |
| 45 | + IgcColorEditorModule |
| 46 | +); |
| 47 | +``` |
| 48 | + |
| 49 | +```tsx |
| 50 | +import { IgrColorEditor, IgrColorEditorModule } from 'igniteui-react'; |
| 51 | +import 'igniteui-webcomponents/themes/light/bootstrap.css'; |
| 52 | + |
| 53 | +IgrColorEditorModule.register(); |
| 54 | +``` |
| 55 | + |
| 56 | +<!-- end:Angular, WebComponents, React --> |
| 57 | + |
| 58 | +<!-- Blazor --> |
| 59 | + |
| 60 | +First, add the **IgniteUI.Blazor.Controls** namespace in the **_Imports.razor** file: |
| 61 | + |
| 62 | +```razor |
| 63 | +@using IgniteUI.Blazor.Controls |
| 64 | +``` |
| 65 | + |
| 66 | +The following modules are required when using the Dashboard Tile component: |
| 67 | + |
| 68 | +```razor |
| 69 | +// in Program.cs file |
| 70 | +builder.Services.AddIgniteUIBlazor( |
| 71 | + typeof(IgbColorEditorModule) |
| 72 | +); |
| 73 | +``` |
| 74 | + |
| 75 | +<!-- end: Blazor --> |
| 76 | + |
| 77 | +For a complete introduction to the {ProductName}, read the [*Getting Started*](../general-getting-started.md) topic. |
| 78 | + |
| 79 | +## Usage |
| 80 | + |
| 81 | +The simplest way to start using the `ColorEditor` is as follows: |
| 82 | + |
| 83 | +<!-- Angular --> |
| 84 | +```html |
| 85 | +<igx-color-editor |
| 86 | + name="colorEditor" |
| 87 | + #colorEditor> |
| 88 | + </igx-color-editor> |
| 89 | +</div> |
| 90 | +``` |
| 91 | +<!-- end: Angular --> |
| 92 | + |
| 93 | +<!-- WebComponents --> |
| 94 | +```html |
| 95 | +<igc-color-editor |
| 96 | + name="colorEditor" |
| 97 | + id="colorEditor"> |
| 98 | +</igc-color-editor> |
| 99 | +``` |
| 100 | +<!-- end: WebComponents --> |
| 101 | + |
| 102 | +<!-- React --> |
| 103 | +```tsx |
| 104 | +<IgrColorEditor |
| 105 | + ref={this.colorEditorRef}> |
| 106 | +</IgrColorEditor> |
| 107 | +``` |
| 108 | +<!-- end:React --> |
| 109 | + |
| 110 | +<!-- Blazor --> |
| 111 | +```razor |
| 112 | +<IgbColorEditor> |
| 113 | +</IgbColorEditor> |
| 114 | +``` |
| 115 | +<!-- end:Blazor --> |
| 116 | + |
| 117 | +## Binding to events |
| 118 | + |
| 119 | +The Color Editor component raises the following events: |
| 120 | + |
| 121 | +- valueChanged |
| 122 | +- valueChanging |
| 123 | + |
| 124 | +<!-- Angular --> |
| 125 | +```ts |
| 126 | +@ViewChild("colorEditor", { static: true } ) |
| 127 | +private colorEditor: IgxColorEditorComponent |
| 128 | +public ngAfterViewInit(): void |
| 129 | +{ |
| 130 | + this.colorEditor.valueChanged.subscribe(this.onValueChanged); |
| 131 | +} |
| 132 | + |
| 133 | +public onValueChanged = (e: any) => { |
| 134 | + console.log("test"); |
| 135 | +} |
| 136 | +``` |
| 137 | +<!-- end: Angular --> |
| 138 | + |
| 139 | +<!-- WebComponents --> |
| 140 | +```ts |
| 141 | +this.OnValueChanged = this.OnValueChanged.bind(this); |
| 142 | +this.colorEditor = document.getElementById('colorEditor') as IgcColorEditorComponent; |
| 143 | +this.colorEditor.valueChanged = this.OnValueChanged; |
| 144 | +``` |
| 145 | +<!-- end: WebComponents --> |
| 146 | + |
| 147 | +<!-- Blazor --> |
| 148 | +```razor |
| 149 | +<IgbColorEditor ValueChanged="@OnValueChanged" /> |
| 150 | +
|
| 151 | +@code { |
| 152 | + public void OnValueChanged(IgbColorEditorPanelSelectedValueChangedEventArgs e) |
| 153 | + { |
| 154 | +
|
| 155 | + } |
| 156 | +} |
| 157 | +``` |
| 158 | +<!-- end:Blazor --> |
| 159 | + |
| 160 | +<!-- React --> |
| 161 | +```tsx |
| 162 | +<IgrColorEditor valueChanged={this.onValueChanged} /> |
| 163 | + |
| 164 | +public onValueChanged(calendar: IgrColorEditor, e: IgrColorEditorPanelSelectedValueChangedEventArgs) { |
| 165 | + |
| 166 | +} |
| 167 | +``` |
| 168 | +<!-- end: React --> |
| 169 | + |
| 170 | +<div class="divider--half"></div> |
| 171 | + |
| 172 | +## API References |
| 173 | + |
| 174 | + - `ColorEditor` |
| 175 | + |
| 176 | +## Additional Resources |
| 177 | + |
| 178 | +* [{ProductName} **Forums**]({ForumsLink}) |
| 179 | +* [{ProductName} **GitHub**]({GithubLink}) |
0 commit comments