Skip to content
Snippets Groups Projects
Commit 3b323148 authored by Cindy's avatar Cindy Committed by bouhaddouzay
Browse files

fix tslint error

parent 00620172
No related branches found
No related tags found
No related merge requests found
export enum ColorErrorEnum {
NONE,
COLOR_INVALID,
COLOR_TOO_LIGHT,
COLOR_TOO_DARK
}
\ No newline at end of file
NONE,
COLOR_INVALID,
COLOR_TOO_LIGHT,
COLOR_TOO_DARK
}
import {Component, Input, OnInit, ViewChild} from '@angular/core';
import {FormControl} from '@angular/forms';
import {ColorErrorEnum} from './color-error.enum';
import {ColorPickerDirective} from 'ngx-color-picker';
import {hexToRgb, rgbToHsl} from 'ui-frontend-common';
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { FormControl } from '@angular/forms';
import { ColorPickerDirective } from 'ngx-color-picker';
import { hexToRgb, rgbToHsl } from 'ui-frontend-common';
import { ColorErrorEnum } from './color-error.enum';
@Component({
selector: 'app-input-color',
templateUrl: './input-color.component.html',
styleUrls: ['./input-color.component.scss'],
})
export class InputColorComponent implements OnInit {
@Input() placeholder: string;
@Input() disabled: boolean;
@Input() colorInput: FormControl;
......@@ -20,21 +18,18 @@ export class InputColorComponent implements OnInit {
public color: string;
@ViewChild('colorPickerInput', {read: ColorPickerDirective, static: false})
@ViewChild('colorPickerInput', { read: ColorPickerDirective, static: false })
private colorPicker: ColorPickerDirective;
public colorErrorEnum: typeof ColorErrorEnum = ColorErrorEnum;
public colorError: ColorErrorEnum = ColorErrorEnum.NONE;
public colorErrorEnum : typeof ColorErrorEnum = ColorErrorEnum;
public colorError : ColorErrorEnum = ColorErrorEnum.NONE;
constructor() {}
constructor() { }
public ngOnInit(): void {
this.color = this.colorInput.value;
this.colorInput.valueChanges.subscribe((color: string) => {
this.color = color;
if(this.checkWarning)
{
if (this.checkWarning) {
this.checkColor500(color);
}
});
......@@ -45,19 +40,16 @@ export class InputColorComponent implements OnInit {
const rgbValue = hexToRgb(color);
if (rgbValue) {
const hslValue = rgbToHsl(rgbValue);
if(hslValue) {
if(hslValue.l > 60) {
if (hslValue) {
if (hslValue.l > 60) {
this.colorError = ColorErrorEnum.COLOR_TOO_LIGHT;
}
else if(hslValue.l < 40) {
} else if (hslValue.l < 40) {
this.colorError = ColorErrorEnum.COLOR_TOO_DARK;
}
}
else{
} else {
this.colorError = ColorErrorEnum.COLOR_INVALID;
}
}
else {
} else {
this.colorError = ColorErrorEnum.COLOR_INVALID;
}
}
......@@ -69,19 +61,18 @@ export class InputColorComponent implements OnInit {
}
public openPicker(): void {
if ( ! this.disabled) {
if (!this.disabled) {
this.colorPicker.openDialog();
}
}
public forceHex(): void {
if (! this.colorInput.value.startsWith('#')) {
if (!this.colorInput.value.startsWith('#')) {
this.colorInput.setValue('#' + this.colorInput.value);
}
}
public handlePicker(pickerValue: string): void {
// Avoid 3 chars hex to become 6 chars (ex. #123 becoming instantly #112233...)
let inputValue: string = this.colorInput.value.toUpperCase();
pickerValue = pickerValue.toUpperCase();
......@@ -95,7 +86,10 @@ export class InputColorComponent implements OnInit {
if (inputValue.length === 3 && pickerValue.length === 6) {
for (let i = 0; i < 3; i++) {
if (inputValue.charAt(i) !== pickerValue.charAt(2 * i) || inputValue.charAt(i) !== pickerValue.charAt(2 * i + 1)) {
if (
inputValue.charAt(i) !== pickerValue.charAt(2 * i) ||
inputValue.charAt(i) !== pickerValue.charAt(2 * i + 1)
) {
continue;
}
return;
......@@ -103,5 +97,4 @@ export class InputColorComponent implements OnInit {
}
this.colorInput.setValue('#' + pickerValue);
}
}
......@@ -41,8 +41,7 @@ export class GraphicIdentityFormComponent implements OnInit {
}
private applyTheme(): void {
if(this.graphicIdentityForm.valid)
{
if (this.graphicIdentityForm.valid) {
const colors = this.themeService.getThemeColors(this.graphicIdentityForm.get('themeColors').value);
this.themeService.overloadLocalTheme(colors, '#toOverride');
}
......
......@@ -37,11 +37,11 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatDialogModule } from '@angular/material/dialog';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSelectModule } from '@angular/material/select';
import { MatSidenavModule } from '@angular/material/sidenav';
import { VitamUICommonModule } from 'ui-frontend-common';
import { SharedModule } from '../shared/shared.module';
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment