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="">
|
2022-06-29 16:30:53 +02:00
|
|
|
<input class="uk-margin-small-left color-input" 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>
|
2022-08-11 15:06:50 +02:00
|
|
|
<div class="uk-margin-small-left"> {{label}}
|
|
|
|
<div class="uk-text-meta uk-text-xsmall" *ngIf="description" >{{description}}</div>
|
|
|
|
</div>
|
2019-10-07 16:36:53 +02:00
|
|
|
</div>
|
2022-08-11 15:06:50 +02:00
|
|
|
</div>
|
|
|
|
|
2023-06-09 12:58:35 +02:00
|
|
|
<div class="uk-text-warning uk-text-xsmall uk-margin-small-left" [class.uk-invisible]="!warningForContrast(color)">Contrast ratio may be too low.</div>
|
2022-06-29 16:30:53 +02:00
|
|
|
`,
|
|
|
|
styles:[
|
|
|
|
`
|
2023-08-04 10:00:57 +02:00
|
|
|
.color-input{
|
|
|
|
width:24px;
|
|
|
|
height:14px;
|
|
|
|
border-radius:3px;
|
|
|
|
border:0.1px solid #707070;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
}`
|
2022-06-29 16:30:53 +02:00
|
|
|
]
|
2019-10-07 16:36:53 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
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;
|
2022-08-11 15:06:50 +02:00
|
|
|
@Input() description:string = null;
|
2021-05-19 13:40:29 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|