2019-10-07 16:36:53 +02:00
|
|
|
import {Component, EventEmitter, Input, OnInit, Output,} from '@angular/core';
|
2021-05-19 13:40:29 +02:00
|
|
|
import {CustomizationOptions} from '../../openaireLibrary/connect/community/CustomizationOptions';
|
2019-10-07 16:36:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'color',
|
|
|
|
template: `
|
2021-05-19 13:40:29 +02:00
|
|
|
<div [class]="(addMargin?'uk-margin-small-top':'') + ' colorPicker uk-flex uk-flex-middle'">
|
|
|
|
<div class=" uk-flex">
|
|
|
|
<div class="">
|
|
|
|
<input id="colorPickerInput" class="uk-margin-small-left uk-width-small " color-picker [colorPicker]="color" [style.background]="color"
|
2020-01-20 15:33:36 +01:00
|
|
|
(colorPickerChange)="color=$event; colorChanged();"/>
|
2019-10-07 16:36:53 +02:00
|
|
|
</div>
|
2021-05-19 13:40:29 +02:00
|
|
|
<div class="uk-margin-small-left"> {{label}}</div>
|
2019-10-07 16:36:53 +02:00
|
|
|
</div>
|
2021-05-19 13:40:29 +02:00
|
|
|
<span class="uk-text-warning uk-text-small uk-margin-small-left" *ngIf="warningForContrast(color)">Contrast ratio may be too low.</span>
|
2019-10-07 16:36:53 +02:00
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ColorComponent implements OnInit {
|
|
|
|
@Input() color = 'white';
|
|
|
|
@Input() label = 'Color';
|
|
|
|
@Input() addMargin: boolean = false;
|
|
|
|
@Output() colorChange = new EventEmitter();
|
2021-05-19 13:40:29 +02:00
|
|
|
@Input() light:boolean;
|
|
|
|
public warningForContrast(color:string){
|
|
|
|
return (this.light && CustomizationOptions.isForLightBackground(color)) || (!this.light && !CustomizationOptions.isForLightBackground(color));
|
|
|
|
}
|
2019-10-07 16:36:53 +02:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
|
|
|
|
colorChanged() {
|
|
|
|
this.colorChange.emit(this.color);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|